@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,378 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.installPanelResizing = installPanelResizing;
4
+ const panel_reflow_js_1 = require("./panel-reflow.js");
5
+ /**
6
+ * Choose one of a viewer's declared viewport widths from its bottom-right corner.
7
+ * The standalone host embeds this function as JavaScript and supplies the layout
8
+ * factory as the third argument. A viewer always owns its intrinsic height.
9
+ * @param {HTMLElement} container
10
+ * @param {AbortSignal} [signal]
11
+ * @param {typeof createPanelReflow} [createReflow]
12
+ */
13
+ function installPanelResizing(container, signal, createReflow = panel_reflow_js_1.createPanelReflow) {
14
+ const doc = container.ownerDocument;
15
+ if (!doc.defaultView || signal?.aborted || container.hasAttribute("data-compose-resizing-ready"))
16
+ return;
17
+ const browser = doc.defaultView;
18
+ if (browser.getComputedStyle(container).display !== "grid")
19
+ return;
20
+ const panels = Array.from(
21
+ /** @type {NodeListOf<HTMLElement>} */ (container.querySelectorAll(":scope > [data-compose-panel]")));
22
+ if (!panels.length)
23
+ return;
24
+ /** @type {Map<HTMLElement, number[]>} */
25
+ const declared = new Map();
26
+ for (const panel of panels) {
27
+ const widths = (panel.dataset.composeWidths ?? "").trim().split(/\s+/)
28
+ .filter((s) => /^\d+$/.test(s)).map(Number)
29
+ .filter((n) => Number.isSafeInteger(n) && n > 0);
30
+ if (widths.length)
31
+ declared.set(panel, [...new Set(widths)].sort((a, b) => a - b));
32
+ }
33
+ if (!declared.size && panels.length < 2)
34
+ return;
35
+ container.setAttribute("data-compose-resizing-ready", "");
36
+ const reflow = createReflow(container);
37
+ const status = doc.createElement("span");
38
+ status.setAttribute("role", "status");
39
+ status.style.cssText =
40
+ "position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)";
41
+ if (declared.size)
42
+ container.append(status);
43
+ /** @type {Map<HTMLElement, number>} */
44
+ const choices = new Map();
45
+ /** @typedef {{beside:HTMLElement, side:"left"|"right"|"below"}} Placement */
46
+ /** @type {Map<HTMLElement, Placement>} */
47
+ let placements = new Map();
48
+ /** @type {Map<HTMLElement, Placement> | undefined} */
49
+ let manualPreview;
50
+ let lastSlots = panels.map(slot);
51
+ /** @type {Map<HTMLElement, HTMLButtonElement>} */
52
+ const handles = new Map();
53
+ /** @type {(() => void) | undefined} */
54
+ let cancelDrag;
55
+ /** @type {(() => void) | undefined} */
56
+ let projectDrag;
57
+ let available = -1, viewport = -1, pending = 0;
58
+ /** Return the chosen widths that fit now; a wider choice survives a temporary narrow viewport. */
59
+ function fittingChoices() {
60
+ /** @type {Map<HTMLElement, number>} */
61
+ const fitting = new Map();
62
+ for (const [panel, wanted] of choices) {
63
+ const widths = /** @type {number[]} */ (declared.get(panel));
64
+ const width = widths.filter((n) => n <= available && n <= wanted).at(-1);
65
+ if (width !== undefined)
66
+ fitting.set(panel, width);
67
+ }
68
+ return fitting;
69
+ }
70
+ /** @param {HTMLElement} panel */
71
+ function slot(panel) {
72
+ return panel.dataset.area ?? panel.style.order;
73
+ }
74
+ // Swapping a viewer supersedes its previous manual drop. During a swap
75
+ // preview keep the previous placement so canceling restores it.
76
+ function placementsAfterSwap() {
77
+ const result = new Map(placements);
78
+ panels.forEach((panel, i) => {
79
+ if (slot(panel) !== lastSlots[i])
80
+ result.delete(panel);
81
+ });
82
+ return result;
83
+ }
84
+ function place() {
85
+ reflow.layout(fittingChoices(), undefined, manualPreview ?? placementsAfterSwap());
86
+ }
87
+ /** @param {HTMLElement} panel @param {number} width */
88
+ function commitWidth(panel, width) {
89
+ choices.set(panel, width);
90
+ place();
91
+ container.dispatchEvent(new browser.Event("compose-panel-layout-committed"));
92
+ status.textContent = (panel.dataset.panelLabel || "Viewer") + " width " + width + " pixels.";
93
+ }
94
+ /** @param {KeyboardEvent} event @param {HTMLElement} panel @param {number[]} widths */
95
+ function keyboard(event, panel, widths) {
96
+ if (cancelDrag)
97
+ return;
98
+ const options = widths.filter((n) => n <= available);
99
+ const current = panel.getBoundingClientRect().width;
100
+ let next;
101
+ switch (event.key) {
102
+ case "ArrowLeft":
103
+ next = options.filter((n) => n < current - 0.5).at(-1);
104
+ break;
105
+ case "ArrowRight":
106
+ next = options.find((n) => n > current + 0.5);
107
+ break;
108
+ case "Home":
109
+ next = options[0];
110
+ break;
111
+ case "End":
112
+ next = options.at(-1);
113
+ break;
114
+ default:
115
+ return;
116
+ }
117
+ event.preventDefault();
118
+ if (next === undefined || Math.abs(next - current) < 0.5)
119
+ return;
120
+ commitWidth(panel, next);
121
+ schedule();
122
+ }
123
+ /**
124
+ * @param {PointerEvent} event @param {HTMLElement} panel
125
+ * @param {HTMLButtonElement} handle @param {number[]} widths
126
+ */
127
+ function start(event, panel, handle, widths) {
128
+ if (container.hasAttribute("data-compose-dragging") || !event.isPrimary || event.button !== 0) {
129
+ return;
130
+ }
131
+ const options = widths.filter((n) => n <= available);
132
+ const bounds = panel.getBoundingClientRect();
133
+ const initial = bounds.width;
134
+ // The authored (possibly fluid) width is the gesture's neutral position.
135
+ const stops = [...options.filter((n) => Math.abs(n - initial) > 0.5), initial].sort((a, b) => a - b);
136
+ if (stops.length < 2)
137
+ return;
138
+ const horizontal = new Map(stops.map((width) => [width, width - initial]));
139
+ const wider = stops.filter((width) => width > initial);
140
+ const down = new Map([initial, ...wider].map((width, i) => [width, i * 40]));
141
+ // At the physical edge the pointer cannot reach the next horizontal midpoint.
142
+ // Pulling down there steps through wider presets without changing height.
143
+ const firstGap = wider[0] - initial;
144
+ const edgeFallback = viewport - bounds.right <= 28 &&
145
+ viewport - event.clientX < firstGap / 2 + Math.min(6, firstGap / 8);
146
+ event.preventDefault();
147
+ const skeleton = doc.createElement("div");
148
+ skeleton.dataset.composeDropPreview = "";
149
+ skeleton.dataset.composeResizePreview = "";
150
+ skeleton.setAttribute("aria-hidden", "true");
151
+ skeleton.inert = true;
152
+ const drag = new AbortController();
153
+ let preview = initial;
154
+ handle.focus({ preventScroll: true });
155
+ handle.setPointerCapture(event.pointerId);
156
+ container.setAttribute("data-compose-dragging", "");
157
+ panel.setAttribute("data-compose-resizing", "");
158
+ /** @param {boolean} commit */
159
+ function finish(commit) {
160
+ drag.abort();
161
+ cancelDrag = undefined;
162
+ projectDrag = undefined;
163
+ if (handle.hasPointerCapture(event.pointerId))
164
+ handle.releasePointerCapture(event.pointerId);
165
+ container.removeAttribute("data-compose-dragging");
166
+ panel.removeAttribute("data-compose-resizing");
167
+ if (preview !== initial) {
168
+ if (commit)
169
+ commitWidth(panel, preview);
170
+ else
171
+ place();
172
+ }
173
+ schedule();
174
+ }
175
+ cancelDrag = () => finish(false);
176
+ projectDrag = () => {
177
+ // A new row can introduce a vertical scrollbar. Keep the gesture alive
178
+ // and project the same preset into the board's available width.
179
+ if (preview > available)
180
+ preview = initial;
181
+ const fitting = fittingChoices();
182
+ if (preview === initial)
183
+ reflow.layout(fitting, undefined, placements);
184
+ else {
185
+ fitting.set(panel, preview);
186
+ reflow.layout(fitting, { panel, skeleton }, placements);
187
+ }
188
+ };
189
+ browser.addEventListener("blur", cancelDrag, { signal: drag.signal });
190
+ handle.addEventListener("keydown", (key) => {
191
+ if (key.key === "Escape") {
192
+ key.preventDefault();
193
+ finish(false);
194
+ }
195
+ }, { signal: drag.signal });
196
+ handle.addEventListener("pointermove", (move) => {
197
+ if (move.pointerId !== event.pointerId)
198
+ return;
199
+ const dx = move.clientX - event.clientX;
200
+ const dy = move.clientY - event.clientY;
201
+ const pullDown = edgeFallback && dy > Math.abs(dx);
202
+ const positions = pullDown ? down : horizontal;
203
+ const delta = pullDown ? dy : dx;
204
+ let next = initial;
205
+ if (Math.abs(delta) >= 5) {
206
+ let nearest = 0;
207
+ for (const [width, offset] of positions) {
208
+ if (width !== initial && width > available)
209
+ continue;
210
+ if (Math.abs(delta - offset) < Math.abs(delta - nearest)) {
211
+ next = width;
212
+ nearest = offset;
213
+ }
214
+ }
215
+ // A small band around the midpoint prevents jitter from moving neighbors.
216
+ const previous = positions.get(preview) ?? 0;
217
+ const hysteresis = Math.min(6, Math.abs(nearest - previous) / 8);
218
+ if (Math.abs(delta - previous) - Math.abs(delta - nearest) < 2 * hysteresis)
219
+ return;
220
+ }
221
+ if (next === preview)
222
+ return;
223
+ preview = next;
224
+ projectDrag?.();
225
+ }, { signal: drag.signal });
226
+ for (const type of /** @type {const} */ (["pointerup", "pointercancel", "lostpointercapture"])) {
227
+ handle.addEventListener(type, (end) => {
228
+ if (end.pointerId === event.pointerId)
229
+ finish(type === "pointerup");
230
+ }, { signal: drag.signal });
231
+ }
232
+ }
233
+ function refresh() {
234
+ pending = 0;
235
+ const style = browser.getComputedStyle(container);
236
+ const padding = (parseFloat(style.paddingLeft) || 0) + (parseFloat(style.paddingRight) || 0);
237
+ const room = container.clientWidth - padding;
238
+ if (room !== available || viewport !== browser.innerWidth) {
239
+ available = room;
240
+ viewport = browser.innerWidth;
241
+ if (projectDrag)
242
+ projectDrag();
243
+ else
244
+ place();
245
+ }
246
+ for (const [panel, widths] of declared) {
247
+ const options = widths.filter((n) => n <= available);
248
+ const bounds = panel.getBoundingClientRect();
249
+ const current = bounds.width;
250
+ let handle = handles.get(panel);
251
+ if (!panel.hasAttribute("data-compose-resizing") &&
252
+ !options.some((n) => Math.abs(n - current) > 0.5)) {
253
+ handle?.remove();
254
+ handles.delete(panel);
255
+ continue;
256
+ }
257
+ if (!handle) {
258
+ handle = doc.createElement("button");
259
+ handle.type = "button";
260
+ handle.dataset.composeResize = "";
261
+ handle.dataset.composeCorner = "right";
262
+ handle.setAttribute("aria-label", "Resize " + (panel.dataset.panelLabel || "viewer") + " from bottom right");
263
+ handle.setAttribute("aria-keyshortcuts", "ArrowLeft ArrowRight Home End");
264
+ const grip = handle;
265
+ grip.addEventListener("keydown", (e) => keyboard(e, panel, widths), { signal });
266
+ grip.addEventListener("pointerdown", (e) => start(e, panel, grip, widths), { signal });
267
+ panel.append(grip);
268
+ handles.set(panel, grip);
269
+ }
270
+ handle.setAttribute("aria-description", "Current width " + Math.round(current) +
271
+ " pixels. Available widths: " + options.join(", ") +
272
+ " pixels. Use Left or Right to choose." +
273
+ (viewport - bounds.right <= 28 && options.some((width) => width > current)
274
+ ? " At the screen edge, pull down to choose a wider size."
275
+ : ""));
276
+ }
277
+ }
278
+ function schedule() {
279
+ if (!pending && !signal?.aborted)
280
+ pending = browser.requestAnimationFrame(refresh);
281
+ }
282
+ const observer = new browser.ResizeObserver(schedule);
283
+ observer.observe(container);
284
+ for (const panel of declared.keys())
285
+ observer.observe(panel);
286
+ browser.addEventListener("resize", schedule, { signal });
287
+ container.addEventListener("compose-layout-preview", () => {
288
+ place();
289
+ schedule();
290
+ }, { signal });
291
+ container.addEventListener("compose-layout-change", () => {
292
+ placements = placementsAfterSwap();
293
+ manualPreview = undefined;
294
+ lastSlots = panels.map(slot);
295
+ place();
296
+ schedule();
297
+ }, { signal });
298
+ container.addEventListener("compose-panel-place", (event) => {
299
+ const d =
300
+ /** @type {CustomEvent<{phase:string, panel:HTMLElement, beside:HTMLElement, side:Placement["side"], placed:boolean}>} */ (event)
301
+ .detail;
302
+ if (!d)
303
+ return;
304
+ d.placed = false;
305
+ manualPreview = undefined;
306
+ if (d.phase === "cancel") {
307
+ place();
308
+ schedule();
309
+ return;
310
+ }
311
+ if ((d.phase !== "preview" && d.phase !== "commit") || !panels.includes(d.panel) ||
312
+ !panels.includes(d.beside) || d.panel === d.beside ||
313
+ (d.side !== "left" && d.side !== "right" && d.side !== "below")) {
314
+ place();
315
+ return;
316
+ }
317
+ const proposed = new Map(placements);
318
+ proposed.delete(d.panel);
319
+ // A new anchor cannot remain a dependent of the moved viewer. Reverse
320
+ // that old relation only if the new drop is successfully committed.
321
+ let anchor = d.beside;
322
+ while (proposed.has(anchor)) {
323
+ const next = /** @type {Placement} */ (proposed.get(anchor)).beside;
324
+ if (next === d.panel) {
325
+ proposed.delete(d.beside);
326
+ break;
327
+ }
328
+ anchor = next;
329
+ }
330
+ proposed.set(d.panel, { beside: d.beside, side: d.side });
331
+ d.placed = reflow.layout(fittingChoices(), undefined, proposed);
332
+ if (!d.placed)
333
+ place();
334
+ else if (d.phase === "commit")
335
+ placements = proposed;
336
+ else
337
+ manualPreview = proposed;
338
+ schedule();
339
+ }, { signal });
340
+ // Expose committed preferences to the owning board without touching viewer results or iframes.
341
+ // Symbol.for also connects hosts that embed these controls as standalone JavaScript.
342
+ const slotState = Symbol.for("@mcpview/compose/panel-layout-controls/v1");
343
+ Reflect.set(container, slotState, {
344
+ read: () => ({
345
+ widths: Array.from(choices, ([p, width]) => ({ panel: p.dataset.composePanelId, width })),
346
+ placements: Array.from(placements, ([p, { beside, side }]) => ({
347
+ panel: p.dataset.composePanelId,
348
+ beside: beside.dataset.composePanelId,
349
+ side,
350
+ })),
351
+ }),
352
+ supports: (/** @type {HTMLElement} */ panel, /** @type {number} */ width) => declared.get(panel)?.includes(width) === true,
353
+ restore: (
354
+ /** @type {Array<[HTMLElement, number]>} */ widths,
355
+ /** @type {Array<[HTMLElement, Placement]>} */ positions) => {
356
+ choices.clear();
357
+ for (const [panel, width] of widths)
358
+ choices.set(panel, width);
359
+ placements = new Map(positions);
360
+ lastSlots = panels.map(slot);
361
+ manualPreview = undefined;
362
+ place();
363
+ schedule();
364
+ },
365
+ });
366
+ signal?.addEventListener("abort", () => {
367
+ Reflect.deleteProperty(container, slotState);
368
+ cancelDrag?.();
369
+ observer.disconnect();
370
+ browser.cancelAnimationFrame(pending);
371
+ reflow.reset();
372
+ for (const handle of handles.values())
373
+ handle.remove();
374
+ status.remove();
375
+ container.removeAttribute("data-compose-resizing-ready");
376
+ }, { once: true });
377
+ refresh();
378
+ }
@@ -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,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.capturePanelLayout = capturePanelLayout;
4
+ exports.restorePanelLayout = restorePanelLayout;
5
+ const layout_js_1 = require("../../code-mode/layout.js");
6
+ const slotState = Symbol.for("@mcpview/compose/panel-layout-controls/v1");
7
+ /** @param {HTMLElement} board */
8
+ function panelSlots(board) {
9
+ const panels = Array.from(
10
+ /** @type {NodeListOf<HTMLElement>} */ (board.querySelectorAll(":scope > [data-compose-panel]")));
11
+ const ids = panels.map((node) => node.dataset.composePanelId);
12
+ if (!ids.every(Boolean) || new Set(ids).size !== ids.length)
13
+ return;
14
+ const named = panels.every((node) => node.dataset.area);
15
+ // Named areas follow the template even when the viewport changes its number of columns.
16
+ const slots = panels.map((node, i) => named ? node.dataset.composeTemplateArea ?? node.dataset.area ?? "" : String(i));
17
+ if (new Set(slots).size !== slots.length)
18
+ return;
19
+ return { panels, slots, named, byId: new Map(panels.map((p) => [p.dataset.composePanelId, p])) };
20
+ }
21
+ /** Read only the last committed layout preferences.
22
+ * @param {HTMLElement} board
23
+ * @returns {import("../../code-mode/layout.ts").PanelLayoutSnapshot | undefined}
24
+ */
25
+ function capturePanelLayout(board) {
26
+ if (board.hasAttribute("data-compose-dragging"))
27
+ return;
28
+ const table = panelSlots(board);
29
+ if (!table)
30
+ return;
31
+ const { panels, named, slots } = table;
32
+ const occupants = new Map(panels.map((panel, i) => [
33
+ named ? panel.dataset.area : (panel.style.order || String(i)),
34
+ panel.dataset.composePanelId,
35
+ ]));
36
+ const controls = Reflect.get(board, slotState);
37
+ const geometry = controls?.read() ?? { widths: [], placements: [] };
38
+ const snapshot = { version: 1, order: slots.map((slot) => occupants.get(slot)), ...geometry };
39
+ return (0, layout_js_1.isPanelLayoutSnapshot)(snapshot) ? snapshot : undefined;
40
+ }
41
+ /** Apply a saved preference only to matching panels and current viewer width declarations.
42
+ * @param {HTMLElement} board
43
+ * @param {unknown} snapshot
44
+ */
45
+ function restorePanelLayout(board, snapshot) {
46
+ if (!(0, layout_js_1.isPanelLayoutSnapshot)(snapshot) || board.hasAttribute("data-compose-dragging"))
47
+ return false;
48
+ const table = panelSlots(board);
49
+ if (!table || snapshot.order.length !== table.panels.length ||
50
+ !snapshot.order.every((id) => table.byId.has(id)))
51
+ return false;
52
+ const controls = Reflect.get(board, slotState);
53
+ if ((snapshot.widths.length || snapshot.placements.length) && !controls)
54
+ return false;
55
+ if (!snapshot.widths.every(({ panel, width }) => controls?.supports(table.byId.get(panel), width)))
56
+ return false;
57
+ snapshot.order.forEach((id, index) => {
58
+ const panel = /** @type {HTMLElement} */ (table.byId.get(id));
59
+ if (table.named)
60
+ panel.dataset.area = table.slots[index];
61
+ else
62
+ panel.style.order = table.slots[index];
63
+ });
64
+ controls?.restore(snapshot.widths.map(({ panel, width }) => [table.byId.get(panel), width]), snapshot.placements.map(({ panel, beside, side }) => [
65
+ table.byId.get(panel),
66
+ { beside: table.byId.get(beside), side },
67
+ ]));
68
+ return true;
69
+ }
@@ -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"}
@@ -111,6 +111,8 @@ async function composeDashboard(request) {
111
111
  toolName: call.tool,
112
112
  args: call.args,
113
113
  surface: call.surface ?? source.surface,
114
+ supportedWidths: manifest.tools.find((tool) => tool.name === call.tool)
115
+ ?.supportedWidths,
114
116
  allowedToolNames,
115
117
  allowedTools,
116
118
  result,
@@ -141,6 +143,7 @@ async function composeDashboard(request) {
141
143
  const collected = collector.collect(outcome.qualifiedName, outcome.result, outcome.args, {
142
144
  componentId: outcome.componentId,
143
145
  surface: outcome.surface,
146
+ supportedWidths: outcome.supportedWidths,
144
147
  });
145
148
  if (!collected) {
146
149
  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"}
@@ -12,6 +12,7 @@ exports.validateManifest = validateManifest;
12
12
  exports.parseManifest = parseManifest;
13
13
  exports.loadManifest = loadManifest;
14
14
  exports.loadManifests = loadManifests;
15
+ const resources_js_1 = require("../core/types/resources.js");
15
16
  const types_js_1 = require("./types.js");
16
17
  /**
17
18
  * Validate a raw object as a manifest. Returns errors if invalid.
@@ -78,6 +79,9 @@ function validateManifest(data) {
78
79
  else if (tool.appCallable !== undefined && typeof tool.appCallable !== "boolean") {
79
80
  errors.push(`tools[${i}].appCallable must be a boolean if provided`);
80
81
  }
82
+ else if (tool.supportedWidths !== undefined && !(0, resources_js_1.isSupportedWidths)(tool.supportedWidths)) {
83
+ errors.push(`tools[${i}].supportedWidths must be an array of positive safe integers`);
84
+ }
81
85
  }
82
86
  }
83
87
  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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,UAAU,EAAE,qBAAqB,CAAC;IAClC,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,6CAA6C;IAC7C,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB;;;;;;;;OAQG;IACH,MAAM,EAAE,SAAS,sBAAsB,EAAE,CAAC;IAC1C,qFAAqF;IACrF,OAAO,CAAC,EAAE,UAAU,CAAC;CACtB;AAMD,2BAA2B;AAC3B,oBAAY,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;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,GAAG,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;;;;;;;;;;OAUG;IACH,cAAc,CACZ,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,oBAAoB,EAC5B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,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,CA2BvD"}
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;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,GAAG,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"}
@@ -38,11 +38,11 @@ const collector_js_1 = require("../core/collector/collector.js");
38
38
  function createMcpSdkCollector() {
39
39
  const inner = (0, collector_js_1.createCollector)();
40
40
  return {
41
- collectFromSdk(toolName, result, context) {
41
+ collectFromSdk(toolName, result, context, options) {
42
42
  if (result.isError) {
43
43
  return null;
44
44
  }
45
- return inner.collect(toolName, result, context);
45
+ return inner.collect(toolName, result, context, options);
46
46
  },
47
47
  getResources() {
48
48
  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
  *
@@ -20,7 +20,7 @@
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.MCP_APPS_PROTOCOL_VERSION = exports.COMPOSE_VERSION = void 0;
22
22
  /** @mcpview/compose package version. */
23
- exports.COMPOSE_VERSION = "0.12.0";
23
+ exports.COMPOSE_VERSION = "0.13.1";
24
24
  /**
25
25
  * MCP Apps protocol version targeted by compose.
26
26
  *