@theoremjs/studio 0.3.4-next.468.ge2da06f → 0.3.4-next.472.gd209e07
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/README.md +1 -1
- package/package.json +4 -4
- package/page/assets/{Banner-Z4LFsB9Y.js → Banner-CtU6GWsR.js} +2 -2
- package/page/assets/{ConsoleFrame-BJo1I5fw.js → ConsoleFrame-rOazU_3-.js} +1 -1
- package/page/assets/{ContextMenu-BrT5KgtG.js → ContextMenu-DmUul6pF.js} +2 -2
- package/page/assets/{ToolResultCharts-CvdG2e3W.js → ToolResultCharts-BDDx1etB.js} +1 -1
- package/page/assets/{TraceInspector-CwsPN13M.js → TraceInspector-D6vHUDyE.js} +1 -1
- package/page/assets/{TraceOverview-Bdz85-Rn.js → TraceOverview-BhXATGPj.js} +1 -1
- package/page/assets/{browser-engine-Biheh6VY.js → browser-engine-C_bnPqwE.js} +1 -1
- package/page/assets/{browser-transport-Cnyo4CDA.js → browser-transport-DhK6zdPU.js} +3 -3
- package/page/assets/{export-agent-CVpG2q1m.js → export-agent-DYkJ9TvF.js} +1 -1
- package/page/assets/{guardrail-tester-CJuC6zTI.js → guardrail-tester-jPLQwdKE.js} +1 -1
- package/page/assets/{index-CYmjuHBy.js → index-CqWriUY5.js} +6 -6
- package/page/assets/{studio-code-pane-CkjZy0ML.js → studio-code-pane-C5Ni_xAW.js} +1 -1
- package/page/assets/{studio-console-D7Gp4J9U.js → studio-console-DAgC8PBu.js} +1 -1
- package/page/assets/{studio-decision-BRgQ4PBH.js → studio-decision-BagUC4JS.js} +1 -1
- package/page/assets/{studio-embedding-Dl4-HUCw.js → studio-embedding-D-cMc1Pu.js} +1 -1
- package/page/assets/{studio-host-console-C2kDYgZ0.js → studio-host-console-DT1bVkuk.js} +2 -2
- package/page/assets/{studio-labels-BOSQZulx.js → studio-labels-13hwz_RT.js} +1 -1
- package/page/assets/{studio-live-BweMJXiN.js → studio-live-KEG55ci9.js} +1 -1
- package/page/assets/{studio-map-ClUV7cPI.js → studio-map-CFMwUuYl.js} +1 -1
- package/page/assets/{studio-trace-replay-BVJ_xUpV.js → studio-trace-replay-CUR5tah-.js} +1 -1
- package/page/assets/{use-one-call-Djq1Oucn.js → use-one-call-COJjNMUc.js} +1 -1
- package/page/index.html +5 -5
- package/ui/tree-map.css +10 -0
- package/ui/tree-map.d.ts +3 -1
- package/ui/tree-map.js +41 -4
package/ui/tree-map.d.ts
CHANGED
|
@@ -15,5 +15,7 @@ export interface StudioTreeMapProps {
|
|
|
15
15
|
width: number;
|
|
16
16
|
height: number;
|
|
17
17
|
} | undefined;
|
|
18
|
+
/** A token dragged moves to where it is dropped, its lines with it; the field dragged moves the whole map. */
|
|
19
|
+
draggable?: boolean | undefined;
|
|
18
20
|
}
|
|
19
|
-
export declare function StudioTreeMap({ workspace, agents, grow, fit }: StudioTreeMapProps): import("react").JSX.Element;
|
|
21
|
+
export declare function StudioTreeMap({ workspace, agents, grow, fit, draggable, }: StudioTreeMapProps): import("react").JSX.Element;
|
package/ui/tree-map.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { IconAdjustments, IconArrowsMinimize, IconChecks, IconCloud, IconEngine, IconFlag, IconKey, IconRepeat, IconSettingsAutomation, IconShieldCheck, IconTimeline, IconTool, } from '@tabler/icons-react';
|
|
3
|
-
import { useMemo, useRef } from 'react';
|
|
3
|
+
import { useMemo, useRef, useState } from 'react';
|
|
4
4
|
import { mapCurve } from "../map-line.js";
|
|
5
5
|
import { createBlankDraft, libraryDraft } from "../mod.js";
|
|
6
6
|
import { drawnAt, HALF, INDENT, PAD, placeAt, rowId, treeMapLayout, } from "./lib/tree-map-layout.js";
|
|
7
7
|
import { toolTypeIcon } from "./lib/type-icons.js";
|
|
8
8
|
import { MapToken, useTokenWidths } from "./map-token.js";
|
|
9
9
|
import { nodeIcon } from "./node-icon.js";
|
|
10
|
+
import { drags, follow } from "./pan.js";
|
|
10
11
|
import './tree-map.css';
|
|
11
12
|
/** Where under a token its children's line runs: the middle of its icon. */
|
|
12
13
|
const TRUNK = 13;
|
|
@@ -68,8 +69,12 @@ function underPath(from, to) {
|
|
|
68
69
|
` Q ${trunk} ${to.y} ${trunk + TURN} ${to.y} H ${to.x - LINE_GAP}`);
|
|
69
70
|
}
|
|
70
71
|
const clamp = (value) => Math.min(Math.max(value, 0), 1);
|
|
71
|
-
|
|
72
|
+
const NONE = { x: 0, y: 0 };
|
|
73
|
+
export function StudioTreeMap({ workspace, agents, grow = 0, fit, draggable = false, }) {
|
|
72
74
|
const root = useRef(null);
|
|
75
|
+
const [moved, setMoved] = useState({});
|
|
76
|
+
const [field, setField] = useState(NONE);
|
|
77
|
+
const [dragging, setDragging] = useState(false);
|
|
73
78
|
// why: Every token is drawn from the start, the undrawn ones unseen, so each is measured before it shows.
|
|
74
79
|
const widths = useTokenWidths(root, workspace);
|
|
75
80
|
const layout = useMemo(() => treeMapLayout(workspace, agents, (id) => widths[id] ?? GUESS), [workspace, agents, widths]);
|
|
@@ -79,7 +84,11 @@ export function StudioTreeMap({ workspace, agents, grow = 0, fit }) {
|
|
|
79
84
|
libraryDraft(workspace, agent.key) ?? createBlankDraft(),
|
|
80
85
|
]));
|
|
81
86
|
const { rows, feeds } = layout;
|
|
82
|
-
const at = (id) =>
|
|
87
|
+
const at = (id) => {
|
|
88
|
+
const place = placeAt(layout, id, grow);
|
|
89
|
+
const by = moved[id] ?? NONE;
|
|
90
|
+
return { ...place, x: place.x + by.x, y: place.y + by.y };
|
|
91
|
+
};
|
|
83
92
|
const drawn = (id) => drawnAt(layout, id, grow);
|
|
84
93
|
const feedById = new Map(feeds.map((feed) => [feed.id, feed]));
|
|
85
94
|
const lineDrawn = (id) => {
|
|
@@ -116,7 +125,35 @@ export function StudioTreeMap({ workspace, agents, grow = 0, fit }) {
|
|
|
116
125
|
}, [layout, widths]);
|
|
117
126
|
const fits = fit ? Math.min(1, fit.width / grown.width, fit.height / grown.height) : 1;
|
|
118
127
|
const scale = 1 + (fits - 1) * clamp(grow);
|
|
119
|
-
|
|
128
|
+
// why: The pointer moves in the page's pixels; the map is scaled, so a move is divided back into its own.
|
|
129
|
+
const drag = (event) => {
|
|
130
|
+
if (!draggable || !drags(event))
|
|
131
|
+
return;
|
|
132
|
+
event.preventDefault();
|
|
133
|
+
const token = event.target.closest('[data-map-token]')?.dataset['mapToken'];
|
|
134
|
+
const from = token === undefined ? field : (moved[token] ?? NONE);
|
|
135
|
+
const put = (to) => {
|
|
136
|
+
if (token === undefined)
|
|
137
|
+
setField(to);
|
|
138
|
+
else
|
|
139
|
+
setMoved((last) => ({ ...last, [token]: to }));
|
|
140
|
+
};
|
|
141
|
+
setDragging(true);
|
|
142
|
+
follow(event, (x, y) => {
|
|
143
|
+
put(token === undefined
|
|
144
|
+
? { x: from.x + x, y: from.y + y }
|
|
145
|
+
: { x: from.x + x / scale, y: from.y + y / scale });
|
|
146
|
+
}, () => {
|
|
147
|
+
setDragging(false);
|
|
148
|
+
});
|
|
149
|
+
};
|
|
150
|
+
const translate = field.x || field.y ? { translate: `${field.x}px ${field.y}px` } : {};
|
|
151
|
+
return (_jsxs("div", { ref: root, className: "studio-tree-map", style: {
|
|
152
|
+
width: mapWidth,
|
|
153
|
+
height,
|
|
154
|
+
...translate,
|
|
155
|
+
...(scale < 1 ? { scale: String(scale) } : {}),
|
|
156
|
+
}, "data-draggable": draggable ? '' : undefined, "data-dragging": dragging ? '' : undefined, onPointerDown: drag, children: [_jsxs("svg", { className: "studio-tree-map-lines", width: mapWidth, height: height, "aria-hidden": "true", children: [rows.map((row) => row.parent && (_jsx("path", { className: "map-line", d: linePath(at(row.parent), at(rowId(row))) }, rowId(row)))), shown.flatMap((feed) => feed.into.map((id) => {
|
|
120
157
|
const from = at(feed.id);
|
|
121
158
|
const { d } = mapCurve({ x: from.x - LINE_GAP, y: from.y }, { x: right(id) + LINE_GAP, y: at(id).y });
|
|
122
159
|
return _jsx("path", { className: "map-line", d: d }, `${feed.id}>${id}`);
|