- Redesigned toolbar with I/O, Gates, and Components sections - Component editor: sub-canvas mode to design reusable chips - Save/Cancel with main circuit state preservation - Components persist in localStorage - Custom components render as purple chips with dynamic I/O ports - Component evaluation simulates internal circuit as black box - Toolbar height increased to 56px for section labels - All height references updated consistently Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
46 lines
1.0 KiB
JavaScript
46 lines
1.0 KiB
JavaScript
// Shared application state — single source of truth
|
|
export const state = {
|
|
// Circuit
|
|
gates: [],
|
|
connections: [],
|
|
nextId: 1,
|
|
|
|
// Interaction
|
|
placingGate: null,
|
|
dragging: null,
|
|
dragOffset: { x: 0, y: 0 },
|
|
connecting: null,
|
|
hoveredGate: null,
|
|
hoveredPort: null,
|
|
mouseX: 0,
|
|
mouseY: 0,
|
|
|
|
// Camera (pan/zoom)
|
|
camX: 0,
|
|
camY: 0,
|
|
zoom: 1,
|
|
|
|
// Waveform
|
|
waveformVisible: false,
|
|
waveformHeight: 220,
|
|
recording: true,
|
|
waveData: {}, // { gateId: [{ t, value }] }
|
|
timeStep: 0,
|
|
waveZoom: 20, // pixels per time step
|
|
waveScroll: 0,
|
|
resizingWave: false,
|
|
|
|
// Simulation
|
|
simRunning: false,
|
|
simInterval: null,
|
|
simSpeed: 500, // ms per tick
|
|
|
|
// Puzzle/Components
|
|
customComponents: {}, // { id -> component definition }
|
|
|
|
// Component Editor
|
|
componentEditorActive: false,
|
|
savedMainCircuit: null, // { gates, connections, nextId } saved before entering editor
|
|
componentEditorName: ''
|
|
};
|