@workbench-kit/shell-react 0.0.2-prototype.0.2.26 → 0.0.2-prototype.0.2.27
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 +18 -2
- package/package.json +10 -10
- package/src/chat/command-policy.ts +3 -17
- package/src/commands/use-command-descriptors.ts +2 -30
- package/src/commands/use-context-key-revision.ts +12 -12
- package/src/commands/use-extension-registry-command-descriptors.ts +46 -0
- package/src/devtools/use-workbench-devtools-snapshot.ts +1 -1
- package/src/editor/pane-visibility.ts +0 -23
- package/src/explorer/reveal.ts +1 -12
- package/src/extensions/builtin/commands/src/command-inspector-editor-host.ts +1 -19
- package/src/extensions/builtin/commands/src/index.ts +2 -2
- package/src/field-remap/flow-adapter.ts +0 -16
- package/src/field-remap/flow-ops.ts +0 -24
- package/src/index.ts +1 -0
- package/src/jdw/widget-form-view.tsx +3 -20
- package/src/jdw/widget-preview-view.tsx +2 -20
- package/src/management/use-command-management.ts +22 -7
- package/src/management/use-keybinding-management.ts +1 -10
- package/src/shell/provider.tsx +19 -9
- package/src/shell/shell.tsx +11 -4
- package/src/workbench/command-host.tsx +42 -5
- package/src/workbench/command-palette.ts +12 -2
- package/src/workbench/workspace-view-state.ts +18 -1
- package/src/field-remap/graph.tsx +0 -559
- package/src/field-remap/table-mapping-adapter.ts +0 -59
- package/src/field-remap/tree.tsx +0 -404
package/src/field-remap/tree.tsx
DELETED
|
@@ -1,404 +0,0 @@
|
|
|
1
|
-
import { useMemo, useState, type JSX } from 'react';
|
|
2
|
-
import { Badge, Button } from '@workbench-kit/react/primitives';
|
|
3
|
-
import type { MappingEdge, SourceField, TargetSlot } from '@workbench-kit/field-remap';
|
|
4
|
-
|
|
5
|
-
type TreeSide = 'source' | 'target';
|
|
6
|
-
|
|
7
|
-
interface TreeNode {
|
|
8
|
-
readonly id: string;
|
|
9
|
-
readonly label: string;
|
|
10
|
-
readonly path?: string;
|
|
11
|
-
readonly dataType?: string;
|
|
12
|
-
readonly children?: readonly TreeNode[];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function sourceToNode(field: SourceField): TreeNode {
|
|
16
|
-
return {
|
|
17
|
-
id: field.id,
|
|
18
|
-
label: field.label,
|
|
19
|
-
path: field.path,
|
|
20
|
-
dataType: field.dataType,
|
|
21
|
-
children: field.children?.map(sourceToNode),
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function targetToNode(slot: TargetSlot): TreeNode {
|
|
26
|
-
return {
|
|
27
|
-
id: slot.id,
|
|
28
|
-
label: slot.label,
|
|
29
|
-
path: slot.path,
|
|
30
|
-
dataType: slot.dataType,
|
|
31
|
-
children: slot.children?.map(targetToNode),
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function findNode(nodes: readonly TreeNode[], id: string): TreeNode | undefined {
|
|
36
|
-
for (const node of nodes) {
|
|
37
|
-
if (node.id === id) {
|
|
38
|
-
return node;
|
|
39
|
-
}
|
|
40
|
-
if (node.children) {
|
|
41
|
-
const nested = findNode(node.children, id);
|
|
42
|
-
if (nested) {
|
|
43
|
-
return nested;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return undefined;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function typeBadge(dataType: string | undefined): string | null {
|
|
51
|
-
if (dataType === 'object' || dataType === 'array') {
|
|
52
|
-
return dataType;
|
|
53
|
-
}
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
interface FieldTreeProps {
|
|
58
|
-
readonly title: string;
|
|
59
|
-
readonly nodes: readonly TreeNode[];
|
|
60
|
-
readonly selectedId: string | null;
|
|
61
|
-
readonly mappedIds: ReadonlySet<string>;
|
|
62
|
-
readonly onSelect: (id: string) => void;
|
|
63
|
-
readonly side: TreeSide;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function FieldTree({
|
|
67
|
-
title,
|
|
68
|
-
nodes,
|
|
69
|
-
selectedId,
|
|
70
|
-
mappedIds,
|
|
71
|
-
onSelect,
|
|
72
|
-
side,
|
|
73
|
-
}: FieldTreeProps): JSX.Element {
|
|
74
|
-
return (
|
|
75
|
-
<div className="workbench-field-remap-tree" data-side={side}>
|
|
76
|
-
<h4 className="workbench-field-remap-tree__title">{title}</h4>
|
|
77
|
-
<ul className="workbench-field-remap-tree__list" role="tree">
|
|
78
|
-
{nodes.map((node) => (
|
|
79
|
-
<TreeRow
|
|
80
|
-
key={node.id}
|
|
81
|
-
node={node}
|
|
82
|
-
depth={0}
|
|
83
|
-
selectedId={selectedId}
|
|
84
|
-
mappedIds={mappedIds}
|
|
85
|
-
onSelect={onSelect}
|
|
86
|
-
/>
|
|
87
|
-
))}
|
|
88
|
-
</ul>
|
|
89
|
-
</div>
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function TreeRow({
|
|
94
|
-
node,
|
|
95
|
-
depth,
|
|
96
|
-
selectedId,
|
|
97
|
-
mappedIds,
|
|
98
|
-
onSelect,
|
|
99
|
-
}: {
|
|
100
|
-
readonly node: TreeNode;
|
|
101
|
-
readonly depth: number;
|
|
102
|
-
readonly selectedId: string | null;
|
|
103
|
-
readonly mappedIds: ReadonlySet<string>;
|
|
104
|
-
readonly onSelect: (id: string) => void;
|
|
105
|
-
}): JSX.Element {
|
|
106
|
-
const [open, setOpen] = useState(true);
|
|
107
|
-
const hasChildren = Boolean(node.children && node.children.length > 0);
|
|
108
|
-
const badge = typeBadge(node.dataType);
|
|
109
|
-
const selected = selectedId === node.id;
|
|
110
|
-
const mapped = mappedIds.has(node.id);
|
|
111
|
-
|
|
112
|
-
return (
|
|
113
|
-
<li role="treeitem" aria-expanded={hasChildren ? open : undefined}>
|
|
114
|
-
<div
|
|
115
|
-
className={[
|
|
116
|
-
'workbench-field-remap-tree__row',
|
|
117
|
-
selected ? 'is-selected' : '',
|
|
118
|
-
mapped ? 'is-mapped' : '',
|
|
119
|
-
]
|
|
120
|
-
.filter(Boolean)
|
|
121
|
-
.join(' ')}
|
|
122
|
-
style={{ paddingLeft: `${0.5 + depth * 0.85}rem` }}
|
|
123
|
-
>
|
|
124
|
-
{hasChildren ? (
|
|
125
|
-
<button
|
|
126
|
-
type="button"
|
|
127
|
-
className="workbench-field-remap-tree__twistie"
|
|
128
|
-
aria-label={open ? 'Collapse' : 'Expand'}
|
|
129
|
-
onClick={() => setOpen((value) => !value)}
|
|
130
|
-
>
|
|
131
|
-
{open ? '▾' : '▸'}
|
|
132
|
-
</button>
|
|
133
|
-
) : (
|
|
134
|
-
<span className="workbench-field-remap-tree__twistie-spacer" />
|
|
135
|
-
)}
|
|
136
|
-
<button
|
|
137
|
-
type="button"
|
|
138
|
-
className="workbench-field-remap-tree__node"
|
|
139
|
-
data-testid={`field-remap-node-${node.id}`}
|
|
140
|
-
onClick={() => onSelect(node.id)}
|
|
141
|
-
>
|
|
142
|
-
<span className="workbench-field-remap-tree__label">{node.label}</span>
|
|
143
|
-
{badge ? <Badge variant="muted">{badge}</Badge> : null}
|
|
144
|
-
</button>
|
|
145
|
-
</div>
|
|
146
|
-
{hasChildren && open ? (
|
|
147
|
-
<ul role="group">
|
|
148
|
-
{node.children!.map((child) => (
|
|
149
|
-
<TreeRow
|
|
150
|
-
key={child.id}
|
|
151
|
-
node={child}
|
|
152
|
-
depth={depth + 1}
|
|
153
|
-
selectedId={selectedId}
|
|
154
|
-
mappedIds={mappedIds}
|
|
155
|
-
onSelect={onSelect}
|
|
156
|
-
/>
|
|
157
|
-
))}
|
|
158
|
-
</ul>
|
|
159
|
-
) : null}
|
|
160
|
-
</li>
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
export interface FieldRemapTreeMapperProps {
|
|
165
|
-
readonly sources: readonly SourceField[];
|
|
166
|
-
readonly targets: readonly TargetSlot[];
|
|
167
|
-
readonly edges: readonly MappingEdge[];
|
|
168
|
-
readonly onEdgesChange: (edges: readonly MappingEdge[]) => void;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Nested-aware A→B mapper: dual trees + edge list + list-context (itemEdges) editor.
|
|
173
|
-
* Replaces flat-only table mappers for object/array shapes.
|
|
174
|
-
*/
|
|
175
|
-
export function FieldRemapTreeMapper({
|
|
176
|
-
sources,
|
|
177
|
-
targets,
|
|
178
|
-
edges,
|
|
179
|
-
onEdgesChange,
|
|
180
|
-
}: FieldRemapTreeMapperProps): JSX.Element {
|
|
181
|
-
const sourceNodes = useMemo(() => sources.map(sourceToNode), [sources]);
|
|
182
|
-
const targetNodes = useMemo(() => targets.map(targetToNode), [targets]);
|
|
183
|
-
|
|
184
|
-
const [pendingSourceId, setPendingSourceId] = useState<string | null>(null);
|
|
185
|
-
const [listContextEdgeId, setListContextEdgeId] = useState<string | null>(null);
|
|
186
|
-
const [pendingItemSourceId, setPendingItemSourceId] = useState<string | null>(null);
|
|
187
|
-
|
|
188
|
-
const mappedSourceIds = useMemo(() => new Set(edges.map((edge) => edge.sourceFieldId)), [edges]);
|
|
189
|
-
const mappedTargetIds = useMemo(() => new Set(edges.map((edge) => edge.targetSlotId)), [edges]);
|
|
190
|
-
|
|
191
|
-
const listContextEdge = edges.find((edge) => edge.id === listContextEdgeId) ?? null;
|
|
192
|
-
const listSourceNode = listContextEdge
|
|
193
|
-
? findNode(sourceNodes, listContextEdge.sourceFieldId)
|
|
194
|
-
: null;
|
|
195
|
-
const listTargetNode = listContextEdge
|
|
196
|
-
? findNode(targetNodes, listContextEdge.targetSlotId)
|
|
197
|
-
: null;
|
|
198
|
-
|
|
199
|
-
const connect = (sourceId: string, targetId: string) => {
|
|
200
|
-
const sourceNode = findNode(sourceNodes, sourceId);
|
|
201
|
-
const targetNode = findNode(targetNodes, targetId);
|
|
202
|
-
if (!sourceNode || !targetNode) {
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
const isListContext =
|
|
207
|
-
sourceNode.dataType === 'array' &&
|
|
208
|
-
targetNode.dataType === 'array' &&
|
|
209
|
-
Boolean(sourceNode.children?.length && targetNode.children?.length);
|
|
210
|
-
|
|
211
|
-
const nextEdge: MappingEdge = {
|
|
212
|
-
id: `e-${sourceId}-${targetId}-${Date.now()}`,
|
|
213
|
-
sourceFieldId: sourceId,
|
|
214
|
-
targetSlotId: targetId,
|
|
215
|
-
...(isListContext ? { itemEdges: [] as MappingEdge[] } : {}),
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
const withoutTarget = edges.filter((edge) => edge.targetSlotId !== targetId);
|
|
219
|
-
onEdgesChange([...withoutTarget, nextEdge]);
|
|
220
|
-
setPendingSourceId(null);
|
|
221
|
-
if (isListContext) {
|
|
222
|
-
setListContextEdgeId(nextEdge.id);
|
|
223
|
-
setPendingItemSourceId(null);
|
|
224
|
-
}
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
const handleSourceSelect = (id: string) => {
|
|
228
|
-
if (listContextEdgeId) {
|
|
229
|
-
setPendingItemSourceId(id);
|
|
230
|
-
return;
|
|
231
|
-
}
|
|
232
|
-
setPendingSourceId(id);
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
const handleTargetSelect = (id: string) => {
|
|
236
|
-
if (listContextEdge && pendingItemSourceId) {
|
|
237
|
-
const itemEdge: MappingEdge = {
|
|
238
|
-
id: `ie-${pendingItemSourceId}-${id}-${Date.now()}`,
|
|
239
|
-
sourceFieldId: pendingItemSourceId,
|
|
240
|
-
targetSlotId: id,
|
|
241
|
-
};
|
|
242
|
-
onEdgesChange(
|
|
243
|
-
edges.map((edge) =>
|
|
244
|
-
edge.id === listContextEdge.id
|
|
245
|
-
? {
|
|
246
|
-
...edge,
|
|
247
|
-
itemEdges: [
|
|
248
|
-
...(edge.itemEdges ?? []).filter((child) => child.targetSlotId !== id),
|
|
249
|
-
itemEdge,
|
|
250
|
-
],
|
|
251
|
-
}
|
|
252
|
-
: edge,
|
|
253
|
-
),
|
|
254
|
-
);
|
|
255
|
-
setPendingItemSourceId(null);
|
|
256
|
-
return;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
if (!pendingSourceId) {
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
connect(pendingSourceId, id);
|
|
263
|
-
};
|
|
264
|
-
|
|
265
|
-
const removeEdge = (edgeId: string) => {
|
|
266
|
-
onEdgesChange(edges.filter((edge) => edge.id !== edgeId));
|
|
267
|
-
if (listContextEdgeId === edgeId) {
|
|
268
|
-
setListContextEdgeId(null);
|
|
269
|
-
setPendingItemSourceId(null);
|
|
270
|
-
}
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
const removeItemEdge = (parentId: string, itemEdgeId: string) => {
|
|
274
|
-
onEdgesChange(
|
|
275
|
-
edges.map((edge) =>
|
|
276
|
-
edge.id === parentId
|
|
277
|
-
? {
|
|
278
|
-
...edge,
|
|
279
|
-
itemEdges: (edge.itemEdges ?? []).filter((child) => child.id !== itemEdgeId),
|
|
280
|
-
}
|
|
281
|
-
: edge,
|
|
282
|
-
),
|
|
283
|
-
);
|
|
284
|
-
};
|
|
285
|
-
|
|
286
|
-
return (
|
|
287
|
-
<div className="workbench-field-remap-mapper" data-testid="field-remap-mapper">
|
|
288
|
-
<p className="workbench-field-remap-mapper__hint" data-testid="field-remap-hint">
|
|
289
|
-
{listContextEdge
|
|
290
|
-
? pendingItemSourceId
|
|
291
|
-
? 'List context: select a target item field.'
|
|
292
|
-
: 'List context: select a source item field, then a target item field.'
|
|
293
|
-
: pendingSourceId
|
|
294
|
-
? 'Select a target field to complete the mapping.'
|
|
295
|
-
: 'Select a source field, then a target field. Array → array opens list context.'}
|
|
296
|
-
</p>
|
|
297
|
-
|
|
298
|
-
<div className="workbench-field-remap-mapper__columns">
|
|
299
|
-
<FieldTree
|
|
300
|
-
title={listContextEdge ? `A item · ${listSourceNode?.label ?? 'source'}` : 'A (source)'}
|
|
301
|
-
nodes={
|
|
302
|
-
listContextEdge && listSourceNode?.children ? listSourceNode.children : sourceNodes
|
|
303
|
-
}
|
|
304
|
-
selectedId={listContextEdge ? pendingItemSourceId : pendingSourceId}
|
|
305
|
-
mappedIds={
|
|
306
|
-
listContextEdge
|
|
307
|
-
? new Set((listContextEdge.itemEdges ?? []).map((edge) => edge.sourceFieldId))
|
|
308
|
-
: mappedSourceIds
|
|
309
|
-
}
|
|
310
|
-
onSelect={handleSourceSelect}
|
|
311
|
-
side="source"
|
|
312
|
-
/>
|
|
313
|
-
<FieldTree
|
|
314
|
-
title={listContextEdge ? `B item · ${listTargetNode?.label ?? 'target'}` : 'B (target)'}
|
|
315
|
-
nodes={
|
|
316
|
-
listContextEdge && listTargetNode?.children ? listTargetNode.children : targetNodes
|
|
317
|
-
}
|
|
318
|
-
selectedId={null}
|
|
319
|
-
mappedIds={
|
|
320
|
-
listContextEdge
|
|
321
|
-
? new Set((listContextEdge.itemEdges ?? []).map((edge) => edge.targetSlotId))
|
|
322
|
-
: mappedTargetIds
|
|
323
|
-
}
|
|
324
|
-
onSelect={handleTargetSelect}
|
|
325
|
-
side="target"
|
|
326
|
-
/>
|
|
327
|
-
</div>
|
|
328
|
-
|
|
329
|
-
{listContextEdge ? (
|
|
330
|
-
<div
|
|
331
|
-
className="workbench-field-remap-mapper__list-context"
|
|
332
|
-
data-testid="field-remap-list-context"
|
|
333
|
-
>
|
|
334
|
-
<div className="workbench-field-remap-mapper__list-context-bar">
|
|
335
|
-
<strong>List context</strong>
|
|
336
|
-
<span>
|
|
337
|
-
{listContextEdge.sourceFieldId} → {listContextEdge.targetSlotId}
|
|
338
|
-
</span>
|
|
339
|
-
<Button
|
|
340
|
-
compact
|
|
341
|
-
type="button"
|
|
342
|
-
onClick={() => {
|
|
343
|
-
setListContextEdgeId(null);
|
|
344
|
-
setPendingItemSourceId(null);
|
|
345
|
-
}}
|
|
346
|
-
>
|
|
347
|
-
Done
|
|
348
|
-
</Button>
|
|
349
|
-
</div>
|
|
350
|
-
<ul className="workbench-field-remap-mapper__edges">
|
|
351
|
-
{(listContextEdge.itemEdges ?? []).map((edge) => (
|
|
352
|
-
<li key={edge.id}>
|
|
353
|
-
<code>
|
|
354
|
-
{edge.sourceFieldId} → {edge.targetSlotId}
|
|
355
|
-
</code>
|
|
356
|
-
<Button
|
|
357
|
-
compact
|
|
358
|
-
type="button"
|
|
359
|
-
onClick={() => removeItemEdge(listContextEdge.id, edge.id)}
|
|
360
|
-
>
|
|
361
|
-
Remove
|
|
362
|
-
</Button>
|
|
363
|
-
</li>
|
|
364
|
-
))}
|
|
365
|
-
</ul>
|
|
366
|
-
</div>
|
|
367
|
-
) : null}
|
|
368
|
-
|
|
369
|
-
<div className="workbench-field-remap-mapper__edges-panel">
|
|
370
|
-
<h4>Bindings</h4>
|
|
371
|
-
<ul className="workbench-field-remap-mapper__edges" data-testid="field-remap-edges">
|
|
372
|
-
{edges.map((edge) => (
|
|
373
|
-
<li key={edge.id}>
|
|
374
|
-
<code>
|
|
375
|
-
{edge.sourceFieldId} → {edge.targetSlotId}
|
|
376
|
-
{edge.itemEdges ? ` · ${edge.itemEdges.length} item fields` : ''}
|
|
377
|
-
{edge.itemSourcePath ? ` · project ${edge.itemSourcePath}` : ''}
|
|
378
|
-
{edge.transformIds?.length ? ` · ${edge.transformIds.join(' → ')}` : ''}
|
|
379
|
-
</code>
|
|
380
|
-
<span className="workbench-field-remap-mapper__edge-actions">
|
|
381
|
-
{edge.itemEdges ? (
|
|
382
|
-
<Button
|
|
383
|
-
compact
|
|
384
|
-
type="button"
|
|
385
|
-
onClick={() => {
|
|
386
|
-
setListContextEdgeId(edge.id);
|
|
387
|
-
setPendingItemSourceId(null);
|
|
388
|
-
setPendingSourceId(null);
|
|
389
|
-
}}
|
|
390
|
-
>
|
|
391
|
-
Edit items
|
|
392
|
-
</Button>
|
|
393
|
-
) : null}
|
|
394
|
-
<Button compact type="button" onClick={() => removeEdge(edge.id)}>
|
|
395
|
-
Remove
|
|
396
|
-
</Button>
|
|
397
|
-
</span>
|
|
398
|
-
</li>
|
|
399
|
-
))}
|
|
400
|
-
</ul>
|
|
401
|
-
</div>
|
|
402
|
-
</div>
|
|
403
|
-
);
|
|
404
|
-
}
|