pmx-canvas 0.1.10 → 0.1.11
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 +83 -0
- package/dist/canvas/index.js +30 -30
- package/dist/json-render/index.js +115 -115
- package/dist/types/json-render/catalog.d.ts +10 -0
- package/dist/types/json-render/charts/components.d.ts +18 -0
- package/dist/types/json-render/charts/definitions.d.ts +4 -0
- package/dist/types/json-render/charts/extra-components.d.ts +3 -0
- package/dist/types/json-render/charts/extra-definitions.d.ts +6 -0
- package/dist/types/json-render/server.d.ts +4 -0
- package/dist/types/server/canvas-operations.d.ts +2 -0
- package/dist/types/server/index.d.ts +2 -0
- package/package.json +1 -1
- package/skills/pmx-canvas/SKILL.md +9 -0
- package/src/cli/agent.ts +78 -2
- package/src/cli/index.ts +6 -3
- package/src/client/canvas/CanvasNode.tsx +3 -1
- package/src/client/canvas/auto-fit.ts +1 -1
- package/src/json-render/charts/components.tsx +18 -10
- package/src/json-render/charts/definitions.ts +4 -0
- package/src/json-render/charts/extra-components.tsx +23 -16
- package/src/json-render/charts/extra-definitions.ts +6 -0
- package/src/json-render/server.ts +11 -0
- package/src/mcp/server.ts +10 -0
- package/src/server/canvas-operations.ts +21 -1
- package/src/server/canvas-schema.ts +5 -0
- package/src/server/diagram-presets.ts +44 -12
- package/src/server/index.ts +7 -1
- package/src/server/server.ts +33 -2
package/src/server/server.ts
CHANGED
|
@@ -828,6 +828,24 @@ function findOnlyPendingCanvasExtAppNodeId(serverName: string, toolName: string)
|
|
|
828
828
|
return matchId;
|
|
829
829
|
}
|
|
830
830
|
|
|
831
|
+
function extAppEventGeometryPatch(
|
|
832
|
+
node: CanvasNodeState,
|
|
833
|
+
payload: PrimaryWorkbenchEventPayload,
|
|
834
|
+
): Partial<Pick<CanvasNodeState, 'position' | 'size'>> {
|
|
835
|
+
const x = typeof payload.x === 'number' ? payload.x : undefined;
|
|
836
|
+
const y = typeof payload.y === 'number' ? payload.y : undefined;
|
|
837
|
+
const width = typeof payload.width === 'number' ? payload.width : undefined;
|
|
838
|
+
const height = typeof payload.height === 'number' ? payload.height : undefined;
|
|
839
|
+
return {
|
|
840
|
+
...(x !== undefined || y !== undefined
|
|
841
|
+
? { position: { x: x ?? node.position.x, y: y ?? node.position.y } }
|
|
842
|
+
: {}),
|
|
843
|
+
...(width !== undefined || height !== undefined
|
|
844
|
+
? { size: { width: width ?? node.size.width, height: height ?? node.size.height } }
|
|
845
|
+
: {}),
|
|
846
|
+
};
|
|
847
|
+
}
|
|
848
|
+
|
|
831
849
|
function toSseFrame(event: string, payload: PrimaryWorkbenchEventPayload): Uint8Array {
|
|
832
850
|
const id = nextWorkbenchEventId++;
|
|
833
851
|
const lines = [`id: ${id}`, `event: ${event}`, `data: ${JSON.stringify(payload)}`, ''];
|
|
@@ -1250,6 +1268,7 @@ async function createCanvasWebpageNode(body: Record<string, unknown>): Promise<R
|
|
|
1250
1268
|
...(typeof body.title === 'string' ? { title: body.title } : {}),
|
|
1251
1269
|
content: normalizedUrl,
|
|
1252
1270
|
...(extraData ? { data: extraData } : {}),
|
|
1271
|
+
...(body.strictSize === true ? { strictSize: true } : {}),
|
|
1253
1272
|
...geometry,
|
|
1254
1273
|
...(geometry.width === undefined ? { width: WEBPAGE_NODE_DEFAULT_SIZE.width } : {}),
|
|
1255
1274
|
...(geometry.height === undefined ? { height: WEBPAGE_NODE_DEFAULT_SIZE.height } : {}),
|
|
@@ -1312,6 +1331,7 @@ async function handleCanvasAddNode(req: Request): Promise<Response> {
|
|
|
1312
1331
|
...(typeof body.title === 'string' ? { title: body.title } : {}),
|
|
1313
1332
|
...(typeof content === 'string' ? { content } : {}),
|
|
1314
1333
|
...(extraData ? { data: extraData } : {}),
|
|
1334
|
+
...(body.strictSize === true ? { strictSize: true } : {}),
|
|
1315
1335
|
...geometry,
|
|
1316
1336
|
defaultWidth: 360,
|
|
1317
1337
|
defaultHeight: 200,
|
|
@@ -1475,7 +1495,7 @@ async function handleCanvasUpdateNode(nodeId: string, req: Request): Promise<Res
|
|
|
1475
1495
|
} catch (error) {
|
|
1476
1496
|
return responseJson({ ok: false, error: error instanceof Error ? error.message : String(error) }, 400);
|
|
1477
1497
|
}
|
|
1478
|
-
} else if (body.title !== undefined || body.content !== undefined || body.data || typeof body.arrangeLocked === 'boolean') {
|
|
1498
|
+
} else if (body.title !== undefined || body.content !== undefined || body.data || typeof body.arrangeLocked === 'boolean' || typeof body.strictSize === 'boolean') {
|
|
1479
1499
|
const data = { ...existing.data };
|
|
1480
1500
|
if (body.title !== undefined) {
|
|
1481
1501
|
data.title = String(body.title);
|
|
@@ -1485,6 +1505,7 @@ async function handleCanvasUpdateNode(nodeId: string, req: Request): Promise<Res
|
|
|
1485
1505
|
}
|
|
1486
1506
|
if (body.content !== undefined) data.content = String(body.content);
|
|
1487
1507
|
if (typeof body.arrangeLocked === 'boolean') data.arrangeLocked = body.arrangeLocked;
|
|
1508
|
+
if (typeof body.strictSize === 'boolean') data.strictSize = body.strictSize;
|
|
1488
1509
|
// Merge extra data fields (for status, context, ledger, trace nodes)
|
|
1489
1510
|
if (body.data && typeof body.data === 'object' && !Array.isArray(body.data)) {
|
|
1490
1511
|
Object.assign(data, body.data as Record<string, unknown>);
|
|
@@ -1720,6 +1741,7 @@ async function handleCanvasAddJsonRender(req: Request): Promise<Response> {
|
|
|
1720
1741
|
const result = createCanvasJsonRenderNode({
|
|
1721
1742
|
...(title ? { title } : {}),
|
|
1722
1743
|
spec: rawSpec,
|
|
1744
|
+
...(body.strictSize === true ? { strictSize: true } : {}),
|
|
1723
1745
|
...geometry,
|
|
1724
1746
|
});
|
|
1725
1747
|
emitPrimaryWorkbenchEvent('canvas-layout-update', { layout: canvasState.getLayout() });
|
|
@@ -1756,6 +1778,8 @@ async function handleCanvasAddGraph(req: Request): Promise<Response> {
|
|
|
1756
1778
|
const y = pickFiniteNumber(body, 'y') ?? (position ? pickFiniteNumber(position, 'y') : undefined);
|
|
1757
1779
|
const width = pickPositiveNumber(body, 'width') ?? (size ? pickPositiveNumber(size, 'width') : undefined);
|
|
1758
1780
|
const nodeHeight = pickPositiveNumber(body, 'nodeHeight') ?? (size ? pickPositiveNumber(size, 'height') : undefined);
|
|
1781
|
+
const showLegend = typeof body.showLegend === 'boolean' ? body.showLegend : undefined;
|
|
1782
|
+
const showLabels = typeof body.showLabels === 'boolean' ? body.showLabels : undefined;
|
|
1759
1783
|
const result = createCanvasGraphNode({
|
|
1760
1784
|
title,
|
|
1761
1785
|
graphType,
|
|
@@ -1775,6 +1799,9 @@ async function handleCanvasAddGraph(req: Request): Promise<Response> {
|
|
|
1775
1799
|
...(typeof body.barColor === 'string' ? { barColor: body.barColor } : {}),
|
|
1776
1800
|
...(typeof body.lineColor === 'string' ? { lineColor: body.lineColor } : {}),
|
|
1777
1801
|
...(typeof body.height === 'number' ? { height: body.height } : {}),
|
|
1802
|
+
...(showLegend !== undefined ? { showLegend } : {}),
|
|
1803
|
+
...(showLabels !== undefined ? { showLabels } : {}),
|
|
1804
|
+
...(body.strictSize === true ? { strictSize: true } : {}),
|
|
1778
1805
|
...(x !== undefined ? { x } : {}),
|
|
1779
1806
|
...(y !== undefined ? { y } : {}),
|
|
1780
1807
|
...(width !== undefined ? { width } : {}),
|
|
@@ -3336,7 +3363,10 @@ function syncEventToCanvasState(event: string, payload: PrimaryWorkbenchEventPay
|
|
|
3336
3363
|
if (previousSessionId && nextSessionId && previousSessionId !== nextSessionId) {
|
|
3337
3364
|
closeMcpAppSession(previousSessionId);
|
|
3338
3365
|
}
|
|
3339
|
-
canvasState.updateNode(id, {
|
|
3366
|
+
canvasState.updateNode(id, {
|
|
3367
|
+
data: { ...existing.data, ...dataPatch },
|
|
3368
|
+
...extAppEventGeometryPatch(existing, payload),
|
|
3369
|
+
});
|
|
3340
3370
|
} else {
|
|
3341
3371
|
const reusableNodeId =
|
|
3342
3372
|
typeof payload.serverName === 'string' &&
|
|
@@ -3355,6 +3385,7 @@ function syncEventToCanvasState(event: string, payload: PrimaryWorkbenchEventPay
|
|
|
3355
3385
|
}
|
|
3356
3386
|
canvasState.updateNode(reusableNodeId, {
|
|
3357
3387
|
data: { ...reusableNode.data, ...dataPatch },
|
|
3388
|
+
...extAppEventGeometryPatch(reusableNode, payload),
|
|
3358
3389
|
});
|
|
3359
3390
|
return;
|
|
3360
3391
|
}
|