@mcpview/compose 0.13.1 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +109 -0
- package/README.md +52 -0
- package/esm/src/code-mode/chain.d.ts +24 -1
- package/esm/src/code-mode/chain.d.ts.map +1 -1
- package/esm/src/code-mode/chain.js +219 -86
- package/esm/src/code-mode/errors.d.ts +80 -0
- package/esm/src/code-mode/errors.d.ts.map +1 -0
- package/esm/src/code-mode/errors.js +140 -0
- package/esm/src/code-mode/guest-worker.d.ts +11 -0
- package/esm/src/code-mode/guest-worker.d.ts.map +1 -0
- package/esm/src/code-mode/guest-worker.js +80 -0
- package/esm/src/code-mode/mod.d.ts +3 -1
- package/esm/src/code-mode/mod.d.ts.map +1 -1
- package/esm/src/code-mode/mod.js +2 -0
- package/esm/src/code-mode/sandbox-core.d.ts +61 -0
- package/esm/src/code-mode/sandbox-core.d.ts.map +1 -0
- package/esm/src/code-mode/sandbox-core.js +424 -0
- package/esm/src/code-mode/sandbox.d.ts +68 -7
- package/esm/src/code-mode/sandbox.d.ts.map +1 -1
- package/esm/src/code-mode/sandbox.js +180 -120
- package/esm/src/code-mode/tool.d.ts.map +1 -1
- package/esm/src/code-mode/tool.js +2 -0
- package/esm/src/code-mode/worker-host.d.ts +70 -0
- package/esm/src/code-mode/worker-host.d.ts.map +1 -0
- package/esm/src/code-mode/worker-host.js +355 -0
- package/esm/src/code-mode/worker-protocol.d.ts +44 -0
- package/esm/src/code-mode/worker-protocol.d.ts.map +1 -0
- package/esm/src/code-mode/worker-protocol.js +7 -0
- package/esm/src/host/renderer/css/panel-controls.d.ts.map +1 -1
- package/esm/src/host/renderer/css/panel-controls.js +5 -1
- package/esm/src/host/renderer/js/card-height.d.ts +11 -1
- package/esm/src/host/renderer/js/card-height.d.ts.map +1 -1
- package/esm/src/host/renderer/js/card-height.js +57 -10
- package/esm/src/host/renderer/js/event-bus.d.ts +11 -0
- package/esm/src/host/renderer/js/event-bus.d.ts.map +1 -1
- package/esm/src/host/renderer/js/event-bus.js +49 -8
- package/esm/src/host/renderer/js/intrinsic-layout.d.ts +26 -0
- package/esm/src/host/renderer/js/intrinsic-layout.d.ts.map +1 -0
- package/esm/src/host/renderer/js/intrinsic-layout.js +44 -0
- package/esm/src/host/renderer/panel-resizing.d.ts.map +1 -1
- package/esm/src/host/renderer/panel-resizing.js +8 -0
- package/esm/src/version.d.ts +1 -1
- package/esm/src/version.js +1 -1
- package/package.json +1 -1
- package/script/src/code-mode/chain.d.ts +24 -1
- package/script/src/code-mode/chain.d.ts.map +1 -1
- package/script/src/code-mode/chain.js +218 -85
- package/script/src/code-mode/errors.d.ts +80 -0
- package/script/src/code-mode/errors.d.ts.map +1 -0
- package/script/src/code-mode/errors.js +148 -0
- package/script/src/code-mode/guest-worker.d.ts +11 -0
- package/script/src/code-mode/guest-worker.d.ts.map +1 -0
- package/script/src/code-mode/guest-worker.js +105 -0
- package/script/src/code-mode/mod.d.ts +3 -1
- package/script/src/code-mode/mod.d.ts.map +1 -1
- package/script/src/code-mode/mod.js +9 -1
- package/script/src/code-mode/sandbox-core.d.ts +61 -0
- package/script/src/code-mode/sandbox-core.d.ts.map +1 -0
- package/script/src/code-mode/sandbox-core.js +430 -0
- package/script/src/code-mode/sandbox.d.ts +68 -7
- package/script/src/code-mode/sandbox.d.ts.map +1 -1
- package/script/src/code-mode/sandbox.js +188 -122
- package/script/src/code-mode/tool.d.ts.map +1 -1
- package/script/src/code-mode/tool.js +2 -0
- package/script/src/code-mode/worker-host.d.ts +70 -0
- package/script/src/code-mode/worker-host.d.ts.map +1 -0
- package/script/src/code-mode/worker-host.js +389 -0
- package/script/src/code-mode/worker-protocol.d.ts +44 -0
- package/script/src/code-mode/worker-protocol.d.ts.map +1 -0
- package/script/src/code-mode/worker-protocol.js +8 -0
- package/script/src/host/renderer/css/panel-controls.d.ts.map +1 -1
- package/script/src/host/renderer/css/panel-controls.js +5 -1
- package/script/src/host/renderer/js/card-height.d.ts +11 -1
- package/script/src/host/renderer/js/card-height.d.ts.map +1 -1
- package/script/src/host/renderer/js/card-height.js +57 -10
- package/script/src/host/renderer/js/event-bus.d.ts +11 -0
- package/script/src/host/renderer/js/event-bus.d.ts.map +1 -1
- package/script/src/host/renderer/js/event-bus.js +50 -8
- package/script/src/host/renderer/js/intrinsic-layout.d.ts +26 -0
- package/script/src/host/renderer/js/intrinsic-layout.d.ts.map +1 -0
- package/script/src/host/renderer/js/intrinsic-layout.js +48 -0
- package/script/src/host/renderer/panel-resizing.d.ts.map +1 -1
- package/script/src/host/renderer/panel-resizing.js +8 -0
- package/script/src/version.d.ts +1 -1
- package/script/src/version.js +1 -1
|
@@ -12,10 +12,23 @@
|
|
|
12
12
|
* @module renderer/js/event-bus
|
|
13
13
|
*/
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.MAX_VIEWER_HEIGHT = void 0;
|
|
15
16
|
exports.generateEventBusScript = generateEventBusScript;
|
|
16
17
|
const compose_events_js_1 = require("../../../sdk/compose-events.js");
|
|
17
18
|
const version_js_1 = require("../../../version.js");
|
|
18
19
|
const components_contract_js_1 = require("../../components-contract.js");
|
|
20
|
+
const intrinsic_layout_js_1 = require("./intrinsic-layout.js");
|
|
21
|
+
/**
|
|
22
|
+
* Tallest height, in CSS pixels, a viewer can claim with
|
|
23
|
+
* `ui/notifications/size-changed`. Taller content scrolls inside the viewer's
|
|
24
|
+
* iframe. Advertised to each viewer as `containerDimensions.maxHeight`.
|
|
25
|
+
*
|
|
26
|
+
* The cap also bounds a viewer whose content follows its own iframe
|
|
27
|
+
* (`min-height: 100vh` plus padding): it stops growing here. Compose does not
|
|
28
|
+
* guess such loops from equal increments, which a list gaining rows produces
|
|
29
|
+
* too.
|
|
30
|
+
*/
|
|
31
|
+
exports.MAX_VIEWER_HEIGHT = 2_400;
|
|
19
32
|
/**
|
|
20
33
|
* Generate the event bus JavaScript for a composite UI.
|
|
21
34
|
*
|
|
@@ -71,6 +84,31 @@ function generateEventBusScript(descriptor, slots = new Map()) {
|
|
|
71
84
|
const lastHostContexts = new Map();
|
|
72
85
|
const COMPONENT_CAPABILITY = '${components_contract_js_1.CASYS_COMPONENT_CATALOG_CAPABILITY_KEY}';
|
|
73
86
|
const SURFACE_CONTEXT = '${components_contract_js_1.CASYS_SURFACE_CONTEXT_KEY}';
|
|
87
|
+
const MAX_VIEWER_HEIGHT = ${exports.MAX_VIEWER_HEIGHT};
|
|
88
|
+
// Viewers already warned about the cap.
|
|
89
|
+
const cappedViewers = new Set();
|
|
90
|
+
${(0, intrinsic_layout_js_1.generateIntrinsicLayoutFunction)()}
|
|
91
|
+
|
|
92
|
+
// Viewer reports apply at once, as for any embed. Only an enclosing host
|
|
93
|
+
// that explicitly refused ui/initialize marks the board as refused: it
|
|
94
|
+
// fills its frame again and later reports no longer size it.
|
|
95
|
+
function handleViewerReport(slot, reported) {
|
|
96
|
+
const panel = iframes.get(slot)?.closest?.('.compose-viewer');
|
|
97
|
+
if (!panel) return;
|
|
98
|
+
const board = panel.parentElement;
|
|
99
|
+
if (board?.hasAttribute?.('data-compose-card-refused')) return;
|
|
100
|
+
const wanted = Math.ceil(reported);
|
|
101
|
+
if (wanted > MAX_VIEWER_HEIGHT && !cappedViewers.has(slot)) {
|
|
102
|
+
cappedViewers.add(slot);
|
|
103
|
+
console.warn('[mcp-compose] Viewer height capped', {
|
|
104
|
+
code: 'VIEWER_HEIGHT_CAPPED', slot, reported: wanted, max: MAX_VIEWER_HEIGHT
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
enterIntrinsicLayout(board);
|
|
108
|
+
panel.style.setProperty(
|
|
109
|
+
'--compose-native-height', Math.min(MAX_VIEWER_HEIGHT, wanted) + 'px'
|
|
110
|
+
);
|
|
111
|
+
}
|
|
74
112
|
|
|
75
113
|
// Build slot -> iframe map + reverse lookup. The fallback lookup matters
|
|
76
114
|
// when the iframe's WindowProxy becomes available after this script runs.
|
|
@@ -167,7 +205,7 @@ function generateEventBusScript(descriptor, slots = new Map()) {
|
|
|
167
205
|
const panel = iframe.closest?.('.compose-viewer');
|
|
168
206
|
// A fixed height in the handshake makes responsive Apps stretch to the
|
|
169
207
|
// track before they can report the height of their own content.
|
|
170
|
-
if (panel) return { width };
|
|
208
|
+
if (panel) return { width, maxHeight: MAX_VIEWER_HEIGHT };
|
|
171
209
|
return { width, height };
|
|
172
210
|
}
|
|
173
211
|
|
|
@@ -499,6 +537,10 @@ function generateEventBusScript(descriptor, slots = new Map()) {
|
|
|
499
537
|
];
|
|
500
538
|
const catalog = validComponentCatalog(advertisedCatalog);
|
|
501
539
|
if (catalog) componentCatalogs.set(sourceSlot, catalog);
|
|
540
|
+
// A reloaded viewer starts a new document: forget its height history,
|
|
541
|
+
// including the height the previous document reported. The captured
|
|
542
|
+
// template height stays as the fallback.
|
|
543
|
+
cappedViewers.delete(sourceSlot);
|
|
502
544
|
const hostContext = hostContextForSlot(sourceSlot);
|
|
503
545
|
lastHostContexts.set(sourceSlot, JSON.stringify(hostContext));
|
|
504
546
|
respond(event.source, message.id, {
|
|
@@ -543,13 +585,13 @@ function generateEventBusScript(descriptor, slots = new Map()) {
|
|
|
543
585
|
}
|
|
544
586
|
|
|
545
587
|
if (message.method === 'ui/notifications/size-changed') {
|
|
546
|
-
const
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
panel
|
|
551
|
-
|
|
552
|
-
|
|
588
|
+
const reported = message.params?.height;
|
|
589
|
+
// Width belongs to the board. Only the child can measure its own document.
|
|
590
|
+
const panel = iframes.get(sourceSlot)?.closest?.('.compose-viewer');
|
|
591
|
+
if (
|
|
592
|
+
panel && initializationResponded.has(sourceSlot) &&
|
|
593
|
+
Number.isFinite(reported) && reported > 0
|
|
594
|
+
) handleViewerReport(sourceSlot, reported);
|
|
553
595
|
ackIfRequested(event.source, message, targetOrigin);
|
|
554
596
|
return;
|
|
555
597
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser helper shared by the event bus and the card-height bridge.
|
|
3
|
+
*
|
|
4
|
+
* In intrinsic mode a board sizes its rows from its viewers instead of filling
|
|
5
|
+
* the viewport. A viewer that reports its height through
|
|
6
|
+
* `ui/notifications/size-changed` gets it as `--compose-native-height`. A
|
|
7
|
+
* viewer that never reports keeps the height its template track gave it when
|
|
8
|
+
* the board switched (`--compose-template-height`), and never less than
|
|
9
|
+
* {@link VIEWER_FALLBACK_HEIGHT}.
|
|
10
|
+
*
|
|
11
|
+
* @module renderer/js/intrinsic-layout
|
|
12
|
+
*/
|
|
13
|
+
/** Height, in CSS pixels, of a viewer that has not reported its own. */
|
|
14
|
+
export declare const VIEWER_FALLBACK_HEIGHT = 200;
|
|
15
|
+
/**
|
|
16
|
+
* Source of `enterIntrinsicLayout(board)`, to embed in a generated script.
|
|
17
|
+
* The function is idempotent: once the board is intrinsic, it does nothing.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* const script = `${generateIntrinsicLayoutFunction()}
|
|
22
|
+
* enterIntrinsicLayout(document.querySelector('[data-compose-board]'));`;
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function generateIntrinsicLayoutFunction(): string;
|
|
26
|
+
//# sourceMappingURL=intrinsic-layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intrinsic-layout.d.ts","sourceRoot":"","sources":["../../../../../src/src/host/renderer/js/intrinsic-layout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,wEAAwE;AACxE,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAE1C;;;;;;;;;GASG;AACH,wBAAgB,+BAA+B,IAAI,MAAM,CAmBxD"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Browser helper shared by the event bus and the card-height bridge.
|
|
4
|
+
*
|
|
5
|
+
* In intrinsic mode a board sizes its rows from its viewers instead of filling
|
|
6
|
+
* the viewport. A viewer that reports its height through
|
|
7
|
+
* `ui/notifications/size-changed` gets it as `--compose-native-height`. A
|
|
8
|
+
* viewer that never reports keeps the height its template track gave it when
|
|
9
|
+
* the board switched (`--compose-template-height`), and never less than
|
|
10
|
+
* {@link VIEWER_FALLBACK_HEIGHT}.
|
|
11
|
+
*
|
|
12
|
+
* @module renderer/js/intrinsic-layout
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.VIEWER_FALLBACK_HEIGHT = void 0;
|
|
16
|
+
exports.generateIntrinsicLayoutFunction = generateIntrinsicLayoutFunction;
|
|
17
|
+
/** Height, in CSS pixels, of a viewer that has not reported its own. */
|
|
18
|
+
exports.VIEWER_FALLBACK_HEIGHT = 200;
|
|
19
|
+
/**
|
|
20
|
+
* Source of `enterIntrinsicLayout(board)`, to embed in a generated script.
|
|
21
|
+
* The function is idempotent: once the board is intrinsic, it does nothing.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* const script = `${generateIntrinsicLayoutFunction()}
|
|
26
|
+
* enterIntrinsicLayout(document.querySelector('[data-compose-board]'));`;
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
function generateIntrinsicLayoutFunction() {
|
|
30
|
+
return `
|
|
31
|
+
function enterIntrinsicLayout(board) {
|
|
32
|
+
if (!board || board.hasAttribute('data-compose-intrinsic')) return;
|
|
33
|
+
// Measure before switching: afterwards the tracks follow their content.
|
|
34
|
+
for (const viewer of Array.from(board.children ?? [])) {
|
|
35
|
+
if (!viewer.classList?.contains('compose-viewer')) continue;
|
|
36
|
+
if (viewer.style.getPropertyValue('--compose-native-height')) continue;
|
|
37
|
+
const height = Math.ceil(viewer.getBoundingClientRect().height);
|
|
38
|
+
if (height > ${exports.VIEWER_FALLBACK_HEIGHT}) {
|
|
39
|
+
viewer.style.setProperty('--compose-template-height', height + 'px');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
board.setAttribute('data-compose-intrinsic', '');
|
|
43
|
+
// Placements committed before the switch hold fixed row minimums.
|
|
44
|
+
if (typeof board.dispatchEvent === 'function') {
|
|
45
|
+
board.dispatchEvent(new Event('compose-layout-intrinsic'));
|
|
46
|
+
}
|
|
47
|
+
}`;
|
|
48
|
+
}
|
|
@@ -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,+FA0XrB;kCAhYiC,mBAAmB"}
|
|
@@ -288,6 +288,14 @@ function installPanelResizing(container, signal, createReflow = panel_reflow_js_
|
|
|
288
288
|
place();
|
|
289
289
|
schedule();
|
|
290
290
|
}, { signal });
|
|
291
|
+
// Entering intrinsic layout drops the row floors of committed placements.
|
|
292
|
+
container.addEventListener("compose-layout-intrinsic", () => {
|
|
293
|
+
if (projectDrag)
|
|
294
|
+
projectDrag();
|
|
295
|
+
else
|
|
296
|
+
place();
|
|
297
|
+
schedule();
|
|
298
|
+
}, { signal });
|
|
291
299
|
container.addEventListener("compose-layout-change", () => {
|
|
292
300
|
placements = placementsAfterSwap();
|
|
293
301
|
manualPreview = undefined;
|
package/script/src/version.d.ts
CHANGED
package/script/src/version.js
CHANGED
|
@@ -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.
|
|
23
|
+
exports.COMPOSE_VERSION = "0.14.0";
|
|
24
24
|
/**
|
|
25
25
|
* MCP Apps protocol version targeted by compose.
|
|
26
26
|
*
|