@mcpview/compose 0.12.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.
Files changed (169) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +104 -1
  3. package/esm/_dnt.polyfills.d.ts +49 -0
  4. package/esm/_dnt.polyfills.d.ts.map +1 -1
  5. package/esm/_dnt.polyfills.js +36 -0
  6. package/esm/src/code-mode/board.d.ts +21 -1
  7. package/esm/src/code-mode/board.d.ts.map +1 -1
  8. package/esm/src/code-mode/board.js +76 -2
  9. package/esm/src/code-mode/chain.d.ts +2 -0
  10. package/esm/src/code-mode/chain.d.ts.map +1 -1
  11. package/esm/src/code-mode/chain.js +34 -8
  12. package/esm/src/code-mode/connections.d.ts +1 -0
  13. package/esm/src/code-mode/connections.d.ts.map +1 -1
  14. package/esm/src/code-mode/connections.js +1 -0
  15. package/esm/src/code-mode/layout-publisher.d.ts +69 -0
  16. package/esm/src/code-mode/layout-publisher.d.ts.map +1 -0
  17. package/esm/src/code-mode/layout-publisher.js +85 -0
  18. package/esm/src/code-mode/layout-runs.d.ts +35 -0
  19. package/esm/src/code-mode/layout-runs.d.ts.map +1 -0
  20. package/esm/src/code-mode/layout-runs.js +130 -0
  21. package/esm/src/code-mode/layout.d.ts +20 -0
  22. package/esm/src/code-mode/layout.d.ts.map +1 -0
  23. package/esm/src/code-mode/layout.js +54 -0
  24. package/esm/src/code-mode/mod.d.ts +1 -0
  25. package/esm/src/code-mode/mod.d.ts.map +1 -1
  26. package/esm/src/code-mode/mod.js +1 -0
  27. package/esm/src/code-mode/panel-contexts.d.ts +25 -0
  28. package/esm/src/code-mode/panel-contexts.d.ts.map +1 -0
  29. package/esm/src/code-mode/panel-contexts.js +115 -0
  30. package/esm/src/code-mode/providers.d.ts +3 -0
  31. package/esm/src/code-mode/providers.d.ts.map +1 -1
  32. package/esm/src/code-mode/sandbox.d.ts.map +1 -1
  33. package/esm/src/code-mode/sandbox.js +2 -1
  34. package/esm/src/code-mode/sync.d.ts +11 -0
  35. package/esm/src/code-mode/sync.d.ts.map +1 -0
  36. package/esm/src/code-mode/sync.js +42 -0
  37. package/esm/src/code-mode/tool.d.ts +1 -1
  38. package/esm/src/code-mode/tool.d.ts.map +1 -1
  39. package/esm/src/code-mode/tool.js +12 -0
  40. package/esm/src/core/collector/collector.d.ts +2 -1
  41. package/esm/src/core/collector/collector.d.ts.map +1 -1
  42. package/esm/src/core/collector/collector.js +6 -0
  43. package/esm/src/core/types/resources.d.ts +4 -0
  44. package/esm/src/core/types/resources.d.ts.map +1 -1
  45. package/esm/src/core/types/resources.js +10 -1
  46. package/esm/src/host/renderer/css/base.d.ts.map +1 -1
  47. package/esm/src/host/renderer/css/base.js +3 -0
  48. package/esm/src/host/renderer/css/layouts.d.ts.map +1 -1
  49. package/esm/src/host/renderer/css/layouts.js +17 -14
  50. package/esm/src/host/renderer/css/panel-controls.d.ts +3 -0
  51. package/esm/src/host/renderer/css/panel-controls.d.ts.map +1 -0
  52. package/esm/src/host/renderer/css/panel-controls.js +89 -0
  53. package/esm/src/host/renderer/html-generator.d.ts.map +1 -1
  54. package/esm/src/host/renderer/html-generator.js +38 -42
  55. package/esm/src/host/renderer/js/card-height.d.ts +3 -0
  56. package/esm/src/host/renderer/js/card-height.d.ts.map +1 -0
  57. package/esm/src/host/renderer/js/card-height.js +58 -0
  58. package/esm/src/host/renderer/js/event-bus.d.ts.map +1 -1
  59. package/esm/src/host/renderer/js/event-bus.js +32 -12
  60. package/esm/src/host/renderer/panel-controls.d.ts +30 -0
  61. package/esm/src/host/renderer/panel-controls.d.ts.map +1 -0
  62. package/esm/src/host/renderer/panel-controls.js +6 -0
  63. package/esm/src/host/renderer/panel-movement.d.ts +8 -0
  64. package/esm/src/host/renderer/panel-movement.d.ts.map +1 -0
  65. package/esm/src/host/renderer/panel-movement.js +396 -0
  66. package/esm/src/host/renderer/panel-reflow.d.ts +17 -0
  67. package/esm/src/host/renderer/panel-reflow.d.ts.map +1 -0
  68. package/esm/src/host/renderer/panel-reflow.js +342 -0
  69. package/esm/src/host/renderer/panel-resizing.d.ts +11 -0
  70. package/esm/src/host/renderer/panel-resizing.d.ts.map +1 -0
  71. package/esm/src/host/renderer/panel-resizing.js +375 -0
  72. package/esm/src/host/renderer/panel-snapshot.d.ts +11 -0
  73. package/esm/src/host/renderer/panel-snapshot.d.ts.map +1 -0
  74. package/esm/src/host/renderer/panel-snapshot.js +65 -0
  75. package/esm/src/runtime/compose.d.ts.map +1 -1
  76. package/esm/src/runtime/compose.js +3 -0
  77. package/esm/src/runtime/manifest.d.ts.map +1 -1
  78. package/esm/src/runtime/manifest.js +4 -0
  79. package/esm/src/runtime/types.d.ts +2 -0
  80. package/esm/src/runtime/types.d.ts.map +1 -1
  81. package/esm/src/sdk/mcp-sdk.d.ts +2 -1
  82. package/esm/src/sdk/mcp-sdk.d.ts.map +1 -1
  83. package/esm/src/sdk/mcp-sdk.js +2 -2
  84. package/esm/src/version.d.ts +1 -1
  85. package/esm/src/version.js +1 -1
  86. package/package.json +9 -1
  87. package/script/_dnt.polyfills.d.ts +49 -0
  88. package/script/_dnt.polyfills.d.ts.map +1 -1
  89. package/script/_dnt.polyfills.js +36 -0
  90. package/script/src/code-mode/board.d.ts +21 -1
  91. package/script/src/code-mode/board.d.ts.map +1 -1
  92. package/script/src/code-mode/board.js +87 -3
  93. package/script/src/code-mode/chain.d.ts +2 -0
  94. package/script/src/code-mode/chain.d.ts.map +1 -1
  95. package/script/src/code-mode/chain.js +34 -8
  96. package/script/src/code-mode/connections.d.ts +1 -0
  97. package/script/src/code-mode/connections.d.ts.map +1 -1
  98. package/script/src/code-mode/connections.js +1 -0
  99. package/script/src/code-mode/layout-publisher.d.ts +69 -0
  100. package/script/src/code-mode/layout-publisher.d.ts.map +1 -0
  101. package/script/src/code-mode/layout-publisher.js +88 -0
  102. package/script/src/code-mode/layout-runs.d.ts +35 -0
  103. package/script/src/code-mode/layout-runs.d.ts.map +1 -0
  104. package/script/src/code-mode/layout-runs.js +134 -0
  105. package/script/src/code-mode/layout.d.ts +20 -0
  106. package/script/src/code-mode/layout.d.ts.map +1 -0
  107. package/script/src/code-mode/layout.js +57 -0
  108. package/script/src/code-mode/mod.d.ts +1 -0
  109. package/script/src/code-mode/mod.d.ts.map +1 -1
  110. package/script/src/code-mode/mod.js +6 -1
  111. package/script/src/code-mode/panel-contexts.d.ts +25 -0
  112. package/script/src/code-mode/panel-contexts.d.ts.map +1 -0
  113. package/script/src/code-mode/panel-contexts.js +118 -0
  114. package/script/src/code-mode/providers.d.ts +3 -0
  115. package/script/src/code-mode/providers.d.ts.map +1 -1
  116. package/script/src/code-mode/sandbox.d.ts.map +1 -1
  117. package/script/src/code-mode/sandbox.js +2 -1
  118. package/script/src/code-mode/sync.d.ts +11 -0
  119. package/script/src/code-mode/sync.d.ts.map +1 -0
  120. package/script/src/code-mode/sync.js +51 -0
  121. package/script/src/code-mode/tool.d.ts +1 -1
  122. package/script/src/code-mode/tool.d.ts.map +1 -1
  123. package/script/src/code-mode/tool.js +12 -0
  124. package/script/src/core/collector/collector.d.ts +2 -1
  125. package/script/src/core/collector/collector.d.ts.map +1 -1
  126. package/script/src/core/collector/collector.js +6 -0
  127. package/script/src/core/types/resources.d.ts +4 -0
  128. package/script/src/core/types/resources.d.ts.map +1 -1
  129. package/script/src/core/types/resources.js +11 -0
  130. package/script/src/host/renderer/css/base.d.ts.map +1 -1
  131. package/script/src/host/renderer/css/base.js +3 -0
  132. package/script/src/host/renderer/css/layouts.d.ts.map +1 -1
  133. package/script/src/host/renderer/css/layouts.js +17 -14
  134. package/script/src/host/renderer/css/panel-controls.d.ts +3 -0
  135. package/script/src/host/renderer/css/panel-controls.d.ts.map +1 -0
  136. package/script/src/host/renderer/css/panel-controls.js +92 -0
  137. package/script/src/host/renderer/html-generator.d.ts.map +1 -1
  138. package/script/src/host/renderer/html-generator.js +38 -42
  139. package/script/src/host/renderer/js/card-height.d.ts +3 -0
  140. package/script/src/host/renderer/js/card-height.d.ts.map +1 -0
  141. package/script/src/host/renderer/js/card-height.js +61 -0
  142. package/script/src/host/renderer/js/event-bus.d.ts.map +1 -1
  143. package/script/src/host/renderer/js/event-bus.js +32 -12
  144. package/script/src/host/renderer/panel-controls.d.ts +30 -0
  145. package/script/src/host/renderer/panel-controls.d.ts.map +1 -0
  146. package/script/src/host/renderer/panel-controls.js +14 -0
  147. package/script/src/host/renderer/panel-movement.d.ts +8 -0
  148. package/script/src/host/renderer/panel-movement.d.ts.map +1 -0
  149. package/script/src/host/renderer/panel-movement.js +399 -0
  150. package/script/src/host/renderer/panel-reflow.d.ts +17 -0
  151. package/script/src/host/renderer/panel-reflow.d.ts.map +1 -0
  152. package/script/src/host/renderer/panel-reflow.js +345 -0
  153. package/script/src/host/renderer/panel-resizing.d.ts +11 -0
  154. package/script/src/host/renderer/panel-resizing.d.ts.map +1 -0
  155. package/script/src/host/renderer/panel-resizing.js +378 -0
  156. package/script/src/host/renderer/panel-snapshot.d.ts +11 -0
  157. package/script/src/host/renderer/panel-snapshot.d.ts.map +1 -0
  158. package/script/src/host/renderer/panel-snapshot.js +69 -0
  159. package/script/src/runtime/compose.d.ts.map +1 -1
  160. package/script/src/runtime/compose.js +3 -0
  161. package/script/src/runtime/manifest.d.ts.map +1 -1
  162. package/script/src/runtime/manifest.js +4 -0
  163. package/script/src/runtime/types.d.ts +2 -0
  164. package/script/src/runtime/types.d.ts.map +1 -1
  165. package/script/src/sdk/mcp-sdk.d.ts +2 -1
  166. package/script/src/sdk/mcp-sdk.d.ts.map +1 -1
  167. package/script/src/sdk/mcp-sdk.js +2 -2
  168. package/script/src/version.d.ts +1 -1
  169. package/script/src/version.js +1 -1
