@mcpview/compose 0.12.0 → 0.13.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 +11 -0
- package/README.md +27 -1
- package/esm/_dnt.polyfills.d.ts +49 -0
- package/esm/_dnt.polyfills.d.ts.map +1 -1
- package/esm/_dnt.polyfills.js +36 -0
- package/esm/src/code-mode/board.d.ts +4 -0
- package/esm/src/code-mode/board.d.ts.map +1 -1
- package/esm/src/code-mode/board.js +3 -1
- package/esm/src/core/collector/collector.d.ts +2 -1
- package/esm/src/core/collector/collector.d.ts.map +1 -1
- package/esm/src/core/collector/collector.js +6 -0
- package/esm/src/core/types/resources.d.ts +4 -0
- package/esm/src/core/types/resources.d.ts.map +1 -1
- package/esm/src/core/types/resources.js +10 -1
- package/esm/src/host/renderer/css/base.d.ts.map +1 -1
- package/esm/src/host/renderer/css/base.js +3 -0
- package/esm/src/host/renderer/css/layouts.d.ts.map +1 -1
- package/esm/src/host/renderer/css/layouts.js +17 -14
- package/esm/src/host/renderer/css/panel-controls.d.ts +3 -0
- package/esm/src/host/renderer/css/panel-controls.d.ts.map +1 -0
- package/esm/src/host/renderer/css/panel-controls.js +89 -0
- package/esm/src/host/renderer/html-generator.d.ts.map +1 -1
- package/esm/src/host/renderer/html-generator.js +38 -42
- package/esm/src/host/renderer/js/card-height.d.ts +3 -0
- package/esm/src/host/renderer/js/card-height.d.ts.map +1 -0
- package/esm/src/host/renderer/js/card-height.js +58 -0
- package/esm/src/host/renderer/js/event-bus.d.ts.map +1 -1
- package/esm/src/host/renderer/js/event-bus.js +32 -12
- package/esm/src/host/renderer/panel-controls.d.ts +23 -0
- package/esm/src/host/renderer/panel-controls.d.ts.map +1 -0
- package/esm/src/host/renderer/panel-controls.js +5 -0
- package/esm/src/host/renderer/panel-movement.d.ts +8 -0
- package/esm/src/host/renderer/panel-movement.d.ts.map +1 -0
- package/esm/src/host/renderer/panel-movement.js +392 -0
- package/esm/src/host/renderer/panel-reflow.d.ts +17 -0
- package/esm/src/host/renderer/panel-reflow.d.ts.map +1 -0
- package/esm/src/host/renderer/panel-reflow.js +342 -0
- package/esm/src/host/renderer/panel-resizing.d.ts +11 -0
- package/esm/src/host/renderer/panel-resizing.d.ts.map +1 -0
- package/esm/src/host/renderer/panel-resizing.js +347 -0
- package/esm/src/runtime/compose.d.ts.map +1 -1
- package/esm/src/runtime/compose.js +3 -0
- package/esm/src/runtime/manifest.d.ts.map +1 -1
- package/esm/src/runtime/manifest.js +4 -0
- package/esm/src/runtime/types.d.ts +2 -0
- package/esm/src/runtime/types.d.ts.map +1 -1
- package/esm/src/sdk/mcp-sdk.d.ts +2 -1
- package/esm/src/sdk/mcp-sdk.d.ts.map +1 -1
- package/esm/src/sdk/mcp-sdk.js +2 -2
- package/esm/src/version.d.ts +1 -1
- package/esm/src/version.js +1 -1
- package/package.json +1 -1
- package/script/_dnt.polyfills.d.ts +49 -0
- package/script/_dnt.polyfills.d.ts.map +1 -1
- package/script/_dnt.polyfills.js +36 -0
- package/script/src/code-mode/board.d.ts +4 -0
- package/script/src/code-mode/board.d.ts.map +1 -1
- package/script/src/code-mode/board.js +7 -2
- package/script/src/core/collector/collector.d.ts +2 -1
- package/script/src/core/collector/collector.d.ts.map +1 -1
- package/script/src/core/collector/collector.js +6 -0
- package/script/src/core/types/resources.d.ts +4 -0
- package/script/src/core/types/resources.d.ts.map +1 -1
- package/script/src/core/types/resources.js +11 -0
- package/script/src/host/renderer/css/base.d.ts.map +1 -1
- package/script/src/host/renderer/css/base.js +3 -0
- package/script/src/host/renderer/css/layouts.d.ts.map +1 -1
- package/script/src/host/renderer/css/layouts.js +17 -14
- package/script/src/host/renderer/css/panel-controls.d.ts +3 -0
- package/script/src/host/renderer/css/panel-controls.d.ts.map +1 -0
- package/script/src/host/renderer/css/panel-controls.js +92 -0
- package/script/src/host/renderer/html-generator.d.ts.map +1 -1
- package/script/src/host/renderer/html-generator.js +38 -42
- package/script/src/host/renderer/js/card-height.d.ts +3 -0
- package/script/src/host/renderer/js/card-height.d.ts.map +1 -0
- package/script/src/host/renderer/js/card-height.js +61 -0
- package/script/src/host/renderer/js/event-bus.d.ts.map +1 -1
- package/script/src/host/renderer/js/event-bus.js +32 -12
- package/script/src/host/renderer/panel-controls.d.ts +23 -0
- package/script/src/host/renderer/panel-controls.d.ts.map +1 -0
- package/script/src/host/renderer/panel-controls.js +11 -0
- package/script/src/host/renderer/panel-movement.d.ts +8 -0
- package/script/src/host/renderer/panel-movement.d.ts.map +1 -0
- package/script/src/host/renderer/panel-movement.js +395 -0
- package/script/src/host/renderer/panel-reflow.d.ts +17 -0
- package/script/src/host/renderer/panel-reflow.d.ts.map +1 -0
- package/script/src/host/renderer/panel-reflow.js +345 -0
- package/script/src/host/renderer/panel-resizing.d.ts +11 -0
- package/script/src/host/renderer/panel-resizing.d.ts.map +1 -0
- package/script/src/host/renderer/panel-resizing.js +350 -0
- package/script/src/runtime/compose.d.ts.map +1 -1
- package/script/src/runtime/compose.js +3 -0
- package/script/src/runtime/manifest.d.ts.map +1 -1
- package/script/src/runtime/manifest.js +4 -0
- package/script/src/runtime/types.d.ts +2 -0
- package/script/src/runtime/types.d.ts.map +1 -1
- package/script/src/sdk/mcp-sdk.d.ts +2 -1
- package/script/src/sdk/mcp-sdk.d.ts.map +1 -1
- package/script/src/sdk/mcp-sdk.js +2 -2
- package/script/src/version.d.ts +1 -1
- package/script/src/version.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,17 @@ documented in this file.
|
|
|
5
5
|
|
|
6
6
|
## [Unreleased]
|
|
7
7
|
|
|
8
|
+
## [0.13.0] - 2026-11-27
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Drag a viewer by its top-left grip to swap or position it beside or below another viewer. Embedded
|
|
13
|
+
dashboards report their height to the host as rows appear or disappear. The bottom-right corner
|
|
14
|
+
snaps to widths declared by the viewer's Compose manifest or local adapter. A skeleton reserves
|
|
15
|
+
the destination during the drag so neighbors can move before release. Each App keeps its content
|
|
16
|
+
height, mounted state and event routes. Code Mode boards can use the same controls for locally
|
|
17
|
+
rendered panels.
|
|
18
|
+
|
|
8
19
|
## [0.12.0] - 2026-11-26
|
|
9
20
|
|
|
10
21
|
### Added
|
package/README.md
CHANGED
|
@@ -220,11 +220,37 @@ Each step is a pure function. Use them independently or together.
|
|
|
220
220
|
|
|
221
221
|
| Layout | Description |
|
|
222
222
|
| ------- | ----------------------------- |
|
|
223
|
-
| `split` | Side-by-side panels
|
|
223
|
+
| `split` | Side-by-side panels |
|
|
224
224
|
| `tabs` | Tabbed interface with tab bar |
|
|
225
225
|
| `grid` | Auto-fit grid for dashboards |
|
|
226
226
|
| `stack` | Vertical stack (default) |
|
|
227
227
|
|
|
228
|
+
Drag the grip in the top-left corner to move a viewer. Aim at the bottom edge of another viewer to
|
|
229
|
+
place it on the row below. Drop beside it to return to one row when both widths fit, or drop in its
|
|
230
|
+
center to swap. The skeleton shows where the viewer will land. An embedded Compose board reports its
|
|
231
|
+
content height to the host as the rows change, including during the preview and on cancellation. You
|
|
232
|
+
can also swap by clicking or tapping two handles in sequence. In a tabbed dashboard the handles
|
|
233
|
+
reorder the tabs.
|
|
234
|
+
|
|
235
|
+
Declare a viewer's supported widths in CSS pixels on its Compose manifest tool, for example
|
|
236
|
+
`"supportedWidths": [380, 640]`. Programmatic descriptors and local Code Mode view adapters accept
|
|
237
|
+
the same field. Omit it for a viewer that should keep its template size.
|
|
238
|
+
|
|
239
|
+
Drag the bottom-right corner to preview an allowed width. At the right edge of the screen, pull down
|
|
240
|
+
to reach a wider format. The skeleton reserves the space and neighbors shift sideways or wrap to a
|
|
241
|
+
new row. When the viewer shrinks, its neighbor returns beside it with the template's original gap as
|
|
242
|
+
soon as both fit. Release to apply the width or press Escape to cancel. The left and right arrow
|
|
243
|
+
keys step between available widths when the corner has focus. Reopening the dashboard restores the
|
|
244
|
+
template layout. Each iframe stays mounted and reports its own content height as its width changes.
|
|
245
|
+
|
|
246
|
+
For a Code Mode board with local renderers, `@mcpview/compose/code-mode/board` exports
|
|
247
|
+
`getPanelControlsCss()`, `installPanelMovement(board, signal?)` and
|
|
248
|
+
`installPanelResizing(board, signal?)`. Mark the grid with `data-compose-board` and its direct panel
|
|
249
|
+
elements with `data-compose-panel` and `data-panel-label`. Set `data-compose-widths` to the
|
|
250
|
+
space-separated widths of each resizable local viewer. Place a `button[data-compose-grip]` inside
|
|
251
|
+
each panel. Named layouts identify each panel's grid area with `data-area`. The
|
|
252
|
+
[CAD and print estimate board](./examples/multi-mcp-snippets/ui/main.ts) shows the full setup.
|
|
253
|
+
|
|
228
254
|
## Sync Rules
|
|
229
255
|
|
|
230
256
|
Declarative event routing between UIs:
|
package/esm/_dnt.polyfills.d.ts
CHANGED
|
@@ -1,3 +1,52 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface Array<T> {
|
|
3
|
+
/**
|
|
4
|
+
* Returns the value of the last element in the array where predicate is true, and undefined
|
|
5
|
+
* otherwise.
|
|
6
|
+
* @param predicate find calls predicate once for each element of the array, in ascending
|
|
7
|
+
* order, until it finds one where predicate returns true. If such an element is found, find
|
|
8
|
+
* immediately returns that element value. Otherwise, find returns undefined.
|
|
9
|
+
* @param thisArg If provided, it will be used as the this value for each invocation of
|
|
10
|
+
* predicate. If it is not provided, undefined is used instead.
|
|
11
|
+
*/
|
|
12
|
+
findLast<S extends T>(predicate: (this: void, value: T, index: number, obj: T[]) => value is S, thisArg?: any): S | undefined;
|
|
13
|
+
findLast(predicate: (value: T, index: number, obj: T[]) => unknown, thisArg?: any): T | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Returns the index of the last element in the array where predicate is true, and -1
|
|
16
|
+
* otherwise.
|
|
17
|
+
* @param predicate find calls predicate once for each element of the array, in ascending
|
|
18
|
+
* order, until it finds one where predicate returns true. If such an element is found,
|
|
19
|
+
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
|
|
20
|
+
* @param thisArg If provided, it will be used as the this value for each invocation of
|
|
21
|
+
* predicate. If it is not provided, undefined is used instead.
|
|
22
|
+
*/
|
|
23
|
+
findLastIndex(predicate: (value: T, index: number, obj: T[]) => unknown, thisArg?: any): number;
|
|
24
|
+
}
|
|
25
|
+
interface Uint8Array {
|
|
26
|
+
/**
|
|
27
|
+
* Returns the value of the last element in the array where predicate is true, and undefined
|
|
28
|
+
* otherwise.
|
|
29
|
+
* @param predicate findLast calls predicate once for each element of the array, in descending
|
|
30
|
+
* order, until it finds one where predicate returns true. If such an element is found, findLast
|
|
31
|
+
* immediately returns that element value. Otherwise, findLast returns undefined.
|
|
32
|
+
* @param thisArg If provided, it will be used as the this value for each invocation of
|
|
33
|
+
* predicate. If it is not provided, undefined is used instead.
|
|
34
|
+
*/
|
|
35
|
+
findLast<S extends number>(predicate: (value: number, index: number, array: Uint8Array) => value is S, thisArg?: any): S | undefined;
|
|
36
|
+
findLast(predicate: (value: number, index: number, array: Uint8Array) => unknown, thisArg?: any): number | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Returns the index of the last element in the array where predicate is true, and -1
|
|
39
|
+
* otherwise.
|
|
40
|
+
* @param predicate findLastIndex calls predicate once for each element of the array, in descending
|
|
41
|
+
* order, until it finds one where predicate returns true. If such an element is found,
|
|
42
|
+
* findLastIndex immediately returns that element index. Otherwise, findLastIndex returns -1.
|
|
43
|
+
* @param thisArg If provided, it will be used as the this value for each invocation of
|
|
44
|
+
* predicate. If it is not provided, undefined is used instead.
|
|
45
|
+
*/
|
|
46
|
+
findLastIndex(predicate: (value: number, index: number, array: Uint8Array) => unknown, thisArg?: any): number;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export {};
|
|
1
50
|
declare global {
|
|
2
51
|
interface Object {
|
|
3
52
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_dnt.polyfills.d.ts","sourceRoot":"","sources":["../src/_dnt.polyfills.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"_dnt.polyfills.d.ts","sourceRoot":"","sources":["../src/_dnt.polyfills.ts"],"names":[],"mappings":"AACA,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,KAAK,CAAC,CAAC;QACf;;;;;;;;WAQG;QACH,QAAQ,CAAC,CAAC,SAAS,CAAC,EAClB,SAAS,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC,EACxE,OAAO,CAAC,EAAE,GAAG,GACZ,CAAC,GAAG,SAAS,CAAC;QACjB,QAAQ,CACN,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,OAAO,EACzD,OAAO,CAAC,EAAE,GAAG,GACZ,CAAC,GAAG,SAAS,CAAC;QAEjB;;;;;;;;WAQG;QACH,aAAa,CACX,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,OAAO,EACzD,OAAO,CAAC,EAAE,GAAG,GACZ,MAAM,CAAC;KACX;IACD,UAAU,UAAU;QAClB;;;;;;;;WAQG;QACH,QAAQ,CAAC,CAAC,SAAS,MAAM,EACvB,SAAS,EAAE,CACP,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,UAAU,KAChB,KAAK,IAAI,CAAC,EACf,OAAO,CAAC,EAAE,GAAG,GACZ,CAAC,GAAG,SAAS,CAAC;QACjB,QAAQ,CACJ,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,KAAK,OAAO,EACvE,OAAO,CAAC,EAAE,GAAG,GACd,MAAM,GAAG,SAAS,CAAC;QAEtB;;;;;;;;WAQG;QACH,aAAa,CACT,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,KAAK,OAAO,EACvE,OAAO,CAAC,EAAE,GAAG,GACd,MAAM,CAAC;KACX;CACF;AA4CD,OAAO,EAAE,CAAC;AAgBV,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd;;;;WAIG;QACH,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC;KAC5C;CACF;AAED,OAAO,EAAE,CAAC;AACV,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,KAAK;QACb,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB;CACF;AAED,OAAO,EAAE,CAAC"}
|
package/esm/_dnt.polyfills.js
CHANGED
|
@@ -1,3 +1,39 @@
|
|
|
1
|
+
function findLastIndex(self, callbackfn, that) {
|
|
2
|
+
const boundFunc = that === undefined ? callbackfn : callbackfn.bind(that);
|
|
3
|
+
let index = self.length - 1;
|
|
4
|
+
while (index >= 0) {
|
|
5
|
+
const result = boundFunc(self[index], index, self);
|
|
6
|
+
if (result) {
|
|
7
|
+
return index;
|
|
8
|
+
}
|
|
9
|
+
index--;
|
|
10
|
+
}
|
|
11
|
+
return -1;
|
|
12
|
+
}
|
|
13
|
+
function findLast(self, callbackfn, that) {
|
|
14
|
+
const index = self.findLastIndex(callbackfn, that);
|
|
15
|
+
return index === -1 ? undefined : self[index];
|
|
16
|
+
}
|
|
17
|
+
if (!Array.prototype.findLastIndex) {
|
|
18
|
+
Array.prototype.findLastIndex = function (callbackfn, that) {
|
|
19
|
+
return findLastIndex(this, callbackfn, that);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
if (!Array.prototype.findLast) {
|
|
23
|
+
Array.prototype.findLast = function (callbackfn, that) {
|
|
24
|
+
return findLast(this, callbackfn, that);
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
if (!Uint8Array.prototype.findLastIndex) {
|
|
28
|
+
Uint8Array.prototype.findLastIndex = function (callbackfn, that) {
|
|
29
|
+
return findLastIndex(this, callbackfn, that);
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
if (!Uint8Array.prototype.findLast) {
|
|
33
|
+
Uint8Array.prototype.findLast = function (callbackfn, that) {
|
|
34
|
+
return findLast(this, callbackfn, that);
|
|
35
|
+
};
|
|
36
|
+
}
|
|
1
37
|
// https://github.com/tc39/proposal-accessible-object-hasownproperty/blob/main/polyfill.js
|
|
2
38
|
if (!Object.hasOwn) {
|
|
3
39
|
Object.defineProperty(Object, "hasOwn", {
|
|
@@ -6,6 +6,8 @@ import "../../_dnt.polyfills.js";
|
|
|
6
6
|
import type { ComponentSurface } from "../core/types/components.js";
|
|
7
7
|
import type { CompositeUiDescriptor } from "../core/types/descriptor.js";
|
|
8
8
|
import type { UiLayout } from "../core/types/layout.js";
|
|
9
|
+
export { getPanelControlsCss } from "../host/renderer/css/panel-controls.js";
|
|
10
|
+
export { installPanelMovement, installPanelResizing } from "../host/renderer/panel-controls.js";
|
|
9
11
|
/** MCP App result metadata containing the receipts selected by the program. */
|
|
10
12
|
export declare const SNIPPET_PANELS_META_KEY = "io.mcpview/snippet-panels";
|
|
11
13
|
/** A selected provider result. The receipt ID distinguishes calls to the same snippet. */
|
|
@@ -21,6 +23,8 @@ export interface SnippetPanelView {
|
|
|
21
23
|
readonly resourceUri: string;
|
|
22
24
|
readonly context?: Record<string, unknown>;
|
|
23
25
|
readonly surface?: ComponentSurface;
|
|
26
|
+
/** Widths offered by this local view in CSS pixels. An empty list disables resizing. */
|
|
27
|
+
readonly supportedWidths?: readonly number[];
|
|
24
28
|
}
|
|
25
29
|
/** Display options supplied by the board hosting the results. */
|
|
26
30
|
export interface SnippetBoardOptions {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"board.d.ts","sourceRoot":"","sources":["../../../src/src/code-mode/board.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,yBAAyB,CAAC;AAMjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD,+EAA+E;AAC/E,eAAO,MAAM,uBAAuB,8BAA8B,CAAC;AAEnE,0FAA0F;AAC1F,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC1C;AAED,4FAA4F;AAC5F,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC3C,QAAQ,CAAC,OAAO,CAAC,EAAE,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"board.d.ts","sourceRoot":"","sources":["../../../src/src/code-mode/board.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,yBAAyB,CAAC;AAMjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAEhG,+EAA+E;AAC/E,eAAO,MAAM,uBAAuB,8BAA8B,CAAC;AAEnE,0FAA0F;AAC1F,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC1C;AAED,4FAA4F;AAC5F,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC3C,QAAQ,CAAC,OAAO,CAAC,EAAE,gBAAgB,CAAC;IACpC,wFAAwF;IACxF,QAAQ,CAAC,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC9C;AAED,iEAAiE;AACjE,MAAM,WAAW,mBAAmB;IAClC,yFAAyF;IACzF,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,QAAQ,CAAC,CAAC;IAC3D,+FAA+F;IAC/F,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,gBAAgB,GAAG,SAAS,CAAC;CAC9E;AAcD;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,GAAG,YAAY,EAAE,CAajE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,OAAO,EACf,OAAO,GAAE,mBAAwB,GAChC,qBAAqB,CAyBvB"}
|
|
@@ -6,6 +6,8 @@ import "../../_dnt.polyfills.js";
|
|
|
6
6
|
import { createCollector } from "../core/collector/collector.js";
|
|
7
7
|
import { extractUiMeta } from "../core/collector/extractor.js";
|
|
8
8
|
import { buildCompositeUi } from "../core/composer/composer.js";
|
|
9
|
+
export { getPanelControlsCss } from "../host/renderer/css/panel-controls.js";
|
|
10
|
+
export { installPanelMovement, installPanelResizing } from "../host/renderer/panel-controls.js";
|
|
9
11
|
/** MCP App result metadata containing the receipts selected by the program. */
|
|
10
12
|
export const SNIPPET_PANELS_META_KEY = "io.mcpview/snippet-panels";
|
|
11
13
|
function record(value) {
|
|
@@ -76,7 +78,7 @@ export function composeSnippetBoard(result, options = {}) {
|
|
|
76
78
|
panel,
|
|
77
79
|
...(view?.context === undefined ? {} : { view: view.context }),
|
|
78
80
|
...(Object.hasOwn(summary, "value") ? { value: summary.value } : {}),
|
|
79
|
-
}, { componentId: panel.id, surface: view?.surface });
|
|
81
|
+
}, { componentId: panel.id, surface: view?.surface, supportedWidths: view?.supportedWidths });
|
|
80
82
|
}
|
|
81
83
|
const resources = collector.getResources();
|
|
82
84
|
const layout = typeof options.layout === "function"
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module collector/collector
|
|
5
5
|
*/
|
|
6
|
-
import type
|
|
6
|
+
import { type CollectedUiResource } from "../types/resources.js";
|
|
7
7
|
import type { ComponentSurface } from "../types/components.js";
|
|
8
8
|
/**
|
|
9
9
|
* Collector interface for accumulating UI resources from MCP tool results.
|
|
@@ -21,6 +21,7 @@ export interface UiCollector {
|
|
|
21
21
|
collect(toolName: string, result: unknown, context?: Record<string, unknown>, options?: {
|
|
22
22
|
readonly componentId?: string;
|
|
23
23
|
readonly surface?: ComponentSurface;
|
|
24
|
+
readonly supportedWidths?: readonly number[];
|
|
24
25
|
}): CollectedUiResource | null;
|
|
25
26
|
/** Get all collected resources in slot order. */
|
|
26
27
|
getResources(): CollectedUiResource[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collector.d.ts","sourceRoot":"","sources":["../../../../src/src/core/collector/collector.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"collector.d.ts","sourceRoot":"","sources":["../../../../src/src/core/collector/collector.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,mBAAmB,EAAqB,MAAM,uBAAuB,CAAC;AACpF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG/D;;;;;;;;;;GAUG;AACH,MAAM,WAAW,WAAW;IAC1B,yFAAyF;IACzF,OAAO,CACL,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,OAAO,EACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,OAAO,CAAC,EAAE;QACR,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAC9B,QAAQ,CAAC,OAAO,CAAC,EAAE,gBAAgB,CAAC;QACpC,QAAQ,CAAC,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;KAC9C,GACA,mBAAmB,GAAG,IAAI,CAAC;IAE9B,iDAAiD;IACjD,YAAY,IAAI,mBAAmB,EAAE,CAAC;IAEtC,iCAAiC;IACjC,KAAK,IAAI,IAAI,CAAC;CACf;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,eAAe,IAAI,WAAW,CAoC7C"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module collector/collector
|
|
5
5
|
*/
|
|
6
|
+
import { isSupportedWidths } from "../types/resources.js";
|
|
6
7
|
import { extractUiMeta } from "./extractor.js";
|
|
7
8
|
/**
|
|
8
9
|
* Create a new UI resource collector.
|
|
@@ -39,12 +40,17 @@ export function createCollector() {
|
|
|
39
40
|
if (!meta?.resourceUri) {
|
|
40
41
|
return null;
|
|
41
42
|
}
|
|
43
|
+
const widths = options?.supportedWidths;
|
|
44
|
+
if (widths !== undefined && !isSupportedWidths(widths)) {
|
|
45
|
+
throw new TypeError("supportedWidths must be an array of positive safe integers");
|
|
46
|
+
}
|
|
42
47
|
const resource = {
|
|
43
48
|
...(options?.componentId === undefined ? {} : { componentId: options.componentId }),
|
|
44
49
|
source: toolName,
|
|
45
50
|
resourceUri: meta.resourceUri,
|
|
46
51
|
context,
|
|
47
52
|
...(options?.surface === undefined ? {} : { surface: options.surface }),
|
|
53
|
+
...(widths === undefined ? {} : { supportedWidths: [...widths] }),
|
|
48
54
|
slot: resources.length,
|
|
49
55
|
};
|
|
50
56
|
resources.push(resource);
|
|
@@ -31,7 +31,11 @@ export interface CollectedUiResource {
|
|
|
31
31
|
context?: Record<string, unknown>;
|
|
32
32
|
/** Optional inner surface assembled from components advertised by this App. */
|
|
33
33
|
surface?: ComponentSurface;
|
|
34
|
+
/** Widths offered by this viewer in CSS pixels. An empty list disables resizing. */
|
|
35
|
+
supportedWidths?: readonly number[];
|
|
34
36
|
/** Slot index (0-based execution order). */
|
|
35
37
|
slot: number;
|
|
36
38
|
}
|
|
39
|
+
/** Whether a Compose width declaration contains only positive whole CSS pixel values. */
|
|
40
|
+
export declare function isSupportedWidths(value: unknown): value is readonly number[];
|
|
37
41
|
//# sourceMappingURL=resources.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../../../src/src/core/types/resources.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD;;;;GAIG;AAEH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,mBAAmB;IAClC,yFAAyF;IACzF,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,sEAAsE;IACtE,MAAM,EAAE,MAAM,CAAC;IAEf,4DAA4D;IAC5D,WAAW,EAAE,MAAM,CAAC;IAEpB,wCAAwC;IACxC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAElC,+EAA+E;IAC/E,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAE3B,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAC;CACd"}
|
|
1
|
+
{"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../../../src/src/core/types/resources.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD;;;;GAIG;AAEH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,mBAAmB;IAClC,yFAAyF;IACzF,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,sEAAsE;IACtE,MAAM,EAAE,MAAM,CAAC;IAEf,4DAA4D;IAC5D,WAAW,EAAE,MAAM,CAAC;IAEpB,wCAAwC;IACxC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAElC,+EAA+E;IAC/E,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAE3B,oFAAoF;IACpF,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAEpC,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAC;CACd;AAED,yFAAyF;AACzF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,MAAM,EAAE,CAM5E"}
|
|
@@ -1 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
/** Whether a Compose width declaration contains only positive whole CSS pixel values. */
|
|
2
|
+
export function isSupportedWidths(value) {
|
|
3
|
+
if (!Array.isArray(value))
|
|
4
|
+
return false;
|
|
5
|
+
for (const width of value) {
|
|
6
|
+
if (!Number.isSafeInteger(width) || width <= 0)
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../../src/src/host/renderer/css/base.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,UAAU,IAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../../src/src/host/renderer/css/base.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,UAAU,IAAI,MAAM,CA6BnC"}
|
|
@@ -26,6 +26,7 @@ export function getBaseCss() {
|
|
|
26
26
|
--mcc-bg-secondary: #f5f5f5;
|
|
27
27
|
--mcc-bg-primary: #ffffff;
|
|
28
28
|
--mcc-bg-hover: #e8e8e8;
|
|
29
|
+
--mcc-text-secondary: #51565a;
|
|
29
30
|
--mcc-accent-color: #1a73e8;
|
|
30
31
|
}
|
|
31
32
|
body.dark {
|
|
@@ -33,6 +34,7 @@ export function getBaseCss() {
|
|
|
33
34
|
--mcc-bg-secondary: #2a2a2a;
|
|
34
35
|
--mcc-bg-primary: #1a1a1a;
|
|
35
36
|
--mcc-bg-hover: #3a3a3a;
|
|
37
|
+
--mcc-text-secondary: #c2c5c8;
|
|
36
38
|
--mcc-accent-color: #8ab4f8;
|
|
37
39
|
}
|
|
38
40
|
@media (prefers-color-scheme: dark) {
|
|
@@ -41,6 +43,7 @@ export function getBaseCss() {
|
|
|
41
43
|
--mcc-bg-secondary: #2a2a2a;
|
|
42
44
|
--mcc-bg-primary: #1a1a1a;
|
|
43
45
|
--mcc-bg-hover: #3a3a3a;
|
|
46
|
+
--mcc-text-secondary: #c2c5c8;
|
|
44
47
|
--mcc-accent-color: #8ab4f8;
|
|
45
48
|
}
|
|
46
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layouts.d.ts","sourceRoot":"","sources":["../../../../../src/src/host/renderer/css/layouts.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAA8B,MAAM,+BAA+B,CAAC;AAW1F;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,QAAQ,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"layouts.d.ts","sourceRoot":"","sources":["../../../../../src/src/host/renderer/css/layouts.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAA8B,MAAM,+BAA+B,CAAC;AAW1F;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,QAAQ,GAAG,MAAM,CAqDrD"}
|
|
@@ -42,13 +42,16 @@ export function getLayoutCss(layout) {
|
|
|
42
42
|
switch (preset) {
|
|
43
43
|
case "split":
|
|
44
44
|
return `
|
|
45
|
-
.layout-split {
|
|
46
|
-
|
|
45
|
+
.layout-split {
|
|
46
|
+
display: grid; height: 100vh; gap: 8px;
|
|
47
|
+
grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
|
|
48
|
+
}
|
|
47
49
|
`;
|
|
48
50
|
case "tabs":
|
|
49
51
|
return `
|
|
50
52
|
.layout-tabs { height: 100vh; display: flex; flex-direction: column; }
|
|
51
|
-
.tab-bar { display: flex; border-bottom: 1px solid var(--mcc-border-color); background: var(--mcc-bg-secondary); }
|
|
53
|
+
.tab-bar { display: flex; overflow-x: auto; border-bottom: 1px solid var(--mcc-border-color); background: var(--mcc-bg-secondary); }
|
|
54
|
+
.tab-bar > [data-compose-panel] { display: flex; align-items: center; }
|
|
52
55
|
.tab { padding: 12px 24px; cursor: pointer; border: none; background: transparent; font-size: 14px; color: inherit; }
|
|
53
56
|
.tab:hover { background: var(--mcc-bg-hover); }
|
|
54
57
|
.tab.active { background: var(--mcc-bg-primary); border-bottom: 2px solid var(--mcc-accent-color); }
|
|
@@ -60,20 +63,23 @@ export function getLayoutCss(layout) {
|
|
|
60
63
|
return `
|
|
61
64
|
.layout-grid {
|
|
62
65
|
display: grid;
|
|
63
|
-
grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
|
|
66
|
+
grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr));
|
|
64
67
|
grid-auto-rows: 1fr;
|
|
65
68
|
gap: 8px;
|
|
66
69
|
height: 100vh;
|
|
67
70
|
padding: 8px;
|
|
68
71
|
box-sizing: border-box;
|
|
69
72
|
}
|
|
70
|
-
.layout-grid > iframe { border: 1px solid var(--mcc-border-color); border-radius: 4px; width: 100%; height: 100%; }
|
|
71
73
|
`;
|
|
72
74
|
case "stack":
|
|
73
75
|
return `
|
|
74
|
-
.layout-stack {
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
.layout-stack {
|
|
77
|
+
display: grid; height: 100vh; gap: 8px;
|
|
78
|
+
grid-template-columns: minmax(0, 1fr); grid-auto-rows: minmax(auto, 1fr);
|
|
79
|
+
}
|
|
80
|
+
.layout-stack > .compose-viewer {
|
|
81
|
+
min-height: var(--compose-native-height, 200px);
|
|
82
|
+
}
|
|
77
83
|
`;
|
|
78
84
|
default: {
|
|
79
85
|
const _exhaustive = preset;
|
|
@@ -118,12 +124,9 @@ function getAreasCss(layout) {
|
|
|
118
124
|
padding: ${gap};
|
|
119
125
|
box-sizing: border-box;
|
|
120
126
|
}
|
|
121
|
-
.layout-areas
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
width: 100%;
|
|
125
|
-
height: 100%;
|
|
126
|
-
}
|
|
127
|
+
${layout.rows ? "" : ` .layout-areas[data-compose-intrinsic] {
|
|
128
|
+
grid-template-rows: repeat(${layout.areas.length}, auto);
|
|
129
|
+
}`}
|
|
127
130
|
${areaStyles}
|
|
128
131
|
`;
|
|
129
132
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"panel-controls.d.ts","sourceRoot":"","sources":["../../../../../src/src/host/renderer/css/panel-controls.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,wBAAgB,mBAAmB,IAAI,MAAM,CAuF5C"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/** Shared styles for the controls around mounted Compose viewers. */
|
|
2
|
+
export function getPanelControlsCss() {
|
|
3
|
+
return `
|
|
4
|
+
[data-compose-board] {
|
|
5
|
+
position: relative;
|
|
6
|
+
--compose-ink: var(--board-muted, var(--mcc-text-secondary, #5b6268));
|
|
7
|
+
--compose-active: var(--board-focus, var(--mcc-accent-color, #286cb7));
|
|
8
|
+
}
|
|
9
|
+
[data-compose-panel] { position: relative; min-width: 0; min-height: 0; }
|
|
10
|
+
.compose-viewer {
|
|
11
|
+
align-self: start;
|
|
12
|
+
height: var(--compose-native-height, 100%);
|
|
13
|
+
}
|
|
14
|
+
#container[data-compose-intrinsic] {
|
|
15
|
+
height: auto;
|
|
16
|
+
align-content: start;
|
|
17
|
+
grid-auto-rows: auto;
|
|
18
|
+
}
|
|
19
|
+
#container[data-compose-intrinsic] > .compose-viewer {
|
|
20
|
+
height: var(--compose-native-height, 200px);
|
|
21
|
+
}
|
|
22
|
+
.compose-viewer > iframe {
|
|
23
|
+
display: block; width: 100%; height: 100%; border: 0;
|
|
24
|
+
}
|
|
25
|
+
button[data-compose-grip] {
|
|
26
|
+
position: absolute; z-index: 4; top: 0; left: 2px;
|
|
27
|
+
display: block; width: 18px; height: 16px;
|
|
28
|
+
margin: 0; padding: 0; border: 0; border-radius: 3px;
|
|
29
|
+
background: transparent; color: var(--compose-ink);
|
|
30
|
+
cursor: grab; touch-action: none; user-select: none;
|
|
31
|
+
}
|
|
32
|
+
button[data-compose-grip][hidden] { display: none; }
|
|
33
|
+
button[data-compose-grip]::before {
|
|
34
|
+
content: ""; position: absolute; top: 4px; left: 8px;
|
|
35
|
+
width: 2px; height: 2px; border-radius: 50%; opacity: 0;
|
|
36
|
+
background: currentColor;
|
|
37
|
+
box-shadow: -4.25px 1.75px, -6px 6px;
|
|
38
|
+
}
|
|
39
|
+
[data-compose-grip]:focus-visible, [data-compose-corner]:focus-visible {
|
|
40
|
+
outline: 2px solid var(--compose-active); outline-offset: -2px;
|
|
41
|
+
}
|
|
42
|
+
[data-compose-moving] [data-compose-grip] { cursor: grabbing; }
|
|
43
|
+
[data-compose-dragging] iframe { pointer-events: none; }
|
|
44
|
+
button[data-compose-corner] {
|
|
45
|
+
position: absolute; z-index: 3; bottom: 0; right: 0; width: 18px; height: 18px;
|
|
46
|
+
padding: 0; margin: 0; min-width: 0; min-height: 0; border: 0; border-radius: 0;
|
|
47
|
+
color: var(--compose-ink); background: transparent; cursor: nwse-resize;
|
|
48
|
+
touch-action: none; user-select: none;
|
|
49
|
+
}
|
|
50
|
+
[data-compose-corner]::after {
|
|
51
|
+
content: ""; position: absolute; bottom: 3px; right: 3px; width: 9px; height: 9px;
|
|
52
|
+
background: linear-gradient(135deg, transparent 43%, currentColor 45% 52%, transparent 54% 68%, currentColor 70% 77%, transparent 79%);
|
|
53
|
+
opacity: 0; pointer-events: none;
|
|
54
|
+
}
|
|
55
|
+
:where([data-compose-panel]:hover) button[data-compose-grip]::before,
|
|
56
|
+
:where([data-compose-panel]:hover) [data-compose-corner]::after { opacity: .4; }
|
|
57
|
+
button[data-compose-grip]:is(:hover, :focus-visible, :active, [aria-pressed="true"])::before,
|
|
58
|
+
[data-compose-corner]:is(:hover, :focus-visible, :active)::after { opacity: 1; color: var(--compose-active); }
|
|
59
|
+
@media (pointer: coarse) {
|
|
60
|
+
button[data-compose-grip] { width: 24px; height: 24px; }
|
|
61
|
+
button[data-compose-corner] { width: 26px; height: 26px; }
|
|
62
|
+
button[data-compose-grip]::before,
|
|
63
|
+
[data-compose-corner]::after { opacity: .5; }
|
|
64
|
+
}
|
|
65
|
+
@media (forced-colors: active) {
|
|
66
|
+
button[data-compose-grip]::before { color: ButtonText; forced-color-adjust: none; }
|
|
67
|
+
[data-compose-corner]::after { color: ButtonText; forced-color-adjust: none; }
|
|
68
|
+
}
|
|
69
|
+
[data-compose-drop-preview] {
|
|
70
|
+
position: absolute; inset: 0; z-index: 5; pointer-events: none; box-sizing: border-box;
|
|
71
|
+
display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 6px;
|
|
72
|
+
border: 1.5px dashed var(--compose-active); border-radius: inherit;
|
|
73
|
+
background: color-mix(in srgb, var(--board-bg, var(--mcc-bg-primary, Canvas)) 90%, transparent);
|
|
74
|
+
color: color-mix(in srgb, var(--compose-active) 42%, transparent);
|
|
75
|
+
}
|
|
76
|
+
[data-compose-drop-preview]::before, [data-compose-drop-preview]::after {
|
|
77
|
+
content: ""; width: min(36%, 80px); height: 5px; border-radius: 3px; background: currentColor;
|
|
78
|
+
}
|
|
79
|
+
[data-compose-drop-preview]::after { width: min(24%, 54px); }
|
|
80
|
+
.tab-bar [data-compose-drop-preview]::before { width: min(50%, 32px); height: 3px; }
|
|
81
|
+
.tab-bar [data-compose-drop-preview]::after { display: none; }
|
|
82
|
+
@media (forced-colors: active) {
|
|
83
|
+
[data-compose-drop-preview] { border-color: Highlight; background: Canvas; color: GrayText; }
|
|
84
|
+
[data-compose-drop-preview]::before, [data-compose-drop-preview]::after {
|
|
85
|
+
background: GrayText; forced-color-adjust: none;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
`;
|
|
89
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-generator.d.ts","sourceRoot":"","sources":["../../../../src/src/host/renderer/html-generator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"html-generator.d.ts","sourceRoot":"","sources":["../../../../src/src/host/renderer/html-generator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAS5E,OAAO,KAAK,EACV,sBAAsB,EAEtB,2BAA2B,EAC5B,MAAM,cAAc,CAAC;AAWtB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,qBAAqB,EACjC,OAAO,GAAE,sBAA2B,GACnC,MAAM,CAuCR;AAkGD;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,qBAAqB,EACjC,OAAO,GAAE,sBAA2B,GACnC,WAAW,CAAC,MAAM,EAAE,2BAA2B,CAAC,CAkClD"}
|
|
@@ -3,10 +3,14 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module renderer/html-generator
|
|
5
5
|
*/
|
|
6
|
+
import { isSupportedWidths } from "../../core/types/resources.js";
|
|
6
7
|
import { isLayoutAreas } from "../../core/types/layout.js";
|
|
7
8
|
import { getBaseCss } from "./css/base.js";
|
|
8
9
|
import { getLayoutCss } from "./css/layouts.js";
|
|
10
|
+
import { getPanelControlsCss } from "./css/panel-controls.js";
|
|
11
|
+
import { generateCardHeightScript } from "./js/card-height.js";
|
|
9
12
|
import { generateEventBusScript } from "./js/event-bus.js";
|
|
13
|
+
import { createPanelReflow, installPanelMovement, installPanelResizing } from "./panel-controls.js";
|
|
10
14
|
/**
|
|
11
15
|
* Interactive App panels run scripts, but intentionally receive no forms,
|
|
12
16
|
* popups, downloads, or top-level navigation permissions. A local multi-App
|
|
@@ -43,6 +47,13 @@ export function renderComposite(descriptor, options = {}) {
|
|
|
43
47
|
const slots = resolveRendererSlots(descriptor, options);
|
|
44
48
|
const bodyContent = generateBodyContent(descriptor, slots);
|
|
45
49
|
const eventBusScript = generateEventBusScript(descriptor, slots);
|
|
50
|
+
const panelScript = descriptor.children.length === 0 ? "" : `
|
|
51
|
+
const board = document.querySelector('[data-compose-board]');
|
|
52
|
+
(${installPanelMovement})(board);
|
|
53
|
+
${descriptor.layout === "tabs"
|
|
54
|
+
? ""
|
|
55
|
+
: `(${installPanelResizing})(board, undefined, (${createPanelReflow}));`}
|
|
56
|
+
`;
|
|
46
57
|
return `<!DOCTYPE html>
|
|
47
58
|
<html>
|
|
48
59
|
<head>
|
|
@@ -54,51 +65,41 @@ export function renderComposite(descriptor, options = {}) {
|
|
|
54
65
|
body { font-family: system-ui, -apple-system, sans-serif; background: var(--mcc-bg-primary); color: inherit; }
|
|
55
66
|
${baseCss}
|
|
56
67
|
${layoutCss}
|
|
68
|
+
${getPanelControlsCss()}
|
|
57
69
|
</style>
|
|
58
70
|
</head>
|
|
59
71
|
<body>
|
|
60
72
|
${bodyContent}
|
|
61
73
|
<script>
|
|
62
74
|
${eventBusScript}
|
|
75
|
+
${panelScript}
|
|
76
|
+
${descriptor.layout === "tabs" ? "" : generateCardHeightScript()}
|
|
63
77
|
</script>
|
|
64
78
|
</body>
|
|
65
79
|
</html>`;
|
|
66
80
|
}
|
|
67
81
|
function generateBodyContent(descriptor, slots) {
|
|
68
|
-
if (isLayoutAreas(descriptor.layout)) {
|
|
69
|
-
return generateAreasLayout(descriptor, slots);
|
|
70
|
-
}
|
|
71
82
|
if (descriptor.layout === "tabs") {
|
|
72
83
|
return generateTabsLayout(descriptor, slots);
|
|
73
84
|
}
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
85
|
+
const layout = isLayoutAreas(descriptor.layout) ? "areas" : descriptor.layout;
|
|
86
|
+
const panels = descriptor.children.map((child) => {
|
|
87
|
+
const id = child.componentId ?? child.source;
|
|
88
|
+
const area = layout === "areas"
|
|
89
|
+
? ` data-area="${escapeAttr(descriptor.areaMap?.[id] ?? id)}"`
|
|
90
|
+
: "";
|
|
91
|
+
const widths = isSupportedWidths(child.supportedWidths) && child.supportedWidths.length
|
|
92
|
+
? ` data-compose-widths="${child.supportedWidths.join(" ")}"`
|
|
93
|
+
: "";
|
|
94
|
+
return `<section class="compose-viewer" data-compose-panel data-panel-label="${escapeAttr(id)}"${area}${widths}>
|
|
95
|
+
${descriptor.children.length > 1 ? grip(child) : ""}
|
|
96
|
+
${generateIframe(child, slots.get(child.slot))}
|
|
97
|
+
</section>`;
|
|
98
|
+
});
|
|
99
|
+
return `<div class="layout-${layout}" id="container" data-compose-board>${panels.join("\n")}</div>`;
|
|
80
100
|
}
|
|
81
|
-
function
|
|
82
|
-
|
|
83
|
-
const iframesHtml = descriptor.children
|
|
84
|
-
.map((child) => {
|
|
85
|
-
const componentId = child.componentId ?? child.source;
|
|
86
|
-
const area = areaMap[componentId] ?? componentId;
|
|
87
|
-
const slot = slots.get(child.slot);
|
|
88
|
-
return `<iframe
|
|
89
|
-
id="ui-${child.slot}"
|
|
90
|
-
src="${escapeAttr(slot?.iframeSrc ?? child.resourceUri)}"
|
|
91
|
-
data-slot="${child.slot}"
|
|
92
|
-
data-source="${escapeAttr(child.source)}"
|
|
93
|
-
data-component-id="${escapeAttr(componentId)}"
|
|
94
|
-
data-area="${escapeAttr(area)}"
|
|
95
|
-
${generateSandboxAttribute(slot)}
|
|
96
|
-
></iframe>`;
|
|
97
|
-
})
|
|
98
|
-
.join("\n ");
|
|
99
|
-
return `<div class="layout-areas" id="container">
|
|
100
|
-
${iframesHtml}
|
|
101
|
-
</div>`;
|
|
101
|
+
function grip(child) {
|
|
102
|
+
return `<button type="button" data-compose-grip aria-label="Move ${escapeAttr(child.componentId ?? child.source)}"></button>`;
|
|
102
103
|
}
|
|
103
104
|
function generateTabsLayout(descriptor, slots) {
|
|
104
105
|
if (descriptor.children.length === 0) {
|
|
@@ -110,21 +111,15 @@ function generateTabsLayout(descriptor, slots) {
|
|
|
110
111
|
</div>`;
|
|
111
112
|
}
|
|
112
113
|
const tabButtons = descriptor.children
|
|
113
|
-
.map((child, i) => `<
|
|
114
|
+
.map((child, i) => `<div data-compose-panel data-panel-label="${escapeAttr(child.componentId ?? child.source)}">
|
|
115
|
+
${descriptor.children.length > 1 ? grip(child) : ""}
|
|
116
|
+
<button type="button" class="tab${i === 0 ? " active" : ""}" data-slot="${child.slot}">${escapeHtml(child.source)}</button></div>`)
|
|
114
117
|
.join("\n ");
|
|
115
118
|
const iframesHtml = descriptor.children
|
|
116
|
-
.map((child, i) =>
|
|
117
|
-
id="ui-${child.slot}"
|
|
118
|
-
class="${i === 0 ? "active" : ""}"
|
|
119
|
-
src="${escapeAttr(slots.get(child.slot)?.iframeSrc ?? child.resourceUri)}"
|
|
120
|
-
data-slot="${child.slot}"
|
|
121
|
-
data-source="${escapeAttr(child.source)}"
|
|
122
|
-
data-component-id="${escapeAttr(child.componentId ?? child.source)}"
|
|
123
|
-
${generateSandboxAttribute(slots.get(child.slot))}
|
|
124
|
-
></iframe>`)
|
|
119
|
+
.map((child, i) => generateIframe(child, slots.get(child.slot), i === 0))
|
|
125
120
|
.join("\n ");
|
|
126
121
|
return `<div class="layout-tabs" id="container">
|
|
127
|
-
<div class="tab-bar">
|
|
122
|
+
<div class="tab-bar" data-compose-board>
|
|
128
123
|
${tabButtons}
|
|
129
124
|
</div>
|
|
130
125
|
<div class="tab-content">
|
|
@@ -132,9 +127,10 @@ ${generateSandboxAttribute(slots.get(child.slot))}
|
|
|
132
127
|
</div>
|
|
133
128
|
</div>`;
|
|
134
129
|
}
|
|
135
|
-
function generateIframe(child, slot) {
|
|
130
|
+
function generateIframe(child, slot, active = false) {
|
|
136
131
|
return `<iframe
|
|
137
132
|
id="ui-${child.slot}"
|
|
133
|
+
title="${escapeAttr(child.source)}"${active ? ' class="active"' : ""}
|
|
138
134
|
src="${escapeAttr(slot?.iframeSrc ?? child.resourceUri)}"
|
|
139
135
|
data-slot="${child.slot}"
|
|
140
136
|
data-source="${escapeAttr(child.source)}"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"card-height.d.ts","sourceRoot":"","sources":["../../../../../src/src/host/renderer/js/card-height.ts"],"names":[],"mappings":"AAEA,gFAAgF;AAChF,wBAAgB,wBAAwB,IAAI,MAAM,CAuDjD"}
|