@mcpview/compose 0.13.0 → 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 +120 -0
- package/README.md +131 -2
- package/esm/_dnt.polyfills.d.ts +11 -11
- package/esm/_dnt.polyfills.d.ts.map +1 -1
- package/esm/_dnt.polyfills.js +14 -14
- package/esm/src/code-mode/board.d.ts +18 -2
- package/esm/src/code-mode/board.d.ts.map +1 -1
- package/esm/src/code-mode/board.js +74 -2
- package/esm/src/code-mode/chain.d.ts +26 -1
- package/esm/src/code-mode/chain.d.ts.map +1 -1
- package/esm/src/code-mode/chain.js +248 -89
- package/esm/src/code-mode/connections.d.ts +1 -0
- package/esm/src/code-mode/connections.d.ts.map +1 -1
- package/esm/src/code-mode/connections.js +1 -0
- package/esm/src/code-mode/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/layout-publisher.d.ts +69 -0
- package/esm/src/code-mode/layout-publisher.d.ts.map +1 -0
- package/esm/src/code-mode/layout-publisher.js +85 -0
- package/esm/src/code-mode/layout-runs.d.ts +35 -0
- package/esm/src/code-mode/layout-runs.d.ts.map +1 -0
- package/esm/src/code-mode/layout-runs.js +130 -0
- package/esm/src/code-mode/layout.d.ts +20 -0
- package/esm/src/code-mode/layout.d.ts.map +1 -0
- package/esm/src/code-mode/layout.js +54 -0
- package/esm/src/code-mode/mod.d.ts +4 -1
- package/esm/src/code-mode/mod.d.ts.map +1 -1
- package/esm/src/code-mode/mod.js +3 -0
- package/esm/src/code-mode/panel-contexts.d.ts +25 -0
- package/esm/src/code-mode/panel-contexts.d.ts.map +1 -0
- package/esm/src/code-mode/panel-contexts.js +115 -0
- package/esm/src/code-mode/providers.d.ts +3 -0
- package/esm/src/code-mode/providers.d.ts.map +1 -1
- package/esm/src/code-mode/sandbox-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 -119
- package/esm/src/code-mode/sync.d.ts +11 -0
- package/esm/src/code-mode/sync.d.ts.map +1 -0
- package/esm/src/code-mode/sync.js +42 -0
- package/esm/src/code-mode/tool.d.ts +1 -1
- package/esm/src/code-mode/tool.d.ts.map +1 -1
- package/esm/src/code-mode/tool.js +14 -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/html-generator.js +2 -2
- 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-controls.d.ts +7 -0
- package/esm/src/host/renderer/panel-controls.js +1 -0
- package/esm/src/host/renderer/panel-movement.d.ts.map +1 -1
- package/esm/src/host/renderer/panel-movement.js +5 -1
- package/esm/src/host/renderer/panel-resizing.d.ts.map +1 -1
- package/esm/src/host/renderer/panel-resizing.js +36 -0
- package/esm/src/host/renderer/panel-snapshot.d.ts +11 -0
- package/esm/src/host/renderer/panel-snapshot.d.ts.map +1 -0
- package/esm/src/host/renderer/panel-snapshot.js +65 -0
- package/esm/src/version.d.ts +1 -1
- package/esm/src/version.js +1 -1
- package/package.json +9 -1
- package/script/_dnt.polyfills.d.ts +11 -11
- package/script/_dnt.polyfills.d.ts.map +1 -1
- package/script/_dnt.polyfills.js +14 -14
- package/script/src/code-mode/board.d.ts +18 -2
- package/script/src/code-mode/board.d.ts.map +1 -1
- package/script/src/code-mode/board.js +81 -2
- package/script/src/code-mode/chain.d.ts +26 -1
- package/script/src/code-mode/chain.d.ts.map +1 -1
- package/script/src/code-mode/chain.js +247 -88
- package/script/src/code-mode/connections.d.ts +1 -0
- package/script/src/code-mode/connections.d.ts.map +1 -1
- package/script/src/code-mode/connections.js +1 -0
- package/script/src/code-mode/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/layout-publisher.d.ts +69 -0
- package/script/src/code-mode/layout-publisher.d.ts.map +1 -0
- package/script/src/code-mode/layout-publisher.js +88 -0
- package/script/src/code-mode/layout-runs.d.ts +35 -0
- package/script/src/code-mode/layout-runs.d.ts.map +1 -0
- package/script/src/code-mode/layout-runs.js +134 -0
- package/script/src/code-mode/layout.d.ts +20 -0
- package/script/src/code-mode/layout.d.ts.map +1 -0
- package/script/src/code-mode/layout.js +57 -0
- package/script/src/code-mode/mod.d.ts +4 -1
- package/script/src/code-mode/mod.d.ts.map +1 -1
- package/script/src/code-mode/mod.js +14 -1
- package/script/src/code-mode/panel-contexts.d.ts +25 -0
- package/script/src/code-mode/panel-contexts.d.ts.map +1 -0
- package/script/src/code-mode/panel-contexts.js +118 -0
- package/script/src/code-mode/providers.d.ts +3 -0
- package/script/src/code-mode/providers.d.ts.map +1 -1
- package/script/src/code-mode/sandbox-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 -121
- package/script/src/code-mode/sync.d.ts +11 -0
- package/script/src/code-mode/sync.d.ts.map +1 -0
- package/script/src/code-mode/sync.js +51 -0
- package/script/src/code-mode/tool.d.ts +1 -1
- package/script/src/code-mode/tool.d.ts.map +1 -1
- package/script/src/code-mode/tool.js +14 -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/html-generator.js +2 -2
- 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-controls.d.ts +7 -0
- package/script/src/host/renderer/panel-controls.js +4 -1
- package/script/src/host/renderer/panel-movement.d.ts.map +1 -1
- package/script/src/host/renderer/panel-movement.js +5 -1
- package/script/src/host/renderer/panel-resizing.d.ts.map +1 -1
- package/script/src/host/renderer/panel-resizing.js +36 -0
- package/script/src/host/renderer/panel-snapshot.d.ts +11 -0
- package/script/src/host/renderer/panel-snapshot.d.ts.map +1 -0
- package/script/src/host/renderer/panel-snapshot.js +69 -0
- package/script/src/version.d.ts +1 -1
- package/script/src/version.js +1 -1
|
@@ -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,8 +1,15 @@
|
|
|
1
|
+
import type { PanelLayoutSnapshot } from "../../code-mode/layout.js";
|
|
2
|
+
|
|
1
3
|
/** The board element available to a caller running in a DOM environment. */
|
|
2
4
|
type PanelContainer = typeof globalThis extends { HTMLElement: { prototype: infer Element } }
|
|
3
5
|
? Element
|
|
4
6
|
: never;
|
|
5
7
|
|
|
8
|
+
/** Capture the current board's committed choices, keeping the requested widths across viewport changes. */
|
|
9
|
+
export declare function capturePanelLayout(board: PanelContainer): PanelLayoutSnapshot | undefined;
|
|
10
|
+
/** Restore the snapshot in place on a compatible mounted board. */
|
|
11
|
+
export declare function restorePanelLayout(board: PanelContainer, value: unknown): boolean;
|
|
12
|
+
|
|
6
13
|
/** Install pointer and keyboard controls for moving panels within a Compose board. */
|
|
7
14
|
export declare function installPanelMovement(container: PanelContainer, signal?: AbortSignal): void;
|
|
8
15
|
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.installPanelResizing = exports.createPanelReflow = exports.installPanelMovement = void 0;
|
|
3
|
+
exports.installPanelResizing = exports.createPanelReflow = exports.restorePanelLayout = exports.capturePanelLayout = exports.installPanelMovement = void 0;
|
|
4
4
|
// @ts-self-types="./panel-controls.d.ts"
|
|
5
5
|
// Server consumers embed these functions in HTML. Only browsers execute their DOM code.
|
|
6
6
|
var panel_movement_js_1 = require("./panel-movement.js");
|
|
7
7
|
Object.defineProperty(exports, "installPanelMovement", { enumerable: true, get: function () { return panel_movement_js_1.installPanelMovement; } });
|
|
8
|
+
var panel_snapshot_js_1 = require("./panel-snapshot.js");
|
|
9
|
+
Object.defineProperty(exports, "capturePanelLayout", { enumerable: true, get: function () { return panel_snapshot_js_1.capturePanelLayout; } });
|
|
10
|
+
Object.defineProperty(exports, "restorePanelLayout", { enumerable: true, get: function () { return panel_snapshot_js_1.restorePanelLayout; } });
|
|
8
11
|
var panel_reflow_js_1 = require("./panel-reflow.js");
|
|
9
12
|
Object.defineProperty(exports, "createPanelReflow", { enumerable: true, get: function () { return panel_reflow_js_1.createPanelReflow; } });
|
|
10
13
|
var panel_resizing_js_1 = require("./panel-resizing.js");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"panel-movement.d.ts","sourceRoot":"","sources":["../../../../src/src/host/renderer/panel-movement.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,gDAHW,WAAW,
|
|
1
|
+
{"version":3,"file":"panel-movement.d.ts","sourceRoot":"","sources":["../../../../src/src/host/renderer/panel-movement.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,gDAHW,WAAW,0CAkYrB"}
|
|
@@ -107,6 +107,7 @@ function installPanelMovement(container, signal) {
|
|
|
107
107
|
function announceSwap(from, to) {
|
|
108
108
|
status.textContent = label(from) + " swapped with " + label(to) + ".";
|
|
109
109
|
container.dispatchEvent(new Event("compose-layout-change"));
|
|
110
|
+
container.dispatchEvent(new Event("compose-panel-layout-committed"));
|
|
110
111
|
}
|
|
111
112
|
/** @param {"preview" | "commit" | "cancel"} phase @param {FreePlace} place */
|
|
112
113
|
function placeBeside(phase, place) {
|
|
@@ -276,7 +277,9 @@ function installPanelMovement(container, signal) {
|
|
|
276
277
|
return best;
|
|
277
278
|
}
|
|
278
279
|
for (const [index, panel] of panels.entries()) {
|
|
279
|
-
if (
|
|
280
|
+
if (namedAreas)
|
|
281
|
+
panel.dataset.composeTemplateArea ??= panel.dataset.area;
|
|
282
|
+
else
|
|
280
283
|
panel.style.order = String(index);
|
|
281
284
|
let grip = /** @type {HTMLButtonElement | null} */ (panel.querySelector("[data-compose-grip]"));
|
|
282
285
|
if (!grip) {
|
|
@@ -370,6 +373,7 @@ function installPanelMovement(container, signal) {
|
|
|
370
373
|
const where = placement.side === "below" ? " below " : " beside ";
|
|
371
374
|
status.textContent = label(from) + " placed" + where + label(placement.beside) + ".";
|
|
372
375
|
container.dispatchEvent(new Event("compose-layout-change"));
|
|
376
|
+
container.dispatchEvent(new Event("compose-panel-layout-committed"));
|
|
373
377
|
}
|
|
374
378
|
select();
|
|
375
379
|
}
|
|
@@ -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"}
|
|
@@ -88,6 +88,7 @@ function installPanelResizing(container, signal, createReflow = panel_reflow_js_
|
|
|
88
88
|
function commitWidth(panel, width) {
|
|
89
89
|
choices.set(panel, width);
|
|
90
90
|
place();
|
|
91
|
+
container.dispatchEvent(new browser.Event("compose-panel-layout-committed"));
|
|
91
92
|
status.textContent = (panel.dataset.panelLabel || "Viewer") + " width " + width + " pixels.";
|
|
92
93
|
}
|
|
93
94
|
/** @param {KeyboardEvent} event @param {HTMLElement} panel @param {number[]} widths */
|
|
@@ -287,6 +288,14 @@ function installPanelResizing(container, signal, createReflow = panel_reflow_js_
|
|
|
287
288
|
place();
|
|
288
289
|
schedule();
|
|
289
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 });
|
|
290
299
|
container.addEventListener("compose-layout-change", () => {
|
|
291
300
|
placements = placementsAfterSwap();
|
|
292
301
|
manualPreview = undefined;
|
|
@@ -336,7 +345,34 @@ function installPanelResizing(container, signal, createReflow = panel_reflow_js_
|
|
|
336
345
|
manualPreview = proposed;
|
|
337
346
|
schedule();
|
|
338
347
|
}, { signal });
|
|
348
|
+
// Expose committed preferences to the owning board without touching viewer results or iframes.
|
|
349
|
+
// Symbol.for also connects hosts that embed these controls as standalone JavaScript.
|
|
350
|
+
const slotState = Symbol.for("@mcpview/compose/panel-layout-controls/v1");
|
|
351
|
+
Reflect.set(container, slotState, {
|
|
352
|
+
read: () => ({
|
|
353
|
+
widths: Array.from(choices, ([p, width]) => ({ panel: p.dataset.composePanelId, width })),
|
|
354
|
+
placements: Array.from(placements, ([p, { beside, side }]) => ({
|
|
355
|
+
panel: p.dataset.composePanelId,
|
|
356
|
+
beside: beside.dataset.composePanelId,
|
|
357
|
+
side,
|
|
358
|
+
})),
|
|
359
|
+
}),
|
|
360
|
+
supports: (/** @type {HTMLElement} */ panel, /** @type {number} */ width) => declared.get(panel)?.includes(width) === true,
|
|
361
|
+
restore: (
|
|
362
|
+
/** @type {Array<[HTMLElement, number]>} */ widths,
|
|
363
|
+
/** @type {Array<[HTMLElement, Placement]>} */ positions) => {
|
|
364
|
+
choices.clear();
|
|
365
|
+
for (const [panel, width] of widths)
|
|
366
|
+
choices.set(panel, width);
|
|
367
|
+
placements = new Map(positions);
|
|
368
|
+
lastSlots = panels.map(slot);
|
|
369
|
+
manualPreview = undefined;
|
|
370
|
+
place();
|
|
371
|
+
schedule();
|
|
372
|
+
},
|
|
373
|
+
});
|
|
339
374
|
signal?.addEventListener("abort", () => {
|
|
375
|
+
Reflect.deleteProperty(container, slotState);
|
|
340
376
|
cancelDrag?.();
|
|
341
377
|
observer.disconnect();
|
|
342
378
|
browser.cancelAnimationFrame(pending);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Read only the last committed layout preferences.
|
|
2
|
+
* @param {HTMLElement} board
|
|
3
|
+
* @returns {import("../../code-mode/layout.ts").PanelLayoutSnapshot | undefined}
|
|
4
|
+
*/
|
|
5
|
+
export function capturePanelLayout(board: HTMLElement): import("../../code-mode/layout.ts").PanelLayoutSnapshot | undefined;
|
|
6
|
+
/** Apply a saved preference only to matching panels and current viewer width declarations.
|
|
7
|
+
* @param {HTMLElement} board
|
|
8
|
+
* @param {unknown} snapshot
|
|
9
|
+
*/
|
|
10
|
+
export function restorePanelLayout(board: HTMLElement, snapshot: unknown): boolean;
|
|
11
|
+
//# sourceMappingURL=panel-snapshot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"panel-snapshot.d.ts","sourceRoot":"","sources":["../../../../src/src/host/renderer/panel-snapshot.js"],"names":[],"mappings":"AAuBA;;;GAGG;AACH,0CAHW,WAAW,GACT,OAAO,2BAA2B,EAAE,mBAAmB,GAAG,SAAS,CAe/E;AAED;;;GAGG;AACH,0CAHW,WAAW,YACX,OAAO,WA2BjB"}
|
|
@@ -0,0 +1,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
|
+
}
|
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
|
*
|