@mcpview/compose 0.13.0 → 0.13.1
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 +11 -0
- package/README.md +79 -2
- package/esm/_dnt.polyfills.d.ts +11 -11
- package/esm/_dnt.polyfills.d.ts.map +1 -1
- package/esm/_dnt.polyfills.js +14 -14
- package/esm/src/code-mode/board.d.ts +18 -2
- package/esm/src/code-mode/board.d.ts.map +1 -1
- package/esm/src/code-mode/board.js +74 -2
- package/esm/src/code-mode/chain.d.ts +2 -0
- package/esm/src/code-mode/chain.d.ts.map +1 -1
- package/esm/src/code-mode/chain.js +34 -8
- package/esm/src/code-mode/connections.d.ts +1 -0
- package/esm/src/code-mode/connections.d.ts.map +1 -1
- package/esm/src/code-mode/connections.js +1 -0
- package/esm/src/code-mode/layout-publisher.d.ts +69 -0
- package/esm/src/code-mode/layout-publisher.d.ts.map +1 -0
- package/esm/src/code-mode/layout-publisher.js +85 -0
- package/esm/src/code-mode/layout-runs.d.ts +35 -0
- package/esm/src/code-mode/layout-runs.d.ts.map +1 -0
- package/esm/src/code-mode/layout-runs.js +130 -0
- package/esm/src/code-mode/layout.d.ts +20 -0
- package/esm/src/code-mode/layout.d.ts.map +1 -0
- package/esm/src/code-mode/layout.js +54 -0
- package/esm/src/code-mode/mod.d.ts +1 -0
- package/esm/src/code-mode/mod.d.ts.map +1 -1
- package/esm/src/code-mode/mod.js +1 -0
- package/esm/src/code-mode/panel-contexts.d.ts +25 -0
- package/esm/src/code-mode/panel-contexts.d.ts.map +1 -0
- package/esm/src/code-mode/panel-contexts.js +115 -0
- package/esm/src/code-mode/providers.d.ts +3 -0
- package/esm/src/code-mode/providers.d.ts.map +1 -1
- package/esm/src/code-mode/sandbox.d.ts.map +1 -1
- package/esm/src/code-mode/sandbox.js +2 -1
- package/esm/src/code-mode/sync.d.ts +11 -0
- package/esm/src/code-mode/sync.d.ts.map +1 -0
- package/esm/src/code-mode/sync.js +42 -0
- package/esm/src/code-mode/tool.d.ts +1 -1
- package/esm/src/code-mode/tool.d.ts.map +1 -1
- package/esm/src/code-mode/tool.js +12 -0
- package/esm/src/host/renderer/html-generator.js +2 -2
- package/esm/src/host/renderer/panel-controls.d.ts +7 -0
- package/esm/src/host/renderer/panel-controls.js +1 -0
- package/esm/src/host/renderer/panel-movement.d.ts.map +1 -1
- package/esm/src/host/renderer/panel-movement.js +5 -1
- package/esm/src/host/renderer/panel-resizing.d.ts.map +1 -1
- package/esm/src/host/renderer/panel-resizing.js +28 -0
- package/esm/src/host/renderer/panel-snapshot.d.ts +11 -0
- package/esm/src/host/renderer/panel-snapshot.d.ts.map +1 -0
- package/esm/src/host/renderer/panel-snapshot.js +65 -0
- package/esm/src/version.d.ts +1 -1
- package/esm/src/version.js +1 -1
- package/package.json +9 -1
- package/script/_dnt.polyfills.d.ts +11 -11
- package/script/_dnt.polyfills.d.ts.map +1 -1
- package/script/_dnt.polyfills.js +14 -14
- package/script/src/code-mode/board.d.ts +18 -2
- package/script/src/code-mode/board.d.ts.map +1 -1
- package/script/src/code-mode/board.js +81 -2
- package/script/src/code-mode/chain.d.ts +2 -0
- package/script/src/code-mode/chain.d.ts.map +1 -1
- package/script/src/code-mode/chain.js +34 -8
- package/script/src/code-mode/connections.d.ts +1 -0
- package/script/src/code-mode/connections.d.ts.map +1 -1
- package/script/src/code-mode/connections.js +1 -0
- package/script/src/code-mode/layout-publisher.d.ts +69 -0
- package/script/src/code-mode/layout-publisher.d.ts.map +1 -0
- package/script/src/code-mode/layout-publisher.js +88 -0
- package/script/src/code-mode/layout-runs.d.ts +35 -0
- package/script/src/code-mode/layout-runs.d.ts.map +1 -0
- package/script/src/code-mode/layout-runs.js +134 -0
- package/script/src/code-mode/layout.d.ts +20 -0
- package/script/src/code-mode/layout.d.ts.map +1 -0
- package/script/src/code-mode/layout.js +57 -0
- package/script/src/code-mode/mod.d.ts +1 -0
- package/script/src/code-mode/mod.d.ts.map +1 -1
- package/script/src/code-mode/mod.js +6 -1
- package/script/src/code-mode/panel-contexts.d.ts +25 -0
- package/script/src/code-mode/panel-contexts.d.ts.map +1 -0
- package/script/src/code-mode/panel-contexts.js +118 -0
- package/script/src/code-mode/providers.d.ts +3 -0
- package/script/src/code-mode/providers.d.ts.map +1 -1
- package/script/src/code-mode/sandbox.d.ts.map +1 -1
- package/script/src/code-mode/sandbox.js +2 -1
- package/script/src/code-mode/sync.d.ts +11 -0
- package/script/src/code-mode/sync.d.ts.map +1 -0
- package/script/src/code-mode/sync.js +51 -0
- package/script/src/code-mode/tool.d.ts +1 -1
- package/script/src/code-mode/tool.d.ts.map +1 -1
- package/script/src/code-mode/tool.js +12 -0
- package/script/src/host/renderer/html-generator.js +2 -2
- package/script/src/host/renderer/panel-controls.d.ts +7 -0
- package/script/src/host/renderer/panel-controls.js +4 -1
- package/script/src/host/renderer/panel-movement.d.ts.map +1 -1
- package/script/src/host/renderer/panel-movement.js +5 -1
- package/script/src/host/renderer/panel-resizing.d.ts.map +1 -1
- package/script/src/host/renderer/panel-resizing.js +28 -0
- package/script/src/host/renderer/panel-snapshot.d.ts +11 -0
- package/script/src/host/renderer/panel-snapshot.d.ts.map +1 -0
- package/script/src/host/renderer/panel-snapshot.js +69 -0
- package/script/src/version.d.ts +1 -1
- package/script/src/version.js +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { snippetPorts } from "./sync.js";
|
|
1
2
|
import { maxCodeLength } from "./sandbox.js";
|
|
2
3
|
/** Build the tool declaration for registration with an MCPView server. */
|
|
3
4
|
export function createSnippetExecuteTool(options) {
|
|
@@ -6,6 +7,10 @@ export function createSnippetExecuteTool(options) {
|
|
|
6
7
|
throw new Error("Supply a ui:// resource URI for the board.");
|
|
7
8
|
}
|
|
8
9
|
const available = [...options.providers.keys()];
|
|
10
|
+
const eventPorts = [...options.providers].flatMap(([provider, config]) => config.names.flatMap((snippet) => {
|
|
11
|
+
const ports = snippetPorts(config.events, snippet);
|
|
12
|
+
return ports ? [{ provider, snippet, ...ports }] : [];
|
|
13
|
+
}));
|
|
9
14
|
return {
|
|
10
15
|
name: "execute",
|
|
11
16
|
description: [
|
|
@@ -14,6 +19,13 @@ export function createSnippetExecuteTool(options) {
|
|
|
14
19
|
"Configured provider aliases: " + JSON.stringify(available) + ".",
|
|
15
20
|
"await api.runSnippet(provider, name, input) returns a receipt {id, value}.",
|
|
16
21
|
"Pass values between calls. Use await api.panel(receipt.id, optionalTitle) for each result to display, in display order. Return a JSON summary.",
|
|
22
|
+
...(eventPorts.length
|
|
23
|
+
? [
|
|
24
|
+
"After selecting both panels, use await api.sync({from: source.id, event, to: target.id, action}) to route a UI event between them.",
|
|
25
|
+
"Use the source's declared emits and the target's declared accepts. Available panel event ports: " +
|
|
26
|
+
JSON.stringify(eventPorts) + ".",
|
|
27
|
+
]
|
|
28
|
+
: []),
|
|
17
29
|
...(options.savedChains
|
|
18
30
|
? [
|
|
19
31
|
"Use saveAs to save a successful chain, listSaved to list your saved chains, or replay with the saved name and new params.",
|
|
@@ -91,7 +91,7 @@ function generateBodyContent(descriptor, slots) {
|
|
|
91
91
|
const widths = isSupportedWidths(child.supportedWidths) && child.supportedWidths.length
|
|
92
92
|
? ` data-compose-widths="${child.supportedWidths.join(" ")}"`
|
|
93
93
|
: "";
|
|
94
|
-
return `<section class="compose-viewer" data-compose-panel data-panel-label="${escapeAttr(id)}"${area}${widths}>
|
|
94
|
+
return `<section class="compose-viewer" data-compose-panel data-compose-panel-id="${escapeAttr(id)}" data-panel-label="${escapeAttr(id)}"${area}${widths}>
|
|
95
95
|
${descriptor.children.length > 1 ? grip(child) : ""}
|
|
96
96
|
${generateIframe(child, slots.get(child.slot))}
|
|
97
97
|
</section>`;
|
|
@@ -111,7 +111,7 @@ function generateTabsLayout(descriptor, slots) {
|
|
|
111
111
|
</div>`;
|
|
112
112
|
}
|
|
113
113
|
const tabButtons = descriptor.children
|
|
114
|
-
.map((child, i) => `<div data-compose-panel data-panel-label="${escapeAttr(child.componentId ?? child.source)}">
|
|
114
|
+
.map((child, i) => `<div data-compose-panel data-compose-panel-id="${escapeAttr(child.componentId ?? child.source)}" data-panel-label="${escapeAttr(child.componentId ?? child.source)}">
|
|
115
115
|
${descriptor.children.length > 1 ? grip(child) : ""}
|
|
116
116
|
<button type="button" class="tab${i === 0 ? " active" : ""}" data-slot="${child.slot}">${escapeHtml(child.source)}</button></div>`)
|
|
117
117
|
.join("\n ");
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
+
import type { PanelLayoutSnapshot } from "../../code-mode/layout.js";
|
|
2
|
+
|
|
1
3
|
/** The board element available to a caller running in a DOM environment. */
|
|
2
4
|
type PanelContainer = typeof globalThis extends { HTMLElement: { prototype: infer Element } }
|
|
3
5
|
? Element
|
|
4
6
|
: never;
|
|
5
7
|
|
|
8
|
+
/** Capture the current board's committed choices, keeping the requested widths across viewport changes. */
|
|
9
|
+
export declare function capturePanelLayout(board: PanelContainer): PanelLayoutSnapshot | undefined;
|
|
10
|
+
/** Restore the snapshot in place on a compatible mounted board. */
|
|
11
|
+
export declare function restorePanelLayout(board: PanelContainer, value: unknown): boolean;
|
|
12
|
+
|
|
6
13
|
/** Install pointer and keyboard controls for moving panels within a Compose board. */
|
|
7
14
|
export declare function installPanelMovement(container: PanelContainer, signal?: AbortSignal): void;
|
|
8
15
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// @ts-self-types="./panel-controls.d.ts"
|
|
2
2
|
// Server consumers embed these functions in HTML. Only browsers execute their DOM code.
|
|
3
3
|
export { installPanelMovement } from "./panel-movement.js";
|
|
4
|
+
export { capturePanelLayout, restorePanelLayout } from "./panel-snapshot.js";
|
|
4
5
|
export { createPanelReflow } from "./panel-reflow.js";
|
|
5
6
|
export { installPanelResizing } from "./panel-resizing.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"panel-movement.d.ts","sourceRoot":"","sources":["../../../../src/src/host/renderer/panel-movement.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,gDAHW,WAAW,
|
|
1
|
+
{"version":3,"file":"panel-movement.d.ts","sourceRoot":"","sources":["../../../../src/src/host/renderer/panel-movement.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,gDAHW,WAAW,0CAkYrB"}
|
|
@@ -104,6 +104,7 @@ export function installPanelMovement(container, signal) {
|
|
|
104
104
|
function announceSwap(from, to) {
|
|
105
105
|
status.textContent = label(from) + " swapped with " + label(to) + ".";
|
|
106
106
|
container.dispatchEvent(new Event("compose-layout-change"));
|
|
107
|
+
container.dispatchEvent(new Event("compose-panel-layout-committed"));
|
|
107
108
|
}
|
|
108
109
|
/** @param {"preview" | "commit" | "cancel"} phase @param {FreePlace} place */
|
|
109
110
|
function placeBeside(phase, place) {
|
|
@@ -273,7 +274,9 @@ export function installPanelMovement(container, signal) {
|
|
|
273
274
|
return best;
|
|
274
275
|
}
|
|
275
276
|
for (const [index, panel] of panels.entries()) {
|
|
276
|
-
if (
|
|
277
|
+
if (namedAreas)
|
|
278
|
+
panel.dataset.composeTemplateArea ??= panel.dataset.area;
|
|
279
|
+
else
|
|
277
280
|
panel.style.order = String(index);
|
|
278
281
|
let grip = /** @type {HTMLButtonElement | null} */ (panel.querySelector("[data-compose-grip]"));
|
|
279
282
|
if (!grip) {
|
|
@@ -367,6 +370,7 @@ export function installPanelMovement(container, signal) {
|
|
|
367
370
|
const where = placement.side === "below" ? " below " : " beside ";
|
|
368
371
|
status.textContent = label(from) + " placed" + where + label(placement.beside) + ".";
|
|
369
372
|
container.dispatchEvent(new Event("compose-layout-change"));
|
|
373
|
+
container.dispatchEvent(new Event("compose-panel-layout-committed"));
|
|
370
374
|
}
|
|
371
375
|
select();
|
|
372
376
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"panel-resizing.d.ts","sourceRoot":"","sources":["../../../../src/src/host/renderer/panel-resizing.js"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,gDAJW,WAAW,+
|
|
1
|
+
{"version":3,"file":"panel-resizing.d.ts","sourceRoot":"","sources":["../../../../src/src/host/renderer/panel-resizing.js"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,gDAJW,WAAW,+FAoXrB;kCA1XiC,mBAAmB"}
|
|
@@ -85,6 +85,7 @@ export function installPanelResizing(container, signal, createReflow = createPan
|
|
|
85
85
|
function commitWidth(panel, width) {
|
|
86
86
|
choices.set(panel, width);
|
|
87
87
|
place();
|
|
88
|
+
container.dispatchEvent(new browser.Event("compose-panel-layout-committed"));
|
|
88
89
|
status.textContent = (panel.dataset.panelLabel || "Viewer") + " width " + width + " pixels.";
|
|
89
90
|
}
|
|
90
91
|
/** @param {KeyboardEvent} event @param {HTMLElement} panel @param {number[]} widths */
|
|
@@ -333,7 +334,34 @@ export function installPanelResizing(container, signal, createReflow = createPan
|
|
|
333
334
|
manualPreview = proposed;
|
|
334
335
|
schedule();
|
|
335
336
|
}, { signal });
|
|
337
|
+
// Expose committed preferences to the owning board without touching viewer results or iframes.
|
|
338
|
+
// Symbol.for also connects hosts that embed these controls as standalone JavaScript.
|
|
339
|
+
const slotState = Symbol.for("@mcpview/compose/panel-layout-controls/v1");
|
|
340
|
+
Reflect.set(container, slotState, {
|
|
341
|
+
read: () => ({
|
|
342
|
+
widths: Array.from(choices, ([p, width]) => ({ panel: p.dataset.composePanelId, width })),
|
|
343
|
+
placements: Array.from(placements, ([p, { beside, side }]) => ({
|
|
344
|
+
panel: p.dataset.composePanelId,
|
|
345
|
+
beside: beside.dataset.composePanelId,
|
|
346
|
+
side,
|
|
347
|
+
})),
|
|
348
|
+
}),
|
|
349
|
+
supports: (/** @type {HTMLElement} */ panel, /** @type {number} */ width) => declared.get(panel)?.includes(width) === true,
|
|
350
|
+
restore: (
|
|
351
|
+
/** @type {Array<[HTMLElement, number]>} */ widths,
|
|
352
|
+
/** @type {Array<[HTMLElement, Placement]>} */ positions) => {
|
|
353
|
+
choices.clear();
|
|
354
|
+
for (const [panel, width] of widths)
|
|
355
|
+
choices.set(panel, width);
|
|
356
|
+
placements = new Map(positions);
|
|
357
|
+
lastSlots = panels.map(slot);
|
|
358
|
+
manualPreview = undefined;
|
|
359
|
+
place();
|
|
360
|
+
schedule();
|
|
361
|
+
},
|
|
362
|
+
});
|
|
336
363
|
signal?.addEventListener("abort", () => {
|
|
364
|
+
Reflect.deleteProperty(container, slotState);
|
|
337
365
|
cancelDrag?.();
|
|
338
366
|
observer.disconnect();
|
|
339
367
|
browser.cancelAnimationFrame(pending);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Read only the last committed layout preferences.
|
|
2
|
+
* @param {HTMLElement} board
|
|
3
|
+
* @returns {import("../../code-mode/layout.ts").PanelLayoutSnapshot | undefined}
|
|
4
|
+
*/
|
|
5
|
+
export function capturePanelLayout(board: HTMLElement): import("../../code-mode/layout.ts").PanelLayoutSnapshot | undefined;
|
|
6
|
+
/** Apply a saved preference only to matching panels and current viewer width declarations.
|
|
7
|
+
* @param {HTMLElement} board
|
|
8
|
+
* @param {unknown} snapshot
|
|
9
|
+
*/
|
|
10
|
+
export function restorePanelLayout(board: HTMLElement, snapshot: unknown): boolean;
|
|
11
|
+
//# sourceMappingURL=panel-snapshot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"panel-snapshot.d.ts","sourceRoot":"","sources":["../../../../src/src/host/renderer/panel-snapshot.js"],"names":[],"mappings":"AAuBA;;;GAGG;AACH,0CAHW,WAAW,GACT,OAAO,2BAA2B,EAAE,mBAAmB,GAAG,SAAS,CAe/E;AAED;;;GAGG;AACH,0CAHW,WAAW,YACX,OAAO,WA2BjB"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { isPanelLayoutSnapshot } from "../../code-mode/layout.js";
|
|
2
|
+
const slotState = Symbol.for("@mcpview/compose/panel-layout-controls/v1");
|
|
3
|
+
/** @param {HTMLElement} board */
|
|
4
|
+
function panelSlots(board) {
|
|
5
|
+
const panels = Array.from(
|
|
6
|
+
/** @type {NodeListOf<HTMLElement>} */ (board.querySelectorAll(":scope > [data-compose-panel]")));
|
|
7
|
+
const ids = panels.map((node) => node.dataset.composePanelId);
|
|
8
|
+
if (!ids.every(Boolean) || new Set(ids).size !== ids.length)
|
|
9
|
+
return;
|
|
10
|
+
const named = panels.every((node) => node.dataset.area);
|
|
11
|
+
// Named areas follow the template even when the viewport changes its number of columns.
|
|
12
|
+
const slots = panels.map((node, i) => named ? node.dataset.composeTemplateArea ?? node.dataset.area ?? "" : String(i));
|
|
13
|
+
if (new Set(slots).size !== slots.length)
|
|
14
|
+
return;
|
|
15
|
+
return { panels, slots, named, byId: new Map(panels.map((p) => [p.dataset.composePanelId, p])) };
|
|
16
|
+
}
|
|
17
|
+
/** Read only the last committed layout preferences.
|
|
18
|
+
* @param {HTMLElement} board
|
|
19
|
+
* @returns {import("../../code-mode/layout.ts").PanelLayoutSnapshot | undefined}
|
|
20
|
+
*/
|
|
21
|
+
export function capturePanelLayout(board) {
|
|
22
|
+
if (board.hasAttribute("data-compose-dragging"))
|
|
23
|
+
return;
|
|
24
|
+
const table = panelSlots(board);
|
|
25
|
+
if (!table)
|
|
26
|
+
return;
|
|
27
|
+
const { panels, named, slots } = table;
|
|
28
|
+
const occupants = new Map(panels.map((panel, i) => [
|
|
29
|
+
named ? panel.dataset.area : (panel.style.order || String(i)),
|
|
30
|
+
panel.dataset.composePanelId,
|
|
31
|
+
]));
|
|
32
|
+
const controls = Reflect.get(board, slotState);
|
|
33
|
+
const geometry = controls?.read() ?? { widths: [], placements: [] };
|
|
34
|
+
const snapshot = { version: 1, order: slots.map((slot) => occupants.get(slot)), ...geometry };
|
|
35
|
+
return isPanelLayoutSnapshot(snapshot) ? snapshot : undefined;
|
|
36
|
+
}
|
|
37
|
+
/** Apply a saved preference only to matching panels and current viewer width declarations.
|
|
38
|
+
* @param {HTMLElement} board
|
|
39
|
+
* @param {unknown} snapshot
|
|
40
|
+
*/
|
|
41
|
+
export function restorePanelLayout(board, snapshot) {
|
|
42
|
+
if (!isPanelLayoutSnapshot(snapshot) || board.hasAttribute("data-compose-dragging"))
|
|
43
|
+
return false;
|
|
44
|
+
const table = panelSlots(board);
|
|
45
|
+
if (!table || snapshot.order.length !== table.panels.length ||
|
|
46
|
+
!snapshot.order.every((id) => table.byId.has(id)))
|
|
47
|
+
return false;
|
|
48
|
+
const controls = Reflect.get(board, slotState);
|
|
49
|
+
if ((snapshot.widths.length || snapshot.placements.length) && !controls)
|
|
50
|
+
return false;
|
|
51
|
+
if (!snapshot.widths.every(({ panel, width }) => controls?.supports(table.byId.get(panel), width)))
|
|
52
|
+
return false;
|
|
53
|
+
snapshot.order.forEach((id, index) => {
|
|
54
|
+
const panel = /** @type {HTMLElement} */ (table.byId.get(id));
|
|
55
|
+
if (table.named)
|
|
56
|
+
panel.dataset.area = table.slots[index];
|
|
57
|
+
else
|
|
58
|
+
panel.style.order = table.slots[index];
|
|
59
|
+
});
|
|
60
|
+
controls?.restore(snapshot.widths.map(({ panel, width }) => [table.byId.get(panel), width]), snapshot.placements.map(({ panel, beside, side }) => [
|
|
61
|
+
table.byId.get(panel),
|
|
62
|
+
{ beside: table.byId.get(beside), side },
|
|
63
|
+
]));
|
|
64
|
+
return true;
|
|
65
|
+
}
|
package/esm/src/version.d.ts
CHANGED
package/esm/src/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcpview/compose",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.1",
|
|
4
4
|
"description": "Compose and synchronize multiple MCP Apps UIs into composite dashboards",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mcp",
|
|
@@ -35,6 +35,14 @@
|
|
|
35
35
|
"import": "./esm/src/code-mode/mod.js",
|
|
36
36
|
"require": "./script/src/code-mode/mod.js"
|
|
37
37
|
},
|
|
38
|
+
"./code-mode/layout": {
|
|
39
|
+
"import": "./esm/src/code-mode/layout.js",
|
|
40
|
+
"require": "./script/src/code-mode/layout.js"
|
|
41
|
+
},
|
|
42
|
+
"./code-mode/layout-runs": {
|
|
43
|
+
"import": "./esm/src/code-mode/layout-runs.js",
|
|
44
|
+
"require": "./script/src/code-mode/layout-runs.js"
|
|
45
|
+
},
|
|
38
46
|
"./code-mode/board": {
|
|
39
47
|
"import": "./esm/src/code-mode/board.js",
|
|
40
48
|
"require": "./script/src/code-mode/board.js"
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface Object {
|
|
3
|
+
/**
|
|
4
|
+
* Determines whether an object has a property with the specified name.
|
|
5
|
+
* @param o An object.
|
|
6
|
+
* @param v A property name.
|
|
7
|
+
*/
|
|
8
|
+
hasOwn(o: object, v: PropertyKey): boolean;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
1
12
|
declare global {
|
|
2
13
|
interface Array<T> {
|
|
3
14
|
/**
|
|
@@ -47,17 +58,6 @@ declare global {
|
|
|
47
58
|
}
|
|
48
59
|
}
|
|
49
60
|
export {};
|
|
50
|
-
declare global {
|
|
51
|
-
interface Object {
|
|
52
|
-
/**
|
|
53
|
-
* Determines whether an object has a property with the specified name.
|
|
54
|
-
* @param o An object.
|
|
55
|
-
* @param v A property name.
|
|
56
|
-
*/
|
|
57
|
-
hasOwn(o: object, v: PropertyKey): boolean;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
export {};
|
|
61
61
|
declare global {
|
|
62
62
|
interface Error {
|
|
63
63
|
cause?: unknown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_dnt.polyfills.d.ts","sourceRoot":"","sources":["../src/_dnt.polyfills.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"_dnt.polyfills.d.ts","sourceRoot":"","sources":["../src/_dnt.polyfills.ts"],"names":[],"mappings":"AAeA,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd;;;;WAIG;QACH,MAAM,CA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H,aAAa,CACT,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,KAAK,OAAO,EACvE,OAAO,CAAC,EAAE,GAAG,GACd,MAAM,CAAC;KACX;CACF;AA4CD,OAAO,EAAE,CAAC;AACV,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,KAAK;QACb,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB;CACF;AAED,OAAO,EAAE,CAAC"}
|
package/script/_dnt.polyfills.js
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// https://github.com/tc39/proposal-accessible-object-hasownproperty/blob/main/polyfill.js
|
|
4
|
+
if (!Object.hasOwn) {
|
|
5
|
+
Object.defineProperty(Object, "hasOwn", {
|
|
6
|
+
value: function (object, property) {
|
|
7
|
+
if (object == null) {
|
|
8
|
+
throw new TypeError("Cannot convert undefined or null to object");
|
|
9
|
+
}
|
|
10
|
+
return Object.prototype.hasOwnProperty.call(Object(object), property);
|
|
11
|
+
},
|
|
12
|
+
configurable: true,
|
|
13
|
+
enumerable: false,
|
|
14
|
+
writable: true,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
3
17
|
function findLastIndex(self, callbackfn, that) {
|
|
4
18
|
const boundFunc = that === undefined ? callbackfn : callbackfn.bind(that);
|
|
5
19
|
let index = self.length - 1;
|
|
@@ -36,17 +50,3 @@ if (!Uint8Array.prototype.findLast) {
|
|
|
36
50
|
return findLast(this, callbackfn, that);
|
|
37
51
|
};
|
|
38
52
|
}
|
|
39
|
-
// https://github.com/tc39/proposal-accessible-object-hasownproperty/blob/main/polyfill.js
|
|
40
|
-
if (!Object.hasOwn) {
|
|
41
|
-
Object.defineProperty(Object, "hasOwn", {
|
|
42
|
-
value: function (object, property) {
|
|
43
|
-
if (object == null) {
|
|
44
|
-
throw new TypeError("Cannot convert undefined or null to object");
|
|
45
|
-
}
|
|
46
|
-
return Object.prototype.hasOwnProperty.call(Object(object), property);
|
|
47
|
-
},
|
|
48
|
-
configurable: true,
|
|
49
|
-
enumerable: false,
|
|
50
|
-
writable: true,
|
|
51
|
-
});
|
|
52
|
-
}
|
|
@@ -3,11 +3,17 @@
|
|
|
3
3
|
* @module
|
|
4
4
|
*/
|
|
5
5
|
import "../../_dnt.polyfills.js";
|
|
6
|
-
import type { ComponentSurface } from "../core/types/components.js";
|
|
6
|
+
import type { ComponentSurface, ViewComponentEventPorts } from "../core/types/components.js";
|
|
7
7
|
import type { CompositeUiDescriptor } from "../core/types/descriptor.js";
|
|
8
8
|
import type { UiLayout } from "../core/types/layout.js";
|
|
9
|
+
import type { UiSyncRule } from "../core/types/sync-rules.js";
|
|
10
|
+
import { SNIPPET_SYNC_META_KEY } from "./sync.js";
|
|
11
|
+
export { SNIPPET_SYNC_META_KEY };
|
|
12
|
+
export { createPanelContexts, type PanelContexts, type PanelContextUpdate, type SendPanelContext, } from "./panel-contexts.js";
|
|
13
|
+
export { connectSnippetBoardLayout, type SnippetBoardLayoutOptions, type SnippetLayoutReceipt, type SnippetLayoutStatus, } from "./layout-publisher.js";
|
|
9
14
|
export { getPanelControlsCss } from "../host/renderer/css/panel-controls.js";
|
|
10
|
-
export {
|
|
15
|
+
export { isPanelLayoutSnapshot, type PanelLayoutSnapshot } from "./layout.js";
|
|
16
|
+
export { capturePanelLayout, installPanelMovement, installPanelResizing, restorePanelLayout, } from "../host/renderer/panel-controls.js";
|
|
11
17
|
/** MCP App result metadata containing the receipts selected by the program. */
|
|
12
18
|
export declare const SNIPPET_PANELS_META_KEY = "io.mcpview/snippet-panels";
|
|
13
19
|
/** A selected provider result. The receipt ID distinguishes calls to the same snippet. */
|
|
@@ -17,6 +23,7 @@ export interface SnippetPanel {
|
|
|
17
23
|
readonly name: string;
|
|
18
24
|
readonly title: string;
|
|
19
25
|
readonly result: Record<string, unknown>;
|
|
26
|
+
readonly events?: ViewComponentEventPorts;
|
|
20
27
|
}
|
|
21
28
|
/** An App-owned view for a receipt, with optional renderer data and component selection. */
|
|
22
29
|
export interface SnippetPanelView {
|
|
@@ -25,6 +32,8 @@ export interface SnippetPanelView {
|
|
|
25
32
|
readonly surface?: ComponentSurface;
|
|
26
33
|
/** Widths offered by this local view in CSS pixels. An empty list disables resizing. */
|
|
27
34
|
readonly supportedWidths?: readonly number[];
|
|
35
|
+
/** Restrict routing to the ports implemented by this local view. */
|
|
36
|
+
readonly events?: ViewComponentEventPorts;
|
|
28
37
|
}
|
|
29
38
|
/** Display options supplied by the board hosting the results. */
|
|
30
39
|
export interface SnippetBoardOptions {
|
|
@@ -46,6 +55,8 @@ export interface SnippetBoardOptions {
|
|
|
46
55
|
* ```
|
|
47
56
|
*/
|
|
48
57
|
export declare function readSnippetPanels(result: unknown): SnippetPanel[];
|
|
58
|
+
/** Read unique, declared Compose routes between panels in this result. */
|
|
59
|
+
export declare function readSnippetSyncRules(result: unknown): UiSyncRule[];
|
|
49
60
|
/**
|
|
50
61
|
* Build a Compose descriptor from the current execution, without making any provider calls.
|
|
51
62
|
* Each child keeps its receipt in `context.panel` and adapter data in `context.view`.
|
|
@@ -63,4 +74,9 @@ export declare function readSnippetPanels(result: unknown): SnippetPanel[];
|
|
|
63
74
|
* ```
|
|
64
75
|
*/
|
|
65
76
|
export declare function composeSnippetBoard(result: unknown, options?: SnippetBoardOptions): CompositeUiDescriptor;
|
|
77
|
+
/**
|
|
78
|
+
* Deliver a JSON event through the current board's declared routes to mounted views.
|
|
79
|
+
* The board owns dispatch and supplies the receipts and data from its active UI.
|
|
80
|
+
*/
|
|
81
|
+
export declare function emitSnippetBoardEvent(descriptor: CompositeUiDescriptor, sourceReceiptId: string, event: string, data: unknown, deliver: (targetReceiptId: string, action: string, data: unknown) => void): void;
|
|
66
82
|
//# sourceMappingURL=board.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"board.d.ts","sourceRoot":"","sources":["../../../src/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EACjC,eAAe,EAAE,MAAM,EACvB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,CAAC,eAAe,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,KAAK,IAAI,GACxE,IAAI,CAoBN"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SNIPPET_PANELS_META_KEY = exports.installPanelResizing = exports.installPanelMovement = exports.getPanelControlsCss = void 0;
|
|
3
|
+
exports.SNIPPET_PANELS_META_KEY = exports.restorePanelLayout = exports.installPanelResizing = exports.installPanelMovement = exports.capturePanelLayout = exports.isPanelLayoutSnapshot = exports.getPanelControlsCss = exports.connectSnippetBoardLayout = exports.createPanelContexts = exports.SNIPPET_SYNC_META_KEY = void 0;
|
|
4
4
|
exports.readSnippetPanels = readSnippetPanels;
|
|
5
|
+
exports.readSnippetSyncRules = readSnippetSyncRules;
|
|
5
6
|
exports.composeSnippetBoard = composeSnippetBoard;
|
|
7
|
+
exports.emitSnippetBoardEvent = emitSnippetBoardEvent;
|
|
6
8
|
/**
|
|
7
9
|
* Browser-side composition of completed Code Mode results.
|
|
8
10
|
* @module
|
|
@@ -11,11 +13,21 @@ require("../../_dnt.polyfills.js");
|
|
|
11
13
|
const collector_js_1 = require("../core/collector/collector.js");
|
|
12
14
|
const extractor_js_1 = require("../core/collector/extractor.js");
|
|
13
15
|
const composer_js_1 = require("../core/composer/composer.js");
|
|
16
|
+
const sync_js_1 = require("./sync.js");
|
|
17
|
+
Object.defineProperty(exports, "SNIPPET_SYNC_META_KEY", { enumerable: true, get: function () { return sync_js_1.SNIPPET_SYNC_META_KEY; } });
|
|
18
|
+
var panel_contexts_js_1 = require("./panel-contexts.js");
|
|
19
|
+
Object.defineProperty(exports, "createPanelContexts", { enumerable: true, get: function () { return panel_contexts_js_1.createPanelContexts; } });
|
|
20
|
+
var layout_publisher_js_1 = require("./layout-publisher.js");
|
|
21
|
+
Object.defineProperty(exports, "connectSnippetBoardLayout", { enumerable: true, get: function () { return layout_publisher_js_1.connectSnippetBoardLayout; } });
|
|
14
22
|
var panel_controls_js_1 = require("../host/renderer/css/panel-controls.js");
|
|
15
23
|
Object.defineProperty(exports, "getPanelControlsCss", { enumerable: true, get: function () { return panel_controls_js_1.getPanelControlsCss; } });
|
|
24
|
+
var layout_js_1 = require("./layout.js");
|
|
25
|
+
Object.defineProperty(exports, "isPanelLayoutSnapshot", { enumerable: true, get: function () { return layout_js_1.isPanelLayoutSnapshot; } });
|
|
16
26
|
var panel_controls_js_2 = require("../host/renderer/panel-controls.js");
|
|
27
|
+
Object.defineProperty(exports, "capturePanelLayout", { enumerable: true, get: function () { return panel_controls_js_2.capturePanelLayout; } });
|
|
17
28
|
Object.defineProperty(exports, "installPanelMovement", { enumerable: true, get: function () { return panel_controls_js_2.installPanelMovement; } });
|
|
18
29
|
Object.defineProperty(exports, "installPanelResizing", { enumerable: true, get: function () { return panel_controls_js_2.installPanelResizing; } });
|
|
30
|
+
Object.defineProperty(exports, "restorePanelLayout", { enumerable: true, get: function () { return panel_controls_js_2.restorePanelLayout; } });
|
|
19
31
|
/** MCP App result metadata containing the receipts selected by the program. */
|
|
20
32
|
exports.SNIPPET_PANELS_META_KEY = "io.mcpview/snippet-panels";
|
|
21
33
|
function record(value) {
|
|
@@ -56,6 +68,33 @@ function readSnippetPanels(result) {
|
|
|
56
68
|
}
|
|
57
69
|
return panels;
|
|
58
70
|
}
|
|
71
|
+
/** Read unique, declared Compose routes between panels in this result. */
|
|
72
|
+
function readSnippetSyncRules(result) {
|
|
73
|
+
if (!record(result) || !record(result._meta))
|
|
74
|
+
return [];
|
|
75
|
+
const routes = result._meta[sync_js_1.SNIPPET_SYNC_META_KEY];
|
|
76
|
+
const items = result._meta[exports.SNIPPET_PANELS_META_KEY];
|
|
77
|
+
if (!Array.isArray(routes) || !Array.isArray(items))
|
|
78
|
+
return [];
|
|
79
|
+
const panels = new Map();
|
|
80
|
+
const duplicates = new Set();
|
|
81
|
+
for (const item of items) {
|
|
82
|
+
if (!isPanel(item))
|
|
83
|
+
continue;
|
|
84
|
+
if (panels.has(item.id))
|
|
85
|
+
duplicates.add(item.id);
|
|
86
|
+
panels.set(item.id, (0, sync_js_1.readSnippetEventPorts)(item.events));
|
|
87
|
+
}
|
|
88
|
+
for (const id of duplicates)
|
|
89
|
+
panels.delete(id);
|
|
90
|
+
const rules = new Map();
|
|
91
|
+
for (const item of routes) {
|
|
92
|
+
const rule = (0, sync_js_1.parseSnippetSyncRule)(item);
|
|
93
|
+
if (rule && (0, sync_js_1.supportsSnippetSync)(rule, panels))
|
|
94
|
+
rules.set((0, sync_js_1.snippetSyncKey)(rule), rule);
|
|
95
|
+
}
|
|
96
|
+
return [...rules.values()];
|
|
97
|
+
}
|
|
59
98
|
/**
|
|
60
99
|
* Build a Compose descriptor from the current execution, without making any provider calls.
|
|
61
100
|
* Each child keeps its receipt in `context.panel` and adapter data in `context.view`.
|
|
@@ -77,13 +116,24 @@ function composeSnippetBoard(result, options = {}) {
|
|
|
77
116
|
? result.structuredContent
|
|
78
117
|
: {};
|
|
79
118
|
const collector = (0, collector_js_1.createCollector)();
|
|
119
|
+
const mountedPorts = new Map();
|
|
80
120
|
for (const panel of readSnippetPanels(result)) {
|
|
81
121
|
const view = options.resolveView?.(panel);
|
|
82
122
|
const resourceUri = view?.resourceUri ?? (0, extractor_js_1.extractUiMeta)(panel.result)?.resourceUri;
|
|
83
123
|
if (!resourceUri || !/^ui:\/\/[^\s]+$/.test(resourceUri))
|
|
84
124
|
continue;
|
|
125
|
+
const declared = (0, sync_js_1.readSnippetEventPorts)(panel.events);
|
|
126
|
+
const viewEvents = (0, sync_js_1.readSnippetEventPorts)(view?.events);
|
|
127
|
+
const panelEvents = view
|
|
128
|
+
? {
|
|
129
|
+
emits: declared?.emits?.filter((name) => viewEvents?.emits?.includes(name)),
|
|
130
|
+
accepts: declared?.accepts?.filter((name) => viewEvents?.accepts?.includes(name)),
|
|
131
|
+
}
|
|
132
|
+
: declared;
|
|
133
|
+
mountedPorts.set(panel.id, panelEvents);
|
|
85
134
|
collector.collect(`${panel.provider}:${panel.name}`, { _meta: { ui: { resourceUri } } }, {
|
|
86
135
|
panel,
|
|
136
|
+
panelEvents,
|
|
87
137
|
...(view?.context === undefined ? {} : { view: view.context }),
|
|
88
138
|
...(Object.hasOwn(summary, "value") ? { value: summary.value } : {}),
|
|
89
139
|
}, { componentId: panel.id, surface: view?.surface, supportedWidths: view?.supportedWidths });
|
|
@@ -92,5 +142,34 @@ function composeSnippetBoard(result, options = {}) {
|
|
|
92
142
|
const layout = typeof options.layout === "function"
|
|
93
143
|
? options.layout(resources.length)
|
|
94
144
|
: options.layout;
|
|
95
|
-
|
|
145
|
+
const sync = readSnippetSyncRules(result).filter((rule) => (0, sync_js_1.supportsSnippetSync)(rule, mountedPorts));
|
|
146
|
+
return (0, composer_js_1.buildCompositeUi)(resources, { layout: layout ?? "stack", sharedContext: ["value"], sync });
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Deliver a JSON event through the current board's declared routes to mounted views.
|
|
150
|
+
* The board owns dispatch and supplies the receipts and data from its active UI.
|
|
151
|
+
*/
|
|
152
|
+
function emitSnippetBoardEvent(descriptor, sourceReceiptId, event, data, deliver) {
|
|
153
|
+
const source = descriptor.children.find((child) => child.componentId === sourceReceiptId);
|
|
154
|
+
if (!source || !(0, sync_js_1.readSnippetEventPorts)(source.context?.panelEvents)?.emits?.includes(event)) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
let payload;
|
|
158
|
+
try {
|
|
159
|
+
payload = JSON.stringify(data);
|
|
160
|
+
}
|
|
161
|
+
catch {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
if (payload === undefined || payload.length > 128 * 1024)
|
|
165
|
+
return;
|
|
166
|
+
for (const rule of descriptor.sync) {
|
|
167
|
+
if (rule.from !== source.slot || rule.event !== event || rule.to === "*")
|
|
168
|
+
continue;
|
|
169
|
+
const target = descriptor.children.find((child) => child.slot === rule.to);
|
|
170
|
+
const ports = (0, sync_js_1.readSnippetEventPorts)(target?.context?.panelEvents);
|
|
171
|
+
if (target?.componentId && ports?.accepts?.includes(rule.action)) {
|
|
172
|
+
deliver(target.componentId, rule.action, JSON.parse(payload));
|
|
173
|
+
}
|
|
174
|
+
}
|
|
96
175
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { CallToolResult } from "@modelcontextprotocol/client";
|
|
2
2
|
import type { SnippetCatalog } from "@mcpview/server/snippets";
|
|
3
|
+
import type { ViewComponentEventPorts } from "../core/types/components.js";
|
|
3
4
|
import { type SnippetChainContext, type SnippetProvider } from "./providers.js";
|
|
4
5
|
/** Selected native result, available only to the MCP App in result metadata. */
|
|
5
6
|
export interface SnippetPanelReceipt {
|
|
@@ -8,6 +9,7 @@ export interface SnippetPanelReceipt {
|
|
|
8
9
|
name: string;
|
|
9
10
|
title: string;
|
|
10
11
|
result: CallToolResult;
|
|
12
|
+
events?: ViewComponentEventPorts;
|
|
11
13
|
}
|
|
12
14
|
/** Execute input from the MCP tool using trusted context supplied separately by the host. */
|
|
13
15
|
export type SnippetChainExecutor = (input: Record<string, unknown>, context?: SnippetChainContext) => Promise<CallToolResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../../../src/src/code-mode/chain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAqB,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../../../src/src/code-mode/chain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAqB,MAAM,0BAA0B,CAAC;AAClF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAU3E,OAAO,EAAiB,KAAK,mBAAmB,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAI/F,gFAAgF;AAChF,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,cAAc,CAAC;IACvB,MAAM,CAAC,EAAE,uBAAuB,CAAC;CAClC;AAyED,6FAA6F;AAC7F,MAAM,MAAM,oBAAoB,GAAG,CACjC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,OAAO,CAAC,EAAE,mBAAmB,KAC1B,OAAO,CAAC,cAAc,CAAC,CAAC;AAE7B;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,eAAe,CAAC,EAC/C,OAAO,CAAC,EAAE,cAAc,GACvB,oBAAoB,CA+NtB"}
|