@@ -0,0 +1,375 @@
1
+ import { createPanelReflow } from "./panel-reflow.js";
2
+ /**
3
+ * Choose one of a viewer's declared viewport widths from its bottom-right corner.
4
+ * The standalone host embeds this function as JavaScript and supplies the layout
5
+ * factory as the third argument. A viewer always owns its intrinsic height.
6
+ * @param {HTMLElement} container
7
+ * @param {AbortSignal} [signal]
8
+ * @param {typeof createPanelReflow} [createReflow]
9
+ */
10
+ export function installPanelResizing(container, signal, createReflow = createPanelReflow) {
11
+ const doc = container.ownerDocument;
12
+ if (!doc.defaultView || signal?.aborted || container.hasAttribute("data-compose-resizing-ready"))
13
+ return;
14
+ const browser = doc.defaultView;
15
+ if (browser.getComputedStyle(container).display !== "grid")
16
+ return;
17
+ const panels = Array.from(
18
+ /** @type {NodeListOf<HTMLElement>} */ (container.querySelectorAll(":scope > [data-compose-panel]")));
19
+ if (!panels.length)
20
+ return;
21
+ /** @type {Map<HTMLElement, number[]>} */
22
+ const declared = new Map();
23
+ for (const panel of panels) {
24
+ const widths = (panel.dataset.composeWidths ?? "").trim().split(/\s+/)
25
+ .filter((s) => /^\d+$/.test(s)).map(Number)
26
+ .filter((n) => Number.isSafeInteger(n) && n > 0);
27
+ if (widths.length)
28
+ declared.set(panel, [...new Set(widths)].sort((a, b) => a - b));
29
+ }
30
+ if (!declared.size && panels.length < 2)
31
+ return;
32
+ container.setAttribute("data-compose-resizing-ready", "");
33
+ const reflow = createReflow(container);
34
+ const status = doc.createElement("span");
35
+ status.setAttribute("role", "status");
36
+ status.style.cssText =
37
+ "position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)";
38
+ if (declared.size)
39
+ container.append(status);
40
+ /** @type {Map<HTMLElement, number>} */
41
+ const choices = new Map();
42
+ /** @typedef {{beside:HTMLElement, side:"left"|"right"|"below"}} Placement */
43
+ /** @type {Map<HTMLElement, Placement>} */
44
+ let placements = new Map();
45
+ /** @type {Map<HTMLElement, Placement> | undefined} */
46
+ let manualPreview;
47
+ let lastSlots = panels.map(slot);
48
+ /** @type {Map<HTMLElement, HTMLButtonElement>} */
49
+ const handles = new Map();
50
+ /** @type {(() => void) | undefined} */
51
+ let cancelDrag;
52
+ /** @type {(() => void) | undefined} */
53
+ let projectDrag;
54
+ let available = -1, viewport = -1, pending = 0;
55
+ /** Return the chosen widths that fit now; a wider choice survives a temporary narrow viewport. */
56
+ function fittingChoices() {
57
+ /** @type {Map<HTMLElement, number>} */
58
+ const fitting = new Map();
59
+ for (const [panel, wanted] of choices) {
60
+ const widths = /** @type {number[]} */ (declared.get(panel));
61
+ const width = widths.filter((n) => n <= available && n <= wanted).at(-1);
62
+ if (width !== undefined)
63
+ fitting.set(panel, width);
64
+ }
65
+ return fitting;
66
+ }
67
+ /** @param {HTMLElement} panel */
68
+ function slot(panel) {
69
+ return panel.dataset.area ?? panel.style.order;
70
+ }
71
+ // Swapping a viewer supersedes its previous manual drop. During a swap
72
+ // preview keep the previous placement so canceling restores it.
73
+ function placementsAfterSwap() {
74
+ const result = new Map(placements);
75
+ panels.forEach((panel, i) => {
76
+ if (slot(panel) !== lastSlots[i])
77
+ result.delete(panel);
78
+ });
79
+ return result;
80
+ }
81
+ function place() {
82
+ reflow.layout(fittingChoices(), undefined, manualPreview ?? placementsAfterSwap());
83
+ }
84
+ /** @param {HTMLElement} panel @param {number} width */
85
+ function commitWidth(panel, width) {
86
+ choices.set(panel, width);
87
+ place();
88
+ container.dispatchEvent(new browser.Event("compose-panel-layout-committed"));
89
+ status.textContent = (panel.dataset.panelLabel || "Viewer") + " width " + width + " pixels.";
90
+ }
91
+ /** @param {KeyboardEvent} event @param {HTMLElement} panel @param {number[]} widths */
92
+ function keyboard(event, panel, widths) {
93
+ if (cancelDrag)
94
+ return;
95
+ const options = widths.filter((n) => n <= available);
96
+ const current = panel.getBoundingClientRect().width;
97
+ let next;
98
+ switch (event.key) {
99
+ case "ArrowLeft":
100
+ next = options.filter((n) => n < current - 0.5).at(-1);
101
+ break;
102
+ case "ArrowRight":
103
+ next = options.find((n) => n > current + 0.5);
104
+ break;
105
+ case "Home":
106
+ next = options[0];
107
+ break;
108
+ case "End":
109
+ next = options.at(-1);
110
+ break;
111
+ default:
112
+ return;
113
+ }
114
+ event.preventDefault();
115
+ if (next === undefined || Math.abs(next - current) < 0.5)
116
+ return;
117
+ commitWidth(panel, next);
118
+ schedule();
119
+ }
120
+ /**
121
+ * @param {PointerEvent} event @param {HTMLElement} panel
122
+ * @param {HTMLButtonElement} handle @param {number[]} widths
123
+ */
124
+ function start(event, panel, handle, widths) {
125
+ if (container.hasAttribute("data-compose-dragging") || !event.isPrimary || event.button !== 0) {
126
+ return;
127
+ }
128
+ const options = widths.filter((n) => n <= available);
129
+ const bounds = panel.getBoundingClientRect();
130
+ const initial = bounds.width;
131
+ // The authored (possibly fluid) width is the gesture's neutral position.
132
+ const stops = [...options.filter((n) => Math.abs(n - initial) > 0.5), initial].sort((a, b) => a - b);
133
+ if (stops.length < 2)
134
+ return;
135
+ const horizontal = new Map(stops.map((width) => [width, width - initial]));
136
+ const wider = stops.filter((width) => width > initial);
137
+ const down = new Map([initial, ...wider].map((width, i) => [width, i * 40]));
138
+ // At the physical edge the pointer cannot reach the next horizontal midpoint.
139
+ // Pulling down there steps through wider presets without changing height.
140
+ const firstGap = wider[0] - initial;
141
+ const edgeFallback = viewport - bounds.right <= 28 &&
142
+ viewport - event.clientX < firstGap / 2 + Math.min(6, firstGap / 8);
143
+ event.preventDefault();
144
+ const skeleton = doc.createElement("div");
145
+ skeleton.dataset.composeDropPreview = "";
146
+ skeleton.dataset.composeResizePreview = "";
147
+ skeleton.setAttribute("aria-hidden", "true");
148
+ skeleton.inert = true;
149
+ const drag = new AbortController();
150
+ let preview = initial;
151
+ handle.focus({ preventScroll: true });
152
+ handle.setPointerCapture(event.pointerId);
153
+ container.setAttribute("data-compose-dragging", "");
154
+ panel.setAttribute("data-compose-resizing", "");
155
+ /** @param {boolean} commit */
156
+ function finish(commit) {
157
+ drag.abort();
158
+ cancelDrag = undefined;
159
+ projectDrag = undefined;
160
+ if (handle.hasPointerCapture(event.pointerId))
161
+ handle.releasePointerCapture(event.pointerId);
162
+ container.removeAttribute("data-compose-dragging");
163
+ panel.removeAttribute("data-compose-resizing");
164
+ if (preview !== initial) {
165
+ if (commit)
166
+ commitWidth(panel, preview);
167
+ else
168
+ place();
169
+ }
170
+ schedule();
171
+ }
172
+ cancelDrag = () => finish(false);
173
+ projectDrag = () => {
174
+ // A new row can introduce a vertical scrollbar. Keep the gesture alive
175
+ // and project the same preset into the board's available width.
176
+ if (preview > available)
177
+ preview = initial;
178
+ const fitting = fittingChoices();
179
+ if (preview === initial)
180
+ reflow.layout(fitting, undefined, placements);
181
+ else {
182
+ fitting.set(panel, preview);
183
+ reflow.layout(fitting, { panel, skeleton }, placements);
184
+ }
185
+ };
186
+ browser.addEventListener("blur", cancelDrag, { signal: drag.signal });
187
+ handle.addEventListener("keydown", (key) => {
188
+ if (key.key === "Escape") {
189
+ key.preventDefault();
190
+ finish(false);
191
+ }
192
+ }, { signal: drag.signal });
193
+ handle.addEventListener("pointermove", (move) => {
194
+ if (move.pointerId !== event.pointerId)
195
+ return;
196
+ const dx = move.clientX - event.clientX;
197
+ const dy = move.clientY - event.clientY;
198
+ const pullDown = edgeFallback && dy > Math.abs(dx);
199
+ const positions = pullDown ? down : horizontal;
200
+ const delta = pullDown ? dy : dx;
201
+ let next = initial;
202
+ if (Math.abs(delta) >= 5) {
203
+ let nearest = 0;
204
+ for (const [width, offset] of positions) {
205
+ if (width !== initial && width > available)
206
+ continue;
207
+ if (Math.abs(delta - offset) < Math.abs(delta - nearest)) {
208
+ next = width;
209
+ nearest = offset;
210
+ }
211
+ }
212
+ // A small band around the midpoint prevents jitter from moving neighbors.
213
+ const previous = positions.get(preview) ?? 0;
214
+ const hysteresis = Math.min(6, Math.abs(nearest - previous) / 8);
215
+ if (Math.abs(delta - previous) - Math.abs(delta - nearest) < 2 * hysteresis)
216
+ return;
217
+ }
218
+ if (next === preview)
219
+ return;
220
+ preview = next;
221
+ projectDrag?.();
222
+ }, { signal: drag.signal });
223
+ for (const type of /** @type {const} */ (["pointerup", "pointercancel", "lostpointercapture"])) {
224
+ handle.addEventListener(type, (end) => {
225
+ if (end.pointerId === event.pointerId)
226
+ finish(type === "pointerup");
227
+ }, { signal: drag.signal });
228
+ }
229
+ }
230
+ function refresh() {
231
+ pending = 0;
232
+ const style = browser.getComputedStyle(container);
233
+ const padding = (parseFloat(style.paddingLeft) || 0) + (parseFloat(style.paddingRight) || 0);
234
+ const room = container.clientWidth - padding;
235
+ if (room !== available || viewport !== browser.innerWidth) {
236
+ available = room;
237
+ viewport = browser.innerWidth;
238
+ if (projectDrag)
239
+ projectDrag();
240
+ else
241
+ place();
242
+ }
243
+ for (const [panel, widths] of declared) {
244
+ const options = widths.filter((n) => n <= available);
245
+ const bounds = panel.getBoundingClientRect();
246
+ const current = bounds.width;
247
+ let handle = handles.get(panel);
248
+ if (!panel.hasAttribute("data-compose-resizing") &&
249
+ !options.some((n) => Math.abs(n - current) > 0.5)) {
250
+ handle?.remove();
251
+ handles.delete(panel);
252
+ continue;
253
+ }
254
+ if (!handle) {
255
+ handle = doc.createElement("button");
256
+ handle.type = "button";
257
+ handle.dataset.composeResize = "";
258
+ handle.dataset.composeCorner = "right";
259
+ handle.setAttribute("aria-label", "Resize " + (panel.dataset.panelLabel || "viewer") + " from bottom right");
260
+ handle.setAttribute("aria-keyshortcuts", "ArrowLeft ArrowRight Home End");
261
+ const grip = handle;
262
+ grip.addEventListener("keydown", (e) => keyboard(e, panel, widths), { signal });
263
+ grip.addEventListener("pointerdown", (e) => start(e, panel, grip, widths), { signal });
264
+ panel.append(grip);
265
+ handles.set(panel, grip);
266
+ }
267
+ handle.setAttribute("aria-description", "Current width " + Math.round(current) +
268
+ " pixels. Available widths: " + options.join(", ") +
269
+ " pixels. Use Left or Right to choose." +
270
+ (viewport - bounds.right <= 28 && options.some((width) => width > current)
271
+ ? " At the screen edge, pull down to choose a wider size."
272
+ : ""));
273
+ }
274
+ }
275
+ function schedule() {
276
+ if (!pending && !signal?.aborted)
277
+ pending = browser.requestAnimationFrame(refresh);
278
+ }
279
+ const observer = new browser.ResizeObserver(schedule);
280
+ observer.observe(container);
281
+ for (const panel of declared.keys())
282
+ observer.observe(panel);
283
+ browser.addEventListener("resize", schedule, { signal });
284
+ container.addEventListener("compose-layout-preview", () => {
285
+ place();
286
+ schedule();
287
+ }, { signal });
288
+ container.addEventListener("compose-layout-change", () => {
289
+ placements = placementsAfterSwap();
290
+ manualPreview = undefined;
291
+ lastSlots = panels.map(slot);
292
+ place();
293
+ schedule();
294
+ }, { signal });
295
+ container.addEventListener("compose-panel-place", (event) => {
296
+ const d =
297
+ /** @type {CustomEvent<{phase:string, panel:HTMLElement, beside:HTMLElement, side:Placement["side"], placed:boolean}>} */ (event)
298
+ .detail;
299
+ if (!d)
300
+ return;
301
+ d.placed = false;
302
+ manualPreview = undefined;
303
+ if (d.phase === "cancel") {
304
+ place();
305
+ schedule();
306
+ return;
307
+ }
308
+ if ((d.phase !== "preview" && d.phase !== "commit") || !panels.includes(d.panel) ||
309
+ !panels.includes(d.beside) || d.panel === d.beside ||
310
+ (d.side !== "left" && d.side !== "right" && d.side !== "below")) {
311
+ place();
312
+ return;
313
+ }
314
+ const proposed = new Map(placements);
315
+ proposed.delete(d.panel);
316
+ // A new anchor cannot remain a dependent of the moved viewer. Reverse
317
+ // that old relation only if the new drop is successfully committed.
318
+ let anchor = d.beside;
319
+ while (proposed.has(anchor)) {
320
+ const next = /** @type {Placement} */ (proposed.get(anchor)).beside;
321
+ if (next === d.panel) {
322
+ proposed.delete(d.beside);
323
+ break;
324
+ }
325
+ anchor = next;
326
+ }
327
+ proposed.set(d.panel, { beside: d.beside, side: d.side });
328
+ d.placed = reflow.layout(fittingChoices(), undefined, proposed);
329
+ if (!d.placed)
330
+ place();
331
+ else if (d.phase === "commit")
332
+ placements = proposed;
333
+ else
334
+ manualPreview = proposed;
335
+ schedule();
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
+ });
363
+ signal?.addEventListener("abort", () => {
364
+ Reflect.deleteProperty(container, slotState);
365
+ cancelDrag?.();
366
+ observer.disconnect();
367
+ browser.cancelAnimationFrame(pending);
368
+ reflow.reset();
369
+ for (const handle of handles.values())
370
+ handle.remove();
371
+ status.remove();
372
+ container.removeAttribute("data-compose-resizing-ready");
373
+ }, { once: true });
374
+ refresh();
375
+ }
@@ -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
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../../../src/src/runtime/compose.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAiBhE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,aAAa,CAAC,CAmMxB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,yBAAyB,CAC7C,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,OAAO,CAAC,aAAa,CAAC,CAIxB"}
1
+ {"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../../../src/src/runtime/compose.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAiBhE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,aAAa,CAAC,CAuMxB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,yBAAyB,CAC7C,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,OAAO,CAAC,aAAa,CAAC,CAIxB"}
@@ -107,6 +107,8 @@ export async function composeDashboard(request) {
107
107
  toolName: call.tool,
108
108
  args: call.args,
109
109
  surface: call.surface ?? source.surface,
110
+ supportedWidths: manifest.tools.find((tool) => tool.name === call.tool)
111
+ ?.supportedWidths,
110
112
  allowedToolNames,
111
113
  allowedTools,
112
114
  result,
@@ -137,6 +139,7 @@ export async function composeDashboard(request) {
137
139
  const collected = collector.collect(outcome.qualifiedName, outcome.result, outcome.args, {
138
140
  componentId: outcome.componentId,
139
141
  surface: outcome.surface,
142
+ supportedWidths: outcome.supportedWidths,
140
143
  });
141
144
  if (!collected) {
142
145
  warnings.push(`Tool "${outcome.qualifiedName}" did not return UI metadata (_meta.ui.resourceUri)`);
@@ -1 +1 @@
1
- {"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../../src/src/runtime/manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAI9C;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,OAAO,GACZ;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAmEtC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,WAAW,CAwB1E;AAED;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAGrE;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAUnC"}
1
+ {"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../../src/src/runtime/manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAI9C;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,OAAO,GACZ;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAqEtC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,WAAW,CAwB1E;AAED;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAGrE;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAUnC"}
@@ -6,6 +6,7 @@
6
6
  *
7
7
  * @module runtime/manifest
8
8
  */
9
+ import { isSupportedWidths } from "../core/types/resources.js";
9
10
  import { RuntimeErrorCode } from "./types.js";
10
11
  /**
11
12
  * Validate a raw object as a manifest. Returns errors if invalid.
@@ -72,6 +73,9 @@ export function validateManifest(data) {
72
73
  else if (tool.appCallable !== undefined && typeof tool.appCallable !== "boolean") {
73
74
  errors.push(`tools[${i}].appCallable must be a boolean if provided`);
74
75
  }
76
+ else if (tool.supportedWidths !== undefined && !isSupportedWidths(tool.supportedWidths)) {
77
+ errors.push(`tools[${i}].supportedWidths must be an array of positive safe integers`);
78
+ }
75
79
  }
76
80
  }
77
81
  return { valid: errors.length === 0, errors };
@@ -88,6 +88,8 @@ export interface McpToolDeclaration {
88
88
  accepts?: string[];
89
89
  /** UI resource URI pattern. */
90
90
  resourceUri?: string;
91
+ /** Widths offered by this tool's viewer in CSS pixels. An empty list disables resizing. */
92
+ supportedWidths?: readonly number[];
91
93
  /**
92
94
  * Whether an embedded MCP App may invoke this tool through Compose's host
93
95
  * bridge. Omitted means deny: interactive capabilities are opt-in per tool.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/src/runtime/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAMpE;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,OAAO,CAAC;IACd,mCAAmC;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,yBAAyB;IACzB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,6CAA6C;IAC7C,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,eAAe,CAAC;CAC5B;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAA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,gBAAgB;IAC1B,oBAAoB,yBAAyB;IAC7C,oBAAoB,yBAAyB;IAC7C,kBAAkB,uBAAuB;IACzC,oBAAoB,yBAAyB;IAC7C,gBAAgB,qBAAqB;IACrC,iBAAiB,sBAAsB;IACvC,gBAAgB,qBAAqB;IACrC,iBAAiB,sBAAsB;IACvC,oBAAoB,yBAAyB;IAC7C,qBAAqB,0BAA0B;IAC/C,oBAAoB,yBAAyB;IAC7C,qBAAqB,0BAA0B;IAC/C,YAAY,iBAAiB;CAC9B;AAED,gCAAgC;AAChC,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,gBAAgB,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB"}
@@ -54,9 +54,10 @@ export interface McpSdkCollector {
54
54
  * @param toolName - Name of the tool that produced this result
55
55
  * @param result - MCP SDK CallToolResult (or any structurally compatible object)
56
56
  * @param context - Optional context data for the UI
57
+ * @param options - Compose layout options for the resulting viewer
57
58
  * @returns Collected resource, or `null` if no UI metadata or if result is an error
58
59
  */
59
- collectFromSdk(toolName: string, result: McpSdkCallToolResult, context?: Record<string, unknown>): CollectedUiResource | null;
60
+ collectFromSdk(toolName: string, result: McpSdkCallToolResult, context?: Record<string, unknown>, options?: Pick<CollectedUiResource, "supportedWidths">): CollectedUiResource | null;
60
61
  /** Get all collected resources in slot order. */
61
62
  getResources(): CollectedUiResource[];
62
63
  /** Reset collected resources. */
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-sdk.d.ts","sourceRoot":"","sources":["../../../src/src/sdk/mcp-sdk.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAElE;;;;;;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AAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC,CAAC;IACzE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;;;;;;;OAWG;IACH,cAAc,CACZ,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,oBAAoB,EAC5B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,OAAO,CAAC,EAAE,IAAI,CAAC,mBAAmB,EAAE,iBAAiB,CAAC,GACrD,mBAAmB,GAAG,IAAI,CAAC;IAE9B,iDAAiD;IACjD,YAAY,IAAI,mBAAmB,EAAE,CAAC;IAEtC,iCAAiC;IACjC,KAAK,IAAI,IAAI,CAAC;IAEd,4CAA4C;IAC5C,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,qBAAqB,IAAI,eAAe,CAuBvD"}
@@ -35,11 +35,11 @@ import { createCollector } from "../core/collector/collector.js";
35
35
  export function createMcpSdkCollector() {
36
36
  const inner = createCollector();
37
37
  return {
38
- collectFromSdk(toolName, result, context) {
38
+ collectFromSdk(toolName, result, context, options) {
39
39
  if (result.isError) {
40
40
  return null;
41
41
  }
42
- return inner.collect(toolName, result, context);
42
+ return inner.collect(toolName, result, context, options);
43
43
  },
44
44
  getResources() {
45
45
  return inner.getResources();
@@ -17,7 +17,7 @@
17
17
  * @module lib/version
18
18
  */
19
19
  /** @mcpview/compose package version. */
20
- export declare const COMPOSE_VERSION: "0.12.0";
20
+ export declare const COMPOSE_VERSION: "0.13.1";
21
21
  /**
22
22
  * MCP Apps protocol version targeted by compose.
23
23
  *
@@ -17,7 +17,7 @@
17
17
  * @module lib/version
18
18
  */
19
19
  /** @mcpview/compose package version. */
20
- export const COMPOSE_VERSION = "0.12.0";
20
+ export const COMPOSE_VERSION = "0.13.1";
21
21
  /**
22
22
  * MCP Apps protocol version targeted by compose.
23
23
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcpview/compose",
3
- "version": "0.12.0",
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"