@mcpview/components 0.0.0-stage → 0.11.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/LICENSE +21 -0
- package/README.md +593 -2
- package/esm/_dnt.polyfills.d.ts +12 -0
- package/esm/_dnt.polyfills.d.ts.map +1 -0
- package/esm/_dnt.polyfills.js +15 -0
- package/esm/fonts.d.ts +13 -0
- package/esm/fonts.d.ts.map +1 -0
- package/esm/fonts.js +12 -0
- package/esm/layout.d.ts +14 -0
- package/esm/layout.d.ts.map +1 -0
- package/esm/layout.js +13 -0
- package/esm/mod.d.ts +19 -0
- package/esm/mod.d.ts.map +1 -0
- package/esm/mod.js +14 -0
- package/esm/package.json +3 -0
- package/esm/preact-components.d.ts +22 -0
- package/esm/preact-components.d.ts.map +1 -0
- package/esm/preact-components.js +20 -0
- package/esm/preact.d.ts +10 -0
- package/esm/preact.d.ts.map +1 -0
- package/esm/preact.js +9 -0
- package/esm/src/component-primitives.d.ts +41 -0
- package/esm/src/component-primitives.d.ts.map +1 -0
- package/esm/src/component-primitives.js +121 -0
- package/esm/src/components.d.ts +50 -0
- package/esm/src/components.d.ts.map +1 -0
- package/esm/src/components.js +283 -0
- package/esm/src/font-families.d.ts +16 -0
- package/esm/src/font-families.d.ts.map +1 -0
- package/esm/src/font-families.js +11 -0
- package/esm/src/fonts-data.d.ts +2 -0
- package/esm/src/fonts-data.d.ts.map +1 -0
- package/esm/src/fonts-data.js +42 -0
- package/esm/src/fonts.d.ts +12 -0
- package/esm/src/fonts.d.ts.map +1 -0
- package/esm/src/fonts.js +19 -0
- package/esm/src/i18n.d.ts +44 -0
- package/esm/src/i18n.d.ts.map +1 -0
- package/esm/src/i18n.js +98 -0
- package/esm/src/layout/hooks.d.ts +60 -0
- package/esm/src/layout/hooks.d.ts.map +1 -0
- package/esm/src/layout/hooks.js +121 -0
- package/esm/src/layout/mod.d.ts +6 -0
- package/esm/src/layout/mod.d.ts.map +1 -0
- package/esm/src/layout/mod.js +3 -0
- package/esm/src/layout/viewer-layout.d.ts +82 -0
- package/esm/src/layout/viewer-layout.d.ts.map +1 -0
- package/esm/src/layout/viewer-layout.js +74 -0
- package/esm/src/preact/components.d.ts +215 -0
- package/esm/src/preact/components.d.ts.map +1 -0
- package/esm/src/preact/components.js +176 -0
- package/esm/src/preact/focused-view.d.ts +42 -0
- package/esm/src/preact/focused-view.d.ts.map +1 -0
- package/esm/src/preact/focused-view.js +20 -0
- package/esm/src/preact/mod.d.ts +6 -0
- package/esm/src/preact/mod.d.ts.map +1 -0
- package/esm/src/preact/mod.js +3 -0
- package/esm/src/preact/plots.d.ts +130 -0
- package/esm/src/preact/plots.d.ts.map +1 -0
- package/esm/src/preact/plots.js +166 -0
- package/esm/src/preact/semantic-element.d.ts +103 -0
- package/esm/src/preact/semantic-element.d.ts.map +1 -0
- package/esm/src/preact/semantic-element.js +103 -0
- package/esm/src/preact/structural.d.ts +178 -0
- package/esm/src/preact/structural.d.ts.map +1 -0
- package/esm/src/preact/structural.js +147 -0
- package/esm/src/preact/surface.d.ts +37 -0
- package/esm/src/preact/surface.d.ts.map +1 -0
- package/esm/src/preact/surface.js +47 -0
- package/esm/src/surface-app.d.ts +188 -0
- package/esm/src/surface-app.d.ts.map +1 -0
- package/esm/src/surface-app.js +374 -0
- package/esm/src/theme.d.ts +65 -0
- package/esm/src/theme.d.ts.map +1 -0
- package/esm/src/theme.js +1964 -0
- package/esm/surface.d.ts +12 -0
- package/esm/surface.d.ts.map +1 -0
- package/esm/surface.js +10 -0
- package/package.json +68 -4
- package/script/_dnt.polyfills.d.ts +12 -0
- package/script/_dnt.polyfills.d.ts.map +1 -0
- package/script/_dnt.polyfills.js +16 -0
- package/script/fonts.d.ts +13 -0
- package/script/fonts.d.ts.map +1 -0
- package/script/fonts.js +19 -0
- package/script/layout.d.ts +14 -0
- package/script/layout.d.ts.map +1 -0
- package/script/layout.js +29 -0
- package/script/mod.d.ts +19 -0
- package/script/mod.d.ts.map +1 -0
- package/script/mod.js +40 -0
- package/script/package.json +3 -0
- package/script/preact-components.d.ts +22 -0
- package/script/preact-components.d.ts.map +1 -0
- package/script/preact-components.js +68 -0
- package/script/preact.d.ts +10 -0
- package/script/preact.d.ts.map +1 -0
- package/script/preact.js +25 -0
- package/script/src/component-primitives.d.ts +41 -0
- package/script/src/component-primitives.d.ts.map +1 -0
- package/script/src/component-primitives.js +127 -0
- package/script/src/components.d.ts +50 -0
- package/script/src/components.d.ts.map +1 -0
- package/script/src/components.js +297 -0
- package/script/src/font-families.d.ts +16 -0
- package/script/src/font-families.d.ts.map +1 -0
- package/script/src/font-families.js +14 -0
- package/script/src/fonts-data.d.ts +2 -0
- package/script/src/fonts-data.d.ts.map +1 -0
- package/script/src/fonts-data.js +45 -0
- package/script/src/fonts.d.ts +12 -0
- package/script/src/fonts.d.ts.map +1 -0
- package/script/src/fonts.js +24 -0
- package/script/src/i18n.d.ts +44 -0
- package/script/src/i18n.d.ts.map +1 -0
- package/script/src/i18n.js +102 -0
- package/script/src/layout/hooks.d.ts +60 -0
- package/script/src/layout/hooks.d.ts.map +1 -0
- package/script/src/layout/hooks.js +126 -0
- package/script/src/layout/mod.d.ts +6 -0
- package/script/src/layout/mod.d.ts.map +1 -0
- package/script/src/layout/mod.js +17 -0
- package/script/src/layout/viewer-layout.d.ts +82 -0
- package/script/src/layout/viewer-layout.d.ts.map +1 -0
- package/script/src/layout/viewer-layout.js +83 -0
- package/script/src/preact/components.d.ts +215 -0
- package/script/src/preact/components.d.ts.map +1 -0
- package/script/src/preact/components.js +199 -0
- package/script/src/preact/focused-view.d.ts +42 -0
- package/script/src/preact/focused-view.d.ts.map +1 -0
- package/script/src/preact/focused-view.js +24 -0
- package/script/src/preact/mod.d.ts +6 -0
- package/script/src/preact/mod.d.ts.map +1 -0
- package/script/src/preact/mod.js +55 -0
- package/script/src/preact/plots.d.ts +130 -0
- package/script/src/preact/plots.d.ts.map +1 -0
- package/script/src/preact/plots.js +171 -0
- package/script/src/preact/semantic-element.d.ts +103 -0
- package/script/src/preact/semantic-element.d.ts.map +1 -0
- package/script/src/preact/semantic-element.js +115 -0
- package/script/src/preact/structural.d.ts +178 -0
- package/script/src/preact/structural.d.ts.map +1 -0
- package/script/src/preact/structural.js +158 -0
- package/script/src/preact/surface.d.ts +37 -0
- package/script/src/preact/surface.d.ts.map +1 -0
- package/script/src/preact/surface.js +53 -0
- package/script/src/surface-app.d.ts +188 -0
- package/script/src/surface-app.d.ts.map +1 -0
- package/script/src/surface-app.js +379 -0
- package/script/src/theme.d.ts +65 -0
- package/script/src/theme.d.ts.map +1 -0
- package/script/src/theme.js +1968 -0
- package/script/surface.d.ts +12 -0
- package/script/surface.d.ts.map +1 -0
- package/script/surface.js +15 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PATH_BAR_DEFAULT_MAX_VISIBLE = void 0;
|
|
4
|
+
exports.PathBar = PathBar;
|
|
5
|
+
exports.DrillHint = DrillHint;
|
|
6
|
+
exports.TypeBadge = TypeBadge;
|
|
7
|
+
exports.StaleBanner = StaleBanner;
|
|
8
|
+
exports.Slot3D = Slot3D;
|
|
9
|
+
exports.TreeList = TreeList;
|
|
10
|
+
exports.LimitGauge = LimitGauge;
|
|
11
|
+
exports.ArtifactRow = ArtifactRow;
|
|
12
|
+
const jsx_runtime_1 = require("preact/jsx-runtime");
|
|
13
|
+
/** Trailing items kept inline before the leading ones collapse. */
|
|
14
|
+
exports.PATH_BAR_DEFAULT_MAX_VISIBLE = 3;
|
|
15
|
+
/**
|
|
16
|
+
* Controlled breadcrumb-like navigation without host or MCP side effects.
|
|
17
|
+
*
|
|
18
|
+
* A one-item path renders nothing: the first level has nothing to leave.
|
|
19
|
+
*/
|
|
20
|
+
function PathBar({ label, items, currentId, onSelect, maxVisible = exports.PATH_BAR_DEFAULT_MAX_VISIBLE, collapsedLabel, backLabel, className, }) {
|
|
21
|
+
validatePath(items, currentId, maxVisible);
|
|
22
|
+
if (items.length < 2)
|
|
23
|
+
return null;
|
|
24
|
+
const collapsed = collapsedLabel !== undefined && items.length > maxVisible
|
|
25
|
+
? items.slice(0, items.length - maxVisible)
|
|
26
|
+
: [];
|
|
27
|
+
const visible = items.slice(collapsed.length);
|
|
28
|
+
const currentIndex = items.findIndex((item) => item.id === currentId);
|
|
29
|
+
const previous = currentIndex > 0 ? items[currentIndex - 1] : undefined;
|
|
30
|
+
return ((0, jsx_runtime_1.jsxs)("nav", { "aria-label": label, class: classes("mcp-view-path-bar", className), children: [backLabel !== undefined && previous !== undefined && ((0, jsx_runtime_1.jsx)("button", { "aria-label": backLabel, class: "mcp-view-path-bar-back", onClick: () => onSelect(previous.id), type: "button", children: (0, jsx_runtime_1.jsx)("span", { "aria-hidden": "true", children: "\u2039" }) })), collapsed.length > 0 && ((0, jsx_runtime_1.jsxs)("details", { class: "mcp-view-path-bar-collapsed", children: [(0, jsx_runtime_1.jsx)("summary", { "aria-label": collapsedLabel, class: "mcp-view-path-bar-collapsed-summary", children: (0, jsx_runtime_1.jsx)("span", { "aria-hidden": "true", children: `…${collapsed.length}` }) }), (0, jsx_runtime_1.jsx)("ul", { class: "mcp-view-path-bar-kept", children: collapsed.map((item, index) => ((0, jsx_runtime_1.jsx)("li", { children: (0, jsx_runtime_1.jsxs)("button", { class: "mcp-view-path-bar-kept-button", onClick: () => onSelect(item.id), type: "button", children: [(0, jsx_runtime_1.jsx)("span", { "aria-hidden": "true", class: "mcp-view-path-bar-kept-rank", children: index + 1 }), (0, jsx_runtime_1.jsx)("span", { class: "mcp-view-path-bar-kept-label", children: item.label }), item.detail !== undefined && ((0, jsx_runtime_1.jsx)("small", { class: "mcp-view-path-bar-kept-detail", children: item.detail }))] }) }, item.id))) })] })), (0, jsx_runtime_1.jsx)("ol", { class: "mcp-view-path-bar-list", children: visible.map((item) => {
|
|
31
|
+
const current = item.id === currentId;
|
|
32
|
+
return ((0, jsx_runtime_1.jsx)("li", { class: "mcp-view-path-bar-item", "data-current": current ? "true" : undefined, children: current
|
|
33
|
+
? ((0, jsx_runtime_1.jsx)("span", { "aria-current": "page", class: "mcp-view-path-bar-current", children: item.label }))
|
|
34
|
+
: ((0, jsx_runtime_1.jsx)("button", { class: "mcp-view-path-bar-button", onClick: () => onSelect(item.id), type: "button", children: item.label })) }, item.id));
|
|
35
|
+
}) })] }));
|
|
36
|
+
}
|
|
37
|
+
const DRILL_HINT_GLYPH = Object.freeze({
|
|
38
|
+
"in-view": "›",
|
|
39
|
+
"to-model": "~",
|
|
40
|
+
});
|
|
41
|
+
/**
|
|
42
|
+
* Affordance for one available drill-down.
|
|
43
|
+
*
|
|
44
|
+
* Without a callback the hint degrades to plain text and shows no glyph, so a
|
|
45
|
+
* host that cannot follow it never advertises a step that does not exist.
|
|
46
|
+
*/
|
|
47
|
+
function DrillHint(props) {
|
|
48
|
+
const className = classes("mcp-view-drill-hint", props.className);
|
|
49
|
+
if (props.onActivate === undefined) {
|
|
50
|
+
return ((0, jsx_runtime_1.jsx)("span", { class: className, "data-degraded": "true", "data-direction": props.direction, children: props.label }));
|
|
51
|
+
}
|
|
52
|
+
return ((0, jsx_runtime_1.jsxs)("button", { "aria-label": props.actionLabel, class: className, "data-direction": props.direction, onClick: props.onActivate, type: "button", children: [(0, jsx_runtime_1.jsx)("span", { class: "mcp-view-drill-hint-label", children: props.label }), (0, jsx_runtime_1.jsx)("span", { "aria-hidden": "true", class: "mcp-view-drill-hint-glyph", children: DRILL_HINT_GLYPH[props.direction] })] }));
|
|
53
|
+
}
|
|
54
|
+
/** Names what one level is, next to the path that reached it. */
|
|
55
|
+
function TypeBadge({ kind, label, className }) {
|
|
56
|
+
return ((0, jsx_runtime_1.jsx)("span", { class: classes("mcp-view-type-badge", className), "data-kind": kind, children: label }));
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Marks the surrounding values as recorded earlier without hiding them.
|
|
60
|
+
*
|
|
61
|
+
* The banner refetches nothing and never replaces a dated value with a gap.
|
|
62
|
+
*/
|
|
63
|
+
function StaleBanner({ message, tone = "warning", action, className, }) {
|
|
64
|
+
return ((0, jsx_runtime_1.jsxs)("div", { class: classes("mcp-view-stale-banner", className), "data-tone": tone, role: tone === "danger" ? "alert" : "status", children: [(0, jsx_runtime_1.jsx)("span", { class: "mcp-view-stale-banner-message", children: message }), action && ((0, jsx_runtime_1.jsx)("button", { class: "mcp-view-stale-banner-action", onClick: action.onActivate, type: "button", children: action.label }))] }));
|
|
65
|
+
}
|
|
66
|
+
/** Reserved area for a provider-owned 3D pose. The kit renders no geometry. */
|
|
67
|
+
function Slot3D({ label, statusLabel, children, className }) {
|
|
68
|
+
const reserved = children === undefined || children === null || children === false;
|
|
69
|
+
return ((0, jsx_runtime_1.jsxs)("figure", { "aria-label": label, class: classes("mcp-view-slot-3d", className), "data-reserved": reserved ? "true" : undefined, role: "group", children: [(0, jsx_runtime_1.jsx)("div", { class: "mcp-view-slot-3d-frame", children: reserved ? (0, jsx_runtime_1.jsx)("span", { "aria-hidden": "true", class: "mcp-view-slot-3d-mark" }) : children }), (0, jsx_runtime_1.jsx)("figcaption", { class: "mcp-view-slot-3d-status", children: statusLabel })] }));
|
|
70
|
+
}
|
|
71
|
+
/** Controlled hierarchy with caller-owned type wording and coverage. */
|
|
72
|
+
function TreeList({ label, nodes, expandedIds, onToggle, toggleLabel, selectedId, onSelect, className, }) {
|
|
73
|
+
validateTree(nodes);
|
|
74
|
+
const expanded = new Set(expandedIds);
|
|
75
|
+
return ((0, jsx_runtime_1.jsx)("ul", { "aria-label": label, class: classes("mcp-view-tree-list", className), role: "tree", children: nodes.map((node) => ((0, jsx_runtime_1.jsx)(TreeListItem, { expanded: expanded, level: 1, node: node, onSelect: onSelect, onToggle: onToggle, selectedId: selectedId, toggleLabel: toggleLabel }, node.id))) }));
|
|
76
|
+
}
|
|
77
|
+
function TreeListItem({ node, level, expanded, onToggle, toggleLabel, selectedId, onSelect, }) {
|
|
78
|
+
const children = node.children ?? [];
|
|
79
|
+
const open = children.length > 0 && expanded.has(node.id);
|
|
80
|
+
const selected = selectedId === node.id;
|
|
81
|
+
return ((0, jsx_runtime_1.jsxs)("li", { "aria-expanded": children.length > 0 ? open : undefined, "aria-level": level, "aria-selected": onSelect === undefined ? undefined : selected, class: "mcp-view-tree-list-item", "data-tone": node.tone, role: "treeitem", children: [(0, jsx_runtime_1.jsxs)("div", { class: "mcp-view-tree-list-row", style: { paddingInlineStart: `${(level - 1) * 0.9}rem` }, children: [children.length > 0
|
|
82
|
+
? ((0, jsx_runtime_1.jsx)("button", { "aria-expanded": open, "aria-label": toggleLabel, class: "mcp-view-tree-list-twisty", onClick: () => onToggle(node.id), type: "button", children: (0, jsx_runtime_1.jsx)("span", { "aria-hidden": "true", children: open ? "▾" : "▸" }) }))
|
|
83
|
+
: (0, jsx_runtime_1.jsx)("span", { "aria-hidden": "true", class: "mcp-view-tree-list-twisty", "data-empty": "true" }), node.typeLabel !== undefined && ((0, jsx_runtime_1.jsx)("span", { class: "mcp-view-tree-list-type", children: node.typeLabel })), onSelect === undefined
|
|
84
|
+
? (0, jsx_runtime_1.jsx)("span", { class: "mcp-view-tree-list-label", children: node.label })
|
|
85
|
+
: ((0, jsx_runtime_1.jsx)("button", { class: "mcp-view-tree-list-label", onClick: () => onSelect(node.id), type: "button", children: node.label })), node.detail !== undefined && (0, jsx_runtime_1.jsx)("span", { class: "mcp-view-tree-list-detail", children: node.detail }), node.coverageLabel !== undefined && ((0, jsx_runtime_1.jsx)("span", { class: "mcp-view-tree-list-coverage", "data-tone": node.tone, children: node.coverageLabel }))] }), open && ((0, jsx_runtime_1.jsx)("ul", { class: "mcp-view-tree-list-group", role: "group", children: children.map((child) => ((0, jsx_runtime_1.jsx)(TreeListItem, { expanded: expanded, level: level + 1, node: child, onSelect: onSelect, onToggle: onToggle, selectedId: selectedId, toggleLabel: toggleLabel }, child.id))) }))] }));
|
|
86
|
+
}
|
|
87
|
+
/** Finite meter with an optional caller-supplied limit marker and explicit status text. */
|
|
88
|
+
function LimitGauge({ label, min, max, value, valueLabel, statusLabel, tone, limit, className, }) {
|
|
89
|
+
validateGaugeRange(min, max, value, limit);
|
|
90
|
+
const markerPosition = limit === undefined
|
|
91
|
+
? undefined
|
|
92
|
+
: `${((limit.value - min) / (max - min)) * 100}%`;
|
|
93
|
+
return ((0, jsx_runtime_1.jsxs)("div", { class: classes("mcp-view-limit-gauge", className), "data-tone": tone, children: [(0, jsx_runtime_1.jsx)("span", { class: "mcp-view-limit-gauge-label", children: label }), (0, jsx_runtime_1.jsxs)("div", { class: "mcp-view-limit-gauge-track", children: [(0, jsx_runtime_1.jsx)("meter", { "aria-label": label, "aria-valuetext": `${valueLabel}; ${statusLabel}`, class: "mcp-view-limit-gauge-meter", min: min, max: max, value: value }), limit && ((0, jsx_runtime_1.jsx)("span", { "aria-hidden": "true", class: "mcp-view-limit-gauge-marker", style: { left: markerPosition } }))] }), (0, jsx_runtime_1.jsx)("span", { class: "mcp-view-limit-gauge-reading", children: valueLabel }), (0, jsx_runtime_1.jsx)("span", { class: "mcp-view-limit-gauge-status", "data-tone": tone, children: statusLabel }), limit && (0, jsx_runtime_1.jsx)("span", { class: "mcp-view-limit-gauge-limit", children: limit.label })] }));
|
|
94
|
+
}
|
|
95
|
+
/** Immutable-artifact presentation; verification is displayed, never inferred or performed. */
|
|
96
|
+
function ArtifactRow(props) {
|
|
97
|
+
const content = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("span", { class: "mcp-view-artifact-row-identity", children: [props.kind && (0, jsx_runtime_1.jsx)("span", { class: "mcp-view-artifact-row-kind", children: props.kind }), (0, jsx_runtime_1.jsx)("strong", { class: "mcp-view-artifact-row-label", children: props.label })] }), (0, jsx_runtime_1.jsx)("code", { class: "mcp-view-artifact-row-uri", children: props.uri }), props.fingerprint && ((0, jsx_runtime_1.jsxs)("span", { class: "mcp-view-artifact-row-fingerprint", children: [(0, jsx_runtime_1.jsx)("span", { children: props.fingerprint.algorithm }), (0, jsx_runtime_1.jsx)("code", { children: props.fingerprint.digest })] })), props.sizeLabel && (0, jsx_runtime_1.jsx)("span", { class: "mcp-view-artifact-row-size", children: props.sizeLabel }), props.verification && ((0, jsx_runtime_1.jsx)("span", { class: "mcp-view-artifact-row-verification", "data-tone": props.verification.tone, children: props.verification.label }))] }));
|
|
98
|
+
const className = classes("mcp-view-artifact-row", props.className);
|
|
99
|
+
if (props.onActivate) {
|
|
100
|
+
return ((0, jsx_runtime_1.jsx)("button", { "aria-label": props.actionLabel, class: className, onClick: props.onActivate, type: "button", children: content }));
|
|
101
|
+
}
|
|
102
|
+
return (0, jsx_runtime_1.jsx)("article", { class: className, children: content });
|
|
103
|
+
}
|
|
104
|
+
function validatePath(items, currentId, maxVisible) {
|
|
105
|
+
if (items.length === 0)
|
|
106
|
+
throw new TypeError("PathBar items must not be empty");
|
|
107
|
+
if (!Number.isInteger(maxVisible) || maxVisible < 1) {
|
|
108
|
+
throw new RangeError("PathBar maxVisible must be a positive integer");
|
|
109
|
+
}
|
|
110
|
+
const ids = new Set();
|
|
111
|
+
for (const item of items) {
|
|
112
|
+
if (!item.id.trim())
|
|
113
|
+
throw new TypeError("PathBar item ids must be non-empty");
|
|
114
|
+
if (ids.has(item.id))
|
|
115
|
+
throw new TypeError(`PathBar item id ${item.id} is duplicated`);
|
|
116
|
+
ids.add(item.id);
|
|
117
|
+
}
|
|
118
|
+
if (!ids.has(currentId))
|
|
119
|
+
throw new TypeError("PathBar currentId must identify one item");
|
|
120
|
+
}
|
|
121
|
+
function validateTree(nodes) {
|
|
122
|
+
if (nodes.length === 0)
|
|
123
|
+
throw new TypeError("TreeList nodes must not be empty");
|
|
124
|
+
const ids = new Set();
|
|
125
|
+
const walk = (candidates) => {
|
|
126
|
+
for (const node of candidates) {
|
|
127
|
+
if (!node.id.trim())
|
|
128
|
+
throw new TypeError("TreeList node ids must be non-empty");
|
|
129
|
+
if (ids.has(node.id))
|
|
130
|
+
throw new TypeError(`TreeList node id ${node.id} is duplicated`);
|
|
131
|
+
ids.add(node.id);
|
|
132
|
+
if (node.children)
|
|
133
|
+
walk(node.children);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
walk(nodes);
|
|
137
|
+
}
|
|
138
|
+
function validateGaugeRange(min, max, value, limit) {
|
|
139
|
+
for (const [name, candidate] of [["min", min], ["max", max], ["value", value]]) {
|
|
140
|
+
if (!Number.isFinite(candidate))
|
|
141
|
+
throw new TypeError(`LimitGauge ${name} must be finite`);
|
|
142
|
+
}
|
|
143
|
+
if (max <= min)
|
|
144
|
+
throw new RangeError("LimitGauge max must be greater than min");
|
|
145
|
+
if (value < min || value > max) {
|
|
146
|
+
throw new RangeError("LimitGauge value must be within min and max");
|
|
147
|
+
}
|
|
148
|
+
if (limit === undefined)
|
|
149
|
+
return;
|
|
150
|
+
if (!Number.isFinite(limit.value))
|
|
151
|
+
throw new TypeError("LimitGauge limit must be finite");
|
|
152
|
+
if (limit.value < min || limit.value > max) {
|
|
153
|
+
throw new RangeError("LimitGauge limit must be within min and max");
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
function classes(...values) {
|
|
157
|
+
return values.filter(Boolean).join(" ");
|
|
158
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** Preact bindings for result-driven MCP App component surfaces. */
|
|
2
|
+
import { type FunctionComponent } from "preact";
|
|
3
|
+
import { type JsonValue, type ViewComponentDefinition, type ViewComponentDescriptor } from "../components.js";
|
|
4
|
+
import { type SurfaceAppContext, type SurfaceAppHandle, type SurfaceAppOptions, type SurfaceAppRuntime, type SurfaceAppState, type SurfaceStatus } from "../surface-app.js";
|
|
5
|
+
export type { SurfaceAppErrorCode, SurfaceAppHandle, SurfaceAppRuntime, SurfaceDisplayState, SurfaceHostAccess, SurfaceLabel, SurfaceMessageKind, SurfaceProjection, SurfaceStatus, SurfaceStatusTone, SurfaceToolResult, SurfaceViewerSession, } from "../surface-app.js";
|
|
6
|
+
export { SurfaceAppError } from "../surface-app.js";
|
|
7
|
+
export type PreactSurfaceAppState<TData> = SurfaceAppState<TData>;
|
|
8
|
+
export type PreactSurfaceContext<TData> = SurfaceAppContext<TData>;
|
|
9
|
+
export interface PreactSurfaceComponentProps<TData, TAppContext = PreactSurfaceContext<TData>> {
|
|
10
|
+
readonly data: TData;
|
|
11
|
+
readonly context: TAppContext;
|
|
12
|
+
readonly instanceId: string;
|
|
13
|
+
readonly props: Readonly<Record<string, JsonValue>>;
|
|
14
|
+
}
|
|
15
|
+
/** Small injection seam for DOM-light unit tests. */
|
|
16
|
+
export interface PreactComponentRenderer {
|
|
17
|
+
mount<P extends object>(component: FunctionComponent<P>, props: P, target: HTMLElement): void;
|
|
18
|
+
unmount(target: HTMLElement): void;
|
|
19
|
+
}
|
|
20
|
+
export declare const preactSurfaceRenderer: PreactComponentRenderer;
|
|
21
|
+
/** Turn one Preact component into a renderer-neutral mcp-view component. */
|
|
22
|
+
export declare function definePreactComponent<TData, TAppContext = PreactSurfaceContext<TData>>(descriptor: ViewComponentDescriptor, component: FunctionComponent<PreactSurfaceComponentProps<TData, TAppContext>>, renderer?: PreactComponentRenderer): ViewComponentDefinition<TData, TAppContext>;
|
|
23
|
+
export interface PreactSurfaceAppOptions<TData, TSession = never> extends Omit<SurfaceAppOptions<TData, TSession>, "renderStatus" | "surfaceClassName"> {
|
|
24
|
+
/** Class of the element wrapping the mounted surface. Default `mcp-view-preact-surface`. */
|
|
25
|
+
readonly surfaceClassName?: string;
|
|
26
|
+
/** Extra class on the rendered `StateMessage`, for viewer-owned styling hooks. */
|
|
27
|
+
readonly statusClassName?: string;
|
|
28
|
+
/** Replace the `StateMessage` bridge with a viewer-owned status renderer. */
|
|
29
|
+
readonly renderStatus?: (status: SurfaceStatus) => Node;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Start a result-driven MCP App whose statuses render through the Preact
|
|
33
|
+
* `StateMessage`. Everything else is `startSurfaceApp`; the shell keeps the
|
|
34
|
+
* `mcp-view-preact-surface` class 0.5 viewers style.
|
|
35
|
+
*/
|
|
36
|
+
export declare function startPreactSurfaceApp<TData, TSession = never>(options: PreactSurfaceAppOptions<TData, TSession>, runtime?: SurfaceAppRuntime): Promise<SurfaceAppHandle<TData>>;
|
|
37
|
+
//# sourceMappingURL=surface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"surface.d.ts","sourceRoot":"","sources":["../../../src/src/preact/surface.ts"],"names":[],"mappings":"AAAA,oEAAoE;AAEpE,OAAO,EAAiB,KAAK,iBAAiB,EAAU,MAAM,QAAQ,CAAC;AAEvE,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC7B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,aAAa,EACnB,MAAM,mBAAmB,CAAC;AAG3B,YAAY,EACV,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,MAAM,qBAAqB,CAAC,KAAK,IAAI,eAAe,CAAC,KAAK,CAAC,CAAC;AAElE,MAAM,MAAM,oBAAoB,CAAC,KAAK,IAAI,iBAAiB,CAAC,KAAK,CAAC,CAAC;AAEnE,MAAM,WAAW,2BAA2B,CAC1C,KAAK,EACL,WAAW,GAAG,oBAAoB,CAAC,KAAK,CAAC;IAEzC,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,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AAC,KAAK,EAAE,QAAQ,CAAC,EACjD,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAkBlC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** Preact bindings for result-driven MCP App component surfaces. */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.preactSurfaceRenderer = exports.SurfaceAppError = void 0;
|
|
5
|
+
exports.definePreactComponent = definePreactComponent;
|
|
6
|
+
exports.startPreactSurfaceApp = startPreactSurfaceApp;
|
|
7
|
+
const preact_1 = require("preact");
|
|
8
|
+
const components_js_1 = require("../components.js");
|
|
9
|
+
const surface_app_js_1 = require("../surface-app.js");
|
|
10
|
+
const components_js_2 = require("./components.js");
|
|
11
|
+
var surface_app_js_2 = require("../surface-app.js");
|
|
12
|
+
Object.defineProperty(exports, "SurfaceAppError", { enumerable: true, get: function () { return surface_app_js_2.SurfaceAppError; } });
|
|
13
|
+
exports.preactSurfaceRenderer = {
|
|
14
|
+
mount(component, props, target) {
|
|
15
|
+
(0, preact_1.render)((0, preact_1.createElement)(component, props), target);
|
|
16
|
+
},
|
|
17
|
+
unmount(target) {
|
|
18
|
+
(0, preact_1.render)(null, target);
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
/** Turn one Preact component into a renderer-neutral mcp-view component. */
|
|
22
|
+
function definePreactComponent(descriptor, component, renderer = exports.preactSurfaceRenderer) {
|
|
23
|
+
return (0, components_js_1.defineViewComponent)({
|
|
24
|
+
descriptor,
|
|
25
|
+
mount(target, context) {
|
|
26
|
+
renderer.mount(component, {
|
|
27
|
+
data: context.data,
|
|
28
|
+
context: context.appContext,
|
|
29
|
+
instanceId: context.instanceId,
|
|
30
|
+
props: context.props,
|
|
31
|
+
}, target);
|
|
32
|
+
return () => renderer.unmount(target);
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Start a result-driven MCP App whose statuses render through the Preact
|
|
38
|
+
* `StateMessage`. Everything else is `startSurfaceApp`; the shell keeps the
|
|
39
|
+
* `mcp-view-preact-surface` class 0.5 viewers style.
|
|
40
|
+
*/
|
|
41
|
+
async function startPreactSurfaceApp(options, runtime) {
|
|
42
|
+
const { statusClassName, renderStatus, surfaceClassName = "mcp-view-preact-surface", ...rest } = options;
|
|
43
|
+
return await (0, surface_app_js_1.startSurfaceApp)({
|
|
44
|
+
...rest,
|
|
45
|
+
surfaceClassName,
|
|
46
|
+
renderStatus: renderStatus ?? ((status) => (0, components_js_2.renderStatusMessage)(status.message, {
|
|
47
|
+
title: status.title,
|
|
48
|
+
tone: status.tone,
|
|
49
|
+
busy: status.busy,
|
|
50
|
+
className: statusClassName,
|
|
51
|
+
})),
|
|
52
|
+
}, runtime);
|
|
53
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Result-driven MCP App over one component registry, renderer-neutral.
|
|
3
|
+
*
|
|
4
|
+
* Every componentized viewer repeats the same lifecycle: install the theme,
|
|
5
|
+
* show a status until the host sends a result, project that result into a
|
|
6
|
+
* data model, mount the host-selected surface, remount it when the host
|
|
7
|
+
* context changes, and make sure only the latest mount survives. Copies of
|
|
8
|
+
* that loop drifted — one lost the generation guard in its error path,
|
|
9
|
+
* another buffered recorded sessions by hand. This module is the loop, once.
|
|
10
|
+
* Renderers plug in through `renderStatus`; `startPreactSurfaceApp` binds it
|
|
11
|
+
* to the Preact `StateMessage`.
|
|
12
|
+
*/
|
|
13
|
+
import { type AppConfig, type AppContext, createMcpApp } from "@mcpview/view";
|
|
14
|
+
import { type ComponentSurface, type ViewComponentRegistry } from "./components.js";
|
|
15
|
+
import type { ComponentTone } from "./component-primitives.js";
|
|
16
|
+
import { type McpViewMessages, type Translator } from "./i18n.js";
|
|
17
|
+
export type SurfaceLabel = string | ((locale?: string) => string);
|
|
18
|
+
export interface SurfaceAppState<TData> {
|
|
19
|
+
currentData?: TData;
|
|
20
|
+
}
|
|
21
|
+
export type SurfaceAppContext<TData> = AppContext<SurfaceAppState<TData>>;
|
|
22
|
+
/** The host tool result exactly as `createMcpApp` delivers it. */
|
|
23
|
+
export type SurfaceToolResult = Parameters<NonNullable<AppConfig<SurfaceAppState<unknown>>["onToolResult"]>>[0];
|
|
24
|
+
type HostApp = AppContext<SurfaceAppState<unknown>>["app"];
|
|
25
|
+
/** The server reads an App may need while projecting a result or a session. */
|
|
26
|
+
export interface SurfaceHostAccess {
|
|
27
|
+
/** Presentation locale at projection time, never an input to domain validation. */
|
|
28
|
+
readonly locale?: string;
|
|
29
|
+
readonly readServerResource: (uri: string) => ReturnType<HostApp["readServerResource"]>;
|
|
30
|
+
}
|
|
31
|
+
export type SurfaceStatusTone = ComponentTone;
|
|
32
|
+
/**
|
|
33
|
+
* What the App displays. `result` mounts the component surface; every other
|
|
34
|
+
* kind renders one status through `renderStatus`. `notice` carries a
|
|
35
|
+
* caller-owned presentation for domain states such as "recorded evidence
|
|
36
|
+
* unresolved" that are neither an error nor an absence of data. `code` is a
|
|
37
|
+
* caller-owned machine identifier, forwarded verbatim to the status.
|
|
38
|
+
* `error` and `notice` `title`/`message` accept `SurfaceLabel` callbacks,
|
|
39
|
+
* resolved on each visible status render; literal strings stay unchanged.
|
|
40
|
+
*/
|
|
41
|
+
export type SurfaceDisplayState<TData> = {
|
|
42
|
+
readonly kind: "loading";
|
|
43
|
+
} | {
|
|
44
|
+
readonly kind: "empty";
|
|
45
|
+
} | {
|
|
46
|
+
readonly kind: "error";
|
|
47
|
+
readonly message: SurfaceLabel;
|
|
48
|
+
readonly title?: SurfaceLabel;
|
|
49
|
+
readonly code?: string;
|
|
50
|
+
} | {
|
|
51
|
+
readonly kind: "notice";
|
|
52
|
+
readonly message: SurfaceLabel;
|
|
53
|
+
readonly title?: SurfaceLabel;
|
|
54
|
+
readonly tone?: SurfaceStatusTone;
|
|
55
|
+
readonly busy?: boolean;
|
|
56
|
+
readonly code?: string;
|
|
57
|
+
} | {
|
|
58
|
+
readonly kind: "result";
|
|
59
|
+
readonly result: TData;
|
|
60
|
+
};
|
|
61
|
+
export type SurfaceMessageKind = "loading" | "empty" | "error" | "notice" | "surface-required";
|
|
62
|
+
/** One status resolved to its presentation, ready for a renderer. */
|
|
63
|
+
export interface SurfaceStatus {
|
|
64
|
+
readonly kind: SurfaceMessageKind;
|
|
65
|
+
readonly message: string;
|
|
66
|
+
readonly title?: string;
|
|
67
|
+
readonly tone: SurfaceStatusTone;
|
|
68
|
+
readonly busy: boolean;
|
|
69
|
+
/** Caller-owned identifier from a `notice` or `error` state, never invented. */
|
|
70
|
+
readonly code?: string;
|
|
71
|
+
}
|
|
72
|
+
export type SurfaceProjection<TInput, TData> = (input: TInput, host: SurfaceHostAccess) => SurfaceDisplayState<TData> | Promise<SurfaceDisplayState<TData>>;
|
|
73
|
+
/** Whole-view `viewer.session.apply` handling, installed before the App connects. */
|
|
74
|
+
export interface SurfaceViewerSession<TData, TSession> {
|
|
75
|
+
readonly validate: (value: unknown) => value is TSession;
|
|
76
|
+
/** Project one validated session exactly as a tool result would be. */
|
|
77
|
+
readonly toState: SurfaceProjection<TSession, TData>;
|
|
78
|
+
readonly onInvalid?: (value: unknown) => void;
|
|
79
|
+
}
|
|
80
|
+
export interface SurfaceAppOptions<TData, TSession = never> {
|
|
81
|
+
readonly root: HTMLElement;
|
|
82
|
+
readonly info: {
|
|
83
|
+
readonly name: string;
|
|
84
|
+
readonly version: string;
|
|
85
|
+
};
|
|
86
|
+
readonly registry: ViewComponentRegistry<TData, SurfaceAppContext<TData>>;
|
|
87
|
+
/**
|
|
88
|
+
* Project one host tool result into a display state. Without it the result's
|
|
89
|
+
* structured content (or JSON text) is the data, checked by `validate`.
|
|
90
|
+
*
|
|
91
|
+
* A throw becomes an `error` status and drops the remembered result, like
|
|
92
|
+
* any non-`result` state. To keep the last values visible under a failure,
|
|
93
|
+
* return a `result` state that carries the failure — the scaffold does.
|
|
94
|
+
*/
|
|
95
|
+
readonly fromToolResult?: SurfaceProjection<SurfaceToolResult, TData>;
|
|
96
|
+
/** Domain guard for the default projection. Exclusive with `fromToolResult`. */
|
|
97
|
+
readonly validate?: (value: unknown) => value is TData;
|
|
98
|
+
readonly viewerSession?: SurfaceViewerSession<TData, TSession>;
|
|
99
|
+
/**
|
|
100
|
+
* The surface a result owns. A returned surface composes that result as is:
|
|
101
|
+
* neither the host selection nor the registry default is consulted, so a
|
|
102
|
+
* recorded session that replaces the whole read model can compose itself.
|
|
103
|
+
* `undefined` keeps the host flow (host-selected surface, then the registry
|
|
104
|
+
* default). Called on every mount of the result, remounts included.
|
|
105
|
+
*/
|
|
106
|
+
readonly surfaceFor?: (data: TData) => ComponentSurface | undefined;
|
|
107
|
+
/** Detail of the `loading` status. Default `Waiting for data…`. */
|
|
108
|
+
readonly loadingLabel?: SurfaceLabel;
|
|
109
|
+
/** Detail of the `empty` status. Default `No structured data received.`. */
|
|
110
|
+
readonly emptyLabel?: SurfaceLabel;
|
|
111
|
+
/**
|
|
112
|
+
* Detail of the `surface-required` status. Default
|
|
113
|
+
* `This App exposes components and requires a host-selected surface.`.
|
|
114
|
+
*/
|
|
115
|
+
readonly surfaceRequiredLabel?: SurfaceLabel;
|
|
116
|
+
/** Translate interface wording only; domain messages and codes remain caller-owned. */
|
|
117
|
+
readonly messages?: (locale?: string) => Translator<keyof McpViewMessages>;
|
|
118
|
+
/**
|
|
119
|
+
* Sets `document.documentElement.lang` at boot and when the host locale
|
|
120
|
+
* changes. Pass `messages.locale` from `createTranslator` so the document
|
|
121
|
+
* language identifies the selected dictionary. Omit to leave `lang` as is.
|
|
122
|
+
* Independent of remount policy; not inferred from message callbacks.
|
|
123
|
+
*/
|
|
124
|
+
readonly documentLanguage?: (hostLocale?: string) => string;
|
|
125
|
+
/**
|
|
126
|
+
* Opt into in-place theme-only updates when components follow CSS tokens (or
|
|
127
|
+
* observe them, e.g. a 3D scene). Other context changes still remount the surface.
|
|
128
|
+
* Default `remount` preserves components that read the theme only at mount.
|
|
129
|
+
* In-place mode compares non-theme fields structurally so equal JSON snapshots
|
|
130
|
+
* with new object identities do not remount.
|
|
131
|
+
*/
|
|
132
|
+
readonly themeUpdates?: "remount" | "in-place";
|
|
133
|
+
/** Class of the element wrapping the mounted surface. Default `mcp-view-surface-shell`. */
|
|
134
|
+
readonly surfaceClassName?: string;
|
|
135
|
+
/**
|
|
136
|
+
* Install the shared mcp-view stylesheet at boot. Default `true`. Only the
|
|
137
|
+
* boot install is skipped: kit primitives still install it when they mount,
|
|
138
|
+
* and the host theme (`createMcpApp`'s `autoTheme`) is unaffected.
|
|
139
|
+
*/
|
|
140
|
+
readonly theme?: boolean;
|
|
141
|
+
/** Forwarded to `createMcpApp`; unset keeps its default (`false`). */
|
|
142
|
+
readonly strict?: boolean;
|
|
143
|
+
/** Render one resolved status as the element the router mounts. */
|
|
144
|
+
readonly renderStatus: (status: SurfaceStatus) => Node;
|
|
145
|
+
/** Receives every failure the lifecycle absorbs. Default `console.error`. */
|
|
146
|
+
readonly onError?: (error: unknown) => void;
|
|
147
|
+
/**
|
|
148
|
+
* Runs once when the host tears the App down or `dispose()` runs, before
|
|
149
|
+
* the router disposes the surface. For what the App holds outside its
|
|
150
|
+
* surface — a bridge to the parent page, a subscription — since the handle
|
|
151
|
+
* has no other end-of-life signal. A throw is absorbed through `onError`.
|
|
152
|
+
*/
|
|
153
|
+
readonly onTeardown?: () => void | Promise<void>;
|
|
154
|
+
}
|
|
155
|
+
export interface SurfaceAppHandle<TData> {
|
|
156
|
+
/**
|
|
157
|
+
* Route one display state exactly as a host tool result would be. Rejects
|
|
158
|
+
* with `SURFACE_APP_CLOSED` once the host tore the App down or `dispose()`
|
|
159
|
+
* ran: there is no router left to show anything.
|
|
160
|
+
*/
|
|
161
|
+
show(state: SurfaceDisplayState<TData>): Promise<void>;
|
|
162
|
+
/** Manual disposal. Host teardown needs no call. */
|
|
163
|
+
dispose(): Promise<void>;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Injection seam for tests that cannot open an ext-apps transport. It is not
|
|
167
|
+
* a production extension point: a viewer never passes it.
|
|
168
|
+
*/
|
|
169
|
+
export interface SurfaceAppRuntime {
|
|
170
|
+
readonly createApp: typeof createMcpApp;
|
|
171
|
+
}
|
|
172
|
+
export type SurfaceAppErrorCode = "SURFACE_APP_PROJECTION_CONFLICT" | "SURFACE_APP_CLOSED";
|
|
173
|
+
/** Options refused at the boundary. Match on `code`, not on `message`. */
|
|
174
|
+
export declare class SurfaceAppError extends TypeError {
|
|
175
|
+
readonly code: SurfaceAppErrorCode;
|
|
176
|
+
readonly data: Readonly<Record<string, unknown>>;
|
|
177
|
+
constructor(code: SurfaceAppErrorCode, message: string, data?: Record<string, unknown>);
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Start a result-driven MCP App backed by a component registry.
|
|
181
|
+
*
|
|
182
|
+
* The registry may expose a default surface or be component-only. In the
|
|
183
|
+
* latter case a host-selected surface is required and no artificial
|
|
184
|
+
* standalone composition is invented.
|
|
185
|
+
*/
|
|
186
|
+
export declare function startSurfaceApp<TData, TSession = never>(options: SurfaceAppOptions<TData, TSession>, runtime?: SurfaceAppRuntime): Promise<SurfaceAppHandle<TData>>;
|
|
187
|
+
export {};
|
|
188
|
+
//# sourceMappingURL=surface-app.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"surface-app.d.ts","sourceRoot":"","sources":["../../src/src/surface-app.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,KAAK,SAAS,EACd,KAAK,UAAU,EAEf,YAAY,EAIb,MAAM,eAAe,CAAC;AACvB,OAAO,EAIL,KAAK,gBAAgB,EAIrB,KAAK,qBAAqB,EAC3B,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,EAAE,KAAK,eAA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