@simten/ui 0.1.1
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/LICENSE +176 -0
- package/README.md +41 -0
- package/dist/canvas/CircuitCanvas.d.ts +45 -0
- package/dist/canvas/CircuitCanvas.d.ts.map +1 -0
- package/dist/canvas/CircuitCanvas.js +293 -0
- package/dist/canvas/CircuitCanvas.js.map +1 -0
- package/dist/canvas/ClockControls.d.ts +31 -0
- package/dist/canvas/ClockControls.d.ts.map +1 -0
- package/dist/canvas/ClockControls.js +33 -0
- package/dist/canvas/ClockControls.js.map +1 -0
- package/dist/canvas/CompositeInspectorDialog.d.ts +24 -0
- package/dist/canvas/CompositeInspectorDialog.d.ts.map +1 -0
- package/dist/canvas/CompositeInspectorDialog.js +290 -0
- package/dist/canvas/CompositeInspectorDialog.js.map +1 -0
- package/dist/canvas/dagre-layout.d.ts +40 -0
- package/dist/canvas/dagre-layout.d.ts.map +1 -0
- package/dist/canvas/dagre-layout.js +86 -0
- package/dist/canvas/dagre-layout.js.map +1 -0
- package/dist/canvas/drill-down-view.d.ts +35 -0
- package/dist/canvas/drill-down-view.d.ts.map +1 -0
- package/dist/canvas/drill-down-view.js +134 -0
- package/dist/canvas/drill-down-view.js.map +1 -0
- package/dist/canvas/hooks/useDetectTheme.d.ts +6 -0
- package/dist/canvas/hooks/useDetectTheme.d.ts.map +1 -0
- package/dist/canvas/hooks/useDetectTheme.js +20 -0
- package/dist/canvas/hooks/useDetectTheme.js.map +1 -0
- package/dist/canvas/hooks/useIsMobile.d.ts +2 -0
- package/dist/canvas/hooks/useIsMobile.d.ts.map +1 -0
- package/dist/canvas/hooks/useIsMobile.js +20 -0
- package/dist/canvas/hooks/useIsMobile.js.map +1 -0
- package/dist/canvas/hooks/useSimulationSession.d.ts +23 -0
- package/dist/canvas/hooks/useSimulationSession.d.ts.map +1 -0
- package/dist/canvas/hooks/useSimulationSession.js +41 -0
- package/dist/canvas/hooks/useSimulationSession.js.map +1 -0
- package/dist/canvas/index.d.ts +22 -0
- package/dist/canvas/index.d.ts.map +1 -0
- package/dist/canvas/index.js +17 -0
- package/dist/canvas/index.js.map +1 -0
- package/dist/canvas/label-utils.d.ts +10 -0
- package/dist/canvas/label-utils.d.ts.map +1 -0
- package/dist/canvas/label-utils.js +32 -0
- package/dist/canvas/label-utils.js.map +1 -0
- package/dist/canvas/node-types.d.ts +10 -0
- package/dist/canvas/node-types.d.ts.map +1 -0
- package/dist/canvas/node-types.js +29 -0
- package/dist/canvas/node-types.js.map +1 -0
- package/dist/canvas/projection.d.ts +19 -0
- package/dist/canvas/projection.d.ts.map +1 -0
- package/dist/canvas/projection.js +317 -0
- package/dist/canvas/projection.js.map +1 -0
- package/dist/canvas/types.d.ts +56 -0
- package/dist/canvas/types.d.ts.map +1 -0
- package/dist/canvas/types.js +6 -0
- package/dist/canvas/types.js.map +1 -0
- package/dist/canvas/useLayout.d.ts +21 -0
- package/dist/canvas/useLayout.d.ts.map +1 -0
- package/dist/canvas/useLayout.js +26 -0
- package/dist/canvas/useLayout.js.map +1 -0
- package/dist/editor/components/CircuitSelector.d.ts +9 -0
- package/dist/editor/components/CircuitSelector.d.ts.map +1 -0
- package/dist/editor/components/CircuitSelector.js +20 -0
- package/dist/editor/components/CircuitSelector.js.map +1 -0
- package/dist/editor/components/CircuitTabBar.d.ts +8 -0
- package/dist/editor/components/CircuitTabBar.d.ts.map +1 -0
- package/dist/editor/components/CircuitTabBar.js +23 -0
- package/dist/editor/components/CircuitTabBar.js.map +1 -0
- package/dist/editor/components/ClockControls.d.ts +6 -0
- package/dist/editor/components/ClockControls.d.ts.map +1 -0
- package/dist/editor/components/ClockControls.js +7 -0
- package/dist/editor/components/ClockControls.js.map +1 -0
- package/dist/editor/components/ComponentTooltip.d.ts +25 -0
- package/dist/editor/components/ComponentTooltip.d.ts.map +1 -0
- package/dist/editor/components/ComponentTooltip.js +82 -0
- package/dist/editor/components/ComponentTooltip.js.map +1 -0
- package/dist/editor/components/ConflictResolutionModal.d.ts +19 -0
- package/dist/editor/components/ConflictResolutionModal.d.ts.map +1 -0
- package/dist/editor/components/ConflictResolutionModal.js +20 -0
- package/dist/editor/components/ConflictResolutionModal.js.map +1 -0
- package/dist/editor/components/HierarchyBreadcrumb.d.ts +9 -0
- package/dist/editor/components/HierarchyBreadcrumb.d.ts.map +1 -0
- package/dist/editor/components/HierarchyBreadcrumb.js +32 -0
- package/dist/editor/components/HierarchyBreadcrumb.js.map +1 -0
- package/dist/editor/components/LabelEditor.d.ts +17 -0
- package/dist/editor/components/LabelEditor.d.ts.map +1 -0
- package/dist/editor/components/LabelEditor.js +40 -0
- package/dist/editor/components/LabelEditor.js.map +1 -0
- package/dist/editor/components/SignalOutputPanel.d.ts +11 -0
- package/dist/editor/components/SignalOutputPanel.d.ts.map +1 -0
- package/dist/editor/components/SignalOutputPanel.js +34 -0
- package/dist/editor/components/SignalOutputPanel.js.map +1 -0
- package/dist/editor/components/index.d.ts +9 -0
- package/dist/editor/components/index.d.ts.map +1 -0
- package/dist/editor/components/index.js +9 -0
- package/dist/editor/components/index.js.map +1 -0
- package/dist/editor/hooks/index.d.ts +1 -0
- package/dist/editor/hooks/index.d.ts.map +1 -0
- package/dist/editor/hooks/index.js +2 -0
- package/dist/editor/hooks/index.js.map +1 -0
- package/dist/editor/index.d.ts +5 -0
- package/dist/editor/index.d.ts.map +1 -0
- package/dist/editor/index.js +5 -0
- package/dist/editor/index.js.map +1 -0
- package/dist/editor/lib/simulation/index.d.ts +7 -0
- package/dist/editor/lib/simulation/index.d.ts.map +1 -0
- package/dist/editor/lib/simulation/index.js +8 -0
- package/dist/editor/lib/simulation/index.js.map +1 -0
- package/dist/editor/lib/utils/circuit-flattener.d.ts +29 -0
- package/dist/editor/lib/utils/circuit-flattener.d.ts.map +1 -0
- package/dist/editor/lib/utils/circuit-flattener.js +230 -0
- package/dist/editor/lib/utils/circuit-flattener.js.map +1 -0
- package/dist/editor/lib/utils/component-utils.d.ts +28 -0
- package/dist/editor/lib/utils/component-utils.d.ts.map +1 -0
- package/dist/editor/lib/utils/component-utils.js +72 -0
- package/dist/editor/lib/utils/component-utils.js.map +1 -0
- package/dist/editor/lib/utils/index.d.ts +3 -0
- package/dist/editor/lib/utils/index.d.ts.map +1 -0
- package/dist/editor/lib/utils/index.js +3 -0
- package/dist/editor/lib/utils/index.js.map +1 -0
- package/dist/editor/lib/visualization/index.d.ts +2 -0
- package/dist/editor/lib/visualization/index.d.ts.map +1 -0
- package/dist/editor/lib/visualization/index.js +2 -0
- package/dist/editor/lib/visualization/index.js.map +1 -0
- package/dist/editor/lib/visualization/vcd-generator.d.ts +63 -0
- package/dist/editor/lib/visualization/vcd-generator.d.ts.map +1 -0
- package/dist/editor/lib/visualization/vcd-generator.js +269 -0
- package/dist/editor/lib/visualization/vcd-generator.js.map +1 -0
- package/dist/editor/stores/circuit-library-store.d.ts +25 -0
- package/dist/editor/stores/circuit-library-store.d.ts.map +1 -0
- package/dist/editor/stores/circuit-library-store.js +51 -0
- package/dist/editor/stores/circuit-library-store.js.map +1 -0
- package/dist/editor/stores/circuit-preview-store.d.ts +687 -0
- package/dist/editor/stores/circuit-preview-store.d.ts.map +1 -0
- package/dist/editor/stores/circuit-preview-store.js +226 -0
- package/dist/editor/stores/circuit-preview-store.js.map +1 -0
- package/dist/editor/stores/circuit-store.d.ts +354 -0
- package/dist/editor/stores/circuit-store.d.ts.map +1 -0
- package/dist/editor/stores/circuit-store.js +227 -0
- package/dist/editor/stores/circuit-store.js.map +1 -0
- package/dist/editor/stores/index.d.ts +11 -0
- package/dist/editor/stores/index.d.ts.map +1 -0
- package/dist/editor/stores/index.js +8 -0
- package/dist/editor/stores/index.js.map +1 -0
- package/dist/editor/stores/ui-store.d.ts +96 -0
- package/dist/editor/stores/ui-store.d.ts.map +1 -0
- package/dist/editor/stores/ui-store.js +101 -0
- package/dist/editor/stores/ui-store.js.map +1 -0
- package/dist/editor/types/circuit.d.ts +207 -0
- package/dist/editor/types/circuit.d.ts.map +1 -0
- package/dist/editor/types/circuit.js +62 -0
- package/dist/editor/types/circuit.js.map +1 -0
- package/dist/editor/types/index.d.ts +12 -0
- package/dist/editor/types/index.d.ts.map +1 -0
- package/dist/editor/types/index.js +11 -0
- package/dist/editor/types/index.js.map +1 -0
- package/dist/editor/types/testbench.d.ts +150 -0
- package/dist/editor/types/testbench.d.ts.map +1 -0
- package/dist/editor/types/testbench.js +85 -0
- package/dist/editor/types/testbench.js.map +1 -0
- package/dist/editor/types/testing.d.ts +88 -0
- package/dist/editor/types/testing.d.ts.map +1 -0
- package/dist/editor/types/testing.js +6 -0
- package/dist/editor/types/testing.js.map +1 -0
- package/dist/editor/types/ui-model.d.ts +68 -0
- package/dist/editor/types/ui-model.d.ts.map +1 -0
- package/dist/editor/types/ui-model.js +66 -0
- package/dist/editor/types/ui-model.js.map +1 -0
- package/dist/editor/types/ui.d.ts +33 -0
- package/dist/editor/types/ui.d.ts.map +1 -0
- package/dist/editor/types/ui.js +8 -0
- package/dist/editor/types/ui.js.map +1 -0
- package/dist/editor/types/visual.d.ts +45 -0
- package/dist/editor/types/visual.d.ts.map +1 -0
- package/dist/editor/types/visual.js +23 -0
- package/dist/editor/types/visual.js.map +1 -0
- package/dist/editor/utils/index.d.ts +5 -0
- package/dist/editor/utils/index.d.ts.map +1 -0
- package/dist/editor/utils/index.js +6 -0
- package/dist/editor/utils/index.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/utils.d.ts +3 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +6 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/nodes/BaseNode.d.ts +20 -0
- package/dist/nodes/BaseNode.d.ts.map +1 -0
- package/dist/nodes/BaseNode.js +26 -0
- package/dist/nodes/BaseNode.js.map +1 -0
- package/dist/nodes/CompositeBadge.d.ts +6 -0
- package/dist/nodes/CompositeBadge.d.ts.map +1 -0
- package/dist/nodes/CompositeBadge.js +10 -0
- package/dist/nodes/CompositeBadge.js.map +1 -0
- package/dist/nodes/ConsoleNode.d.ts +8 -0
- package/dist/nodes/ConsoleNode.d.ts.map +1 -0
- package/dist/nodes/ConsoleNode.js +16 -0
- package/dist/nodes/ConsoleNode.js.map +1 -0
- package/dist/nodes/EmbedConsoleNode.d.ts +8 -0
- package/dist/nodes/EmbedConsoleNode.d.ts.map +1 -0
- package/dist/nodes/EmbedConsoleNode.js +24 -0
- package/dist/nodes/EmbedConsoleNode.js.map +1 -0
- package/dist/nodes/EmbedScreenNode.d.ts +8 -0
- package/dist/nodes/EmbedScreenNode.d.ts.map +1 -0
- package/dist/nodes/EmbedScreenNode.js +24 -0
- package/dist/nodes/EmbedScreenNode.js.map +1 -0
- package/dist/nodes/EthFrameInputNode.d.ts +8 -0
- package/dist/nodes/EthFrameInputNode.d.ts.map +1 -0
- package/dist/nodes/EthFrameInputNode.js +14 -0
- package/dist/nodes/EthFrameInputNode.js.map +1 -0
- package/dist/nodes/InputNode.d.ts +8 -0
- package/dist/nodes/InputNode.d.ts.map +1 -0
- package/dist/nodes/InputNode.js +57 -0
- package/dist/nodes/InputNode.js.map +1 -0
- package/dist/nodes/LogicGateNode.d.ts +8 -0
- package/dist/nodes/LogicGateNode.d.ts.map +1 -0
- package/dist/nodes/LogicGateNode.js +51 -0
- package/dist/nodes/LogicGateNode.js.map +1 -0
- package/dist/nodes/NicFifoNode.d.ts +8 -0
- package/dist/nodes/NicFifoNode.d.ts.map +1 -0
- package/dist/nodes/NicFifoNode.js +10 -0
- package/dist/nodes/NicFifoNode.js.map +1 -0
- package/dist/nodes/NodeData.d.ts +34 -0
- package/dist/nodes/NodeData.d.ts.map +1 -0
- package/dist/nodes/NodeData.js +2 -0
- package/dist/nodes/NodeData.js.map +1 -0
- package/dist/nodes/NumericInputNode.d.ts +8 -0
- package/dist/nodes/NumericInputNode.d.ts.map +1 -0
- package/dist/nodes/NumericInputNode.js +47 -0
- package/dist/nodes/NumericInputNode.js.map +1 -0
- package/dist/nodes/OutputNode.d.ts +8 -0
- package/dist/nodes/OutputNode.d.ts.map +1 -0
- package/dist/nodes/OutputNode.js +32 -0
- package/dist/nodes/OutputNode.js.map +1 -0
- package/dist/nodes/RAMNode.d.ts +8 -0
- package/dist/nodes/RAMNode.d.ts.map +1 -0
- package/dist/nodes/RAMNode.js +23 -0
- package/dist/nodes/RAMNode.js.map +1 -0
- package/dist/nodes/ROMNode.d.ts +8 -0
- package/dist/nodes/ROMNode.d.ts.map +1 -0
- package/dist/nodes/ROMNode.js +23 -0
- package/dist/nodes/ROMNode.js.map +1 -0
- package/dist/nodes/RV32IInstrMemNode.d.ts +16 -0
- package/dist/nodes/RV32IInstrMemNode.d.ts.map +1 -0
- package/dist/nodes/RV32IInstrMemNode.js +183 -0
- package/dist/nodes/RV32IInstrMemNode.js.map +1 -0
- package/dist/nodes/RasterDisplayNode.d.ts +8 -0
- package/dist/nodes/RasterDisplayNode.d.ts.map +1 -0
- package/dist/nodes/RasterDisplayNode.js +14 -0
- package/dist/nodes/RasterDisplayNode.js.map +1 -0
- package/dist/nodes/RegisterNode.d.ts +8 -0
- package/dist/nodes/RegisterNode.d.ts.map +1 -0
- package/dist/nodes/RegisterNode.js +14 -0
- package/dist/nodes/RegisterNode.js.map +1 -0
- package/dist/nodes/ScreenNode.d.ts +8 -0
- package/dist/nodes/ScreenNode.d.ts.map +1 -0
- package/dist/nodes/ScreenNode.js +16 -0
- package/dist/nodes/ScreenNode.js.map +1 -0
- package/dist/nodes/UartTxNode.d.ts +8 -0
- package/dist/nodes/UartTxNode.d.ts.map +1 -0
- package/dist/nodes/UartTxNode.js +16 -0
- package/dist/nodes/UartTxNode.js.map +1 -0
- package/dist/nodes/index.d.ts +27 -0
- package/dist/nodes/index.d.ts.map +1 -0
- package/dist/nodes/index.js +30 -0
- package/dist/nodes/index.js.map +1 -0
- package/dist/primitives/button.d.ts +12 -0
- package/dist/primitives/button.d.ts.map +1 -0
- package/dist/primitives/button.js +32 -0
- package/dist/primitives/button.js.map +1 -0
- package/dist/primitives/index.d.ts +4 -0
- package/dist/primitives/index.d.ts.map +1 -0
- package/dist/primitives/index.js +4 -0
- package/dist/primitives/index.js.map +1 -0
- package/dist/primitives/sheet.d.ts +15 -0
- package/dist/primitives/sheet.d.ts.map +1 -0
- package/dist/primitives/sheet.js +40 -0
- package/dist/primitives/sheet.js.map +1 -0
- package/dist/primitives/tooltip.d.ts +8 -0
- package/dist/primitives/tooltip.d.ts.map +1 -0
- package/dist/primitives/tooltip.js +17 -0
- package/dist/primitives/tooltip.js.map +1 -0
- package/dist/sandbox/SandboxProvider.d.ts +13 -0
- package/dist/sandbox/SandboxProvider.d.ts.map +1 -0
- package/dist/sandbox/SandboxProvider.js +34 -0
- package/dist/sandbox/SandboxProvider.js.map +1 -0
- package/dist/sandbox/index.d.ts +4 -0
- package/dist/sandbox/index.d.ts.map +1 -0
- package/dist/sandbox/index.js +3 -0
- package/dist/sandbox/index.js.map +1 -0
- package/dist/sandbox/useSandbox.d.ts +197 -0
- package/dist/sandbox/useSandbox.d.ts.map +1 -0
- package/dist/sandbox/useSandbox.js +250 -0
- package/dist/sandbox/useSandbox.js.map +1 -0
- package/dist/share/encode-source.d.ts +13 -0
- package/dist/share/encode-source.d.ts.map +1 -0
- package/dist/share/encode-source.js +31 -0
- package/dist/share/encode-source.js.map +1 -0
- package/dist/share/index.d.ts +2 -0
- package/dist/share/index.d.ts.map +1 -0
- package/dist/share/index.js +2 -0
- package/dist/share/index.js.map +1 -0
- package/dist/waveform/WaveformViewer.d.ts +30 -0
- package/dist/waveform/WaveformViewer.d.ts.map +1 -0
- package/dist/waveform/WaveformViewer.js +356 -0
- package/dist/waveform/WaveformViewer.js.map +1 -0
- package/package.json +110 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Drill-Down View Utilities
|
|
3
|
+
*
|
|
4
|
+
* Creates viewable circuits for composite component internals.
|
|
5
|
+
* When a user drills into a composite (e.g., HalfAdder), we need to:
|
|
6
|
+
* 1. Show its internal nodes on the canvas
|
|
7
|
+
* 2. Add synthetic boundary nodes for the composite's ports
|
|
8
|
+
* 3. Scope port values so internal node IDs match simulation keys
|
|
9
|
+
*/
|
|
10
|
+
/** Prefix for synthetic boundary input nodes */
|
|
11
|
+
export const BOUNDARY_IN_PREFIX = '__boundary_in_';
|
|
12
|
+
/** Prefix for synthetic boundary output nodes */
|
|
13
|
+
export const BOUNDARY_OUT_PREFIX = '__boundary_out_';
|
|
14
|
+
/**
|
|
15
|
+
* Creates a viewable circuit from a composite's definition.
|
|
16
|
+
*
|
|
17
|
+
* The composite Circuit has internal nodes and connections where circuit-level
|
|
18
|
+
* ports use `nodeId: ""`. We replace those with synthetic Switch/Input (for inputs)
|
|
19
|
+
* and Led (for outputs) boundary nodes, so the canvas renders them naturally.
|
|
20
|
+
*/
|
|
21
|
+
export function createDrillDownViewCircuit(composite) {
|
|
22
|
+
const boundaryNodes = [];
|
|
23
|
+
const rewrittenConnections = [];
|
|
24
|
+
// Create boundary input nodes (one per composite input port)
|
|
25
|
+
for (const port of composite.inputs) {
|
|
26
|
+
const boundaryId = `${BOUNDARY_IN_PREFIX}${port.name}`;
|
|
27
|
+
const isBus = port.portType.kind === 'bus';
|
|
28
|
+
boundaryNodes.push({
|
|
29
|
+
id: boundaryId,
|
|
30
|
+
label: port.name,
|
|
31
|
+
componentRef: isBus ? 'Input' : 'Switch',
|
|
32
|
+
arguments: isBus ? { value: 0, width: port.portType.width } : { value: false },
|
|
33
|
+
inputs: [],
|
|
34
|
+
outputs: [{
|
|
35
|
+
id: `${boundaryId}_out`,
|
|
36
|
+
name: 'out',
|
|
37
|
+
portType: port.portType,
|
|
38
|
+
}],
|
|
39
|
+
clocks: [],
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
// Create boundary output nodes (one per composite output port)
|
|
43
|
+
// Bus outputs use HexDisplay (shows numeric value), bit outputs use Led (shows on/off)
|
|
44
|
+
for (const port of composite.outputs) {
|
|
45
|
+
const boundaryId = `${BOUNDARY_OUT_PREFIX}${port.name}`;
|
|
46
|
+
const isBus = port.portType.kind === 'bus';
|
|
47
|
+
boundaryNodes.push({
|
|
48
|
+
id: boundaryId,
|
|
49
|
+
label: port.name,
|
|
50
|
+
componentRef: isBus ? 'HexDisplay' : 'Led',
|
|
51
|
+
arguments: {},
|
|
52
|
+
inputs: [{
|
|
53
|
+
id: `${boundaryId}_in`,
|
|
54
|
+
name: 'in',
|
|
55
|
+
portType: port.portType,
|
|
56
|
+
}],
|
|
57
|
+
outputs: [],
|
|
58
|
+
clocks: [],
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
// Rewrite connections: replace circuit-level port references (nodeId: "")
|
|
62
|
+
// with the corresponding boundary node IDs
|
|
63
|
+
for (const conn of composite.connections) {
|
|
64
|
+
const newSource = { ...conn.source };
|
|
65
|
+
const newTarget = { ...conn.target };
|
|
66
|
+
if (conn.source.nodeId === '') {
|
|
67
|
+
// Circuit-level input port → boundary input node's output
|
|
68
|
+
newSource.nodeId = `${BOUNDARY_IN_PREFIX}${conn.source.portName}`;
|
|
69
|
+
newSource.portName = 'out';
|
|
70
|
+
}
|
|
71
|
+
if (conn.target.nodeId === '') {
|
|
72
|
+
// Circuit-level output port → boundary output node's input
|
|
73
|
+
newTarget.nodeId = `${BOUNDARY_OUT_PREFIX}${conn.target.portName}`;
|
|
74
|
+
newTarget.portName = 'in';
|
|
75
|
+
}
|
|
76
|
+
rewrittenConnections.push({
|
|
77
|
+
...conn,
|
|
78
|
+
source: newSource,
|
|
79
|
+
target: newTarget,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
...composite,
|
|
84
|
+
name: `__drilldown_${composite.name}`,
|
|
85
|
+
nodes: [...boundaryNodes, ...composite.nodes],
|
|
86
|
+
connections: rewrittenConnections,
|
|
87
|
+
// Mark as primitive so the view circuit itself isn't treated as drillable
|
|
88
|
+
implementation: { kind: 'primitive' },
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Scopes port values for a drilled-in view.
|
|
93
|
+
*
|
|
94
|
+
* The flat simulator produces port value keys with hierarchical prefixes like
|
|
95
|
+
* "ha1_abc.xor1_def.out". When we drill into "ha1_abc", we need to strip
|
|
96
|
+
* that prefix so keys become "xor1_def.out" — matching the composite's internal node IDs.
|
|
97
|
+
*
|
|
98
|
+
* Also maps boundary port values: the composite instance's own port values
|
|
99
|
+
* get mapped to synthetic boundary node IDs.
|
|
100
|
+
*/
|
|
101
|
+
export function scopePortValues(portValues, prefix, composite) {
|
|
102
|
+
if (!prefix)
|
|
103
|
+
return portValues;
|
|
104
|
+
const scoped = new Map();
|
|
105
|
+
for (const [key, value] of portValues.entries()) {
|
|
106
|
+
if (key.startsWith(prefix)) {
|
|
107
|
+
const scopedKey = key.slice(prefix.length);
|
|
108
|
+
scoped.set(scopedKey, value);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
// Map boundary port values from the parent scope
|
|
112
|
+
// The composite instance's ports in the parent are keyed as "nodeId.portName"
|
|
113
|
+
// We map them to "__boundary_in_portName.out" and "__boundary_out_portName.in"
|
|
114
|
+
if (composite) {
|
|
115
|
+
// Strip trailing dot from prefix to get the instance nodeId
|
|
116
|
+
const instanceId = prefix.endsWith('.') ? prefix.slice(0, -1) : prefix;
|
|
117
|
+
for (const port of composite.inputs) {
|
|
118
|
+
const parentKey = `${instanceId}.${port.name}`;
|
|
119
|
+
const value = portValues.get(parentKey);
|
|
120
|
+
if (value !== undefined) {
|
|
121
|
+
scoped.set(`${BOUNDARY_IN_PREFIX}${port.name}.out`, value);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
for (const port of composite.outputs) {
|
|
125
|
+
const parentKey = `${instanceId}.${port.name}`;
|
|
126
|
+
const value = portValues.get(parentKey);
|
|
127
|
+
if (value !== undefined) {
|
|
128
|
+
scoped.set(`${BOUNDARY_OUT_PREFIX}${port.name}.in`, value);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return scoped;
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=drill-down-view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drill-down-view.js","sourceRoot":"","sources":["../../src/canvas/drill-down-view.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,gDAAgD;AAChD,MAAM,CAAC,MAAM,kBAAkB,GAAG,gBAAgB,CAAC;AACnD,iDAAiD;AACjD,MAAM,CAAC,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;AAErD;;;;;;GAMG;AACH,MAAM,UAAU,0BAA0B,CAAC,SAAkB;IAC3D,MAAM,aAAa,GAAW,EAAE,CAAC;IACjC,MAAM,oBAAoB,GAAiB,EAAE,CAAC;IAE9C,6DAA6D;IAC7D,KAAK,MAAM,IAAI,IAAI,SAAS,CAAC,MAAM,EAAE,CAAC;QACpC,MAAM,UAAU,GAAG,GAAG,kBAAkB,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QACvD,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,KAAK,CAAC;QAE3C,aAAa,CAAC,IAAI,CAAC;YACjB,EAAE,EAAE,UAAU;YACd,KAAK,EAAE,IAAI,CAAC,IAAI;YAChB,YAAY,EAAE,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ;YACxC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAG,IAAI,CAAC,QAA2C,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE;YAClH,MAAM,EAAE,EAAE;YACV,OAAO,EAAE,CAAC;oBACR,EAAE,EAAE,GAAG,UAAU,MAAM;oBACvB,IAAI,EAAE,KAAK;oBACX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AAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QAEvE,KAAK,MAAM,IAAI,IAAI,SAAS,CAAC,MAAM,EAAE,CAAC;YACpC,MAAM,SAAS,GAAG,GAAG,UAAU,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YAC/C,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YACxC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACxB,MAAM,CAAC,GAAG,CAAC,GAAG,kBAAkB,GAAG,IAAI,CAAC,IAAI,MAAM,EAAE,KAAK,CAAC,CAAC;YAC7D,CAAC;QACH,CAAC;QAED,KAAK,MAAM,IAAI,IAAI,SAAS,CAAC,OAAO,EAAE,CAAC;YACrC,MAAM,SAAS,GAAG,GAAG,UAAU,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YAC/C,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YACxC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACxB,MAAM,CAAC,GAAG,CAAC,GAAG,mBAAmB,GAAG,IAAI,CAAC,IAAI,KAAK,EAAE,KAAK,CAAC,CAAC;YAC7D,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDetectTheme.d.ts","sourceRoot":"","sources":["../../../src/canvas/hooks/useDetectTheme.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,cAAc,IAAI,OAAO,GAAG,MAAM,CAiBjD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useState, useEffect } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Reactive theme detection from the `dark` class on `<html>`.
|
|
4
|
+
* Falls back to `"light"` during SSR / when document is unavailable.
|
|
5
|
+
*/
|
|
6
|
+
export function useDetectTheme() {
|
|
7
|
+
const [theme, setTheme] = useState(() => typeof document !== "undefined" && document.documentElement.classList.contains("dark")
|
|
8
|
+
? "dark"
|
|
9
|
+
: "light");
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const el = document.documentElement;
|
|
12
|
+
const observer = new MutationObserver(() => {
|
|
13
|
+
setTheme(el.classList.contains("dark") ? "dark" : "light");
|
|
14
|
+
});
|
|
15
|
+
observer.observe(el, { attributes: true, attributeFilter: ["class"] });
|
|
16
|
+
return () => observer.disconnect();
|
|
17
|
+
}, []);
|
|
18
|
+
return theme;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=useDetectTheme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDetectTheme.js","sourceRoot":"","sources":["../../../src/canvas/hooks/useDetectTheme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE5C;;;GAGG;AACH,MAAM,UAAU,cAAc;IAC5B,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAmB,GAAG,EAAE,CACxD,OAAO,QAAQ,KAAK,WAAW,IAAI,QAAQ,CAAC,eAAe,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC;QACpF,CAAC,CAAC,MAAM;QACR,CAAC,CAAC,OAAO,CACZ,CAAC;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,EAAE,GAAG,QAAQ,CAAC,eAAe,CAAC;QACpC,MAAM,QAAQ,GAAG,IAAI,gBAAgB,CAAC,GAAG,EAAE;YACzC,QAAQ,CAAC,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;QACH,QAAQ,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACvE,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;IACrC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIsMobile.d.ts","sourceRoot":"","sources":["../../../src/canvas/hooks/useIsMobile.ts"],"names":[],"mappings":"AAIA,wBAAgB,WAAW,IAAI,OAAO,CAgBrC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
const MOBILE_QUERY = "(pointer: coarse) and (max-width: 1024px)";
|
|
3
|
+
export function useIsMobile() {
|
|
4
|
+
const [isMobile, setIsMobile] = useState(() => {
|
|
5
|
+
if (typeof window === "undefined" || !window.matchMedia)
|
|
6
|
+
return false;
|
|
7
|
+
return window.matchMedia(MOBILE_QUERY).matches;
|
|
8
|
+
});
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
if (typeof window === "undefined" || !window.matchMedia)
|
|
11
|
+
return;
|
|
12
|
+
const mql = window.matchMedia(MOBILE_QUERY);
|
|
13
|
+
const onChange = (e) => setIsMobile(e.matches);
|
|
14
|
+
setIsMobile(mql.matches);
|
|
15
|
+
mql.addEventListener("change", onChange);
|
|
16
|
+
return () => mql.removeEventListener("change", onChange);
|
|
17
|
+
}, []);
|
|
18
|
+
return isMobile;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=useIsMobile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIsMobile.js","sourceRoot":"","sources":["../../../src/canvas/hooks/useIsMobile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,MAAM,YAAY,GAAG,2CAA2C,CAAC;AAEjE,MAAM,UAAU,WAAW;IACzB,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAU,GAAG,EAAE;QACrD,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,CAAC,MAAM,CAAC,UAAU;YAAE,OAAO,KAAK,CAAC;QACtE,OAAO,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC;IACjD,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,CAAC,MAAM,CAAC,UAAU;YAAE,OAAO;QAChE,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;QAC5C,MAAM,QAAQ,GAAG,CAAC,CAAsB,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QACpE,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACzB,GAAG,CAAC,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACzC,OAAO,GAAG,EAAE,CAAC,GAAG,CAAC,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAC3D,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React binding for SimulationSession.
|
|
3
|
+
*
|
|
4
|
+
* Thin wrapper using useSyncExternalStore — the session's getState()
|
|
5
|
+
* returns a stable reference, so React only re-renders when something
|
|
6
|
+
* actually changes.
|
|
7
|
+
*/
|
|
8
|
+
import type { SimulationSession, SimulationSessionState, SessionSnapshot } from "@simten/core/simulator";
|
|
9
|
+
import type { BitValue, BusValue } from "@simten/core/simulator";
|
|
10
|
+
export interface UseSimulationSessionResult<TMeta = unknown> extends SimulationSessionState<TMeta> {
|
|
11
|
+
tick: (metadata?: TMeta) => void;
|
|
12
|
+
reset: () => void;
|
|
13
|
+
setNode: (name: string, value: BitValue | BusValue) => void;
|
|
14
|
+
runCombinational: () => void;
|
|
15
|
+
stepBack: () => SessionSnapshot<TMeta> | null;
|
|
16
|
+
stepForward: () => SessionSnapshot<TMeta> | null;
|
|
17
|
+
seek: (index: number) => SessionSnapshot<TMeta> | null;
|
|
18
|
+
startAutoRun: SimulationSession<TMeta>["startAutoRun"];
|
|
19
|
+
stopAutoRun: () => void;
|
|
20
|
+
setSpeed: (ticksPerSecond: number) => void;
|
|
21
|
+
}
|
|
22
|
+
export declare function useSimulationSession<TMeta = unknown>(session: SimulationSession<TMeta> | null): UseSimulationSessionResult<TMeta>;
|
|
23
|
+
//# sourceMappingURL=useSimulationSession.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSimulationSession.d.ts","sourceRoot":"","sources":["../../../src/canvas/hooks/useSimulationSession.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EACV,iBAAiB,EACjB,sBAAsB,EACtB,eAAe,EAChB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAiBjE,MAAM,WAAW,0BAA0B,CAAC,KAAK,GAAG,OAAO,CACzD,SAAQ,sBAAsB,CAAC,KAAK,CAAC;IACrC,IAAI,EAAE,CAAC,QAAQ,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,GAAG,QAAQ,KAAK,IAAI,CAAC;IAC5D,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B,QAAQ,EAAE,MAAM,eAAe,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IAC9C,WAAW,EAAE,MAAM,eAAe,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IACjD,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,eAAe,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IACvD,YAAY,EAAE,iBAAiB,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC,CAAC;IACvD,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,QAAQ,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5C;AAED,wBAAgB,oBAAoB,CAAC,KAAK,GAAG,OAAO,EAClD,OAAO,EAAE,iBAAiB,CAAC,KAAK,CAAC,GAAG,IAAI,GACvC,0BAA0B,CAAC,KAAK,CAAC,CA8BnC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React binding for SimulationSession.
|
|
3
|
+
*
|
|
4
|
+
* Thin wrapper using useSyncExternalStore — the session's getState()
|
|
5
|
+
* returns a stable reference, so React only re-renders when something
|
|
6
|
+
* actually changes.
|
|
7
|
+
*/
|
|
8
|
+
"use client";
|
|
9
|
+
import { useSyncExternalStore, useCallback, useMemo } from "react";
|
|
10
|
+
const EMPTY_STATE = {
|
|
11
|
+
portValues: new Map(),
|
|
12
|
+
sequentialState: null,
|
|
13
|
+
cycle: 0,
|
|
14
|
+
isSequential: false,
|
|
15
|
+
history: [],
|
|
16
|
+
historyIndex: -1,
|
|
17
|
+
isViewingPast: false,
|
|
18
|
+
isRunning: false,
|
|
19
|
+
speed: 0,
|
|
20
|
+
};
|
|
21
|
+
const noopUnsubscribe = () => { };
|
|
22
|
+
const noopSubscribe = () => noopUnsubscribe;
|
|
23
|
+
export function useSimulationSession(session) {
|
|
24
|
+
const subscribe = useCallback((listener) => session ? session.subscribe(listener) : noopSubscribe(), [session]);
|
|
25
|
+
const getSnapshot = useCallback(() => (session ? session.getState() : EMPTY_STATE), [session]);
|
|
26
|
+
const state = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
27
|
+
const actions = useMemo(() => ({
|
|
28
|
+
tick: (metadata) => session?.tick(metadata),
|
|
29
|
+
reset: () => session?.reset(),
|
|
30
|
+
setNode: (name, value) => session?.setNode(name, value),
|
|
31
|
+
runCombinational: () => session?.runCombinational(),
|
|
32
|
+
stepBack: () => session?.stepBack() ?? null,
|
|
33
|
+
stepForward: () => session?.stepForward() ?? null,
|
|
34
|
+
seek: (index) => session?.seek(index) ?? null,
|
|
35
|
+
startAutoRun: (...args) => session?.startAutoRun(...args),
|
|
36
|
+
stopAutoRun: () => session?.stopAutoRun(),
|
|
37
|
+
setSpeed: (tps) => session?.setSpeed(tps),
|
|
38
|
+
}), [session]);
|
|
39
|
+
return { ...state, ...actions };
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=useSimulationSession.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSimulationSession.js","sourceRoot":"","sources":["../../../src/canvas/hooks/useSimulationSession.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,YAAY,CAAC;AAEb,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAQnE,MAAM,WAAW,GAA2B;IAC1C,UAAU,EAAE,IAAI,GAAG,EAAE;IACrB,eAAe,EAAE,IAAI;IACrB,KAAK,EAAE,CAAC;IACR,YAAY,EAAE,KAAK;IACnB,OAAO,EAAE,EAAE;IACX,YAAY,EAAE,CAAC,CAAC;IAChB,aAAa,EAAE,KAAK;IACpB,SAAS,EAAE,KAAK;IAChB,KAAK,EAAE,CAAC;CACT,CAAC;AAEF,MAAM,eAAe,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;AACjC,MAAM,aAAa,GAAG,GAAG,EAAE,CAAC,eAAe,CAAC;AAgB5C,MAAM,UAAU,oBAAoB,CAClC,OAAwC;IAExC,MAAM,SAAS,GAAG,WAAW,CAC3B,CAAC,QAAoB,EAAE,EAAE,CACvB,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC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C,CAAC;IAEf,OAAO,EAAE,GAAG,KAAK,EAAE,GAAG,OAAO,EAAuC,CAAC;AACvE,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @simten/ui/canvas
|
|
3
|
+
*
|
|
4
|
+
* Unified circuit canvas — props-driven, store-free.
|
|
5
|
+
* Used by both the embed package and the editor.
|
|
6
|
+
*/
|
|
7
|
+
export { CircuitCanvas } from "./CircuitCanvas";
|
|
8
|
+
export type { CircuitCanvasProps } from "./CircuitCanvas";
|
|
9
|
+
export { NODE_TYPES, EDGE_TYPES } from "./node-types";
|
|
10
|
+
export { projectCircuitToReactFlow } from "./projection";
|
|
11
|
+
export { useLayout } from "./useLayout";
|
|
12
|
+
export { computeDagreLayout } from "./dagre-layout";
|
|
13
|
+
export { createDrillDownViewCircuit, scopePortValues } from "./drill-down-view";
|
|
14
|
+
export { CompositeInspectorDialog } from "./CompositeInspectorDialog";
|
|
15
|
+
export type { CompositeInspectorDialogProps } from "./CompositeInspectorDialog";
|
|
16
|
+
export type { CircuitLayout, MetadataState, InspectorFrame, OriginRect } from "./types";
|
|
17
|
+
export { useSimulationSession } from "./hooks/useSimulationSession";
|
|
18
|
+
export type { UseSimulationSessionResult } from "./hooks/useSimulationSession";
|
|
19
|
+
export { ClockControls } from "./ClockControls";
|
|
20
|
+
export type { ClockControlsProps } from "./ClockControls";
|
|
21
|
+
export { useDetectTheme } from "./hooks/useDetectTheme";
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/canvas/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,0BAA0B,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,YAAY,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAChF,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACxF,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,YAAY,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @simten/ui/canvas
|
|
3
|
+
*
|
|
4
|
+
* Unified circuit canvas — props-driven, store-free.
|
|
5
|
+
* Used by both the embed package and the editor.
|
|
6
|
+
*/
|
|
7
|
+
export { CircuitCanvas } from "./CircuitCanvas";
|
|
8
|
+
export { NODE_TYPES, EDGE_TYPES } from "./node-types";
|
|
9
|
+
export { projectCircuitToReactFlow } from "./projection";
|
|
10
|
+
export { useLayout } from "./useLayout";
|
|
11
|
+
export { computeDagreLayout } from "./dagre-layout";
|
|
12
|
+
export { createDrillDownViewCircuit, scopePortValues } from "./drill-down-view";
|
|
13
|
+
export { CompositeInspectorDialog } from "./CompositeInspectorDialog";
|
|
14
|
+
export { useSimulationSession } from "./hooks/useSimulationSession";
|
|
15
|
+
export { ClockControls } from "./ClockControls";
|
|
16
|
+
export { useDetectTheme } from "./hooks/useDetectTheme";
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/canvas/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,0BAA0B,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAGtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEpE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Circuit } from "@simten/core";
|
|
2
|
+
/**
|
|
3
|
+
* Extract clean label from node ID (removes timestamps and prefixes).
|
|
4
|
+
*/
|
|
5
|
+
export declare function extractCleanLabel(nodeId: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Clean up node labels for display.
|
|
8
|
+
*/
|
|
9
|
+
export declare function cleanCircuitLabels(circuit: Circuit): Circuit;
|
|
10
|
+
//# sourceMappingURL=label-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"label-utils.d.ts","sourceRoot":"","sources":["../../src/canvas/label-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAexD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAQ5D"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extract clean label from node ID (removes timestamps and prefixes).
|
|
3
|
+
*/
|
|
4
|
+
export function extractCleanLabel(nodeId) {
|
|
5
|
+
if (nodeId.includes('.')) {
|
|
6
|
+
return extractCleanLabel(nodeId.split('.').pop() || nodeId);
|
|
7
|
+
}
|
|
8
|
+
const parts = nodeId.split('_');
|
|
9
|
+
for (let i = 0; i < parts.length; i++) {
|
|
10
|
+
if (/^\d{10,}$/.test(parts[i])) {
|
|
11
|
+
const nameParts = parts.slice(0, i);
|
|
12
|
+
if (nameParts.length > 1 && /^[A-Z]/.test(nameParts[0])) {
|
|
13
|
+
return nameParts.slice(1).join('_') || nameParts[0];
|
|
14
|
+
}
|
|
15
|
+
return nameParts.join('_') || nodeId;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return nodeId;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Clean up node labels for display.
|
|
22
|
+
*/
|
|
23
|
+
export function cleanCircuitLabels(circuit) {
|
|
24
|
+
return {
|
|
25
|
+
...circuit,
|
|
26
|
+
nodes: circuit.nodes.map(node => ({
|
|
27
|
+
...node,
|
|
28
|
+
label: extractCleanLabel(node.label || node.id),
|
|
29
|
+
})),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=label-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"label-utils.js","sourceRoot":"","sources":["../../src/canvas/label-utils.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAc;IAC9C,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACzB,OAAO,iBAAiB,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,MAAM,CAAC,CAAC;IAC9D,CAAC;IACD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAChC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,IAAI,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC/B,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YACpC,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBACxD,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC;YACtD,CAAC;YACD,OAAO,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC;QACvC,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAgB;IACjD,OAAO;QACL,GAAG,OAAO;QACV,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAChC,GAAG,IAAI;YACP,KAAK,EAAE,iBAAiB,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,EAAE,CAAC;SAChD,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type NodeTypes, type EdgeTypes } from "@xyflow/react";
|
|
2
|
+
/**
|
|
3
|
+
* Default node type map — all rich components, no fallbacks.
|
|
4
|
+
*/
|
|
5
|
+
export declare const NODE_TYPES: NodeTypes;
|
|
6
|
+
/**
|
|
7
|
+
* Edge type map.
|
|
8
|
+
*/
|
|
9
|
+
export declare const EDGE_TYPES: EdgeTypes;
|
|
10
|
+
//# sourceMappingURL=node-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-types.d.ts","sourceRoot":"","sources":["../../src/canvas/node-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,eAAe,CAAC;AAmB/E;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,SAgBjB,CAAC;AAET;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,SAExB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { SmoothStepEdge } from "@xyflow/react";
|
|
2
|
+
import { InputNode, NumericInputNode, OutputNode, LogicGateNode, ConsoleNode, ScreenNode, RasterDisplayNode, RegisterNode, RAMNode, ROMNode, UartTxNode, NicFifoNode, RV32IInstrMemNode, EthFrameInputNode, } from "../nodes";
|
|
3
|
+
/**
|
|
4
|
+
* Default node type map — all rich components, no fallbacks.
|
|
5
|
+
*/
|
|
6
|
+
export const NODE_TYPES = {
|
|
7
|
+
inputNode: InputNode,
|
|
8
|
+
numericInputNode: NumericInputNode,
|
|
9
|
+
outputNode: OutputNode,
|
|
10
|
+
logicGateNode: LogicGateNode,
|
|
11
|
+
registerNode: RegisterNode,
|
|
12
|
+
ramNode: RAMNode,
|
|
13
|
+
romNode: ROMNode,
|
|
14
|
+
rv32iInstrMemNode: RV32IInstrMemNode,
|
|
15
|
+
ethFrameInputNode: EthFrameInputNode,
|
|
16
|
+
consoleNode: ConsoleNode,
|
|
17
|
+
uartTxNode: UartTxNode,
|
|
18
|
+
nicFifoNode: NicFifoNode,
|
|
19
|
+
screenNode: ScreenNode,
|
|
20
|
+
rasterDisplayNode: RasterDisplayNode,
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Edge type map.
|
|
25
|
+
*/
|
|
26
|
+
export const EDGE_TYPES = {
|
|
27
|
+
orthogonal: SmoothStepEdge,
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=node-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-types.js","sourceRoot":"","sources":["../../src/canvas/node-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAkC,MAAM,eAAe,CAAC;AAE/E,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,YAAY,EACZ,OAAO,EACP,OAAO,EACP,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,UAAU,CAAC;AAElB;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAc;IACnC,SAAS,EAAE,SAAS;IACpB,gBAAgB,EAAE,gBAAgB;IAClC,UAAU,EAAE,UAAU;IACtB,aAAa,EAAE,aAAa;IAC5B,YAAY,EAAE,YAAY;IAC1B,OAAO,EAAE,OAAO;IAChB,OAAO,EAAE,OAAO;IAChB,iBAAiB,EAAE,iBAAiB;IACpC,iBAAiB,EAAE,iBAAiB;IACpC,WAAW,EAAE,WAAW;IACxB,UAAU,EAAE,UAAU;IACtB,WAAW,EAAE,WAAW;IACxB,UAAU,EAAE,UAAU;IACtB,iBAAiB,EAAE,iBAAiB;IACpC,8DAA8D;CACxD,CAAC;AAET;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAc;IACnC,UAAU,EAAE,cAAc;CAC3B,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure projection utility for embed.
|
|
3
|
+
* Converts Circuit + Metadata into ReactFlow nodes and edges.
|
|
4
|
+
* No stores, no caches, no globals — explicit params only.
|
|
5
|
+
*/
|
|
6
|
+
import type { Node as ReactFlowNode, Edge } from '@xyflow/react';
|
|
7
|
+
import type { Circuit } from '@simten/core';
|
|
8
|
+
import type { CircuitLibrary, FlatPortValueMap, FlatSequentialState } from '@simten/core/simulator';
|
|
9
|
+
import type { MetadataState } from './types';
|
|
10
|
+
import type { NodeData } from '../nodes';
|
|
11
|
+
export type { NodeData };
|
|
12
|
+
/**
|
|
13
|
+
* Main projection function — pure, no side effects.
|
|
14
|
+
*/
|
|
15
|
+
export declare function projectCircuitToReactFlow(circuit: Circuit | null, metadata: MetadataState, library: CircuitLibrary, portValues?: FlatPortValueMap, seqState?: FlatSequentialState): {
|
|
16
|
+
nodes: ReactFlowNode<NodeData>[];
|
|
17
|
+
edges: Edge[];
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=projection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projection.d.ts","sourceRoot":"","sources":["../../src/canvas/projection.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,IAAI,IAAI,aAAa,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,KAAK,EAAE,OAAO,EAAY,MAAM,cAAc,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AACpG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC,YAAY,EAAE,QAAQ,EAAE,CAAC;AA+TzB;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,OAAO,GAAG,IAAI,EACvB,QAAQ,EAAE,aAAa,EACvB,OAAO,EAAE,cAAc,EACvB,UAAU,CAAC,EAAE,gBAAgB,EAC7B,QAAQ,CAAC,EAAE,mBAAmB;;;EAQ/B"}
|