2026-10-17 10:49:38 +00:00
< script setup lang = "ts" >
A ports on top of the box, split into lines to wire by hand
On a component's box every connector port now sits at the very top of its
side, above the single pins, in auto and hand-drawn boxes alike. A port
can be split on one placed component (its settings or right click: Split
… into lines): right below the socket the box then gets a pin per line,
named after the line, so lines can be wired by hand without an adapter.
Lines going into the component are inputs, lines coming out outputs, each
facing out of its side; a bar in the type's colour ties them to the
socket. A cable still plugs into the socket at the same time. Dropping a
single wire on a socket (or clicking one while connecting) splits the
port and takes the first free line that runs that way. Join … lines
takes the line pins and their wires away again, as one undo step.
A line wired by hand joins the same net the cable's line reaches inside;
a wire and a cable on one line both drive it, and the check says so.
Line pins are left out of the open-input warning, docked panels and
bubbles; docked panels no longer get a row for a port's socket either.
Saved as an optional list on the placed component (splitPorts); without
it a box only has its ports moved to the top.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 17:08:27 +00:00
import { cableKeys } from '~/lib/logic/compile'
A Loxone-style working aids: named signals, inverted inputs, a project check, values on cables, search, printable sheets; wire ends move by dragging
- Send signal / Use signal: name a signal (CLK, RESET) once and use it anywhere in the circuit without a wire; selecting one lights up all of them, a use with no sender shows dashed
- Inverted inputs: Alt + click an input (or the menu/settings) puts a bubble on it; it reads the signal inverted through one NAND, counted in every transistor total
- Check (Circuit tab): open inputs, parts that drive nothing, duplicate pin names, unsent or doubly sent signals, loops that never settle; click one to show it. Open inputs get an orange marker on the canvas. Components no other circuit uses are listed with a delete
- Cables show the number they carry (= 13 · 0x0D); hovering a wire tells where it runs and its value
- Ctrl+F finds parts, signals, panel rows, notes and components in every circuit, with where each component is used
- Ctrl+P prints the circuit as a sheet with a title block on white paper (or save as PDF); also as an SVG file
- + and − under a selected gate change its number of inputs; swaps keep bubbles in place
- Drag a wire by its end to move that end to another pin; drop a dragged wire on another wire to tap its signal or feed what it fed
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 11:26:59 +00:00
import { CHECKED _INPUTS } from '~/lib/logic/check'
2026-10-22 16:59:56 +00:00
import { cableBits , GRID as G , pinKindOf , pinPos , routeWire , type Pt , type Shape } from '~/lib/logic/geometry'
A input panels, automatic names, one-by-one wiring, tidy routing, truth table export
- Input panel part: rows of switches, buttons and clocks. "Attach input
panel" docks one to a component with a row per free input; it moves
with the component and follows its pins.
- Copies and new pins continue name series (D0 -> D1, A -> B); unnamed
switches, lamps and pins take the name of the component pin they are
wired to.
- Connecting: target pins are ringed, dropping on a part uses its next
free pin, click-then-click works, and "Connect one by one" (W) wires a
selection's pins in turn.
- Tidy wiring option and "Tidy all wires": sorted, evenly spaced columns
per gap, one trunk per signal, fewer crossings.
- Truth table full screen, CSV download, copy as Markdown, current row
highlighted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 17:17:25 +00:00
import type { CircuitNode , PanelRow , PinRef , Wire } from '~/lib/logic/types'
A Loxone-style working aids: named signals, inverted inputs, a project check, values on cables, search, printable sheets; wire ends move by dragging
- Send signal / Use signal: name a signal (CLK, RESET) once and use it anywhere in the circuit without a wire; selecting one lights up all of them, a use with no sender shows dashed
- Inverted inputs: Alt + click an input (or the menu/settings) puts a bubble on it; it reads the signal inverted through one NAND, counted in every transistor total
- Check (Circuit tab): open inputs, parts that drive nothing, duplicate pin names, unsent or doubly sent signals, loops that never settle; click one to show it. Open inputs get an orange marker on the canvas. Components no other circuit uses are listed with a delete
- Cables show the number they carry (= 13 · 0x0D); hovering a wire tells where it runs and its value
- Ctrl+F finds parts, signals, panel rows, notes and components in every circuit, with where each component is used
- Ctrl+P prints the circuit as a sheet with a title block on white paper (or save as PDF); also as an SVG file
- + and − under a selected gate change its number of inputs; swaps keep bubbles in place
- Drag a wire by its end to move that end to another pin; drop a dragged wire on another wire to tap its signal or feed what it fed
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 11:26:59 +00:00
import { branchCorners , branchTo , endGrip , moveCorner , moveSegment , nearEnd , routeTouchesBox , segmentAt , segmentDrag , splitDrag } from '~/lib/logic/wires'
BF jumps always on top of what they cross; R circuit commands in a menu on its name, the side panel only says what it is
A jump is drawn once more over every line, so a cable that arches over
another is never hidden under it, whatever order they are drawn in. Cable
labels sit on the longest stretch no other line crosses.
The circuit's name in the top bar opens what can be done with it: tidy
its wires or every circuit's, design its box, duplicate, delete, print,
export SVG, publish as a puzzle. The This panel keeps what the circuit is:
its health, its numbers (the transistors tile opens their breakdown), its
truth table and how it looks as a part. Unused components are a tab of
the Components list in the parts bar, with a delete button on each.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-23 13:12:43 +00:00
import { circuitRoutes , crossingPoints , planHops } from '~/lib/logic/routing'
2026-10-21 10:16:26 +00:00
import { seriesLinks , type Link } from '~/lib/logic/bulk'
import { dropLinks , dropPins , fitStart , type DropPin } from '~/lib/logic/fit'
A right-click menu for parts, wires and the canvas, "Wire them all to" as cards, plugged latches in plain greys
- Right click (or the menu key) shows what can be done with what is under the pointer: one part (open, rename, change to, inputs, colour, speed, panels, unpack, plug and unplug, cable colour), several parts (wire them all to with live preview, connect one by one, switches, change all, arrange, keep only, make a component), wires (bundle, colour, whole signal, straighten, remove cable) or empty canvas (paste here, add a part here, select all, fit, tidy, undo); right drag still moves the view
- "Wire them all to": a card per part, each fit a strip of its pins, and which wire goes where for the fit pointed at
- Plugged cable ends no longer look selected: grey connector, steel clips
- Icons named in menus are bundled for the browser too
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 10:33:30 +00:00
import type { CanvasOps , MenuEntry } from '~/composables/useMenu'
2026-10-27 12:42:47 +00:00
import { cableInUse , LANE , plugLayout , ribbon , RIBBON _MAX } from '~/lib/logic/cables'
2026-10-23 13:34:36 +00:00
import { latchLayout , latchSeam } from '~/lib/logic/latch'
2026-10-28 12:05:57 +00:00
import { keyCode } from '~/lib/logic/devices'
2026-10-26 17:21:34 +00:00
import { moveParts , moveStart , type MoveStart } from '~/lib/logic/move'
BF jumps always on top of what they cross; R circuit commands in a menu on its name, the side panel only says what it is
A jump is drawn once more over every line, so a cable that arches over
another is never hidden under it, whatever order they are drawn in. Cable
labels sit on the longest stretch no other line crosses.
The circuit's name in the top bar opens what can be done with it: tidy
its wires or every circuit's, design its box, duplicate, delete, print,
export SVG, publish as a puzzle. The This panel keeps what the circuit is:
its health, its numbers (the transistors tile opens their breakdown), its
truth table and how it looks as a part. Unused components are a tab of
the Components list in the parts bar, with a delete button on each.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-23 13:12:43 +00:00
import { wirePath , type HopSpan } from '~/lib/draw'
A Loxone-style working aids: named signals, inverted inputs, a project check, values on cables, search, printable sheets; wire ends move by dragging
- Send signal / Use signal: name a signal (CLK, RESET) once and use it anywhere in the circuit without a wire; selecting one lights up all of them, a use with no sender shows dashed
- Inverted inputs: Alt + click an input (or the menu/settings) puts a bubble on it; it reads the signal inverted through one NAND, counted in every transistor total
- Check (Circuit tab): open inputs, parts that drive nothing, duplicate pin names, unsent or doubly sent signals, loops that never settle; click one to show it. Open inputs get an orange marker on the canvas. Components no other circuit uses are listed with a delete
- Cables show the number they carry (= 13 · 0x0D); hovering a wire tells where it runs and its value
- Ctrl+F finds parts, signals, panel rows, notes and components in every circuit, with where each component is used
- Ctrl+P prints the circuit as a sheet with a title block on white paper (or save as PDF); also as an SVG file
- + and − under a selected gate change its number of inputs; swaps keep bubbles in place
- Drag a wire by its end to move that end to another pin; drop a dragged wire on another wire to tap its signal or feed what it fed
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 11:26:59 +00:00
import { downloadSheet , printSheet , sheetSvg } from '~/lib/sheet'
import { inputCount } from '~/lib/logic/wide'
2026-10-20 18:15:38 +00:00
import { pinName } from '~/lib/logic/labels'
A ports on top of the box, split into lines to wire by hand
On a component's box every connector port now sits at the very top of its
side, above the single pins, in auto and hand-drawn boxes alike. A port
can be split on one placed component (its settings or right click: Split
… into lines): right below the socket the box then gets a pin per line,
named after the line, so lines can be wired by hand without an adapter.
Lines going into the component are inputs, lines coming out outputs, each
facing out of its side; a bar in the type's colour ties them to the
socket. A cable still plugs into the socket at the same time. Dropping a
single wire on a socket (or clicking one while connecting) splits the
port and takes the first free line that runs that way. Join … lines
takes the line pins and their wires away again, as one undo step.
A line wired by hand joins the same net the cable's line reaches inside;
a wire and a cable on one line both drive it, and the check says so.
Line pins are left out of the open-input warning, docked panels and
bubbles; docked panels no longer get a row for a port's socket either.
Saved as an optional list on the placed component (splitPorts); without
it a box only has its ports moved to the top.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 17:08:27 +00:00
import { lineForWire } from '~/lib/logic/ops'
2026-10-17 10:49:38 +00:00
const ed = useEditor ( )
const root = ref < HTMLDivElement > ( )
const size = reactive ( { w : 800 , h : 600 } )
const def = ed . def
const view = computed ( ( ) => ed . views [ def . value . id ] ? ? { x : 40 , y : 40 , zoom : 1 } )
const nodeMap = computed ( ( ) => new Map ( def . value . nodes . map ( n => [ n . id , n ] ) ) )
const shapes = computed ( ( ) => new Map < string , Shape > ( def . value . nodes . map ( n => [ n . id , ed . shape ( n ) ] ) ) )
const selected = computed ( ( ) => new Set ( ed . selection . value ) )
A component faces, project library with share links, fine-grained wire editing
- Lamps and hex displays inside a component show on its box with their
labels, lit by that instance's state; Counter 4 example shows its count.
- Several projects per browser; share links at /p/<id> that the creator's
edits save to automatically, others get their own copy. Export, open a
file as project, or add a file's components to the open project.
- Wires: drag any segment or corner, Alt+drag for a new bend, Ctrl+drag to
branch, double-click selects the whole signal, multi-select, arrow keys,
colour tags.
- Share-link API (POST/GET/PUT /api/p) on Nitro fs storage in data/, mounted
as a volume on edgerealm.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-17 11:21:49 +00:00
const wireSelected = computed ( ( ) => new Set ( ed . wireSel . value ) )
2026-10-17 10:49:38 +00:00
// ── Wires ───────────────────────────────────────────────────────────
interface Route {
wire : Wire
A settings for every part, overlap-free wiring with crossing styles, accounts with sync
- Clicking anything opens its settings: swap parts in place (wires stay on
matching pins), clock frequency per clock, keyboard keys for switches and
buttons, lamp/display colours, note sizes, component names on the canvas,
position, unlink all wires, unpack a component, make an independent copy.
- Wires of different signals never share a line: auto routes pick free
columns or detours, remaining clashes go on separate lanes. Crossings drawn
as bow, triangle, bridge, gap or plain.
- Accounts (email + scrypt password, httpOnly session) with two-way project
sync and conflict copies; per-account limits; cross-site writes refused.
- Compatibility suite: a project and both browser-storage layouts from
release a241adc must load and compute identically.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-20 11:09:37 +00:00
/** Whole-grid route, used for dragging, handles and hit areas. */
2026-10-17 10:49:38 +00:00
pts : Pt [ ]
A settings for every part, overlap-free wiring with crossing styles, accounts with sync
- Clicking anything opens its settings: swap parts in place (wires stay on
matching pins), clock frequency per clock, keyboard keys for switches and
buttons, lamp/display colours, note sizes, component names on the canvas,
position, unlink all wires, unpack a component, make an independent copy.
- Wires of different signals never share a line: auto routes pick free
columns or detours, remaining clashes go on separate lanes. Crossings drawn
as bow, triangle, bridge, gap or plain.
- Accounts (email + scrypt password, httpOnly session) with two-way project
sync and conflict copies; per-account limits; cross-site writes refused.
- Compatibility suite: a project and both browser-storage layouts from
release a241adc must load and compute identically.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-20 11:09:37 +00:00
/** Route as drawn: on its own lane where it would share a line with another signal. */
draw : Pt [ ]
2026-10-17 10:49:38 +00:00
d : string
src : string
2026-10-20 17:29:16 +00:00
/** Wires in it when this is a cable (it leaves a bundle). */
bits ? : number
/** Where the cable's width mark goes. */
mark ? : Pt
2026-10-21 08:39:54 +00:00
/** A cable drawn as a ribbon: one line per wire, coloured like that wire. */
lanes ? : { i : number ; d : string ; color ? : string } [ ]
/** Width of the cable's sleeve in pixels. */
sleeve ? : number
2026-10-22 16:59:56 +00:00
/** What its pins plug into: '' a wire, 'bus' a cable, 'c:<id>' a connector port. */
kind : string
/** A cable between connector ports: its type's name and colour. */
port ? : { name : string ; color ? : string }
2026-10-23 12:57:16 +00:00
/** It jumps over other lines somewhere. */
hops ? : boolean
BF jumps always on top of what they cross; R circuit commands in a menu on its name, the side panel only says what it is
A jump is drawn once more over every line, so a cable that arches over
another is never hidden under it, whatever order they are drawn in. Cable
labels sit on the longest stretch no other line crosses.
The circuit's name in the top bar opens what can be done with it: tidy
its wires or every circuit's, design its box, duplicate, delete, print,
export SVG, publish as a puzzle. The This panel keeps what the circuit is:
its health, its numbers (the transistors tile opens their breakdown), its
truth table and how it looks as a part. Unused components are a tab of
the Components list in the parts bar, with a delete button on each.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-23 13:12:43 +00:00
/** Each jump once more on its own, drawn on top of everything it crosses: the line, and a cable's lines. */
patches ? : { d : string ; lanes : { i : number ; d : string ; color ? : string } [ ] } [ ]
2026-10-22 16:59:56 +00:00
}
BF jumps always on top of what they cross; R circuit commands in a menu on its name, the side panel only says what it is
A jump is drawn once more over every line, so a cable that arches over
another is never hidden under it, whatever order they are drawn in. Cable
labels sit on the longest stretch no other line crosses.
The circuit's name in the top bar opens what can be done with it: tidy
its wires or every circuit's, design its box, duplicate, delete, print,
export SVG, publish as a puzzle. The This panel keeps what the circuit is:
its health, its numbers (the transistors tile opens their breakdown), its
truth table and how it looks as a part. Unused components are a tab of
the Components list in the parts bar, with a delete button on each.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-23 13:12:43 +00:00
/ * *
* Short pieces of a route around each of its jumps , from a little before to
* a little after , with the jump in them . Drawn over all other lines , a jump
* always lies on top of what it crosses , whatever order the lines are in .
* /
function jumpPieces ( pts : Pt [ ] , hops : Map < number , HopSpan [ ] > | undefined , style : Parameters < typeof wirePath > [ 2 ] ) : { seg : number ; from : number ; to : number ; hop : HopSpan } [ ] {
const out : { seg : number ; from : number ; to : number ; hop : HopSpan } [ ] = [ ]
for ( const [ seg , list ] of hops ? ? [ ] ) {
const a = pts [ seg ]
const b = pts [ seg + 1 ]
if ( ! a || ! b || style === 'plain' ) continue
const axis = a [ 1 ] === b [ 1 ] ? 0 : 1
const lo = Math . min ( a [ axis ] , b [ axis ] )
const hi = Math . max ( a [ axis ] , b [ axis ] )
for ( const hop of list ) out . push ( { seg , from : Math . max ( lo , hop . lo - 0.3 ) , to : Math . min ( hi , hop . hi + 0.3 ) , hop } )
}
return out
}
/** One piece of a polyline's segment (or of a lane beside it), drawn with its jump. */
function piecePath ( line : Pt [ ] , p : { seg : number ; from : number ; to : number ; hop : HopSpan } , style : Parameters < typeof wirePath > [ 2 ] ) : string {
const a = line [ p . seg ] !
const b = line [ p . seg + 1 ] !
const axis = a [ 1 ] === b [ 1 ] ? 0 : 1
const forward = b [ axis ] > a [ axis ]
const at = ( v : number ) : Pt => ( axis === 0 ? [ v , a [ 1 ] ] : [ a [ 0 ] , v ] )
const [ s , e ] = forward ? [ p . from , p . to ] : [ p . to , p . from ]
return wirePath ( [ at ( s ) , at ( e ) ] , new Map ( [ [ 0 , [ p . hop ] ] ] ) , style )
}
/ * *
* Where a cable ' s label goes : the middle of the longest straight stretch
* that no other line crosses ( keeping clear of the crossings on each side ) .
* /
function midOfLongest ( draw : Pt [ ] , busy : Pt [ ] = [ ] ) : Pt | undefined {
const CLEAR = 1.5
2026-10-22 16:59:56 +00:00
let best = 0
let at : Pt | undefined
for ( let i = 0 ; i < draw . length - 1 ; i ++ ) {
const [ ax , ay ] = draw [ i ] !
const [ bx , by ] = draw [ i + 1 ] !
BF jumps always on top of what they cross; R circuit commands in a menu on its name, the side panel only says what it is
A jump is drawn once more over every line, so a cable that arches over
another is never hidden under it, whatever order they are drawn in. Cable
labels sit on the longest stretch no other line crosses.
The circuit's name in the top bar opens what can be done with it: tidy
its wires or every circuit's, design its box, duplicate, delete, print,
export SVG, publish as a puzzle. The This panel keeps what the circuit is:
its health, its numbers (the transistors tile opens their breakdown), its
truth table and how it looks as a part. Unused components are a tab of
the Components list in the parts bar, with a delete button on each.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-23 13:12:43 +00:00
const axis = ay === by ? 0 : 1
const lo = Math . min ( draw [ i ] ! [ axis ] , draw [ i + 1 ] ! [ axis ] )
const hi = Math . max ( draw [ i ] ! [ axis ] , draw [ i + 1 ] ! [ axis ] )
const cuts = busy . filter ( p => p [ 1 - axis ] === draw [ i ] ! [ 1 - axis ] && p [ axis ] > lo && p [ axis ] < hi ) . map ( p => p [ axis ] ) . sort ( ( p , q ) => p - q )
// Stretches between the crossings, each kept clear of them.
const edges = [ lo - CLEAR , ... cuts , hi + CLEAR ]
for ( let k = 0 ; k < edges . length - 1 ; k ++ ) {
const from = Math . max ( lo , edges [ k ] ! + CLEAR )
const to = Math . min ( hi , edges [ k + 1 ] ! - CLEAR )
if ( to - from > best ) {
best = to - from
const m = ( from + to ) / 2
at = axis === 0 ? [ m , ay ] : [ ax , m ]
}
2026-10-22 16:59:56 +00:00
}
}
BF jumps always on top of what they cross; R circuit commands in a menu on its name, the side panel only says what it is
A jump is drawn once more over every line, so a cable that arches over
another is never hidden under it, whatever order they are drawn in. Cable
labels sit on the longest stretch no other line crosses.
The circuit's name in the top bar opens what can be done with it: tidy
its wires or every circuit's, design its box, duplicate, delete, print,
export SVG, publish as a puzzle. The This panel keeps what the circuit is:
its health, its numbers (the transistors tile opens their breakdown), its
truth table and how it looks as a part. Unused components are a tab of
the Components list in the parts bar, with a delete button on each.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-23 13:12:43 +00:00
return at ? ? ( draw . length > 1 ? [ ( draw [ 0 ] ! [ 0 ] + draw [ 1 ] ! [ 0 ] ) / 2 , ( draw [ 0 ] ! [ 1 ] + draw [ 1 ] ! [ 1 ] ) / 2 ] : undefined )
2026-10-17 10:49:38 +00:00
}
const toPath = ( pts : Pt [ ] ) => pts . map ( ( [ x , y ] , i ) => ` ${ i ? 'L' : 'M' } ${ x * G } ${ y * G } ` ) . join ( '' )
2026-10-23 12:57:16 +00:00
/** How wide a wire is drawn, in pixels, when it is a cable: its sleeve with the outline. */
function cablePx ( w : Wire | undefined ) : number | undefined {
const from = w && nodeMap . value . get ( w . from . node )
if ( ! from ) return
if ( from . kind === 'bundle' ) {
const bits = cableBits ( from )
return bits <= RIBBON _MAX ? bits * LANE * G + 6 : 8
2026-10-17 10:49:38 +00:00
}
2026-10-23 12:57:16 +00:00
const conn = shapes . value . get ( from . id ) ? . outputs . find ( p => p . key === w . from . pin ) ? . conn
if ( conn ) return Math . min ( 8 , Math . max ( 2 , ed . getDef . value . conn ? . ( conn ) ? . lines . length ? ? 2 ) ) * LANE * G + 6
}
2026-10-26 17:21:34 +00:00
/** Puts the parts of a move `dx`, `dy` squares from where they started, with their wires (cables as wide as drawn). */
function moveTo ( start : MoveStart , dx : number , dy : number ) {
const byId = new Map ( def . value . wires . map ( w => [ w . id , w ] ) )
moveParts ( def . value , start , dx , dy , shapes . value , { widthOf : id => cablePx ( byId . get ( id ) ) } )
}
2026-10-23 12:57:16 +00:00
const routes = computed < Route [ ] > ( ( ) => {
A settings for every part, overlap-free wiring with crossing styles, accounts with sync
- Clicking anything opens its settings: swap parts in place (wires stay on
matching pins), clock frequency per clock, keyboard keys for switches and
buttons, lamp/display colours, note sizes, component names on the canvas,
position, unlink all wires, unpack a component, make an independent copy.
- Wires of different signals never share a line: auto routes pick free
columns or detours, remaining clashes go on separate lanes. Crossings drawn
as bow, triangle, bridge, gap or plain.
- Accounts (email + scrypt password, httpOnly session) with two-way project
sync and conflict copies; per-account limits; cross-site writes refused.
- Compatibility suite: a project and both browser-storage layouts from
release a241adc must load and compute identically.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-20 11:09:37 +00:00
const byId = new Map ( def . value . wires . map ( w => [ w . id , w ] ) )
2026-10-23 12:57:16 +00:00
const routed = circuitRoutes ( def . value , shapes . value , { tidy : ! ! ed . project . value . settings . tidy , widthOf : id => cablePx ( byId . get ( id ) ) } )
const hops = planHops ( routed )
BF jumps always on top of what they cross; R circuit commands in a menu on its name, the side panel only says what it is
A jump is drawn once more over every line, so a cable that arches over
another is never hidden under it, whatever order they are drawn in. Cable
labels sit on the longest stretch no other line crosses.
The circuit's name in the top bar opens what can be done with it: tidy
its wires or every circuit's, design its box, duplicate, delete, print,
export SVG, publish as a puzzle. The This panel keeps what the circuit is:
its health, its numbers (the transistors tile opens their breakdown), its
truth table and how it looks as a part. Unused components are a tab of
the Components list in the parts bar, with a delete button on each.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-23 13:12:43 +00:00
const crossed = crossingPoints ( routed )
2026-10-23 12:57:16 +00:00
const style = ed . project . value . settings . crossing ? ? 'bow'
2026-10-20 17:29:16 +00:00
return routed . map ( ( r , k ) => {
const wire = byId . get ( r . id ) !
const from = nodeMap . value . get ( wire . from . node )
2026-10-22 16:59:56 +00:00
const pin = from && shapes . value . get ( from . id ) ? . outputs . find ( p => p . key === wire . from . pin )
2026-10-23 12:57:16 +00:00
const route : Route = { wire , pts : r . grid , draw : r . draw , d : wirePath ( r . draw , hops . get ( k ) , style ) , src : r . net , kind : pin ? pinKindOf ( pin ) : '' , hops : ! ! hops . get ( k ) ? . size }
2026-10-22 16:59:56 +00:00
if ( pin ? . conn ) {
// A cable between connector ports: a sleeve in its type's colour, named.
const type = ed . getDef . value . conn ? . ( pin . conn )
route . port = { name : type ? . name ? ? '?' , color : type ? . color }
route . sleeve = Math . min ( 8 , Math . max ( 2 , type ? . lines . length ? ? 2 ) ) * LANE * G + 3
BF jumps always on top of what they cross; R circuit commands in a menu on its name, the side panel only says what it is
A jump is drawn once more over every line, so a cable that arches over
another is never hidden under it, whatever order they are drawn in. Cable
labels sit on the longest stretch no other line crosses.
The circuit's name in the top bar opens what can be done with it: tidy
its wires or every circuit's, design its box, duplicate, delete, print,
export SVG, publish as a puzzle. The This panel keeps what the circuit is:
its health, its numbers (the transistors tile opens their breakdown), its
truth table and how it looks as a part. Unused components are a tab of
the Components list in the parts bar, with a delete button on each.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-23 13:12:43 +00:00
route . mark = midOfLongest ( r . draw , crossed . get ( k ) )
2026-10-22 16:59:56 +00:00
}
2026-10-20 17:29:16 +00:00
if ( from ? . kind === 'bundle' ) {
route . bits = cableBits ( from )
2026-10-21 08:39:54 +00:00
if ( route . bits <= RIBBON _MAX ) {
// Each wire keeps the colour of the wire that runs into the bundle.
const feed = new Map ( def . value . wires . filter ( w => w . to . node === from . id ) . map ( w => [ w . to . pin , w . color ] ) )
BF jumps always on top of what they cross; R circuit commands in a menu on its name, the side panel only says what it is
A jump is drawn once more over every line, so a cable that arches over
another is never hidden under it, whatever order they are drawn in. Cable
labels sit on the longest stretch no other line crosses.
The circuit's name in the top bar opens what can be done with it: tidy
its wires or every circuit's, design its box, duplicate, delete, print,
export SVG, publish as a puzzle. The This panel keeps what the circuit is:
its health, its numbers (the transistors tile opens their breakdown), its
truth table and how it looks as a part. Unused components are a tab of
the Components list in the parts bar, with a delete button on each.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-23 13:12:43 +00:00
const lanes = ribbon ( r . draw , route . bits )
route . lanes = lanes . map ( ( lane , i ) => ( { i , d : wirePath ( lane , hops . get ( k ) , style ) , color : feed . get ( ` b ${ i } ` ) } ) )
route . patches = jumpPieces ( r . draw , hops . get ( k ) , style ) . map ( p => ( {
d : piecePath ( r . draw , p , style ) ,
lanes : lanes . map ( ( lane , i ) => ( { i , d : piecePath ( lane , p , style ) , color : feed . get ( ` b ${ i } ` ) } ) ) ,
} ) )
2026-10-21 08:39:54 +00:00
route . sleeve = route . bits * LANE * G + 3
}
2026-10-20 17:29:16 +00:00
// The width mark sits on the middle of the longest straight run.
BF jumps always on top of what they cross; R circuit commands in a menu on its name, the side panel only says what it is
A jump is drawn once more over every line, so a cable that arches over
another is never hidden under it, whatever order they are drawn in. Cable
labels sit on the longest stretch no other line crosses.
The circuit's name in the top bar opens what can be done with it: tidy
its wires or every circuit's, design its box, duplicate, delete, print,
export SVG, publish as a puzzle. The This panel keeps what the circuit is:
its health, its numbers (the transistors tile opens their breakdown), its
truth table and how it looks as a part. Unused components are a tab of
the Components list in the parts bar, with a delete button on each.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-23 13:12:43 +00:00
route . mark = midOfLongest ( r . draw , crossed . get ( k ) )
2026-10-20 17:29:16 +00:00
}
BF jumps always on top of what they cross; R circuit commands in a menu on its name, the side panel only says what it is
A jump is drawn once more over every line, so a cable that arches over
another is never hidden under it, whatever order they are drawn in. Cable
labels sit on the longest stretch no other line crosses.
The circuit's name in the top bar opens what can be done with it: tidy
its wires or every circuit's, design its box, duplicate, delete, print,
export SVG, publish as a puzzle. The This panel keeps what the circuit is:
its health, its numbers (the transistors tile opens their breakdown), its
truth table and how it looks as a part. Unused components are a tab of
the Components list in the parts bar, with a delete button on each.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-23 13:12:43 +00:00
route . patches ? ? = jumpPieces ( r . draw , hops . get ( k ) , style ) . map ( p => ( { d : piecePath ( r . draw , p , style ) , lanes : [ ] } ) )
2026-10-20 17:29:16 +00:00
return route
} )
2026-10-17 10:49:38 +00:00
} )
A component faces, project library with share links, fine-grained wire editing
- Lamps and hex displays inside a component show on its box with their
labels, lit by that instance's state; Counter 4 example shows its count.
- Several projects per browser; share links at /p/<id> that the creator's
edits save to automatically, others get their own copy. Export, open a
file as project, or add a file's components to the open project.
- Wires: drag any segment or corner, Alt+drag for a new bend, Ctrl+drag to
branch, double-click selects the whole signal, multi-select, arrow keys,
colour tags.
- Share-link API (POST/GET/PUT /api/p) on Nitro fs storage in data/, mounted
as a volume on edgerealm.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-17 11:21:49 +00:00
const routeOf = ( wire : Wire ) => routes . value . find ( r => r . wire === wire )
2026-10-23 12:57:16 +00:00
/** Classes of a wire's group: its colour, its signal's value, and how it is being used. */
function wireClass ( r : Route ) {
return [
r . wire . color ? ` c- ${ r . wire . color } ` : r . port ? . color ? ` c- ${ r . port . color } ` : '' ,
{
on : srcVal ( r . src ) === 1 ,
'port-cable' : ! ! r . port ,
selected : wireSelected . value . has ( r . wire . id ) ,
hover : hoverSrc . value === r . src ,
cable : ! ! r . bits ,
'drop-target' : dropWire . value === r . wire . id ,
moving : movingWire . value === r . wire . id ,
} ,
]
}
/ * *
* Sleeved cables , grouped by signal : each group is drawn outline first , then
* core , then lines , so cables of one signal that share a trunk merge into
* one cable that splits . Groups that hop over others come later , on top .
* /
const cableGroups = computed ( ( ) => {
const groups = new Map < string , Route [ ] > ( )
for ( const r of routes . value ) if ( r . lanes || r . port ) groups . set ( r . src , [ ... ( groups . get ( r . src ) ? ? [ ] ) , r ] )
const hopping = ( g : Route [ ] ) => ( g . some ( r => r . hops ) ? 1 : 0 )
return [ ... groups . values ( ) ] . sort ( ( a , b ) => hopping ( a ) - hopping ( b ) )
} )
A Loxone-style working aids: named signals, inverted inputs, a project check, values on cables, search, printable sheets; wire ends move by dragging
- Send signal / Use signal: name a signal (CLK, RESET) once and use it anywhere in the circuit without a wire; selecting one lights up all of them, a use with no sender shows dashed
- Inverted inputs: Alt + click an input (or the menu/settings) puts a bubble on it; it reads the signal inverted through one NAND, counted in every transistor total
- Check (Circuit tab): open inputs, parts that drive nothing, duplicate pin names, unsent or doubly sent signals, loops that never settle; click one to show it. Open inputs get an orange marker on the canvas. Components no other circuit uses are listed with a delete
- Cables show the number they carry (= 13 · 0x0D); hovering a wire tells where it runs and its value
- Ctrl+F finds parts, signals, panel rows, notes and components in every circuit, with where each component is used
- Ctrl+P prints the circuit as a sheet with a title block on white paper (or save as PDF); also as an SVG file
- + and − under a selected gate change its number of inputs; swaps keep bubbles in place
- Drag a wire by its end to move that end to another pin; drop a dragged wire on another wire to tap its signal or feed what it fed
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 11:26:59 +00:00
/** The number a cable carries right now: wire 0 is the lowest bit. */
function cableValue ( r : Route ) : { dec : string ; tip : string } | null {
if ( ! r . bits ) return null
const from = r . wire . from . node
const bits = Array . from ( { length : r . bits } , ( _ , i ) => ed . val ( from , ` b ${ i } ` ) === 1 )
const n = bits . reduce ( ( v , on , i ) => v + ( on ? 2 * * i : 0 ) , 0 )
const hex = ` 0x ${ n . toString ( 16 ) . toUpperCase ( ) . padStart ( Math . ceil ( r . bits / 4 ) , '0' ) } `
const bin = bits . map ( b => ( b ? '1' : '0' ) ) . reverse ( ) . join ( '' )
return { dec : r . bits > 4 ? ` ${ n } · ${ hex } ` : String ( n ) , tip : ` ${ r . bits } wires: ${ bin } = ${ n } = ${ hex } (wire 0 is the lowest bit) ` }
}
/** What a wire carries, for its tooltip: where it comes from, where it goes, and its value. */
function wireTip ( r : Route ) : string {
const v = cableValue ( r )
if ( v ) return v . tip
const name = ( ref : PinRef ) => {
const n = nodeMap . value . get ( ref . node )
if ( ! n ) return '?'
const pin = pinName ( n , ref . pin , ed . getDef . value )
const part = n . label ? . trim ( ) || ( n . kind === 'chip' ? ( n . chip && ed . getDef . value ( n . chip ) ? . name ) || 'Component' : n . kind . toUpperCase ( ) )
return pin ? ` ${ part } ${ pin } ` : part
}
2026-10-22 16:59:56 +00:00
if ( r . port ) {
const type = r . kind . startsWith ( 'c:' ) ? ed . getDef . value . conn ? . ( r . kind . slice ( 2 ) ) : undefined
const lines = ( type ? . lines ? ? [ ] ) . map ( l => ( l . back ? ` ${ l . name } (back) ` : l . name ) ) . join ( ', ' )
return ` ${ name ( r . wire . from ) } → ${ name ( r . wire . to ) } : ${ r . port . name } cable ${ lines ? ` with ${ lines } ` : '' } `
}
A Loxone-style working aids: named signals, inverted inputs, a project check, values on cables, search, printable sheets; wire ends move by dragging
- Send signal / Use signal: name a signal (CLK, RESET) once and use it anywhere in the circuit without a wire; selecting one lights up all of them, a use with no sender shows dashed
- Inverted inputs: Alt + click an input (or the menu/settings) puts a bubble on it; it reads the signal inverted through one NAND, counted in every transistor total
- Check (Circuit tab): open inputs, parts that drive nothing, duplicate pin names, unsent or doubly sent signals, loops that never settle; click one to show it. Open inputs get an orange marker on the canvas. Components no other circuit uses are listed with a delete
- Cables show the number they carry (= 13 · 0x0D); hovering a wire tells where it runs and its value
- Ctrl+F finds parts, signals, panel rows, notes and components in every circuit, with where each component is used
- Ctrl+P prints the circuit as a sheet with a title block on white paper (or save as PDF); also as an SVG file
- + and − under a selected gate change its number of inputs; swaps keep bubbles in place
- Drag a wire by its end to move that end to another pin; drop a dragged wire on another wire to tap its signal or feed what it fed
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 11:26:59 +00:00
return ` ${ name ( r . wire . from ) } → ${ name ( r . wire . to ) } : ${ srcVal ( r . src ) } `
}
2026-10-17 10:49:38 +00:00
/** Dots where a net branches, so crossings without a dot read as "not connected". */
const junctions = computed ( ( ) => {
const groups = new Map < string , Pt [ ] [ ] > ( )
A component faces, project library with share links, fine-grained wire editing
- Lamps and hex displays inside a component show on its box with their
labels, lit by that instance's state; Counter 4 example shows its count.
- Several projects per browser; share links at /p/<id> that the creator's
edits save to automatically, others get their own copy. Export, open a
file as project, or add a file's components to the open project.
- Wires: drag any segment or corner, Alt+drag for a new bend, Ctrl+drag to
branch, double-click selects the whole signal, multi-select, arrow keys,
colour tags.
- Share-link API (POST/GET/PUT /api/p) on Nitro fs storage in data/, mounted
as a volume on edgerealm.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-17 11:21:49 +00:00
const colors = new Map < string , string > ( )
2026-10-17 10:49:38 +00:00
for ( const r of routes . value ) {
const g = groups . get ( r . src )
A settings for every part, overlap-free wiring with crossing styles, accounts with sync
- Clicking anything opens its settings: swap parts in place (wires stay on
matching pins), clock frequency per clock, keyboard keys for switches and
buttons, lamp/display colours, note sizes, component names on the canvas,
position, unlink all wires, unpack a component, make an independent copy.
- Wires of different signals never share a line: auto routes pick free
columns or detours, remaining clashes go on separate lanes. Crossings drawn
as bow, triangle, bridge, gap or plain.
- Accounts (email + scrypt password, httpOnly session) with two-way project
sync and conflict copies; per-account limits; cross-site writes refused.
- Compatibility suite: a project and both browser-storage layouts from
release a241adc must load and compute identically.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-20 11:09:37 +00:00
if ( g ) g . push ( r . draw )
else groups . set ( r . src , [ r . draw ] )
A component faces, project library with share links, fine-grained wire editing
- Lamps and hex displays inside a component show on its box with their
labels, lit by that instance's state; Counter 4 example shows its count.
- Several projects per browser; share links at /p/<id> that the creator's
edits save to automatically, others get their own copy. Export, open a
file as project, or add a file's components to the open project.
- Wires: drag any segment or corner, Alt+drag for a new bend, Ctrl+drag to
branch, double-click selects the whole signal, multi-select, arrow keys,
colour tags.
- Share-link API (POST/GET/PUT /api/p) on Nitro fs storage in data/, mounted
as a volume on edgerealm.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-17 11:21:49 +00:00
if ( r . wire . color && ! colors . has ( r . src ) ) colors . set ( r . src , r . wire . color )
2026-10-17 10:49:38 +00:00
}
A component faces, project library with share links, fine-grained wire editing
- Lamps and hex displays inside a component show on its box with their
labels, lit by that instance's state; Counter 4 example shows its count.
- Several projects per browser; share links at /p/<id> that the creator's
edits save to automatically, others get their own copy. Export, open a
file as project, or add a file's components to the open project.
- Wires: drag any segment or corner, Alt+drag for a new bend, Ctrl+drag to
branch, double-click selects the whole signal, multi-select, arrow keys,
colour tags.
- Share-link API (POST/GET/PUT /api/p) on Nitro fs storage in data/, mounted
as a volume on edgerealm.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-17 11:21:49 +00:00
const dots : { x : number ; y : number ; src : string ; color : string } [ ] = [ ]
2026-10-17 10:49:38 +00:00
for ( const [ src , list ] of groups ) {
if ( list . length < 2 ) continue
const candidates = new Map < string , Pt > ( )
for ( const r of list ) for ( let i = 0 ; i < r . length - 1 ; i ++ ) candidates . set ( ` ${ r [ i ] ! [ 0 ] } , ${ r [ i ] ! [ 1 ] } ` , r [ i ] ! )
for ( const [ x , y ] of candidates . values ( ) ) {
const dirs = new Set < string > ( )
for ( const r of list ) {
for ( let i = 0 ; i < r . length - 1 ; i ++ ) {
const [ ax , ay ] = r [ i ] !
const [ bx , by ] = r [ i + 1 ] !
const onV = ax === bx && x === ax && y >= Math . min ( ay , by ) && y <= Math . max ( ay , by )
const onH = ay === by && y === ay && x >= Math . min ( ax , bx ) && x <= Math . max ( ax , bx )
if ( ! onV && ! onH ) continue
for ( const [ px , py ] of [ [ ax , ay ] , [ bx , by ] ] as Pt [ ] ) {
if ( px === x && py === y ) continue
dirs . add ( px < x ? 'L' : px > x ? 'R' : py < y ? 'U' : 'D' )
}
}
}
A component faces, project library with share links, fine-grained wire editing
- Lamps and hex displays inside a component show on its box with their
labels, lit by that instance's state; Counter 4 example shows its count.
- Several projects per browser; share links at /p/<id> that the creator's
edits save to automatically, others get their own copy. Export, open a
file as project, or add a file's components to the open project.
- Wires: drag any segment or corner, Alt+drag for a new bend, Ctrl+drag to
branch, double-click selects the whole signal, multi-select, arrow keys,
colour tags.
- Share-link API (POST/GET/PUT /api/p) on Nitro fs storage in data/, mounted
as a volume on edgerealm.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-17 11:21:49 +00:00
if ( dirs . size >= 3 ) dots . push ( { x , y , src , color : colors . get ( src ) ? ? '' } )
2026-10-17 10:49:38 +00:00
}
}
return dots
} )
const srcVal = ( src : string ) => {
const [ node , pin ] = src . split ( ':' )
2026-10-20 17:29:16 +00:00
const n = nodeMap . value . get ( node ! )
// A cable is lit while any of its wires carries a 1.
if ( n ? . kind === 'bundle' ) return cableKeys ( n ) . some ( k => ed . val ( n . id , k ) === 1 ) ? 1 : 0
2026-10-17 10:49:38 +00:00
return ed . val ( node ! , pin ! )
}
A component faces, project library with share links, fine-grained wire editing
- Lamps and hex displays inside a component show on its box with their
labels, lit by that instance's state; Counter 4 example shows its count.
- Several projects per browser; share links at /p/<id> that the creator's
edits save to automatically, others get their own copy. Export, open a
file as project, or add a file's components to the open project.
- Wires: drag any segment or corner, Alt+drag for a new bend, Ctrl+drag to
branch, double-click selects the whole signal, multi-select, arrow keys,
colour tags.
- Share-link API (POST/GET/PUT /api/p) on Nitro fs storage in data/, mounted
as a volume on edgerealm.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-17 11:21:49 +00:00
const hoverSrc = ref < string | null > ( null )
2026-10-17 10:49:38 +00:00
// ── View ────────────────────────────────────────────────────────────
function bounds ( nodes : CircuitNode [ ] ) {
let x0 = Infinity
let y0 = Infinity
let x1 = - Infinity
let y1 = - Infinity
for ( const n of nodes ) {
const b = ( shapes . value . get ( n . id ) ? ? ed . shape ( n ) ) . body
x0 = Math . min ( x0 , n . x + b . x - ( n . kind === 'input' || n . kind === 'button' ? 2 : 0 ) )
y0 = Math . min ( y0 , n . y + b . y )
x1 = Math . max ( x1 , n . x + b . x + b . w + ( n . kind === 'output' || n . kind === 'lamp' ? 2 : 0 ) )
y1 = Math . max ( y1 , n . y + b . y + b . h )
}
return { x0 , y0 , x1 , y1 }
}
function fit ( ) {
const nodes = def . value . nodes
if ( ! nodes . length ) {
ed . views [ def . value . id ] = { x : size . w / 2 , y : size . h / 2 , zoom : 1.25 }
return
}
const { x0 , y0 , x1 , y1 } = bounds ( nodes )
2026-10-21 08:09:43 +00:00
const zoom = Math . min ( 2.2 , fitZoom ( ) )
2026-10-17 10:49:38 +00:00
ed . views [ def . value . id ] = {
zoom ,
x : size . w / 2 - ( ( x0 + x1 ) / 2 ) * G * zoom ,
y : size . h / 2 - ( ( y0 + y1 ) / 2 ) * G * zoom ,
}
}
2026-10-21 08:09:43 +00:00
/** Zoom at which the whole circuit just fits on screen. */
function fitZoom ( ) : number {
const nodes = def . value . nodes
if ( ! nodes . length ) return 1
const { x0 , y0 , x1 , y1 } = bounds ( nodes )
const pad = 2
return Math . min ( size . w / ( ( x1 - x0 + 2 * pad ) * G ) , size . h / ( ( y1 - y0 + 2 * pad ) * G ) )
}
/** Zooming out goes at least far enough to see the whole circuit with room around it. */
const minZoom = ( ) => Math . max ( 0.005 , Math . min ( 0.15 , fitZoom ( ) * 0.5 ) )
2026-10-17 10:49:38 +00:00
function zoomAt ( factor : number , sx = size . w / 2 , sy = size . h / 2 ) {
const v = view . value
2026-10-21 08:09:43 +00:00
const zoom = Math . min ( 4 , Math . max ( minZoom ( ) , v . zoom * factor ) )
2026-10-17 10:49:38 +00:00
const k = zoom / v . zoom
ed . views [ def . value . id ] = { zoom , x : sx - ( sx - v . x ) * k , y : sy - ( sy - v . y ) * k }
}
function toWorld ( e : { clientX : number ; clientY : number } ) : Pt {
const r = root . value ! . getBoundingClientRect ( )
const v = view . value
return [ ( e . clientX - r . left - v . x ) / ( G * v . zoom ) , ( e . clientY - r . top - v . y ) / ( G * v . zoom ) ]
}
watch (
( ) => def . value . id ,
id => {
if ( ! ed . views [ id ] ) nextTick ( fit )
} ,
)
A right panel in tabs, Pins list, bulk editing, transistor breakdown, Settings dialog
- Right panel tabs: Selection, Circuit, Pins, Test. Display and sound
preferences move to a Settings dialog (gear in the top bar).
- Pins tab: every input and output in pin order with live values; rename in
place (Enter goes to the next), number a whole side from a pattern, flag
duplicate names, centre the canvas on a part.
- Several selected parts: narrow by type, swap all, rename all from a
pattern, set switches to 0/1 or flip, shared colour/frequency/size, align
and spread.
- Transistors on every part (NAND 4, switches and lamps 0), NAND 4T in the
palette, and a per-part breakdown of the circuit. Test: the count equals
4 x the gates the simulator builds, for every example and wide gate.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 07:29:55 +00:00
// Centre on a part picked elsewhere (the Pins list), keeping the zoom.
watch (
( ) => ed . focusRequest . value ,
r => {
const n = r && nodeMap . value . get ( r . id )
const s = n && shapes . value . get ( n . id )
if ( ! n || ! s ) return
const v = view . value
ed . views [ def . value . id ] = {
... v ,
x : size . w / 2 - ( n . x + s . body . x + s . body . w / 2 ) * G * v . zoom ,
y : size . h / 2 - ( n . y + s . body . y + s . body . h / 2 ) * G * v . zoom ,
}
} ,
)
2026-10-17 10:49:38 +00:00
let resize : ResizeObserver | undefined
onMounted ( ( ) => {
resize = new ResizeObserver ( ( [ entry ] ) => {
size . w = entry ! . contentRect . width
size . h = entry ! . contentRect . height
if ( ! ed . views [ def . value . id ] ) fit ( )
} )
resize . observe ( root . value ! )
window . addEventListener ( 'keydown' , onKey )
window . addEventListener ( 'keyup' , onKeyUp )
} )
onBeforeUnmount ( ( ) => {
resize ? . disconnect ( )
window . removeEventListener ( 'keydown' , onKey )
window . removeEventListener ( 'keyup' , onKeyUp )
} )
// ── Placing ─────────────────────────────────────────────────────────
const cursor = ref < Pt | null > ( null )
2026-10-22 16:59:56 +00:00
function originFor ( p : { kind : CircuitNode [ 'kind' ] ; chip ? : string ; conn ? : string } , at : Pt ) : Pt {
const b = ed . shape ( { id : 'ghost' , kind : p . kind , chip : p . chip , conn : p . conn , x : 0 , y : 0 } ) . body
2026-10-17 10:49:38 +00:00
return [ Math . round ( at [ 0 ] - ( b . x + b . w / 2 ) ) , Math . round ( at [ 1 ] - ( b . y + b . h / 2 ) ) ]
}
2026-10-21 12:21:40 +00:00
/** Pins of everything on the canvas, for a new part to land on. */
const allPins = computed ( ( ) => dropPins ( def . value , def . value . nodes , n => shapes . value . get ( n . id ) ! ) )
/** Alt held while placing: just place, connect nothing. */
const altDown = ref ( false )
/ * *
* Where a new part goes ( being placed or dragged in from the parts list ) :
* at the mouse , or a square over so its free pins land on pins they can
* join , with the wires that makes .
* /
2026-10-22 16:59:56 +00:00
function landing ( p : { kind : CircuitNode [ 'kind' ] ; chip ? : string ; conn ? : string } , at : Pt , alt : boolean ) {
2026-10-21 12:21:40 +00:00
const [ x , y ] = originFor ( p , at )
2026-10-22 16:59:56 +00:00
const node : CircuitNode = { id : 'ghost' , kind : p . kind , chip : p . chip , conn : p . conn , x , y , label : p . kind === 'note' ? 'Note' : p . kind === 'input' ? '?' : undefined }
2026-10-21 12:21:40 +00:00
const snap = alt ? null : dropLinks ( dropPins ( def . value , [ node ] , n => ed . shape ( n ) ) , allPins . value , 1 )
if ( snap ) {
node . x += snap . shift [ 0 ]
node . y += snap . shift [ 1 ]
}
return { node , links : snap ? . links ? ? [ ] }
}
const ghostLanding = computed ( ( ) => {
const p = ed . placing . value ? ? ed . dragPart . value
return p && cursor . value ? landing ( p , cursor . value , altDown . value ) : null
2026-10-17 10:49:38 +00:00
} )
2026-10-21 12:21:40 +00:00
const ghost = computed < CircuitNode | null > ( ( ) => ghostLanding . value ? . node ? ? null )
function onDragOver ( e : DragEvent ) {
if ( ! ed . dragPart . value ) return
cursor . value = toWorld ( e )
altDown . value = e . altKey
}
function onDragLeave ( e : DragEvent ) {
// Leaving the canvas, not just moving from one part of it to another.
if ( ! root . value ? . contains ( e . relatedTarget as Node | null ) ) cursor . value = null
}
2026-10-26 21:45:47 +00:00
// ── Buttons beside what is selected ─────────────────────────────────
/** A round button on the canvas next to the selection, for what is done most with it. */
interface ActionButton {
key : string
x : number
y : number
title : string
/** A lucide icon, or else the cable mark (mirrored with `flip`). */
icon ? : string
flip ? : boolean
run : ( e : PointerEvent ) => void
}
/** The cable that a cable end belongs to, when it has one (a bundle with a split behind it). */
function cableOfEnd ( n : CircuitNode ) : CircuitNode | undefined {
const w = def . value . wires . find ( x => ( n . kind === 'bundle' ? x . from . node === n . id : x . to . node === n . id && x . to . pin === 'a' ) )
const bundle = w && nodeMap . value . get ( w . from . node )
if ( bundle ? . kind !== 'bundle' ) return undefined
return def . value . wires . some ( x => x . from . node === bundle . id && nodeMap . value . get ( x . to . node ) ? . kind === 'split' ) ? bundle : undefined
}
2026-10-21 12:21:40 +00:00
/ * *
A pick pins for a cable, buttons on pointing, right-click on pins; docked panels move freely
- Pointing at a part shows its round buttons, as if it were selected; they
stay while the pointer goes to them.
- A box around some pins of one part (not over its middle), or Shift +
click on pins, picks exactly those pins: a cable plug on them, wire them
one by one, invert or unwire them, from buttons beside them or a
right-click.
- Right-click on a pin offers what can be done right there first: split a
component's cable socket into wires (or join), pull a cable out of a cable
end, invert an input.
- A docked panel moves both ways now: moved up or down off its component's
pins it lets go and stays a panel of its own (rows and wires kept);
moved sideways it stays docked.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-27 12:34:16 +00:00
* Buttons beside a part : a cable onto its outputs and its inputs , and each
* connector port split into its wires or joined again . A cable end : plug in
* or out , take the cable apart .
* /
function nodeButtons ( n : CircuitNode ) : ActionButton [ ] {
const out : ActionButton [ ] = [ ]
const s = shapes . value . get ( n . id )
if ( ! s ) return out
const key = ( k : string ) => ` ${ n . id } | ${ k } `
// Connector ports: beside the socket, out of the box.
for ( const p of [ ... s . inputs , ... s . outputs ] ) {
if ( ! p . conn || n . kind !== 'chip' ) continue
const split = ! ! n . splitPorts ? . includes ( p . key )
out . push ( {
key : key ( ` port: ${ p . key } ` ) ,
x : n . x + p . dx + ( p . dx === 0 ? - 1.3 : 1.3 ) ,
y : n . y + p . dy ,
title : split ? ` Join the ${ p . label } wires back into its socket ` : ` Split ${ p . label } into wires ` ,
icon : split ? 'lucide:merge' : 'lucide:split' ,
run : ( ) => ed . toggleSplit ( n , p . key ) ,
} )
}
const choices = ed . cableChoices ( n )
const mid = ( ps : { dy : number } [ ] ) => ( Math . min ( ... ps . map ( p => p . dy ) ) + Math . max ( ... ps . map ( p => p . dy ) ) ) / 2
const outs = s . outputs . filter ( p => ! p . bus && p . face !== - 1 )
const ins = s . inputs . filter ( p => ! p . bus && p . face !== 1 )
// Clear of a port's button on the same edge.
const clear = ( x : number , y : number ) => {
while ( out . some ( b => b . x === x && Math . abs ( b . y - y ) < 1.2 ) ) y += 0.5
return y
}
if ( choices . out . length && outs . length ) {
const x = n . x + Math . max ( ... outs . map ( p => p . dx ) ) + 1.3
out . push ( { key : key ( 'cable:out' ) , x , y : clear ( x , n . y + mid ( outs ) ) , title : 'A cable plug on these outputs' , run : e => onCableButton ( n , 'out' , e ) } )
}
if ( choices . in . length && ins . length ) {
const x = n . x + Math . min ( ... ins . map ( p => p . dx ) ) - 1.3
out . push ( { key : key ( 'cable:in' ) , x , y : clear ( x , n . y + mid ( ins ) ) , title : 'A cable plug on these inputs' , flip : true , run : e => onCableButton ( n , 'in' , e ) } )
}
if ( n . kind === 'bundle' || n . kind === 'split' ) {
// On the cable's side of the end, clear of its cable pin: pull a cable out, plug in or out, take the cable apart.
const x = n . kind === 'bundle' ? n . x + s . body . x + s . body . w + 1 : n . x + s . body . x - 1
const busY = n . y + ( n . kind === 'bundle' ? s . outputs : s . inputs ) . find ( p => p . bus ) ! . dy
// From its top row down, stepping over the cable pin's row.
let y = n . y + s . body . y + 0.5
for ( const b of endActions ( n ) ) {
if ( Math . abs ( y - busY ) < 0.9 ) y = busY + 1
out . push ( { ... b , key : key ( b . key ) , x , y } )
y += 1.2
}
}
return out
}
/** What can be done at a cable end: pull a cable out, plug in or out, take the cable apart. */
function endActions ( n : CircuitNode ) : Omit < ActionButton , ' x ' | ' y ' > [ ] {
const ends : Omit < ActionButton , ' x ' | ' y ' > [ ] = [ ]
const bus = n . kind === 'bundle' ? { pin : 'q' , dir : 'out' as const } : { pin : 'a' , dir : 'in' as const }
if ( pullable ( { node : n . id , ... bus } ) && ! linked . value [ bus . dir ] . has ( ` ${ n . id } : ${ bus . pin } ` ) ) {
ends . push ( {
key : 'pull' ,
title : 'Pull the cable out: click where its other end goes (or drag it out of its pin)' ,
icon : 'lucide:cable' ,
run : ( ) => ( ed . linking . value = { queue : [ { node : n . id , ... bus , label : '' } ] , at : 0 } ) ,
} )
}
if ( n . plug ) ends . push ( { key : 'unplug' , title : 'Unplug: it steps aside and its wires show again' , icon : 'lucide:unplug' , run : ( ) => ed . unplugEnd ( n ) } )
else if ( ed . plugTarget ( n ) ) ends . push ( { key : 'plug' , title : 'Plug straight onto the pins its wires run to' , icon : 'lucide:plug' , run : ( ) => ed . plugEnd ( n ) } )
2026-10-27 12:42:47 +00:00
const use = cableInUse ( def . value , n . id )
if ( use && use . after < use . before ) {
ends . push ( { key : 'trim' , title : ` Drop the ${ use . before - use . after } unused wires ( ${ use . before } → ${ use . after } ) ` , icon : 'lucide:scissors' , run : ( ) => ed . trimCableEnd ( n . id ) } )
}
A pick pins for a cable, buttons on pointing, right-click on pins; docked panels move freely
- Pointing at a part shows its round buttons, as if it were selected; they
stay while the pointer goes to them.
- A box around some pins of one part (not over its middle), or Shift +
click on pins, picks exactly those pins: a cable plug on them, wire them
one by one, invert or unwire them, from buttons beside them or a
right-click.
- Right-click on a pin offers what can be done right there first: split a
component's cable socket into wires (or join), pull a cable out of a cable
end, invert an input.
- A docked panel moves both ways now: moved up or down off its component's
pins it lets go and stays a panel of its own (rows and wires kept);
moved sideways it stays docked.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-27 12:34:16 +00:00
const cable = cableOfEnd ( n )
if ( cable ) ends . push ( { key : 'apart' , title : 'Split the cable into single wires' , icon : 'lucide:split' , run : ( ) => ed . removeCable ( cable . id ) } )
return ends
}
/** Buttons beside picked pins: a cable plug on exactly them, or wire them one by one. */
function pickedButtons ( ) : ActionButton [ ] {
const sel = ed . pinSel . value
const n = sel && nodeMap . value . get ( sel . node )
const s = n && shapes . value . get ( n . id )
if ( ! sel || ! n || ! s ) return [ ]
const pins = ( sel . dir === 'out' ? s . outputs : s . inputs ) . filter ( p => sel . pins . includes ( p . key ) )
if ( ! pins . length ) return [ ]
const side = sel . dir === 'out' ? 1 : - 1
const x = n . x + ( side > 0 ? Math . max ( ... pins . map ( p => p . dx ) ) : Math . min ( ... pins . map ( p => p . dx ) ) ) + side * 1.3
const mid = n . y + ( Math . min ( ... pins . map ( p => p . dy ) ) + Math . max ( ... pins . map ( p => p . dy ) ) ) / 2
const count = ` ${ pins . length } ${ sel . dir === 'out' ? 'output' : 'input' } ${ pins . length === 1 ? '' : 's' } `
const out : ActionButton [ ] = [ ]
if ( pins . length >= 2 ) out . push ( { key : 'picked|cable' , x , y : mid - 0.6 , title : ` A cable plug on these ${ count } ` , flip : side < 0 , run : ( ) => ed . cablePicked ( ) } )
out . push ( { key : 'picked|link' , x , y : out . length ? mid + 0.6 : mid , title : ` Wire these ${ count } one by one: click where each goes ` , icon : 'lucide:cable' , run : ( ) => ed . linkPicked ( ) } )
return out
}
// ── A part pointed at shows its buttons too, as if it were selected ──
const hoverNode = ref < string | null > ( null )
let hoverTimer : ReturnType < typeof setTimeout > | undefined
/** Pointing at a part (after a moment), or at one of its buttons, keeps them; leaving lets them go a moment later. */
2026-10-27 12:42:47 +00:00
let hoverNext : string | null | undefined
A pick pins for a cable, buttons on pointing, right-click on pins; docked panels move freely
- Pointing at a part shows its round buttons, as if it were selected; they
stay while the pointer goes to them.
- A box around some pins of one part (not over its middle), or Shift +
click on pins, picks exactly those pins: a cable plug on them, wire them
one by one, invert or unwire them, from buttons beside them or a
right-click.
- Right-click on a pin offers what can be done right there first: split a
component's cable socket into wires (or join), pull a cable out of a cable
end, invert an input.
- A docked panel moves both ways now: moved up or down off its component's
pins it lets go and stays a panel of its own (rows and wires kept);
moved sideways it stays docked.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-27 12:34:16 +00:00
function trackHover ( target : Element | null ) {
2026-10-27 12:42:47 +00:00
// On one of the buttons: they stay.
if ( target ? . closest ( '[data-action]' ) ) {
clearTimeout ( hoverTimer )
hoverNext = undefined
return
}
A pick pins for a cable, buttons on pointing, right-click on pins; docked panels move freely
- Pointing at a part shows its round buttons, as if it were selected; they
stay while the pointer goes to them.
- A box around some pins of one part (not over its middle), or Shift +
click on pins, picks exactly those pins: a cable plug on them, wire them
one by one, invert or unwire them, from buttons beside them or a
right-click.
- Right-click on a pin offers what can be done right there first: split a
component's cable socket into wires (or join), pull a cable out of a cable
end, invert an input.
- A docked panel moves both ways now: moved up or down off its component's
pins it lets go and stays a panel of its own (rows and wires kept);
moved sideways it stays docked.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-27 12:34:16 +00:00
const id = target ? . closest ( '[data-node]' ) ? . getAttribute ( 'data-node' ) ? ? null
2026-10-27 12:42:47 +00:00
if ( id === hoverNode . value ) {
clearTimeout ( hoverTimer )
hoverNext = undefined
return
}
// Already on its way to this one: let it come (moving on must not keep putting it off).
if ( hoverNext === id ) return
clearTimeout ( hoverTimer )
hoverNext = id
hoverTimer = setTimeout (
( ) => {
hoverNode . value = id
hoverNext = undefined
} ,
id ? 150 : 400 ,
)
}
/** While the view or a part is dragged, nothing is pointed at. */
function dropHover ( ) {
A pick pins for a cable, buttons on pointing, right-click on pins; docked panels move freely
- Pointing at a part shows its round buttons, as if it were selected; they
stay while the pointer goes to them.
- A box around some pins of one part (not over its middle), or Shift +
click on pins, picks exactly those pins: a cable plug on them, wire them
one by one, invert or unwire them, from buttons beside them or a
right-click.
- Right-click on a pin offers what can be done right there first: split a
component's cable socket into wires (or join), pull a cable out of a cable
end, invert an input.
- A docked panel moves both ways now: moved up or down off its component's
pins it lets go and stays a panel of its own (rows and wires kept);
moved sideways it stays docked.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-27 12:34:16 +00:00
clearTimeout ( hoverTimer )
2026-10-27 12:42:47 +00:00
hoverNext = undefined
hoverNode . value = null
A pick pins for a cable, buttons on pointing, right-click on pins; docked panels move freely
- Pointing at a part shows its round buttons, as if it were selected; they
stay while the pointer goes to them.
- A box around some pins of one part (not over its middle), or Shift +
click on pins, picks exactly those pins: a cable plug on them, wire them
one by one, invert or unwire them, from buttons beside them or a
right-click.
- Right-click on a pin offers what can be done right there first: split a
component's cable socket into wires (or join), pull a cable out of a cable
end, invert an input.
- A docked panel moves both ways now: moved up or down off its component's
pins it lets go and stays a panel of its own (rows and wires kept);
moved sideways it stays docked.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-27 12:34:16 +00:00
}
/ * *
* Buttons beside the selection , and beside a part pointed at . Picked pins :
* a cable on them , or wire them one by one . A cable : take it apart . Several
* wires : bundle them into a cable .
2026-10-21 12:21:40 +00:00
* /
2026-10-26 21:45:47 +00:00
const actionButtons = computed < ActionButton [ ] > ( ( ) => {
if ( drag . value || ed . linking . value || ed . placing . value || ed . cabling . value ) return [ ]
A pick pins for a cable, buttons on pointing, right-click on pins; docked panels move freely
- Pointing at a part shows its round buttons, as if it were selected; they
stay while the pointer goes to them.
- A box around some pins of one part (not over its middle), or Shift +
click on pins, picks exactly those pins: a cable plug on them, wire them
one by one, invert or unwire them, from buttons beside them or a
right-click.
- Right-click on a pin offers what can be done right there first: split a
component's cable socket into wires (or join), pull a cable out of a cable
end, invert an input.
- A docked panel moves both ways now: moved up or down off its component's
pins it lets go and stays a panel of its own (rows and wires kept);
moved sideways it stays docked.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-27 12:34:16 +00:00
const out : ActionButton [ ] = [ ... pickedButtons ( ) ]
2026-10-26 21:45:47 +00:00
const sel = ed . selection . value
A pick pins for a cable, buttons on pointing, right-click on pins; docked panels move freely
- Pointing at a part shows its round buttons, as if it were selected; they
stay while the pointer goes to them.
- A box around some pins of one part (not over its middle), or Shift +
click on pins, picks exactly those pins: a cable plug on them, wire them
one by one, invert or unwire them, from buttons beside them or a
right-click.
- Right-click on a pin offers what can be done right there first: split a
component's cable socket into wires (or join), pull a cable out of a cable
end, invert an input.
- A docked panel moves both ways now: moved up or down off its component's
pins it lets go and stays a panel of its own (rows and wires kept);
moved sideways it stays docked.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-27 12:34:16 +00:00
const picked = sel . length === 1 && ! ed . wireSel . value . length ? sel [ 0 ] : undefined
for ( const id of new Set ( [ picked , hoverNode . value ] ) ) {
const n = id ? nodeMap . value . get ( id ) : undefined
// With pins of it picked, the buttons for those pins stand in for its own.
if ( n && n . id !== ed . pinSel . value ? . node ) out . push ( ... nodeButtons ( n ) )
2026-10-26 21:45:47 +00:00
}
// Wires: a cable can be taken apart, several single wires bundled.
const wires = sel . length ? [ ] : routes . value . filter ( r => wireSelected . value . has ( r . wire . id ) )
// Above the middle of the topmost one.
const at = ( rs : Route [ ] ) => {
const ps = rs . map ( r => midOfLongest ( r . pts ) ) . filter ( p => ! ! p )
return ps . length ? { x : ps . reduce ( ( a , p ) => a + p [ 0 ] , 0 ) / ps . length , y : Math . min ( ... ps . map ( p => p [ 1 ] ) ) - 1.2 } : null
}
const cable = wires . length === 1 && wires [ 0 ] ! . bits ? nodeMap . value . get ( wires [ 0 ] ! . wire . from . node ) : undefined
const singles = wires . filter ( r => ! r . bits )
const spot = at ( wires )
if ( cable && spot ) out . push ( { key : 'apart' , ... spot , title : 'Split the cable into single wires' , icon : 'lucide:split' , run : ( ) => ed . removeCable ( cable . id ) } )
else if ( singles . length >= 2 && singles . length === wires . length && spot ) {
out . push ( { key : 'bundle' , ... spot , title : ` Bundle the ${ singles . length } wires into a cable (Ctrl+G) ` , run : ( ) => ed . bundleSelected ( singles . map ( r => r . wire . id ) ) } )
}
2026-10-21 12:21:40 +00:00
return out
} )
/** A cable button: with one way to do it, it is done; with several, they are offered. */
A pick pins for a cable, buttons on pointing, right-click on pins; docked panels move freely
- Pointing at a part shows its round buttons, as if it were selected; they
stay while the pointer goes to them.
- A box around some pins of one part (not over its middle), or Shift +
click on pins, picks exactly those pins: a cable plug on them, wire them
one by one, invert or unwire them, from buttons beside them or a
right-click.
- Right-click on a pin offers what can be done right there first: split a
component's cable socket into wires (or join), pull a cable out of a cable
end, invert an input.
- A docked panel moves both ways now: moved up or down off its component's
pins it lets go and stays a panel of its own (rows and wires kept);
moved sideways it stays docked.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-27 12:34:16 +00:00
function onCableButton ( n : CircuitNode , side : 'out' | 'in' , e : PointerEvent ) {
2026-10-21 12:21:40 +00:00
const groups = ed . cableChoices ( n ) [ side ]
const run = ( pins : string [ ] ) => ( side === 'out' ? ed . cableOut ( n . id , pins ) : ed . cableIn ( n . id , pins ) )
if ( groups . length === 1 ) return run ( groups [ 0 ] ! . pins )
menu . value = {
x : e . clientX + 6 ,
y : e . clientY + 6 ,
entries : [
2026-10-26 21:45:47 +00:00
{ head : side === 'out' ? 'Plug on outputs' : 'Plug on inputs' } ,
2026-10-21 12:21:40 +00:00
... groups . map ( g => ( { label : g . label , note : ` ${ g . pins . length } wires ` , icon : side === 'out' ? 'lucide:merge' : 'lucide:split' , run : ( ) => run ( g . pins ) } ) ) ,
] ,
}
}
2026-10-17 10:49:38 +00:00
function onDrop ( e : DragEvent ) {
const raw = e . dataTransfer ? . getData ( 'application/x-logigate' )
2026-10-21 12:21:40 +00:00
ed . dragPart . value = null
2026-10-17 10:49:38 +00:00
if ( ! raw ) return
2026-10-22 16:59:56 +00:00
const p = JSON . parse ( raw ) as { kind : CircuitNode [ 'kind' ] ; chip ? : string ; conn ? : string }
2026-10-17 10:49:38 +00:00
if ( p . chip && ! ed . canPlace ( p . chip ) ) return ed . notify ( 'A component cannot contain itself' , 'error' )
A campaign with unlocks, synthesised sound, puzzles and the puzzle of the week
- Campaign projects start with NAND only; challenges open along a
dependency chain, each solution becomes a usable part, and basic parts
unlock on the way. Locked parts and challenges say what opens them.
- Sound effects made with Web Audio: place, connect, switches, buttons,
delete, clock ticks (opt-in), solve, fail, unlock, record. Mute and
volume in the top bar and Display settings.
- Publish any circuit as a puzzle link; only its behaviour is shared.
The server re-runs the checks on submitted solutions, counts their
transistors and keeps each player's best; the board shows a histogram
and your place. A generated puzzle of the week for everyone.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 17:54:57 +00:00
if ( ! ed . canPlaceKind ( p . kind ) ) return
2026-10-21 12:21:40 +00:00
const { node , links } = landing ( p , toWorld ( e ) , e . altKey )
ed . addNode ( p , node . x , node . y , links )
2026-10-17 10:49:38 +00:00
}
// ── Pointer interaction ─────────────────────────────────────────────
type Drag =
A right-click menu for parts, wires and the canvas, "Wire them all to" as cards, plugged latches in plain greys
- Right click (or the menu key) shows what can be done with what is under the pointer: one part (open, rename, change to, inputs, colour, speed, panels, unpack, plug and unplug, cable colour), several parts (wire them all to with live preview, connect one by one, switches, change all, arrange, keep only, make a component), wires (bundle, colour, whole signal, straighten, remove cable) or empty canvas (paste here, add a part here, select all, fit, tidy, undo); right drag still moves the view
- "Wire them all to": a card per part, each fit a strip of its pins, and which wire goes where for the fit pointed at
- Plugged cable ends no longer look selected: grey connector, steel clips
- Icons named in menus are bundled for the browser too
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 10:33:30 +00:00
| {
kind : 'pan'
sx : number
sy : number
vx : number
vy : number
/** A right click that doesn't move opens the menu for what is under it. */
menu ? : { target : Element ; at : Pt }
}
A input panels, automatic names, one-by-one wiring, tidy routing, truth table export
- Input panel part: rows of switches, buttons and clocks. "Attach input
panel" docks one to a component with a row per free input; it moves
with the component and follows its pins.
- Copies and new pins continue name series (D0 -> D1, A -> B); unnamed
switches, lamps and pins take the name of the component pin they are
wired to.
- Connecting: target pins are ringed, dropping on a part uses its next
free pin, click-then-click works, and "Connect one by one" (W) wires a
selection's pins in turn.
- Tidy wiring option and "Tidy all wires": sorted, evenly spaced columns
per gap, one trunk per signal, fewer crossings.
- Truth table full screen, CSV download, copy as Markdown, current row
highlighted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 17:17:25 +00:00
| {
kind : 'move'
start : Pt
2026-10-26 17:21:34 +00:00
/** Where the moving parts and the corners were: every step moves from there. */
orig : MoveStart
/** Squares moved so far. */
at : Pt
A input panels, automatic names, one-by-one wiring, tidy routing, truth table export
- Input panel part: rows of switches, buttons and clocks. "Attach input
panel" docks one to a component with a row per free input; it moves
with the component and follows its pins.
- Copies and new pins continue name series (D0 -> D1, A -> B); unnamed
switches, lamps and pins take the name of the component pin they are
wired to.
- Connecting: target pins are ringed, dropping on a part uses its next
free pin, click-then-click works, and "Connect one by one" (W) wires a
selection's pins in turn.
- Tidy wiring option and "Tidy all wires": sorted, evenly spaced columns
per gap, one trunk per signal, fewer crossings.
- Truth table full screen, CSV download, copy as Markdown, current row
highlighted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 17:17:25 +00:00
moved : boolean
node : CircuitNode
toggle : boolean
row ? : PanelRow
2026-10-28 12:30:07 +00:00
/** On a test bench: its run button, or one of its rows (a click puts it on the circuit). */
benchHit ? : 'run' | number
2026-10-21 10:16:26 +00:00
/** How many parts were picked up (followers not counted): one part may snap to a pin a square away. */
grabbed : number
/** Pins of the parts staying put, and of the moving parts where they started; filled once the drag moves. */
still ? : DropPin [ ]
from ? : DropPin [ ]
/** Pins the moving parts land on: the step that lines them up and the wires dropping makes. */
snap ? : { shift : Pt ; links : Link [ ] } | null
2026-10-26 17:21:34 +00:00
/** A cable end brought close to the part its wires run to: dropped, it plugs in (at `at`). */
plug ? : { part : string ; rings : Pt [ ] ; at : Pt } | null
A input panels, automatic names, one-by-one wiring, tidy routing, truth table export
- Input panel part: rows of switches, buttons and clocks. "Attach input
panel" docks one to a component with a row per free input; it moves
with the component and follows its pins.
- Copies and new pins continue name series (D0 -> D1, A -> B); unnamed
switches, lamps and pins take the name of the component pin they are
wired to.
- Connecting: target pins are ringed, dropping on a part uses its next
free pin, click-then-click works, and "Connect one by one" (W) wires a
selection's pins in turn.
- Tidy wiring option and "Tidy all wires": sorted, evenly spaced columns
per gap, one trunk per signal, fewer crossings.
- Truth table full screen, CSV download, copy as Markdown, current row
highlighted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 17:17:25 +00:00
}
A Loxone-style working aids: named signals, inverted inputs, a project check, values on cables, search, printable sheets; wire ends move by dragging
- Send signal / Use signal: name a signal (CLK, RESET) once and use it anywhere in the circuit without a wire; selecting one lights up all of them, a use with no sender shows dashed
- Inverted inputs: Alt + click an input (or the menu/settings) puts a bubble on it; it reads the signal inverted through one NAND, counted in every transistor total
- Check (Circuit tab): open inputs, parts that drive nothing, duplicate pin names, unsent or doubly sent signals, loops that never settle; click one to show it. Open inputs get an orange marker on the canvas. Components no other circuit uses are listed with a delete
- Cables show the number they carry (= 13 · 0x0D); hovering a wire tells where it runs and its value
- Ctrl+F finds parts, signals, panel rows, notes and components in every circuit, with where each component is used
- Ctrl+P prints the circuit as a sheet with a title block on white paper (or save as PDF); also as an SVG file
- + and − under a selected gate change its number of inputs; swaps keep bubbles in place
- Drag a wire by its end to move that end to another pin; drop a dragged wire on another wire to tap its signal or feed what it fed
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 11:26:59 +00:00
| {
kind : 'wire'
node : string
pin : string
dir : 'in' | 'out'
start : Pt
cur : Pt
moved : boolean
branch ? : Pt [ ]
/** Moving one end of this wire: the other end stays, the wire goes where it is dropped. */
replace ? : string
}
A component faces, project library with share links, fine-grained wire editing
- Lamps and hex displays inside a component show on its box with their
labels, lit by that instance's state; Counter 4 example shows its count.
- Several projects per browser; share links at /p/<id> that the creator's
edits save to automatically, others get their own copy. Export, open a
file as project, or add a file's components to the open project.
- Wires: drag any segment or corner, Alt+drag for a new bend, Ctrl+drag to
branch, double-click selects the whole signal, multi-select, arrow keys,
colour tags.
- Share-link API (POST/GET/PUT /api/p) on Nitro fs storage in data/, mounted
as a volume on edgerealm.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-17 11:21:49 +00:00
| { kind : 'box' ; start : Pt ; cur : Pt ; nodes : string [ ] ; wires : string [ ] }
| { kind : 'segment' ; wire : Wire ; base : Pt [ ] ; k : number ; axis : 0 | 1 ; start : number ; moved : boolean }
| { kind : 'corner' ; wire : Wire ; route : Pt [ ] ; i : number ; moved : boolean }
2026-10-17 10:49:38 +00:00
const drag = ref < Drag | null > ( null )
const spaceDown = ref ( false )
2026-10-23 10:43:08 +00:00
/** Space pressed and let go quickly, without moving the view: opens the search box at the mouse. */
let spaceTap : { at : number } | null = null
2026-10-17 10:49:38 +00:00
let lastClick = { id : '' , t : 0 }
A component faces, project library with share links, fine-grained wire editing
- Lamps and hex displays inside a component show on its box with their
labels, lit by that instance's state; Counter 4 example shows its count.
- Several projects per browser; share links at /p/<id> that the creator's
edits save to automatically, others get their own copy. Export, open a
file as project, or add a file's components to the open project.
- Wires: drag any segment or corner, Alt+drag for a new bend, Ctrl+drag to
branch, double-click selects the whole signal, multi-select, arrow keys,
colour tags.
- Share-link API (POST/GET/PUT /api/p) on Nitro fs storage in data/, mounted
as a volume on edgerealm.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-17 11:21:49 +00:00
function isDoubleClick ( id : string ) {
const now = performance . now ( )
const dbl = lastClick . id === id && now - lastClick . t < 350
lastClick = dbl ? { id : '' , t : 0 } : { id , t : now }
return dbl
}
2026-10-17 10:49:38 +00:00
function onPointerDown ( e : PointerEvent ) {
const w = toWorld ( e )
const v = view . value
if ( e . button === 1 || e . button === 2 || ( e . button === 0 && spaceDown . value ) ) {
2026-10-23 10:43:08 +00:00
spaceTap = null
A right-click menu for parts, wires and the canvas, "Wire them all to" as cards, plugged latches in plain greys
- Right click (or the menu key) shows what can be done with what is under the pointer: one part (open, rename, change to, inputs, colour, speed, panels, unpack, plug and unplug, cable colour), several parts (wire them all to with live preview, connect one by one, switches, change all, arrange, keep only, make a component), wires (bundle, colour, whole signal, straighten, remove cable) or empty canvas (paste here, add a part here, select all, fit, tidy, undo); right drag still moves the view
- "Wire them all to": a card per part, each fit a strip of its pins, and which wire goes where for the fit pointed at
- Plugged cable ends no longer look selected: grey connector, steel clips
- Icons named in menus are bundled for the browser too
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 10:33:30 +00:00
menu . value = null
2026-10-27 12:42:47 +00:00
dropHover ( )
A right-click menu for parts, wires and the canvas, "Wire them all to" as cards, plugged latches in plain greys
- Right click (or the menu key) shows what can be done with what is under the pointer: one part (open, rename, change to, inputs, colour, speed, panels, unpack, plug and unplug, cable colour), several parts (wire them all to with live preview, connect one by one, switches, change all, arrange, keep only, make a component), wires (bundle, colour, whole signal, straighten, remove cable) or empty canvas (paste here, add a part here, select all, fit, tidy, undo); right drag still moves the view
- "Wire them all to": a card per part, each fit a strip of its pins, and which wire goes where for the fit pointed at
- Plugged cable ends no longer look selected: grey connector, steel clips
- Icons named in menus are bundled for the browser too
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 10:33:30 +00:00
drag . value = { kind : 'pan' , sx : e . clientX , sy : e . clientY , vx : v . x , vy : v . y , menu : e . button === 2 ? { target : e . target as Element , at : w } : undefined }
2026-10-17 10:49:38 +00:00
root . value ! . setPointerCapture ( e . pointerId )
return
}
if ( e . button !== 0 ) return
root . value ! . setPointerCapture ( e . pointerId )
2026-10-28 12:05:57 +00:00
// A click anywhere but the keyboard being typed into stops the typing.
if ( ed . typingInto . value && ( e . target as Element ) . closest ? . ( '[data-node]' ) ? . getAttribute ( 'data-node' ) !== ed . typingInto . value ) ed . typeInto ( null )
2026-10-17 10:49:38 +00:00
A input panels, automatic names, one-by-one wiring, tidy routing, truth table export
- Input panel part: rows of switches, buttons and clocks. "Attach input
panel" docks one to a component with a row per free input; it moves
with the component and follows its pins.
- Copies and new pins continue name series (D0 -> D1, A -> B); unnamed
switches, lamps and pins take the name of the component pin they are
wired to.
- Connecting: target pins are ringed, dropping on a part uses its next
free pin, click-then-click works, and "Connect one by one" (W) wires a
selection's pins in turn.
- Tidy wiring option and "Tidy all wires": sorted, evenly spaced columns
per gap, one trunk per signal, fewer crossings.
- Truth table full screen, CSV download, copy as Markdown, current row
highlighted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 17:17:25 +00:00
const link = ed . linking . value
const end = link ? . queue [ link . at ]
if ( end ) {
A ports on top of the box, split into lines to wire by hand
On a component's box every connector port now sits at the very top of its
side, above the single pins, in auto and hand-drawn boxes alike. A port
can be split on one placed component (its settings or right click: Split
… into lines): right below the socket the box then gets a pin per line,
named after the line, so lines can be wired by hand without an adapter.
Lines going into the component are inputs, lines coming out outputs, each
facing out of its side; a bar in the type's colour ties them to the
socket. A cable still plugs into the socket at the same time. Dropping a
single wire on a socket (or clicking one while connecting) splits the
port and takes the first free line that runs that way. Join … lines
takes the line pins and their wires away again, as one undo step.
A line wired by hand joins the same net the cable's line reaches inside;
a wire and a cable on one line both drive it, and the check says so.
Line pins are left out of the open-input warning, docked panels and
bubbles; docked panels no longer get a row for a port's socket either.
Saved as an optional list on the placed component (splitPorts); without
it a box only has its ports moved to the top.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 17:08:27 +00:00
// Connecting: a click on a pin or a part wires the current pin there (on a port's socket, to one of its lines).
const socket = socketAt ( { ... end , cur : w } )
const target = socket ? ed . lineAt ( end . dir , socket . node , socket . port ) : targetAt ( w , end . dir === 'out' ? 'in' : 'out' , ed . pinKind ( end . node , end . pin , end . dir ) )
2026-10-23 11:11:19 +00:00
if ( target ) return ed . linkTo ( target , e . shiftKey )
2026-10-26 21:45:47 +00:00
// A cable pulled out of a cable end: its other end goes where the click is.
const pulled = link . queue . length === 1 ? pullEnd ( { ... end , cur : w } ) : null
if ( pulled ) {
ed . stopLinking ( )
return ed . pullCable ( end . node , pulled . x , pulled . y , pulled . links )
}
A input panels, automatic names, one-by-one wiring, tidy routing, truth table export
- Input panel part: rows of switches, buttons and clocks. "Attach input
panel" docks one to a component with a row per free input; it moves
with the component and follows its pins.
- Copies and new pins continue name series (D0 -> D1, A -> B); unnamed
switches, lamps and pins take the name of the component pin they are
wired to.
- Connecting: target pins are ringed, dropping on a part uses its next
free pin, click-then-click works, and "Connect one by one" (W) wires a
selection's pins in turn.
- Tidy wiring option and "Tidy all wires": sorted, evenly spaced columns
per gap, one trunk per signal, fewer crossings.
- Truth table full screen, CSV download, copy as Markdown, current row
highlighted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 17:17:25 +00:00
const pinEl = ( e . target as Element ) . closest ( '[data-pin]' )
if ( pinEl && link . queue . length === 1 ) {
// Another pin of the same kind: start from that one instead.
const node = pinEl . getAttribute ( 'data-node' ) !
const pin = pinEl . getAttribute ( 'data-pin' ) !
ed . linking . value = { queue : [ { node , pin , dir : pinEl . getAttribute ( 'data-dir' ) as 'in' | 'out' , label : '' } ] , at : 0 }
return
}
return ed . stopLinking ( )
}
2026-10-21 08:39:54 +00:00
if ( ed . cabling . value ) {
ed . placeCable ( [ Math . round ( w [ 0 ] ) , Math . round ( w [ 1 ] ) ] )
return
}
2026-10-17 10:49:38 +00:00
const placing = ed . placing . value
if ( placing ) {
if ( placing . chip && ! ed . canPlace ( placing . chip ) ) {
ed . placing . value = null
return ed . notify ( 'A component cannot contain itself' , 'error' )
}
2026-10-21 12:21:40 +00:00
const { node , links } = landing ( placing , w , e . altKey )
ed . addNode ( placing , node . x , node . y , links )
2026-10-17 10:49:38 +00:00
if ( ! e . shiftKey && ! placing . keep ) ed . placing . value = null
return
}
const target = e . target as Element
2026-10-26 21:45:47 +00:00
const actionEl = target . closest ( '[data-action]' )
if ( actionEl ) return actionButtons . value . find ( b => b . key === actionEl . getAttribute ( 'data-action' ) ) ? . run ( e )
A Loxone-style working aids: named signals, inverted inputs, a project check, values on cables, search, printable sheets; wire ends move by dragging
- Send signal / Use signal: name a signal (CLK, RESET) once and use it anywhere in the circuit without a wire; selecting one lights up all of them, a use with no sender shows dashed
- Inverted inputs: Alt + click an input (or the menu/settings) puts a bubble on it; it reads the signal inverted through one NAND, counted in every transistor total
- Check (Circuit tab): open inputs, parts that drive nothing, duplicate pin names, unsent or doubly sent signals, loops that never settle; click one to show it. Open inputs get an orange marker on the canvas. Components no other circuit uses are listed with a delete
- Cables show the number they carry (= 13 · 0x0D); hovering a wire tells where it runs and its value
- Ctrl+F finds parts, signals, panel rows, notes and components in every circuit, with where each component is used
- Ctrl+P prints the circuit as a sheet with a title block on white paper (or save as PDF); also as an SVG file
- + and − under a selected gate change its number of inputs; swaps keep bubbles in place
- Drag a wire by its end to move that end to another pin; drop a dragged wire on another wire to tap its signal or feed what it fed
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 11:26:59 +00:00
const widenEl = target . closest ( '[data-inputs]' )
if ( widenEl ) {
// + or − under a selected gate: one input more or less.
const n = nodeMap . value . get ( widenEl . closest ( '[data-node]' ) ? . getAttribute ( 'data-node' ) ? ? '' )
if ( n ) ed . setInputs ( n , inputCount ( n , ed . getDef . value ) + Number ( widenEl . getAttribute ( 'data-inputs' ) ) )
return
}
2026-10-21 10:16:26 +00:00
const fitEl = target . closest ( '[data-fit]' )
if ( fitEl ) {
// A green box: wire the selection to the pins pointed at.
const i = Number ( fitEl . getAttribute ( 'data-fit' ) )
const spot = ed . fits . value [ i ]
const h = ed . fitHover . value
if ( spot ) ed . connectFit ( i , h ? . spot === i ? h . start : fitStart ( spot , w [ 1 ] ) )
return
}
2026-10-17 10:49:38 +00:00
const pinEl = target . closest ( '[data-pin]' )
A Loxone-style working aids: named signals, inverted inputs, a project check, values on cables, search, printable sheets; wire ends move by dragging
- Send signal / Use signal: name a signal (CLK, RESET) once and use it anywhere in the circuit without a wire; selecting one lights up all of them, a use with no sender shows dashed
- Inverted inputs: Alt + click an input (or the menu/settings) puts a bubble on it; it reads the signal inverted through one NAND, counted in every transistor total
- Check (Circuit tab): open inputs, parts that drive nothing, duplicate pin names, unsent or doubly sent signals, loops that never settle; click one to show it. Open inputs get an orange marker on the canvas. Components no other circuit uses are listed with a delete
- Cables show the number they carry (= 13 · 0x0D); hovering a wire tells where it runs and its value
- Ctrl+F finds parts, signals, panel rows, notes and components in every circuit, with where each component is used
- Ctrl+P prints the circuit as a sheet with a title block on white paper (or save as PDF); also as an SVG file
- + and − under a selected gate change its number of inputs; swaps keep bubbles in place
- Drag a wire by its end to move that end to another pin; drop a dragged wire on another wire to tap its signal or feed what it fed
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 11:26:59 +00:00
if ( pinEl && e . altKey && pinEl . getAttribute ( 'data-dir' ) === 'in' ) {
// Alt + click on an input: invert it (a bubble), or take the bubble off.
const n = nodeMap . value . get ( pinEl . getAttribute ( 'data-node' ) ! )
A ports on top of the box, split into lines to wire by hand
On a component's box every connector port now sits at the very top of its
side, above the single pins, in auto and hand-drawn boxes alike. A port
can be split on one placed component (its settings or right click: Split
… into lines): right below the socket the box then gets a pin per line,
named after the line, so lines can be wired by hand without an adapter.
Lines going into the component are inputs, lines coming out outputs, each
facing out of its side; a bar in the type's colour ties them to the
socket. A cable still plugs into the socket at the same time. Dropping a
single wire on a socket (or clicking one while connecting) splits the
port and takes the first free line that runs that way. Join … lines
takes the line pins and their wires away again, as one undo step.
A line wired by hand joins the same net the cable's line reaches inside;
a wire and a cable on one line both drive it, and the check says so.
Line pins are left out of the open-input warning, docked panels and
bubbles; docked panels no longer get a row for a port's socket either.
Saved as an optional list on the placed component (splitPorts); without
it a box only has its ports moved to the top.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 17:08:27 +00:00
if ( n && ed . canInvert ( n , pinEl . getAttribute ( 'data-pin' ) ! ) ) return ed . toggleInvert ( n , pinEl . getAttribute ( 'data-pin' ) ! )
A Loxone-style working aids: named signals, inverted inputs, a project check, values on cables, search, printable sheets; wire ends move by dragging
- Send signal / Use signal: name a signal (CLK, RESET) once and use it anywhere in the circuit without a wire; selecting one lights up all of them, a use with no sender shows dashed
- Inverted inputs: Alt + click an input (or the menu/settings) puts a bubble on it; it reads the signal inverted through one NAND, counted in every transistor total
- Check (Circuit tab): open inputs, parts that drive nothing, duplicate pin names, unsent or doubly sent signals, loops that never settle; click one to show it. Open inputs get an orange marker on the canvas. Components no other circuit uses are listed with a delete
- Cables show the number they carry (= 13 · 0x0D); hovering a wire tells where it runs and its value
- Ctrl+F finds parts, signals, panel rows, notes and components in every circuit, with where each component is used
- Ctrl+P prints the circuit as a sheet with a title block on white paper (or save as PDF); also as an SVG file
- + and − under a selected gate change its number of inputs; swaps keep bubbles in place
- Drag a wire by its end to move that end to another pin; drop a dragged wire on another wire to tap its signal or feed what it fed
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 11:26:59 +00:00
}
A pick pins for a cable, buttons on pointing, right-click on pins; docked panels move freely
- Pointing at a part shows its round buttons, as if it were selected; they
stay while the pointer goes to them.
- A box around some pins of one part (not over its middle), or Shift +
click on pins, picks exactly those pins: a cable plug on them, wire them
one by one, invert or unwire them, from buttons beside them or a
right-click.
- Right-click on a pin offers what can be done right there first: split a
component's cable socket into wires (or join), pull a cable out of a cable
end, invert an input.
- A docked panel moves both ways now: moved up or down off its component's
pins it lets go and stays a panel of its own (rows and wires kept);
moved sideways it stays docked.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-27 12:34:16 +00:00
if ( pinEl && e . shiftKey ) {
// Shift + click on a pin: in or out of the picked pins.
ed . pickPin ( pinEl . getAttribute ( 'data-node' ) ! , pinEl . getAttribute ( 'data-dir' ) as 'in' | 'out' , pinEl . getAttribute ( 'data-pin' ) ! )
return
}
2026-10-17 10:49:38 +00:00
if ( pinEl ) {
drag . value = {
kind : 'wire' ,
node : pinEl . getAttribute ( 'data-node' ) ! ,
pin : pinEl . getAttribute ( 'data-pin' ) ! ,
dir : pinEl . getAttribute ( 'data-dir' ) as 'in' | 'out' ,
A input panels, automatic names, one-by-one wiring, tidy routing, truth table export
- Input panel part: rows of switches, buttons and clocks. "Attach input
panel" docks one to a component with a row per free input; it moves
with the component and follows its pins.
- Copies and new pins continue name series (D0 -> D1, A -> B); unnamed
switches, lamps and pins take the name of the component pin they are
wired to.
- Connecting: target pins are ringed, dropping on a part uses its next
free pin, click-then-click works, and "Connect one by one" (W) wires a
selection's pins in turn.
- Tidy wiring option and "Tidy all wires": sorted, evenly spaced columns
per gap, one trunk per signal, fewer crossings.
- Truth table full screen, CSV download, copy as Markdown, current row
highlighted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 17:17:25 +00:00
start : w ,
2026-10-17 10:49:38 +00:00
cur : w ,
A input panels, automatic names, one-by-one wiring, tidy routing, truth table export
- Input panel part: rows of switches, buttons and clocks. "Attach input
panel" docks one to a component with a row per free input; it moves
with the component and follows its pins.
- Copies and new pins continue name series (D0 -> D1, A -> B); unnamed
switches, lamps and pins take the name of the component pin they are
wired to.
- Connecting: target pins are ringed, dropping on a part uses its next
free pin, click-then-click works, and "Connect one by one" (W) wires a
selection's pins in turn.
- Tidy wiring option and "Tidy all wires": sorted, evenly spaced columns
per gap, one trunk per signal, fewer crossings.
- Truth table full screen, CSV download, copy as Markdown, current row
highlighted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 17:17:25 +00:00
moved : false ,
2026-10-17 10:49:38 +00:00
}
return
}
A settings for every part, overlap-free wiring with crossing styles, accounts with sync
- Clicking anything opens its settings: swap parts in place (wires stay on
matching pins), clock frequency per clock, keyboard keys for switches and
buttons, lamp/display colours, note sizes, component names on the canvas,
position, unlink all wires, unpack a component, make an independent copy.
- Wires of different signals never share a line: auto routes pick free
columns or detours, remaining clashes go on separate lanes. Crossings drawn
as bow, triangle, bridge, gap or plain.
- Accounts (email + scrypt password, httpOnly session) with two-way project
sync and conflict copies; per-account limits; cross-site writes refused.
- Compatibility suite: a project and both browser-storage layouts from
release a241adc must load and compute identically.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-20 11:09:37 +00:00
const junctionEl = target . closest ( '[data-junction]' )
if ( junctionEl ) {
// A junction dot stands for its whole signal.
const src = junctionEl . getAttribute ( 'data-junction' )
ed . wireSel . value = def . value . wires . filter ( x => ` ${ x . from . node } : ${ x . from . pin } ` === src ) . map ( x => x . id )
ed . selection . value = [ ]
return
}
A component faces, project library with share links, fine-grained wire editing
- Lamps and hex displays inside a component show on its box with their
labels, lit by that instance's state; Counter 4 example shows its count.
- Several projects per browser; share links at /p/<id> that the creator's
edits save to automatically, others get their own copy. Export, open a
file as project, or add a file's components to the open project.
- Wires: drag any segment or corner, Alt+drag for a new bend, Ctrl+drag to
branch, double-click selects the whole signal, multi-select, arrow keys,
colour tags.
- Share-link API (POST/GET/PUT /api/p) on Nitro fs storage in data/, mounted
as a volume on edgerealm.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-17 11:21:49 +00:00
const wireEl = target . closest ( '[data-wire]' )
if ( wireEl ) return onWireDown ( e , wireEl , w )
2026-10-17 10:49:38 +00:00
const nodeEl = target . closest ( '[data-node]' )
if ( nodeEl ) {
const id = nodeEl . getAttribute ( 'data-node' ) !
const node = nodeMap . value . get ( id )
if ( ! node ) return
const multi = e . shiftKey || e . ctrlKey || e . metaKey
if ( multi ) {
ed . selection . value = selected . value . has ( id ) ? ed . selection . value . filter ( s => s !== id ) : [ ... ed . selection . value , id ]
} else if ( ! selected . value . has ( id ) ) {
ed . selection . value = [ id ]
A component faces, project library with share links, fine-grained wire editing
- Lamps and hex displays inside a component show on its box with their
labels, lit by that instance's state; Counter 4 example shows its count.
- Several projects per browser; share links at /p/<id> that the creator's
edits save to automatically, others get their own copy. Export, open a
file as project, or add a file's components to the open project.
- Wires: drag any segment or corner, Alt+drag for a new bend, Ctrl+drag to
branch, double-click selects the whole signal, multi-select, arrow keys,
colour tags.
- Share-link API (POST/GET/PUT /api/p) on Nitro fs storage in data/, mounted
as a volume on edgerealm.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-17 11:21:49 +00:00
ed . wireSel . value = [ ]
2026-10-17 10:49:38 +00:00
}
A input panels, automatic names, one-by-one wiring, tidy routing, truth table export
- Input panel part: rows of switches, buttons and clocks. "Attach input
panel" docks one to a component with a row per free input; it moves
with the component and follows its pins.
- Copies and new pins continue name series (D0 -> D1, A -> B); unnamed
switches, lamps and pins take the name of the component pin they are
wired to.
- Connecting: target pins are ringed, dropping on a part uses its next
free pin, click-then-click works, and "Connect one by one" (W) wires a
selection's pins in turn.
- Tidy wiring option and "Tidy all wires": sorted, evenly spaced columns
per gap, one trunk per signal, fewer crossings.
- Truth table full screen, CSV download, copy as Markdown, current row
highlighted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 17:17:25 +00:00
const rowId = target . closest ( '[data-row]' ) ? . getAttribute ( 'data-row' )
const row = rowId ? node . rows ? . find ( r => r . id === rowId ) : undefined
if ( ! row && isDoubleClick ( ` n: ${ id } ` ) ) return onDoubleClick ( node )
2026-10-17 10:49:38 +00:00
if ( node . kind === 'button' ) ed . press ( node , true )
A input panels, automatic names, one-by-one wiring, tidy routing, truth table export
- Input panel part: rows of switches, buttons and clocks. "Attach input
panel" docks one to a component with a row per free input; it moves
with the component and follows its pins.
- Copies and new pins continue name series (D0 -> D1, A -> B); unnamed
switches, lamps and pins take the name of the component pin they are
wired to.
- Connecting: target pins are ringed, dropping on a part uses its next
free pin, click-then-click works, and "Connect one by one" (W) wires a
selection's pins in turn.
- Tidy wiring option and "Tidy all wires": sorted, evenly spaced columns
per gap, one trunk per signal, fewer crossings.
- Truth table full screen, CSV download, copy as Markdown, current row
highlighted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 17:17:25 +00:00
if ( row && ! multi ) ed . pressRow ( node , row , true )
2026-10-21 09:51:45 +00:00
const ids = ed . withFollowers ( selected . value . has ( id ) ? ed . selection . value : [ id ] )
A input panels, automatic names, one-by-one wiring, tidy routing, truth table export
- Input panel part: rows of switches, buttons and clocks. "Attach input
panel" docks one to a component with a row per free input; it moves
with the component and follows its pins.
- Copies and new pins continue name series (D0 -> D1, A -> B); unnamed
switches, lamps and pins take the name of the component pin they are
wired to.
- Connecting: target pins are ringed, dropping on a part uses its next
free pin, click-then-click works, and "Connect one by one" (W) wires a
selection's pins in turn.
- Tidy wiring option and "Tidy all wires": sorted, evenly spaced columns
per gap, one trunk per signal, fewer crossings.
- Truth table full screen, CSV download, copy as Markdown, current row
highlighted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 17:17:25 +00:00
drag . value = {
kind : 'move' ,
start : w ,
2026-10-26 17:21:34 +00:00
orig : moveStart ( def . value , ids , ed . wireSel . value ) ,
at : [ 0 , 0 ] ,
A input panels, automatic names, one-by-one wiring, tidy routing, truth table export
- Input panel part: rows of switches, buttons and clocks. "Attach input
panel" docks one to a component with a row per free input; it moves
with the component and follows its pins.
- Copies and new pins continue name series (D0 -> D1, A -> B); unnamed
switches, lamps and pins take the name of the component pin they are
wired to.
- Connecting: target pins are ringed, dropping on a part uses its next
free pin, click-then-click works, and "Connect one by one" (W) wires a
selection's pins in turn.
- Tidy wiring option and "Tidy all wires": sorted, evenly spaced columns
per gap, one trunk per signal, fewer crossings.
- Truth table full screen, CSV download, copy as Markdown, current row
highlighted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 17:17:25 +00:00
moved : false ,
node ,
2026-10-28 12:05:57 +00:00
toggle : ( node . kind === 'input' || node . kind === 'keyboard' || ! ! row ) && ! multi ,
A input panels, automatic names, one-by-one wiring, tidy routing, truth table export
- Input panel part: rows of switches, buttons and clocks. "Attach input
panel" docks one to a component with a row per free input; it moves
with the component and follows its pins.
- Copies and new pins continue name series (D0 -> D1, A -> B); unnamed
switches, lamps and pins take the name of the component pin they are
wired to.
- Connecting: target pins are ringed, dropping on a part uses its next
free pin, click-then-click works, and "Connect one by one" (W) wires a
selection's pins in turn.
- Tidy wiring option and "Tidy all wires": sorted, evenly spaced columns
per gap, one trunk per signal, fewer crossings.
- Truth table full screen, CSV download, copy as Markdown, current row
highlighted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 17:17:25 +00:00
row ,
2026-10-28 12:30:07 +00:00
benchHit : benchHitAt ( target , node , multi ) ,
2026-10-21 10:16:26 +00:00
grabbed : selected . value . has ( id ) ? ed . selection . value . length : 1 ,
2026-10-17 10:49:38 +00:00
}
return
}
A component faces, project library with share links, fine-grained wire editing
- Lamps and hex displays inside a component show on its box with their
labels, lit by that instance's state; Counter 4 example shows its count.
- Several projects per browser; share links at /p/<id> that the creator's
edits save to automatically, others get their own copy. Export, open a
file as project, or add a file's components to the open project.
- Wires: drag any segment or corner, Alt+drag for a new bend, Ctrl+drag to
branch, double-click selects the whole signal, multi-select, arrow keys,
colour tags.
- Share-link API (POST/GET/PUT /api/p) on Nitro fs storage in data/, mounted
as a volume on edgerealm.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-17 11:21:49 +00:00
if ( ! e . shiftKey ) ed . clearSelection ( )
drag . value = { kind : 'box' , start : w , cur : w , nodes : [ ... ed . selection . value ] , wires : [ ... ed . wireSel . value ] }
}
function onWireDown ( e : PointerEvent , el : Element , w : Pt ) {
const wire = def . value . wires . find ( x => x . id === el . getAttribute ( 'data-wire' ) )
const route = wire && routeOf ( wire )
if ( ! wire || ! route ) return
const corner = el . getAttribute ( 'data-corner' )
if ( corner !== null ) {
drag . value = { kind : 'corner' , wire , route : route . pts . map ( p => [ ... p ] as Pt ) , i : Number ( corner ) , moved : false }
2026-10-17 10:49:38 +00:00
return
}
A Loxone-style working aids: named signals, inverted inputs, a project check, values on cables, search, printable sheets; wire ends move by dragging
- Send signal / Use signal: name a signal (CLK, RESET) once and use it anywhere in the circuit without a wire; selecting one lights up all of them, a use with no sender shows dashed
- Inverted inputs: Alt + click an input (or the menu/settings) puts a bubble on it; it reads the signal inverted through one NAND, counted in every transistor total
- Check (Circuit tab): open inputs, parts that drive nothing, duplicate pin names, unsent or doubly sent signals, loops that never settle; click one to show it. Open inputs get an orange marker on the canvas. Components no other circuit uses are listed with a delete
- Cables show the number they carry (= 13 · 0x0D); hovering a wire tells where it runs and its value
- Ctrl+F finds parts, signals, panel rows, notes and components in every circuit, with where each component is used
- Ctrl+P prints the circuit as a sheet with a title block on white paper (or save as PDF); also as an SVG file
- + and − under a selected gate change its number of inputs; swaps keep bubbles in place
- Drag a wire by its end to move that end to another pin; drop a dragged wire on another wire to tap its signal or feed what it fed
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 11:26:59 +00:00
const index = el . hasAttribute ( 'data-seg' ) ? Number ( el . getAttribute ( 'data-seg' ) ) : Math . max ( 0 , segmentAt ( route . pts , w , 1 ) )
A component faces, project library with share links, fine-grained wire editing
- Lamps and hex displays inside a component show on its box with their
labels, lit by that instance's state; Counter 4 example shows its count.
- Several projects per browser; share links at /p/<id> that the creator's
edits save to automatically, others get their own copy. Export, open a
file as project, or add a file's components to the open project.
- Wires: drag any segment or corner, Alt+drag for a new bend, Ctrl+drag to
branch, double-click selects the whole signal, multi-select, arrow keys,
colour tags.
- Share-link API (POST/GET/PUT /api/p) on Nitro fs storage in data/, mounted
as a volume on edgerealm.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-17 11:21:49 +00:00
if ( e . ctrlKey || e . metaKey ) {
// Branch: a new wire from the same signal, starting at this point.
A input panels, automatic names, one-by-one wiring, tidy routing, truth table export
- Input panel part: rows of switches, buttons and clocks. "Attach input
panel" docks one to a component with a row per free input; it moves
with the component and follows its pins.
- Copies and new pins continue name series (D0 -> D1, A -> B); unnamed
switches, lamps and pins take the name of the component pin they are
wired to.
- Connecting: target pins are ringed, dropping on a part uses its next
free pin, click-then-click works, and "Connect one by one" (W) wires a
selection's pins in turn.
- Tidy wiring option and "Tidy all wires": sorted, evenly spaced columns
per gap, one trunk per signal, fewer crossings.
- Truth table full screen, CSV download, copy as Markdown, current row
highlighted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 17:17:25 +00:00
drag . value = { kind : 'wire' , node : wire . from . node , pin : wire . from . pin , dir : 'out' , start : w , cur : w , moved : true , branch : branchCorners ( route . pts , index , w ) }
A component faces, project library with share links, fine-grained wire editing
- Lamps and hex displays inside a component show on its box with their
labels, lit by that instance's state; Counter 4 example shows its count.
- Several projects per browser; share links at /p/<id> that the creator's
edits save to automatically, others get their own copy. Export, open a
file as project, or add a file's components to the open project.
- Wires: drag any segment or corner, Alt+drag for a new bend, Ctrl+drag to
branch, double-click selects the whole signal, multi-select, arrow keys,
colour tags.
- Share-link API (POST/GET/PUT /api/p) on Nitro fs storage in data/, mounted
as a volume on edgerealm.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-17 11:21:49 +00:00
return
}
if ( e . shiftKey ) {
ed . wireSel . value = wireSelected . value . has ( wire . id ) ? ed . wireSel . value . filter ( id => id !== wire . id ) : [ ... ed . wireSel . value , wire . id ]
return
}
if ( isDoubleClick ( ` w: ${ wire . id } ` ) ) {
ed . selectNet ( wire . id )
2026-10-17 10:49:38 +00:00
ed . selection . value = [ ]
A component faces, project library with share links, fine-grained wire editing
- Lamps and hex displays inside a component show on its box with their
labels, lit by that instance's state; Counter 4 example shows its count.
- Several projects per browser; share links at /p/<id> that the creator's
edits save to automatically, others get their own copy. Export, open a
file as project, or add a file's components to the open project.
- Wires: drag any segment or corner, Alt+drag for a new bend, Ctrl+drag to
branch, double-click selects the whole signal, multi-select, arrow keys,
colour tags.
- Share-link API (POST/GET/PUT /api/p) on Nitro fs storage in data/, mounted
as a volume on edgerealm.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-17 11:21:49 +00:00
return
2026-10-17 10:49:38 +00:00
}
A Loxone-style working aids: named signals, inverted inputs, a project check, values on cables, search, printable sheets; wire ends move by dragging
- Send signal / Use signal: name a signal (CLK, RESET) once and use it anywhere in the circuit without a wire; selecting one lights up all of them, a use with no sender shows dashed
- Inverted inputs: Alt + click an input (or the menu/settings) puts a bubble on it; it reads the signal inverted through one NAND, counted in every transistor total
- Check (Circuit tab): open inputs, parts that drive nothing, duplicate pin names, unsent or doubly sent signals, loops that never settle; click one to show it. Open inputs get an orange marker on the canvas. Components no other circuit uses are listed with a delete
- Cables show the number they carry (= 13 · 0x0D); hovering a wire tells where it runs and its value
- Ctrl+F finds parts, signals, panel rows, notes and components in every circuit, with where each component is used
- Ctrl+P prints the circuit as a sheet with a title block on white paper (or save as PDF); also as an SVG file
- + and − under a selected gate change its number of inputs; swaps keep bubbles in place
- Drag a wire by its end to move that end to another pin; drop a dragged wire on another wire to tap its signal or feed what it fed
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 11:26:59 +00:00
// Grabbing a wire by its end (the grip, or close to the pin) moves that end to another pin.
const end = ( el . getAttribute ( 'data-end' ) as 'from' | 'to' | null ) ? ? ( e . altKey ? null : nearEnd ( route . pts , w ) )
if ( end && ! isCable ( wire ) ) {
const stay = end === 'to' ? wire . from : wire . to
drag . value = { kind : 'wire' , node : stay . node , pin : stay . pin , dir : end === 'to' ? 'out' : 'in' , start : w , cur : w , moved : false , replace : wire . id }
ed . wireSel . value = [ wire . id ]
ed . selection . value = [ ]
return
}
A component faces, project library with share links, fine-grained wire editing
- Lamps and hex displays inside a component show on its box with their
labels, lit by that instance's state; Counter 4 example shows its count.
- Several projects per browser; share links at /p/<id> that the creator's
edits save to automatically, others get their own copy. Export, open a
file as project, or add a file's components to the open project.
- Wires: drag any segment or corner, Alt+drag for a new bend, Ctrl+drag to
branch, double-click selects the whole signal, multi-select, arrow keys,
colour tags.
- Share-link API (POST/GET/PUT /api/p) on Nitro fs storage in data/, mounted
as a volume on edgerealm.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-17 11:21:49 +00:00
if ( ! wireSelected . value . has ( wire . id ) ) {
ed . wireSel . value = [ wire . id ]
ed . selection . value = [ ]
}
const prep = e . altKey ? splitDrag ( route . pts , index , w ) : segmentDrag ( route . pts , index )
if ( prep ) drag . value = { kind : 'segment' , wire , ... prep , start : w [ prep . axis ] , moved : false }
2026-10-17 10:49:38 +00:00
}
function onPointerMove ( e : PointerEvent ) {
A finer component boxes, a regrouped parts list with keyboard search, a real green for wires and cables
- Box designer: drag pins up or down to open gaps between groups; size (+/−) and turn (R) lamps, displays, screens and drawings; pixels belong to named screens, each placed on its own; displays of the components inside can be shown on the box (off unless ticked); a list of everything the box can show, each optional; the box grows to hold what it shows
- Lamps and displays deep inside placed components light up on the box
- Parts list: one search box for parts and components (letters in order match too), recently placed parts first, grouped Logic / Inputs / Outputs / Wiring / Notes, then components by group; groups fold away
- Keys: / searches the parts list (Enter starts placing), Shift+A or Ctrl+K adds a part at the mouse
- Wires and cables get a green; the default swatch shows grey, as the default really is
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-22 04:48:42 +00:00
lastClient = { x : e . clientX , y : e . clientY }
2026-10-17 10:49:38 +00:00
const w = toWorld ( e )
cursor . value = w
2026-10-21 12:21:40 +00:00
altDown . value = e . altKey
2026-10-17 10:49:38 +00:00
const d = drag . value
A pick pins for a cable, buttons on pointing, right-click on pins; docked panels move freely
- Pointing at a part shows its round buttons, as if it were selected; they
stay while the pointer goes to them.
- A box around some pins of one part (not over its middle), or Shift +
click on pins, picks exactly those pins: a cable plug on them, wire them
one by one, invert or unwire them, from buttons beside them or a
right-click.
- Right-click on a pin offers what can be done right there first: split a
component's cable socket into wires (or join), pull a cable out of a cable
end, invert an input.
- A docked panel moves both ways now: moved up or down off its component's
pins it lets go and stays a panel of its own (rows and wires kept);
moved sideways it stays docked.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-27 12:34:16 +00:00
if ( ! d ) return trackHover ( e . target as Element )
2026-10-17 10:49:38 +00:00
switch ( d . kind ) {
case 'pan' :
ed . views [ def . value . id ] = { ... view . value , x : d . vx + e . clientX - d . sx , y : d . vy + e . clientY - d . sy }
break
case 'move' : {
const dx = Math . round ( w [ 0 ] - d . start [ 0 ] )
const dy = Math . round ( w [ 1 ] - d . start [ 1 ] )
if ( ! d . moved && ( dx || dy ) ) {
d . moved = true
if ( d . node . kind === 'button' ) ed . press ( d . node , false )
A input panels, automatic names, one-by-one wiring, tidy routing, truth table export
- Input panel part: rows of switches, buttons and clocks. "Attach input
panel" docks one to a component with a row per free input; it moves
with the component and follows its pins.
- Copies and new pins continue name series (D0 -> D1, A -> B); unnamed
switches, lamps and pins take the name of the component pin they are
wired to.
- Connecting: target pins are ringed, dropping on a part uses its next
free pin, click-then-click works, and "Connect one by one" (W) wires a
selection's pins in turn.
- Tidy wiring option and "Tidy all wires": sorted, evenly spaced columns
per gap, one trunk per signal, fewer crossings.
- Truth table full screen, CSV download, copy as Markdown, current row
highlighted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 17:17:25 +00:00
if ( d . row ) ed . pressRow ( d . node , d . row , false )
2026-10-26 17:21:34 +00:00
const moving = def . value . nodes . filter ( n => d . orig . nodes . has ( n . id ) )
d . still = dropPins ( def . value , def . value . nodes . filter ( n => ! d . orig . nodes . has ( n . id ) ) , n => shapes . value . get ( n . id ) ! )
2026-10-21 10:16:26 +00:00
d . from = dropPins ( def . value , moving , n => shapes . value . get ( n . id ) ! )
}
if ( d . still && d . from ) {
// Dropped onto pins it can join, it connects there (Alt: just place it).
A pick pins for a cable, buttons on pointing, right-click on pins; docked panels move freely
- Pointing at a part shows its round buttons, as if it were selected; they
stay while the pointer goes to them.
- A box around some pins of one part (not over its middle), or Shift +
click on pins, picks exactly those pins: a cable plug on them, wire them
one by one, invert or unwire them, from buttons beside them or a
right-click.
- Right-click on a pin offers what can be done right there first: split a
component's cable socket into wires (or join), pull a cable out of a cable
end, invert an input.
- A docked panel moves both ways now: moved up or down off its component's
pins it lets go and stays a panel of its own (rows and wires kept);
moved sideways it stays docked.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-27 12:34:16 +00:00
const at = d . from . map ( p => ( { ... p , x : p . x + dx , y : p . y + dy } ) )
2026-10-21 10:16:26 +00:00
d . snap = e . altKey ? null : dropLinks ( at , d . still , d . grabbed === 1 ? 1 : 0 )
2026-10-17 10:49:38 +00:00
}
2026-10-26 17:21:34 +00:00
if ( dx !== d . at [ 0 ] || dy !== d . at [ 1 ] ) {
d . at = [ dx , dy ]
moveTo ( d . orig , dx , dy )
2026-10-17 10:49:38 +00:00
}
2026-10-26 17:21:34 +00:00
d . plug = d . moved && d . grabbed === 1 && ! e . altKey ? plugNear ( d . node ) : null
2026-10-17 10:49:38 +00:00
break
}
case 'wire' :
d . cur = w
A input panels, automatic names, one-by-one wiring, tidy routing, truth table export
- Input panel part: rows of switches, buttons and clocks. "Attach input
panel" docks one to a component with a row per free input; it moves
with the component and follows its pins.
- Copies and new pins continue name series (D0 -> D1, A -> B); unnamed
switches, lamps and pins take the name of the component pin they are
wired to.
- Connecting: target pins are ringed, dropping on a part uses its next
free pin, click-then-click works, and "Connect one by one" (W) wires a
selection's pins in turn.
- Tidy wiring option and "Tidy all wires": sorted, evenly spaced columns
per gap, one trunk per signal, fewer crossings.
- Truth table full screen, CSV download, copy as Markdown, current row
highlighted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 17:17:25 +00:00
if ( Math . hypot ( w [ 0 ] - d . start [ 0 ] , w [ 1 ] - d . start [ 1 ] ) > 0.4 ) d . moved = true
2026-10-17 10:49:38 +00:00
break
case 'box' : {
d . cur = w
const x0 = Math . min ( d . start [ 0 ] , w [ 0 ] )
const x1 = Math . max ( d . start [ 0 ] , w [ 0 ] )
const y0 = Math . min ( d . start [ 1 ] , w [ 1 ] )
const y1 = Math . max ( d . start [ 1 ] , w [ 1 ] )
A component faces, project library with share links, fine-grained wire editing
- Lamps and hex displays inside a component show on its box with their
labels, lit by that instance's state; Counter 4 example shows its count.
- Several projects per browser; share links at /p/<id> that the creator's
edits save to automatically, others get their own copy. Export, open a
file as project, or add a file's components to the open project.
- Wires: drag any segment or corner, Alt+drag for a new bend, Ctrl+drag to
branch, double-click selects the whole signal, multi-select, arrow keys,
colour tags.
- Share-link API (POST/GET/PUT /api/p) on Nitro fs storage in data/, mounted
as a volume on edgerealm.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-17 11:21:49 +00:00
const nodes = def . value . nodes
2026-10-17 10:49:38 +00:00
. filter ( n => {
const b = shapes . value . get ( n . id ) ! . body
return n . x + b . x < x1 && n . x + b . x + b . w > x0 && n . y + b . y < y1 && n . y + b . y + b . h > y0
} )
. map ( n => n . id )
2026-10-21 09:08:32 +00:00
// Dragged right to left, or across wires without touching any part: every wire the box
// crosses. Otherwise only wires lying fully inside, so a box over some parts doesn't
// catch (and on Delete remove) unrelated wires passing through.
A pick pins for a cable, buttons on pointing, right-click on pins; docked panels move freely
- Pointing at a part shows its round buttons, as if it were selected; they
stay while the pointer goes to them.
- A box around some pins of one part (not over its middle), or Shift +
click on pins, picks exactly those pins: a cable plug on them, wire them
one by one, invert or unwire them, from buttons beside them or a
right-click.
- Right-click on a pin offers what can be done right there first: split a
component's cable socket into wires (or join), pull a cable out of a cable
end, invert an input.
- A docked panel moves both ways now: moved up or down off its component's
pins it lets go and stays a panel of its own (rows and wires kept);
moved sideways it stays docked.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-27 12:34:16 +00:00
// Around pins of one part, all inputs or all outputs, and not over its middle: those pins.
const pinsIn = allPins . value . filter ( p => ! p . bus && p . x > x0 && p . x < x1 && p . y > y0 && p . y < y1 )
const owner = pinsIn [ 0 ] ? . node
const host = owner ? nodeMap . value . get ( owner ) : undefined
if ( host && pinsIn . every ( p => p . node === owner && p . dir === pinsIn [ 0 ] ! . dir ) && nodes . every ( id => id === owner ) ) {
const b = shapes . value . get ( owner ! ) ! . body
const cx = host . x + b . x + b . w / 2
const cy = host . y + b . y + b . h / 2
if ( ! ( cx > x0 && cx < x1 && cy > y0 && cy < y1 ) ) {
ed . pickPins ( owner ! , pinsIn [ 0 ] ! . dir , pinsIn . map ( p => p . pin ) )
break
}
}
if ( ed . pinSel . value ) ed . pinSel . value = null
2026-10-21 09:08:32 +00:00
const box = { x0 , y0 , x1 , y1 }
const crossing = w [ 0 ] < d . start [ 0 ] || ! nodes . length
const wires = routes . value
. filter ( r => ( crossing ? routeTouchesBox ( r . pts , box ) : r . pts . every ( ( [ x , y ] ) => x >= x0 && x <= x1 && y >= y0 && y <= y1 ) ) )
. map ( r => r . wire . id )
A component faces, project library with share links, fine-grained wire editing
- Lamps and hex displays inside a component show on its box with their
labels, lit by that instance's state; Counter 4 example shows its count.
- Several projects per browser; share links at /p/<id> that the creator's
edits save to automatically, others get their own copy. Export, open a
file as project, or add a file's components to the open project.
- Wires: drag any segment or corner, Alt+drag for a new bend, Ctrl+drag to
branch, double-click selects the whole signal, multi-select, arrow keys,
colour tags.
- Share-link API (POST/GET/PUT /api/p) on Nitro fs storage in data/, mounted
as a volume on edgerealm.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-17 11:21:49 +00:00
ed . selection . value = [ ... new Set ( [ ... d . nodes , ... nodes ] ) ]
ed . wireSel . value = [ ... new Set ( [ ... d . wires , ... wires ] ) ]
2026-10-17 10:49:38 +00:00
break
}
case 'segment' : {
const delta = Math . round ( w [ d . axis ] - d . start )
A component faces, project library with share links, fine-grained wire editing
- Lamps and hex displays inside a component show on its box with their
labels, lit by that instance's state; Counter 4 example shows its count.
- Several projects per browser; share links at /p/<id> that the creator's
edits save to automatically, others get their own copy. Export, open a
file as project, or add a file's components to the open project.
- Wires: drag any segment or corner, Alt+drag for a new bend, Ctrl+drag to
branch, double-click selects the whole signal, multi-select, arrow keys,
colour tags.
- Share-link API (POST/GET/PUT /api/p) on Nitro fs storage in data/, mounted
as a volume on edgerealm.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-17 11:21:49 +00:00
if ( ! delta && ! d . moved ) break
d . moved = true
d . wire . pts = moveSegment ( d . base , d . k , d . axis , delta )
break
}
case 'corner' : {
const to : Pt = [ Math . round ( w [ 0 ] ) , Math . round ( w [ 1 ] ) ]
const at = d . route [ d . i ] !
if ( ! d . moved && to [ 0 ] === at [ 0 ] && to [ 1 ] === at [ 1 ] ) break
d . moved = true
d . wire . pts = moveCorner ( d . route , d . i , to )
2026-10-17 10:49:38 +00:00
break
}
}
}
A input panels, automatic names, one-by-one wiring, tidy routing, truth table export
- Input panel part: rows of switches, buttons and clocks. "Attach input
panel" docks one to a component with a row per free input; it moves
with the component and follows its pins.
- Copies and new pins continue name series (D0 -> D1, A -> B); unnamed
switches, lamps and pins take the name of the component pin they are
wired to.
- Connecting: target pins are ringed, dropping on a part uses its next
free pin, click-then-click works, and "Connect one by one" (W) wires a
selection's pins in turn.
- Tidy wiring option and "Tidy all wires": sorted, evenly spaced columns
per gap, one trunk per signal, fewer crossings.
- Truth table full screen, CSV download, copy as Markdown, current row
highlighted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 17:17:25 +00:00
/** Pin keys that already have a wire, as "node:pin": inputs by their wire, outputs by any wire. */
const linked = computed ( ( ) => {
const ins = new Set < string > ( )
const outs = new Set < string > ( )
for ( const w of def . value . wires ) {
ins . add ( ` ${ w . to . node } : ${ w . to . pin } ` )
outs . add ( ` ${ w . from . node } : ${ w . from . pin } ` )
}
return { in : ins , out : outs }
} )
2026-10-20 18:15:38 +00:00
/ * *
* Names to show , dimmed , on switches , buttons , clocks , lamps and output pins
* that have none of their own : the component pin they are wired to .
* /
const hints = computed ( ( ) => {
const out = new Map < string , string > ( )
const nodes = nodeMap . value
for ( const w of def . value . wires ) {
const from = nodes . get ( w . from . node )
const to = nodes . get ( w . to . node )
if ( ! from || ! to ) continue
if ( SOURCES . has ( from . kind ) && ( from . autoLabel || ! from . label ? . trim ( ) ) && ! out . has ( from . id ) ) {
const name = pinName ( to , w . to . pin , ed . getDef . value )
if ( name ) out . set ( from . id , name )
}
if ( SINKS . has ( to . kind ) && ( to . autoLabel || ! to . label ? . trim ( ) ) && ! out . has ( to . id ) ) {
const name = pinName ( from , w . from . pin , ed . getDef . value )
if ( name ) out . set ( to . id , name )
}
}
return out
} )
A Loxone-style working aids: named signals, inverted inputs, a project check, values on cables, search, printable sheets; wire ends move by dragging
- Send signal / Use signal: name a signal (CLK, RESET) once and use it anywhere in the circuit without a wire; selecting one lights up all of them, a use with no sender shows dashed
- Inverted inputs: Alt + click an input (or the menu/settings) puts a bubble on it; it reads the signal inverted through one NAND, counted in every transistor total
- Check (Circuit tab): open inputs, parts that drive nothing, duplicate pin names, unsent or doubly sent signals, loops that never settle; click one to show it. Open inputs get an orange marker on the canvas. Components no other circuit uses are listed with a delete
- Cables show the number they carry (= 13 · 0x0D); hovering a wire tells where it runs and its value
- Ctrl+F finds parts, signals, panel rows, notes and components in every circuit, with where each component is used
- Ctrl+P prints the circuit as a sheet with a title block on white paper (or save as PDF); also as an SVG file
- + and − under a selected gate change its number of inputs; swaps keep bubbles in place
- Drag a wire by its end to move that end to another pin; drop a dragged wire on another wire to tap its signal or feed what it fed
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 11:26:59 +00:00
/** Inputs with no wire, marked like Loxone does: they read 0. */
const openPins = computed ( ( ) => {
const out = new Map < string , Set < string > > ( )
for ( const n of def . value . nodes ) {
if ( ! CHECKED _INPUTS . has ( n . kind ) ) continue
BF split ports: no wire against the cable, pins that stay put, lines kept on unpack
A wire dropped on a socket with a cable in it only takes a line coming
out; the lines going in are the cable's, so it no longer drives one
against the cable. Wired by hand anyway, the check calls that an error,
like a signal sent by two parts. A line going in with neither a wire nor
a cable gets the usual "not connected (reads 0)" warning and marker.
While a wire is drawn over a socket it ends on the socket, where it goes
when let go, not on the pin below. Splitting or joining a port no longer
moves the pins on the other side of the box. Pins on their usual edge
come first, so a wire dropped on the box body takes those, and the cable
button only offers pins whose cable end sits outside the box.
Unpacking a component joins wires on its split lines to the parts that
used the line inside; wires that had nowhere to go are counted in a
notice. Docked panels line up with the moved ports when a project is
opened, not at the next edit.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 17:38:32 +00:00
// A line of a split port is fed by the cable when one is in its socket.
const cabled = ( port : string ) => linked . value . in . has ( ` ${ n . id } : ${ port } ` ) || linked . value . out . has ( ` ${ n . id } : ${ port } ` )
const open = shapes . value . get ( n . id ) ! . inputs . filter ( p => ! p . bus && ! ( p . port && cabled ( p . port ) ) && ! linked . value . in . has ( ` ${ n . id } : ${ p . key } ` ) ) . map ( p => p . key )
A Loxone-style working aids: named signals, inverted inputs, a project check, values on cables, search, printable sheets; wire ends move by dragging
- Send signal / Use signal: name a signal (CLK, RESET) once and use it anywhere in the circuit without a wire; selecting one lights up all of them, a use with no sender shows dashed
- Inverted inputs: Alt + click an input (or the menu/settings) puts a bubble on it; it reads the signal inverted through one NAND, counted in every transistor total
- Check (Circuit tab): open inputs, parts that drive nothing, duplicate pin names, unsent or doubly sent signals, loops that never settle; click one to show it. Open inputs get an orange marker on the canvas. Components no other circuit uses are listed with a delete
- Cables show the number they carry (= 13 · 0x0D); hovering a wire tells where it runs and its value
- Ctrl+F finds parts, signals, panel rows, notes and components in every circuit, with where each component is used
- Ctrl+P prints the circuit as a sheet with a title block on white paper (or save as PDF); also as an SVG file
- + and − under a selected gate change its number of inputs; swaps keep bubbles in place
- Drag a wire by its end to move that end to another pin; drop a dragged wire on another wire to tap its signal or feed what it fed
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 11:26:59 +00:00
if ( open . length ) out . set ( n . id , new Set ( open ) )
}
return out
} )
/** The signal of the one selected tag or reference: all of its tags and references light up. */
const signalSel = computed ( ( ) => {
if ( ed . selection . value . length !== 1 ) return ''
const n = nodeMap . value . get ( ed . selection . value [ 0 ] ! )
return n && ( n . kind === 'tag' || n . kind === 'ref' ) ? ( n . label ? . trim ( ) ? ? '' ) : ''
} )
2026-10-20 18:15:38 +00:00
const SOURCES = new Set ( [ 'input' , 'button' , 'clock' ] )
const SINKS = new Set ( [ 'output' , 'lamp' ] )
A input panels, automatic names, one-by-one wiring, tidy routing, truth table export
- Input panel part: rows of switches, buttons and clocks. "Attach input
panel" docks one to a component with a row per free input; it moves
with the component and follows its pins.
- Copies and new pins continue name series (D0 -> D1, A -> B); unnamed
switches, lamps and pins take the name of the component pin they are
wired to.
- Connecting: target pins are ringed, dropping on a part uses its next
free pin, click-then-click works, and "Connect one by one" (W) wires a
selection's pins in turn.
- Tidy wiring option and "Tidy all wires": sorted, evenly spaced columns
per gap, one trunk per signal, fewer crossings.
- Truth table full screen, CSV download, copy as Markdown, current row
highlighted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 17:17:25 +00:00
/** The part whose body is under the point; the one drawn on top wins. */
function nodeAt ( at : Pt ) : CircuitNode | undefined {
const list = def . value . nodes
for ( let i = list . length - 1 ; i >= 0 ; i -- ) {
const n = list [ i ] !
if ( n . kind === 'note' ) continue
const b = shapes . value . get ( n . id ) ! . body
if ( at [ 0 ] >= n . x + b . x - 0.3 && at [ 0 ] <= n . x + b . x + b . w + 0.3 && at [ 1 ] >= n . y + b . y - 0.3 && at [ 1 ] <= n . y + b . y + b . h + 0.3 ) return n
}
return undefined
}
2026-10-26 21:45:47 +00:00
/** The cable pin of a cable end that a cable can be pulled out of: a bundle's always, a split's while it has no cable. */
function pullable ( d : { node : string ; pin : string ; dir : 'in' | 'out' } ) : CircuitNode | undefined {
const n = nodeMap . value . get ( d . node )
if ( ! n || ed . pinKind ( d . node , d . pin , d . dir ) !== 'bus' ) return undefined
if ( n . kind === 'bundle' || ( n . kind === 'split' && ! linked . value . in . has ( ` ${ n . id } :a ` ) ) ) return n
return undefined
}
/ * *
* Where the other end of a cable pulled out of a cable end goes when let
* go at ` cur ` : over a part ' s pins ( or its body ) , its wires land on them
* from the pin under the mouse on ; elsewhere its cable pin is at the mouse .
* /
function pullEnd ( d : { node : string ; pin : string ; dir : 'in' | 'out' ; cur : Pt } ) : { x : number ; y : number ; links : Link [ ] } | null {
const from = pullable ( d )
if ( ! from ) return null
const end : CircuitNode = { id : 'ghost' , kind : from . kind === 'bundle' ? 'split' : 'bundle' , bits : cableBits ( from ) , x : 0 , y : 0 }
const s = ed . shape ( end )
const wires = end . kind === 'split' ? s . outputs : s . inputs
const pin = targetAt ( d . cur , end . kind === 'split' ? 'in' : 'out' )
const host = pin && nodeMap . value . get ( pin . node )
const at = host && pinPos ( host , shapes . value . get ( host . id ) ! , pin . pin , end . kind === 'split' ? 'in' : 'out' )
if ( at ) {
end . x = at . x - wires [ 0 ] ! . dx
end . y = at . y - wires [ 0 ] ! . dy
const links = ( dropLinks ( dropPins ( def . value , [ end ] , ( ) => s ) , allPins . value , 0 ) ? . links ? ? [ ] ) . filter ( l => [ l . from , l . to ] . some ( r => r . node === 'ghost' && r . pin !== 'a' && r . pin !== 'q' ) )
if ( links . length ) return { x : end . x , y : end . y , links }
}
const bus = end . kind === 'split' ? s . inputs [ 0 ] ! : s . outputs [ 0 ] !
return { x : Math . round ( d . cur [ 0 ] ) - bus . dx , y : Math . round ( d . cur [ 1 ] ) - bus . dy , links : [ ] }
}
A input panels, automatic names, one-by-one wiring, tidy routing, truth table export
- Input panel part: rows of switches, buttons and clocks. "Attach input
panel" docks one to a component with a row per free input; it moves
with the component and follows its pins.
- Copies and new pins continue name series (D0 -> D1, A -> B); unnamed
switches, lamps and pins take the name of the component pin they are
wired to.
- Connecting: target pins are ringed, dropping on a part uses its next
free pin, click-then-click works, and "Connect one by one" (W) wires a
selection's pins in turn.
- Tidy wiring option and "Tidy all wires": sorted, evenly spaced columns
per gap, one trunk per signal, fewer crossings.
- Truth table full screen, CSV download, copy as Markdown, current row
highlighted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 17:17:25 +00:00
/ * *
* Where a wire would go : a pin of the wanted direction close to the point ,
* else , over a part , that part ' s first free pin ( or its nearest one when
* all are taken ) . So dropping a wire anywhere on a component works .
* /
2026-10-22 16:59:56 +00:00
function targetAt ( at : Pt , dir : 'in' | 'out' , bus = '' ) : PinRef | null {
A input panels, automatic names, one-by-one wiring, tidy routing, truth table export
- Input panel part: rows of switches, buttons and clocks. "Attach input
panel" docks one to a component with a row per free input; it moves
with the component and follows its pins.
- Copies and new pins continue name series (D0 -> D1, A -> B); unnamed
switches, lamps and pins take the name of the component pin they are
wired to.
- Connecting: target pins are ringed, dropping on a part uses its next
free pin, click-then-click works, and "Connect one by one" (W) wires a
selection's pins in turn.
- Tidy wiring option and "Tidy all wires": sorted, evenly spaced columns
per gap, one trunk per signal, fewer crossings.
- Truth table full screen, CSV download, copy as Markdown, current row
highlighted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 17:17:25 +00:00
let best : PinRef | null = null
let bestD = 1.1 * 1.1
2026-10-17 10:49:38 +00:00
for ( const n of def . value . nodes ) {
const s = shapes . value . get ( n . id ) !
for ( const p of dir === 'in' ? s . inputs : s . outputs ) {
2026-10-22 16:59:56 +00:00
if ( pinKindOf ( p ) !== bus ) continue
2026-10-17 10:49:38 +00:00
const dx = n . x + p . dx - at [ 0 ]
const dy = n . y + p . dy - at [ 1 ]
const dd = dx * dx + dy * dy
if ( dd < bestD ) {
bestD = dd
best = { node : n . id , pin : p . key }
}
}
}
A input panels, automatic names, one-by-one wiring, tidy routing, truth table export
- Input panel part: rows of switches, buttons and clocks. "Attach input
panel" docks one to a component with a row per free input; it moves
with the component and follows its pins.
- Copies and new pins continue name series (D0 -> D1, A -> B); unnamed
switches, lamps and pins take the name of the component pin they are
wired to.
- Connecting: target pins are ringed, dropping on a part uses its next
free pin, click-then-click works, and "Connect one by one" (W) wires a
selection's pins in turn.
- Tidy wiring option and "Tidy all wires": sorted, evenly spaced columns
per gap, one trunk per signal, fewer crossings.
- Truth table full screen, CSV download, copy as Markdown, current row
highlighted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 17:17:25 +00:00
if ( best ) return best
const n = nodeAt ( at )
if ( ! n ) return null
2026-10-22 16:59:56 +00:00
const pins = ( dir === 'in' ? shapes . value . get ( n . id ) ! . inputs : shapes . value . get ( n . id ) ! . outputs ) . filter ( p => pinKindOf ( p ) === bus )
A input panels, automatic names, one-by-one wiring, tidy routing, truth table export
- Input panel part: rows of switches, buttons and clocks. "Attach input
panel" docks one to a component with a row per free input; it moves
with the component and follows its pins.
- Copies and new pins continue name series (D0 -> D1, A -> B); unnamed
switches, lamps and pins take the name of the component pin they are
wired to.
- Connecting: target pins are ringed, dropping on a part uses its next
free pin, click-then-click works, and "Connect one by one" (W) wires a
selection's pins in turn.
- Tidy wiring option and "Tidy all wires": sorted, evenly spaced columns
per gap, one trunk per signal, fewer crossings.
- Truth table full screen, CSV download, copy as Markdown, current row
highlighted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 17:17:25 +00:00
if ( ! pins . length ) return null
const taken = linked . value [ dir ]
const free = pins . find ( p => ! taken . has ( ` ${ n . id } : ${ p . key } ` ) )
if ( free ) return { node : n . id , pin : free . key }
const near = pins . reduce ( ( a , p ) => ( Math . abs ( n . y + p . dy - at [ 1 ] ) < Math . abs ( n . y + a . dy - at [ 1 ] ) ? p : a ) )
return { node : n . id , pin : near . key }
2026-10-17 10:49:38 +00:00
}
A ports on top of the box, split into lines to wire by hand
On a component's box every connector port now sits at the very top of its
side, above the single pins, in auto and hand-drawn boxes alike. A port
can be split on one placed component (its settings or right click: Split
… into lines): right below the socket the box then gets a pin per line,
named after the line, so lines can be wired by hand without an adapter.
Lines going into the component are inputs, lines coming out outputs, each
facing out of its side; a bar in the type's colour ties them to the
socket. A cable still plugs into the socket at the same time. Dropping a
single wire on a socket (or clicking one while connecting) splits the
port and takes the first free line that runs that way. Join … lines
takes the line pins and their wires away again, as one undo step.
A line wired by hand joins the same net the cable's line reaches inside;
a wire and a cable on one line both drive it, and the check says so.
Line pins are left out of the open-input warning, docked panels and
bubbles; docked panels no longer get a row for a port's socket either.
Saved as an optional list on the placed component (splitPorts); without
it a box only has its ports moved to the top.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 17:08:27 +00:00
/ * *
* Port sockets on components ' boxes , not split yet , that a single wire can
* go onto ( the port then splits into its lines ) : with a free line going in ,
* for a wire from an output , or a line coming out , for a wire to an input .
* /
const openSockets = computed ( ( ) => {
BF split ports: no wire against the cable, pins that stay put, lines kept on unpack
A wire dropped on a socket with a cable in it only takes a line coming
out; the lines going in are the cable's, so it no longer drives one
against the cable. Wired by hand anyway, the check calls that an error,
like a signal sent by two parts. A line going in with neither a wire nor
a cable gets the usual "not connected (reads 0)" warning and marker.
While a wire is drawn over a socket it ends on the socket, where it goes
when let go, not on the pin below. Splitting or joining a port no longer
moves the pins on the other side of the box. Pins on their usual edge
come first, so a wire dropped on the box body takes those, and the cable
button only offers pins whose cable end sits outside the box.
Unpacking a component joins wires on its split lines to the parts that
used the line inside; wires that had nowhere to go are counted in a
notice. Docked panels line up with the moved ports when a project is
opened, not at the next edit.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 17:38:32 +00:00
const out : Record < 'in' | 'out' , { node : string ; port : string ; x : number ; y : number ; face : 1 | - 1 } [ ] > = { in : [ ] , out : [ ] }
A ports on top of the box, split into lines to wire by hand
On a component's box every connector port now sits at the very top of its
side, above the single pins, in auto and hand-drawn boxes alike. A port
can be split on one placed component (its settings or right click: Split
… into lines): right below the socket the box then gets a pin per line,
named after the line, so lines can be wired by hand without an adapter.
Lines going into the component are inputs, lines coming out outputs, each
facing out of its side; a bar in the type's colour ties them to the
socket. A cable still plugs into the socket at the same time. Dropping a
single wire on a socket (or clicking one while connecting) splits the
port and takes the first free line that runs that way. Join … lines
takes the line pins and their wires away again, as one undo step.
A line wired by hand joins the same net the cable's line reaches inside;
a wire and a cable on one line both drive it, and the check says so.
Line pins are left out of the open-input warning, docked panels and
bubbles; docked panels no longer get a row for a port's socket either.
Saved as an optional list on the placed component (splitPorts); without
it a box only has its ports moved to the top.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 17:08:27 +00:00
for ( const n of def . value . nodes ) {
if ( n . kind !== 'chip' ) continue
const s = shapes . value . get ( n . id ) !
for ( const p of [ ... s . inputs , ... s . outputs ] ) {
if ( ! p . conn || n . splitPorts ? . includes ( p . key ) ) continue
BF split ports: no wire against the cable, pins that stay put, lines kept on unpack
A wire dropped on a socket with a cable in it only takes a line coming
out; the lines going in are the cable's, so it no longer drives one
against the cable. Wired by hand anyway, the check calls that an error,
like a signal sent by two parts. A line going in with neither a wire nor
a cable gets the usual "not connected (reads 0)" warning and marker.
While a wire is drawn over a socket it ends on the socket, where it goes
when let go, not on the pin below. Splitting or joining a port no longer
moves the pins on the other side of the box. Pins on their usual edge
come first, so a wire dropped on the box body takes those, and the cable
button only offers pins whose cable end sits outside the box.
Unpacking a component joins wires on its split lines to the parts that
used the line inside; wires that had nowhere to go are counted in a
notice. Docked panels line up with the moved ports when a project is
opened, not at the next edit.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 17:38:32 +00:00
const at = { node : n . id , port : p . key , x : n . x + p . dx , y : n . y + p . dy , face : p . dx > 0 ? ( 1 as const ) : ( - 1 as const ) }
A ports on top of the box, split into lines to wire by hand
On a component's box every connector port now sits at the very top of its
side, above the single pins, in auto and hand-drawn boxes alike. A port
can be split on one placed component (its settings or right click: Split
… into lines): right below the socket the box then gets a pin per line,
named after the line, so lines can be wired by hand without an adapter.
Lines going into the component are inputs, lines coming out outputs, each
facing out of its side; a bar in the type's colour ties them to the
socket. A cable still plugs into the socket at the same time. Dropping a
single wire on a socket (or clicking one while connecting) splits the
port and takes the first free line that runs that way. Join … lines
takes the line pins and their wires away again, as one undo step.
A line wired by hand joins the same net the cable's line reaches inside;
a wire and a cable on one line both drive it, and the check says so.
Line pins are left out of the open-input warning, docked panels and
bubbles; docked panels no longer get a row for a port's socket either.
Saved as an optional list on the placed component (splitPorts); without
it a box only has its ports moved to the top.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 17:08:27 +00:00
if ( lineForWire ( ed . project . value , def . value , n . id , p . key , true ) ) out . in . push ( at )
if ( lineForWire ( ed . project . value , def . value , n . id , p . key , false ) ) out . out . push ( at )
}
}
return out
} )
/** The socket a single wire being drawn from this pin is dropped on, if any. */
function socketAt ( d : { node : string ; pin : string ; dir : 'in' | 'out' ; cur : Pt } ) {
if ( ed . isBus ( d . node , d . pin , d . dir ) ) return undefined
return openSockets . value [ d . dir === 'out' ? 'in' : 'out' ] . find ( s => Math . abs ( s . x - d . cur [ 0 ] ) <= 0.5 && Math . abs ( s . y - d . cur [ 1 ] ) <= 0.5 )
}
A right-click menu for parts, wires and the canvas, "Wire them all to" as cards, plugged latches in plain greys
- Right click (or the menu key) shows what can be done with what is under the pointer: one part (open, rename, change to, inputs, colour, speed, panels, unpack, plug and unplug, cable colour), several parts (wire them all to with live preview, connect one by one, switches, change all, arrange, keep only, make a component), wires (bundle, colour, whole signal, straighten, remove cable) or empty canvas (paste here, add a part here, select all, fit, tidy, undo); right drag still moves the view
- "Wire them all to": a card per part, each fit a strip of its pins, and which wire goes where for the fit pointed at
- Plugged cable ends no longer look selected: grey connector, steel clips
- Icons named in menus are bundled for the browser too
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 10:33:30 +00:00
function onPointerUp ( e : PointerEvent ) {
2026-10-17 10:49:38 +00:00
const d = drag . value
drag . value = null
if ( ! d ) return
switch ( d . kind ) {
A right-click menu for parts, wires and the canvas, "Wire them all to" as cards, plugged latches in plain greys
- Right click (or the menu key) shows what can be done with what is under the pointer: one part (open, rename, change to, inputs, colour, speed, panels, unpack, plug and unplug, cable colour), several parts (wire them all to with live preview, connect one by one, switches, change all, arrange, keep only, make a component), wires (bundle, colour, whole signal, straighten, remove cable) or empty canvas (paste here, add a part here, select all, fit, tidy, undo); right drag still moves the view
- "Wire them all to": a card per part, each fit a strip of its pins, and which wire goes where for the fit pointed at
- Plugged cable ends no longer look selected: grey connector, steel clips
- Icons named in menus are bundled for the browser too
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 10:33:30 +00:00
case 'pan' :
if ( d . menu && Math . abs ( e . clientX - d . sx ) + Math . abs ( e . clientY - d . sy ) < 5 ) openMenuAt ( d . menu . target , d . menu . at , e . clientX , e . clientY )
break
2026-10-17 10:49:38 +00:00
case 'move' :
if ( d . node . kind === 'button' ) ed . press ( d . node , false )
A input panels, automatic names, one-by-one wiring, tidy routing, truth table export
- Input panel part: rows of switches, buttons and clocks. "Attach input
panel" docks one to a component with a row per free input; it moves
with the component and follows its pins.
- Copies and new pins continue name series (D0 -> D1, A -> B); unnamed
switches, lamps and pins take the name of the component pin they are
wired to.
- Connecting: target pins are ringed, dropping on a part uses its next
free pin, click-then-click works, and "Connect one by one" (W) wires a
selection's pins in turn.
- Tidy wiring option and "Tidy all wires": sorted, evenly spaced columns
per gap, one trunk per signal, fewer crossings.
- Truth table full screen, CSV download, copy as Markdown, current row
highlighted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 17:17:25 +00:00
if ( d . row && ! d . moved ) ed . pressRow ( d . node , d . row , false )
BF input panels are component inputs, cable ends plug in more reliably; A merge panels, hex pass-through, design a component's box
- Inside a component, the switch and button rows of its input panels are now input pins (in order with the other inputs, named after the rows); "Rows are component inputs" can be turned off per panel to keep the old fixed switches
- Select input panels, Merge: one panel with all rows, spacing and wires kept; circuits that place this one keep their wires
- Cable ends plug in more often: bundling orders the wires by the part a side runs to, an end with only some wires on a part still plugs, an end placed by hand next to the pins plugs, and dragging an end near its part shows green rings and plugs it on drop
- Hex displays pass their four bits on (outputs on the right), so they can sit in the middle of a bus
- Design the box: move lamps, displays, the screen and the name on a component's box, draw lines, boxes, circles and text in six colours, size it, leave things off; every placed copy shows it
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 11:49:29 +00:00
if ( d . moved && d . plug ) {
2026-10-26 17:21:34 +00:00
// Onto the pins it plugs into, its wires settled there as for any move.
const [ ox , oy ] = d . orig . nodes . get ( d . node . id ) !
moveTo ( d . orig , d . plug . at [ 0 ] - ox , d . plug . at [ 1 ] - oy )
ed . unplugMoved ( new Set ( d . orig . nodes . keys ( ) ) )
2026-10-23 13:34:36 +00:00
if ( d . node . kind === 'bundle' || d . node . kind === 'split' ) ed . plugEnd ( d . node )
else ed . latchPart ( d . node )
BF input panels are component inputs, cable ends plug in more reliably; A merge panels, hex pass-through, design a component's box
- Inside a component, the switch and button rows of its input panels are now input pins (in order with the other inputs, named after the rows); "Rows are component inputs" can be turned off per panel to keep the old fixed switches
- Select input panels, Merge: one panel with all rows, spacing and wires kept; circuits that place this one keep their wires
- Cable ends plug in more often: bundling orders the wires by the part a side runs to, an end with only some wires on a part still plugs, an end placed by hand next to the pins plugs, and dragging an end near its part shows green rings and plugs it on drop
- Hex displays pass their four bits on (outputs on the right), so they can sit in the middle of a bus
- Design the box: move lamps, displays, the screen and the name on a component's box, draw lines, boxes, circles and text in six colours, size it, leave things off; every placed copy shows it
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 11:49:29 +00:00
} else if ( d . moved && d . snap ? . links . length ) {
2026-10-21 10:16:26 +00:00
const [ sx , sy ] = d . snap . shift
2026-10-26 17:21:34 +00:00
moveTo ( d . orig , d . at [ 0 ] + sx , d . at [ 1 ] + sy )
ed . unplugMoved ( new Set ( d . orig . nodes . keys ( ) ) )
2026-10-21 10:16:26 +00:00
ed . connectMany ( d . snap . links )
ed . commit ( false )
} else if ( d . moved ) {
2026-10-26 17:21:34 +00:00
ed . unplugMoved ( new Set ( d . orig . nodes . keys ( ) ) )
2026-10-28 12:35:04 +00:00
if ( ( d . node . kind !== 'bench' && d . node . kind !== 'scope' ) || ! ed . dropBench ( d . node ) ) ed . commit ( false )
2026-10-28 12:30:07 +00:00
} else if ( d . benchHit === 'run' ) ed . runBenchNow ( d . node . id , true )
else if ( typeof d . benchHit === 'number' ) ed . applyBenchRow ( d . node . id , d . benchHit )
else if ( d . toggle && d . row ) ed . toggleRow ( d . node , d . row )
2026-10-28 12:05:57 +00:00
else if ( d . toggle && d . node . kind === 'keyboard' ) ed . typeInto ( d . node . id )
2026-10-17 10:49:38 +00:00
else if ( d . toggle ) ed . toggleInput ( d . node )
break
case 'wire' : {
const here = { node : d . node , pin : d . pin }
A input panels, automatic names, one-by-one wiring, tidy routing, truth table export
- Input panel part: rows of switches, buttons and clocks. "Attach input
panel" docks one to a component with a row per free input; it moves
with the component and follows its pins.
- Copies and new pins continue name series (D0 -> D1, A -> B); unnamed
switches, lamps and pins take the name of the component pin they are
wired to.
- Connecting: target pins are ringed, dropping on a part uses its next
free pin, click-then-click works, and "Connect one by one" (W) wires a
selection's pins in turn.
- Tidy wiring option and "Tidy all wires": sorted, evenly spaced columns
per gap, one trunk per signal, fewer crossings.
- Truth table full screen, CSV download, copy as Markdown, current row
highlighted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 17:17:25 +00:00
if ( ! d . moved ) {
A Loxone-style working aids: named signals, inverted inputs, a project check, values on cables, search, printable sheets; wire ends move by dragging
- Send signal / Use signal: name a signal (CLK, RESET) once and use it anywhere in the circuit without a wire; selecting one lights up all of them, a use with no sender shows dashed
- Inverted inputs: Alt + click an input (or the menu/settings) puts a bubble on it; it reads the signal inverted through one NAND, counted in every transistor total
- Check (Circuit tab): open inputs, parts that drive nothing, duplicate pin names, unsent or doubly sent signals, loops that never settle; click one to show it. Open inputs get an orange marker on the canvas. Components no other circuit uses are listed with a delete
- Cables show the number they carry (= 13 · 0x0D); hovering a wire tells where it runs and its value
- Ctrl+F finds parts, signals, panel rows, notes and components in every circuit, with where each component is used
- Ctrl+P prints the circuit as a sheet with a title block on white paper (or save as PDF); also as an SVG file
- + and − under a selected gate change its number of inputs; swaps keep bubbles in place
- Drag a wire by its end to move that end to another pin; drop a dragged wire on another wire to tap its signal or feed what it fed
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 11:26:59 +00:00
if ( d . replace ) break
A input panels, automatic names, one-by-one wiring, tidy routing, truth table export
- Input panel part: rows of switches, buttons and clocks. "Attach input
panel" docks one to a component with a row per free input; it moves
with the component and follows its pins.
- Copies and new pins continue name series (D0 -> D1, A -> B); unnamed
switches, lamps and pins take the name of the component pin they are
wired to.
- Connecting: target pins are ringed, dropping on a part uses its next
free pin, click-then-click works, and "Connect one by one" (W) wires a
selection's pins in turn.
- Tidy wiring option and "Tidy all wires": sorted, evenly spaced columns
per gap, one trunk per signal, fewer crossings.
- Truth table full screen, CSV download, copy as Markdown, current row
highlighted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 17:17:25 +00:00
// A click on a pin: the wire follows the mouse until the next click.
ed . linking . value = { queue : [ { ... here , dir : d . dir , label : '' } ] , at : 0 }
break
}
A ports on top of the box, split into lines to wire by hand
On a component's box every connector port now sits at the very top of its
side, above the single pins, in auto and hand-drawn boxes alike. A port
can be split on one placed component (its settings or right click: Split
… into lines): right below the socket the box then gets a pin per line,
named after the line, so lines can be wired by hand without an adapter.
Lines going into the component are inputs, lines coming out outputs, each
facing out of its side; a bar in the type's colour ties them to the
socket. A cable still plugs into the socket at the same time. Dropping a
single wire on a socket (or clicking one while connecting) splits the
port and takes the first free line that runs that way. Join … lines
takes the line pins and their wires away again, as one undo step.
A line wired by hand joins the same net the cable's line reaches inside;
a wire and a cable on one line both drive it, and the check says so.
Line pins are left out of the open-input warning, docked panels and
bubbles; docked panels no longer get a row for a port's socket either.
Saved as an optional list on the placed component (splitPorts); without
it a box only has its ports moved to the top.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 17:08:27 +00:00
// A single wire dropped on a port's socket: the port splits and the wire takes one of its lines.
const socket = d . replace ? undefined : socketAt ( d )
if ( socket ) {
const line = ed . lineAt ( d . dir , socket . node , socket . port )
if ( line ) ed . connect ( d . dir === 'out' ? here : line , d . dir === 'out' ? line : here )
break
}
A Loxone-style working aids: named signals, inverted inputs, a project check, values on cables, search, printable sheets; wire ends move by dragging
- Send signal / Use signal: name a signal (CLK, RESET) once and use it anywhere in the circuit without a wire; selecting one lights up all of them, a use with no sender shows dashed
- Inverted inputs: Alt + click an input (or the menu/settings) puts a bubble on it; it reads the signal inverted through one NAND, counted in every transistor total
- Check (Circuit tab): open inputs, parts that drive nothing, duplicate pin names, unsent or doubly sent signals, loops that never settle; click one to show it. Open inputs get an orange marker on the canvas. Components no other circuit uses are listed with a delete
- Cables show the number they carry (= 13 · 0x0D); hovering a wire tells where it runs and its value
- Ctrl+F finds parts, signals, panel rows, notes and components in every circuit, with where each component is used
- Ctrl+P prints the circuit as a sheet with a title block on white paper (or save as PDF); also as an SVG file
- + and − under a selected gate change its number of inputs; swaps keep bubbles in place
- Drag a wire by its end to move that end to another pin; drop a dragged wire on another wire to tap its signal or feed what it fed
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 11:26:59 +00:00
const onWire = wireDrop ( d )
2026-10-22 16:59:56 +00:00
const target = targetAt ( d . cur , d . dir === 'out' ? 'in' : 'out' , ed . pinKind ( d . node , d . pin , d . dir ) ) ? ? onWire ? . pin
2026-10-26 21:45:47 +00:00
if ( ! target && ! d . replace && ! d . branch ) {
// A cable pulled out of a cable end: its other end goes where it is let go.
const end = pullEnd ( d )
if ( end ) ed . pullCable ( d . node , end . x , end . y , end . links )
break
}
A input panels, automatic names, one-by-one wiring, tidy routing, truth table export
- Input panel part: rows of switches, buttons and clocks. "Attach input
panel" docks one to a component with a row per free input; it moves
with the component and follows its pins.
- Copies and new pins continue name series (D0 -> D1, A -> B); unnamed
switches, lamps and pins take the name of the component pin they are
wired to.
- Connecting: target pins are ringed, dropping on a part uses its next
free pin, click-then-click works, and "Connect one by one" (W) wires a
selection's pins in turn.
- Tidy wiring option and "Tidy all wires": sorted, evenly spaced columns
per gap, one trunk per signal, fewer crossings.
- Truth table full screen, CSV download, copy as Markdown, current row
highlighted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 17:17:25 +00:00
if ( ! target ) break
A Loxone-style working aids: named signals, inverted inputs, a project check, values on cables, search, printable sheets; wire ends move by dragging
- Send signal / Use signal: name a signal (CLK, RESET) once and use it anywhere in the circuit without a wire; selecting one lights up all of them, a use with no sender shows dashed
- Inverted inputs: Alt + click an input (or the menu/settings) puts a bubble on it; it reads the signal inverted through one NAND, counted in every transistor total
- Check (Circuit tab): open inputs, parts that drive nothing, duplicate pin names, unsent or doubly sent signals, loops that never settle; click one to show it. Open inputs get an orange marker on the canvas. Components no other circuit uses are listed with a delete
- Cables show the number they carry (= 13 · 0x0D); hovering a wire tells where it runs and its value
- Ctrl+F finds parts, signals, panel rows, notes and components in every circuit, with where each component is used
- Ctrl+P prints the circuit as a sheet with a title block on white paper (or save as PDF); also as an SVG file
- + and − under a selected gate change its number of inputs; swaps keep bubbles in place
- Drag a wire by its end to move that end to another pin; drop a dragged wire on another wire to tap its signal or feed what it fed
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 11:26:59 +00:00
if ( d . replace ) {
ed . rewire ( d . replace , d . dir === 'out' ? here : target , d . dir === 'out' ? target : here )
break
}
if ( onWire && d . dir === 'in' && ! d . branch ) {
// Dropped on a wire from a pin that needs a signal: it taps that wire's signal where it was dropped.
const r = onWire . route
const fn = nodeMap . value . get ( target . node ) !
const tn = nodeMap . value . get ( here . node ) !
const a = pinPos ( fn , shapes . value . get ( fn . id ) ! , target . pin , 'out' ) !
const b = pinPos ( tn , shapes . value . get ( tn . id ) ! , here . pin , 'in' ) !
ed . connect ( target , here , branchTo ( branchCorners ( r . pts , onWire . seg , d . cur ) , [ a . x , a . y ] , [ b . x , b . y ] ) )
break
}
2026-10-21 08:09:43 +00:00
// Dragged from one of several selected parts to another part: wire them all, in order.
if ( ! d . branch && ed . selection . value . length > 1 && ed . selection . value . includes ( d . node ) && ! ed . selection . value . includes ( target . node ) ) {
ed . connectMany ( seriesLinks ( def . value , ed . getDef . value , ed . selection . value , { node : d . node , pin : d . pin , dir : d . dir } , target ) )
break
}
A component faces, project library with share links, fine-grained wire editing
- Lamps and hex displays inside a component show on its box with their
labels, lit by that instance's state; Counter 4 example shows its count.
- Several projects per browser; share links at /p/<id> that the creator's
edits save to automatically, others get their own copy. Export, open a
file as project, or add a file's components to the open project.
- Wires: drag any segment or corner, Alt+drag for a new bend, Ctrl+drag to
branch, double-click selects the whole signal, multi-select, arrow keys,
colour tags.
- Share-link API (POST/GET/PUT /api/p) on Nitro fs storage in data/, mounted
as a volume on edgerealm.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-17 11:21:49 +00:00
if ( d . dir === 'in' ) {
ed . connect ( target , here )
2026-10-23 11:11:19 +00:00
// Let go with Shift: go on from the output it now comes from.
if ( e . shiftKey ) ed . linking . value = { queue : [ { ... target , dir : 'out' , label : '' } ] , at : 0 }
A component faces, project library with share links, fine-grained wire editing
- Lamps and hex displays inside a component show on its box with their
labels, lit by that instance's state; Counter 4 example shows its count.
- Several projects per browser; share links at /p/<id> that the creator's
edits save to automatically, others get their own copy. Export, open a
file as project, or add a file's components to the open project.
- Wires: drag any segment or corner, Alt+drag for a new bend, Ctrl+drag to
branch, double-click selects the whole signal, multi-select, arrow keys,
colour tags.
- Share-link API (POST/GET/PUT /api/p) on Nitro fs storage in data/, mounted
as a volume on edgerealm.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-17 11:21:49 +00:00
break
}
let corners = d . branch
if ( corners ) {
const fn = nodeMap . value . get ( d . node ) !
const tn = nodeMap . value . get ( target . node ) !
const a = pinPos ( fn , shapes . value . get ( fn . id ) ! , d . pin , 'out' ) !
const b = pinPos ( tn , shapes . value . get ( tn . id ) ! , target . pin , 'in' ) !
corners = branchTo ( corners , [ a . x , a . y ] , [ b . x , b . y ] )
}
ed . connect ( here , target , corners )
2026-10-23 11:11:19 +00:00
// Let go with Shift: the wire goes on from the same output, for another connection.
if ( e . shiftKey ) ed . linking . value = { queue : [ { ... here , dir : 'out' , label : '' } ] , at : 0 }
2026-10-17 10:49:38 +00:00
break
}
case 'segment' :
A component faces, project library with share links, fine-grained wire editing
- Lamps and hex displays inside a component show on its box with their
labels, lit by that instance's state; Counter 4 example shows its count.
- Several projects per browser; share links at /p/<id> that the creator's
edits save to automatically, others get their own copy. Export, open a
file as project, or add a file's components to the open project.
- Wires: drag any segment or corner, Alt+drag for a new bend, Ctrl+drag to
branch, double-click selects the whole signal, multi-select, arrow keys,
colour tags.
- Share-link API (POST/GET/PUT /api/p) on Nitro fs storage in data/, mounted
as a volume on edgerealm.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-17 11:21:49 +00:00
case 'corner' :
if ( d . moved ) ed . commit ( false )
2026-10-17 10:49:38 +00:00
break
}
}
2026-10-28 12:30:07 +00:00
/** What a press on a test bench's box hits: its run button or a row. */
function benchHitAt ( target : Element , node : CircuitNode , multi : boolean ) : 'run' | number | undefined {
if ( node . kind !== 'bench' || multi ) return undefined
if ( target . closest ( '[data-bench-run]' ) ) return 'run'
const row = target . closest ( '[data-bench-row]' ) ? . getAttribute ( 'data-bench-row' )
return row ? Number ( row ) : undefined
}
2026-10-17 10:49:38 +00:00
function onDoubleClick ( node : CircuitNode ) {
if ( node . kind === 'chip' && node . chip ) ed . open ( node . chip )
2026-10-28 12:12:43 +00:00
else if ( node . kind === 'bench' ) ed . benchOpen . value = node . id
2026-10-21 12:38:59 +00:00
else if ( [ 'input' , 'output' , 'lamp' , 'button' , 'note' , 'hex' , 'panel' , 'outpanel' , 'tag' , 'ref' ] . includes ( node . kind ) ) {
2026-10-17 10:49:38 +00:00
ed . selection . value = [ node . id ]
ed . labelFocus . value ++
}
}
function onWheel ( e : WheelEvent ) {
2026-10-27 12:42:47 +00:00
// Zooming moves everything under the pointer: what it points at is found again when it moves.
dropHover ( )
2026-10-17 10:49:38 +00:00
const r = root . value ! . getBoundingClientRect ( )
const k = e . ctrlKey ? 0.01 : 0.0015
zoomAt ( Math . exp ( - e . deltaY * k ) , e . clientX - r . left , e . clientY - r . top )
}
// ── Keyboard ────────────────────────────────────────────────────────
2026-10-20 17:29:16 +00:00
const QUICK : Record < string , CircuitNode [ ' kind ' ] > = { n : 'nand' , i : 'input' , o : 'output' , l : 'lamp' , c : 'clock' , b : 'button' , h : 'hex' , t : 'note' , p : 'panel' , x : 'pixel' }
A component faces, project library with share links, fine-grained wire editing
- Lamps and hex displays inside a component show on its box with their
labels, lit by that instance's state; Counter 4 example shows its count.
- Several projects per browser; share links at /p/<id> that the creator's
edits save to automatically, others get their own copy. Export, open a
file as project, or add a file's components to the open project.
- Wires: drag any segment or corner, Alt+drag for a new bend, Ctrl+drag to
branch, double-click selects the whole signal, multi-select, arrow keys,
colour tags.
- Share-link API (POST/GET/PUT /api/p) on Nitro fs storage in data/, mounted
as a volume on edgerealm.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-17 11:21:49 +00:00
const ARROWS : Record < string , Pt > = { ArrowLeft : [ - 1 , 0 ] , ArrowRight : [ 1 , 0 ] , ArrowUp : [ 0 , - 1 ] , ArrowDown : [ 0 , 1 ] }
/** Arrow keys: move the selected parts and wires one grid step (four with Shift). */
function nudge ( dx : number , dy : number ) {
2026-10-21 09:51:45 +00:00
const ids = ed . withFollowers ( ed . selection . value )
A component faces, project library with share links, fine-grained wire editing
- Lamps and hex displays inside a component show on its box with their
labels, lit by that instance's state; Counter 4 example shows its count.
- Several projects per browser; share links at /p/<id> that the creator's
edits save to automatically, others get their own copy. Export, open a
file as project, or add a file's components to the open project.
- Wires: drag any segment or corner, Alt+drag for a new bend, Ctrl+drag to
branch, double-click selects the whole signal, multi-select, arrow keys,
colour tags.
- Share-link API (POST/GET/PUT /api/p) on Nitro fs storage in data/, mounted
as a volume on edgerealm.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-17 11:21:49 +00:00
if ( ! ids . size && ! ed . wireSel . value . length ) return
2026-10-26 17:21:34 +00:00
// A wire moved on its own keeps the shape it has.
A component faces, project library with share links, fine-grained wire editing
- Lamps and hex displays inside a component show on its box with their
labels, lit by that instance's state; Counter 4 example shows its count.
- Several projects per browser; share links at /p/<id> that the creator's
edits save to automatically, others get their own copy. Export, open a
file as project, or add a file's components to the open project.
- Wires: drag any segment or corner, Alt+drag for a new bend, Ctrl+drag to
branch, double-click selects the whole signal, multi-select, arrow keys,
colour tags.
- Share-link API (POST/GET/PUT /api/p) on Nitro fs storage in data/, mounted
as a volume on edgerealm.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-17 11:21:49 +00:00
for ( const r of routes . value ) {
2026-10-26 17:21:34 +00:00
if ( wireSelected . value . has ( r . wire . id ) && ! r . wire . pts && ! ids . has ( r . wire . from . node ) && ! ids . has ( r . wire . to . node ) ) r . wire . pts = r . pts . slice ( 1 , - 1 )
A component faces, project library with share links, fine-grained wire editing
- Lamps and hex displays inside a component show on its box with their
labels, lit by that instance's state; Counter 4 example shows its count.
- Several projects per browser; share links at /p/<id> that the creator's
edits save to automatically, others get their own copy. Export, open a
file as project, or add a file's components to the open project.
- Wires: drag any segment or corner, Alt+drag for a new bend, Ctrl+drag to
branch, double-click selects the whole signal, multi-select, arrow keys,
colour tags.
- Share-link API (POST/GET/PUT /api/p) on Nitro fs storage in data/, mounted
as a volume on edgerealm.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-17 11:21:49 +00:00
}
2026-10-26 17:21:34 +00:00
moveTo ( moveStart ( def . value , ids , ed . wireSel . value ) , dx , dy )
A pick pins for a cable, buttons on pointing, right-click on pins; docked panels move freely
- Pointing at a part shows its round buttons, as if it were selected; they
stay while the pointer goes to them.
- A box around some pins of one part (not over its middle), or Shift +
click on pins, picks exactly those pins: a cable plug on them, wire them
one by one, invert or unwire them, from buttons beside them or a
right-click.
- Right-click on a pin offers what can be done right there first: split a
component's cable socket into wires (or join), pull a cable out of a cable
end, invert an input.
- A docked panel moves both ways now: moved up or down off its component's
pins it lets go and stays a panel of its own (rows and wires kept);
moved sideways it stays docked.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-27 12:34:16 +00:00
ed . unplugMoved ( ids )
A component faces, project library with share links, fine-grained wire editing
- Lamps and hex displays inside a component show on its box with their
labels, lit by that instance's state; Counter 4 example shows its count.
- Several projects per browser; share links at /p/<id> that the creator's
edits save to automatically, others get their own copy. Export, open a
file as project, or add a file's components to the open project.
- Wires: drag any segment or corner, Alt+drag for a new bend, Ctrl+drag to
branch, double-click selects the whole signal, multi-select, arrow keys,
colour tags.
- Share-link API (POST/GET/PUT /api/p) on Nitro fs storage in data/, mounted
as a volume on edgerealm.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-17 11:21:49 +00:00
ed . commit ( false )
}
2026-10-17 10:49:38 +00:00
function onKey ( e : KeyboardEvent ) {
const el = e . target as HTMLElement
R saves like a game: one save per project on every device, Load game in the menu, a pause menu, and a lean side panel
- Sync: when two devices changed the same project, the newer save wins
everywhere and the other becomes a savegame of it (new endpoint to keep
a savegame without replacing the save), never an "(other device)" copy.
A first visit keeps its starter unsaved until something changes, and
the main menu waits for the account's saves before anything starts.
- Main menu: Load game lists every save. In the editor, Esc with nothing
selected (or the project button) opens a pause menu: Resume, Save,
Save as copy, Load, Settings, How to play, Main menu. The projects
dialog is gone.
- Selection tab: name and transistors on top, one icon row (open,
duplicate, unlink, delete, more = the right-click menu), only the
settings that matter for the part; pins, component tools, keys, cable
and panel options fold away and remember it. X/Y fields removed.
The Circuit tab folds its component settings, transistor breakdown
and tools the same way.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 16:36:17 +00:00
if ( el . closest ? . ( 'input, textarea, select, [contenteditable]' ) ) return
2026-10-28 12:12:43 +00:00
if ( ed . benchOpen . value ) return
A component faces, project library with share links, fine-grained wire editing
- Lamps and hex displays inside a component show on its box with their
labels, lit by that instance's state; Counter 4 example shows its count.
- Several projects per browser; share links at /p/<id> that the creator's
edits save to automatically, others get their own copy. Export, open a
file as project, or add a file's components to the open project.
- Wires: drag any segment or corner, Alt+drag for a new bend, Ctrl+drag to
branch, double-click selects the whole signal, multi-select, arrow keys,
colour tags.
- Share-link API (POST/GET/PUT /api/p) on Nitro fs storage in data/, mounted
as a volume on edgerealm.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-17 11:21:49 +00:00
if ( ed . dialog . value || ed . showHelp . value ) {
if ( e . key === 'Escape' ) {
ed . dialog . value = null
ed . showHelp . value = false
}
return
}
R saves like a game: one save per project on every device, Load game in the menu, a pause menu, and a lean side panel
- Sync: when two devices changed the same project, the newer save wins
everywhere and the other becomes a savegame of it (new endpoint to keep
a savegame without replacing the save), never an "(other device)" copy.
A first visit keeps its starter unsaved until something changes, and
the main menu waits for the account's saves before anything starts.
- Main menu: Load game lists every save. In the editor, Esc with nothing
selected (or the project button) opens a pause menu: Resume, Save,
Save as copy, Load, Settings, How to play, Main menu. The projects
dialog is gone.
- Selection tab: name and transistors on top, one icon row (open,
duplicate, unlink, delete, more = the right-click menu), only the
settings that matter for the part; pins, component tools, keys, cable
and panel options fold away and remember it. X/Y fields removed.
The Circuit tab folds its component settings, transistor breakdown
and tools the same way.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 16:36:17 +00:00
// Paused: the pause menu has the keys.
if ( ed . paused . value ) return
2026-10-28 12:05:57 +00:00
// Typing into a keyboard: the keys go there (Esc stops).
if ( ed . typingInto . value ) {
if ( e . key === 'Escape' ) return ed . typeInto ( null )
const code = keyCode ( e )
if ( code !== null ) {
e . preventDefault ( )
return ed . typeKey ( code )
}
}
2026-10-17 10:49:38 +00:00
const mod = e . ctrlKey || e . metaKey
const key = e . key . toLowerCase ( )
A right-click menu for parts, wires and the canvas, "Wire them all to" as cards, plugged latches in plain greys
- Right click (or the menu key) shows what can be done with what is under the pointer: one part (open, rename, change to, inputs, colour, speed, panels, unpack, plug and unplug, cable colour), several parts (wire them all to with live preview, connect one by one, switches, change all, arrange, keep only, make a component), wires (bundle, colour, whole signal, straighten, remove cable) or empty canvas (paste here, add a part here, select all, fit, tidy, undo); right drag still moves the view
- "Wire them all to": a card per part, each fit a strip of its pins, and which wire goes where for the fit pointed at
- Plugged cable ends no longer look selected: grey connector, steel clips
- Icons named in menus are bundled for the browser too
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 10:33:30 +00:00
if ( e . key === 'ContextMenu' || ( e . shiftKey && e . key === 'F10' ) ) {
e . preventDefault ( )
return openMenuForSelection ( )
}
R Top bar like the parts bar, no left panel
The parts panel on the left is gone: pinned parts sit at the start of the
bottom bar, components open from the pencil in its Components list (or a
double-click), examples load from there too. The side panel moved to the
left. The top bar floats across the whole width: menu with the project,
Main and the way into the open component instead of the circuit
selector, Challenges in a drop-down, clock, search, undo, settings,
share and account. / and the bar's search open quick add.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 18:17:41 +00:00
// Finding parts from the keyboard: /, Shift+A or Ctrl+K add one at the mouse.
A finer component boxes, a regrouped parts list with keyboard search, a real green for wires and cables
- Box designer: drag pins up or down to open gaps between groups; size (+/−) and turn (R) lamps, displays, screens and drawings; pixels belong to named screens, each placed on its own; displays of the components inside can be shown on the box (off unless ticked); a list of everything the box can show, each optional; the box grows to hold what it shows
- Lamps and displays deep inside placed components light up on the box
- Parts list: one search box for parts and components (letters in order match too), recently placed parts first, grouped Logic / Inputs / Outputs / Wiring / Notes, then components by group; groups fold away
- Keys: / searches the parts list (Enter starts placing), Shift+A or Ctrl+K adds a part at the mouse
- Wires and cables get a green; the default swatch shows grey, as the default really is
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-22 04:48:42 +00:00
if ( e . key === '/' && ! mod ) {
e . preventDefault ( )
R Top bar like the parts bar, no left panel
The parts panel on the left is gone: pinned parts sit at the start of the
bottom bar, components open from the pencil in its Components list (or a
double-click), examples load from there too. The side panel moved to the
left. The top bar floats across the whole width: menu with the project,
Main and the way into the open component instead of the circuit
selector, Challenges in a drop-down, clock, search, undo, settings,
share and account. / and the bar's search open quick add.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 18:17:41 +00:00
return openQuickAdd ( )
A finer component boxes, a regrouped parts list with keyboard search, a real green for wires and cables
- Box designer: drag pins up or down to open gaps between groups; size (+/−) and turn (R) lamps, displays, screens and drawings; pixels belong to named screens, each placed on its own; displays of the components inside can be shown on the box (off unless ticked); a list of everything the box can show, each optional; the box grows to hold what it shows
- Lamps and displays deep inside placed components light up on the box
- Parts list: one search box for parts and components (letters in order match too), recently placed parts first, grouped Logic / Inputs / Outputs / Wiring / Notes, then components by group; groups fold away
- Keys: / searches the parts list (Enter starts placing), Shift+A or Ctrl+K adds a part at the mouse
- Wires and cables get a green; the default swatch shows grey, as the default really is
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-22 04:48:42 +00:00
}
if ( ( e . shiftKey && key === 'a' && ! mod ) || ( mod && key === 'k' ) ) {
e . preventDefault ( )
return openQuickAdd ( )
}
2026-10-21 09:51:45 +00:00
// Keys bound to switches, buttons and panel rows win over the shortcuts below.
A settings for every part, overlap-free wiring with crossing styles, accounts with sync
- Clicking anything opens its settings: swap parts in place (wires stay on
matching pins), clock frequency per clock, keyboard keys for switches and
buttons, lamp/display colours, note sizes, component names on the canvas,
position, unlink all wires, unpack a component, make an independent copy.
- Wires of different signals never share a line: auto routes pick free
columns or detours, remaining clashes go on separate lanes. Crossings drawn
as bow, triangle, bridge, gap or plain.
- Accounts (email + scrypt password, httpOnly session) with two-way project
sync and conflict copies; per-account limits; cross-site writes refused.
- Compatibility suite: a project and both browser-storage layouts from
release a241adc must load and compute identically.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-20 11:09:37 +00:00
if ( ! mod && ! e . altKey && e . key . length === 1 ) {
const bound = def . value . nodes . filter ( n => n . key === key && ( n . kind === 'input' || n . kind === 'button' ) )
2026-10-21 09:51:45 +00:00
const rows = boundRows ( key )
if ( bound . length || rows . length ) {
A settings for every part, overlap-free wiring with crossing styles, accounts with sync
- Clicking anything opens its settings: swap parts in place (wires stay on
matching pins), clock frequency per clock, keyboard keys for switches and
buttons, lamp/display colours, note sizes, component names on the canvas,
position, unlink all wires, unpack a component, make an independent copy.
- Wires of different signals never share a line: auto routes pick free
columns or detours, remaining clashes go on separate lanes. Crossings drawn
as bow, triangle, bridge, gap or plain.
- Accounts (email + scrypt password, httpOnly session) with two-way project
sync and conflict copies; per-account limits; cross-site writes refused.
- Compatibility suite: a project and both browser-storage layouts from
release a241adc must load and compute identically.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-20 11:09:37 +00:00
e . preventDefault ( )
2026-10-21 09:51:45 +00:00
if ( e . repeat ) return
for ( const n of bound ) n . kind === 'input' ? ed . toggleInput ( n ) : ed . press ( n , true )
for ( const [ n , r ] of rows ) r . type === 'button' ? ed . pressRow ( n , r , true ) : ed . toggleRow ( n , r )
A settings for every part, overlap-free wiring with crossing styles, accounts with sync
- Clicking anything opens its settings: swap parts in place (wires stay on
matching pins), clock frequency per clock, keyboard keys for switches and
buttons, lamp/display colours, note sizes, component names on the canvas,
position, unlink all wires, unpack a component, make an independent copy.
- Wires of different signals never share a line: auto routes pick free
columns or detours, remaining clashes go on separate lanes. Crossings drawn
as bow, triangle, bridge, gap or plain.
- Accounts (email + scrypt password, httpOnly session) with two-way project
sync and conflict copies; per-account limits; cross-site writes refused.
- Compatibility suite: a project and both browser-storage layouts from
release a241adc must load and compute identically.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-20 11:09:37 +00:00
return
}
}
A Loxone-style working aids: named signals, inverted inputs, a project check, values on cables, search, printable sheets; wire ends move by dragging
- Send signal / Use signal: name a signal (CLK, RESET) once and use it anywhere in the circuit without a wire; selecting one lights up all of them, a use with no sender shows dashed
- Inverted inputs: Alt + click an input (or the menu/settings) puts a bubble on it; it reads the signal inverted through one NAND, counted in every transistor total
- Check (Circuit tab): open inputs, parts that drive nothing, duplicate pin names, unsent or doubly sent signals, loops that never settle; click one to show it. Open inputs get an orange marker on the canvas. Components no other circuit uses are listed with a delete
- Cables show the number they carry (= 13 · 0x0D); hovering a wire tells where it runs and its value
- Ctrl+F finds parts, signals, panel rows, notes and components in every circuit, with where each component is used
- Ctrl+P prints the circuit as a sheet with a title block on white paper (or save as PDF); also as an SVG file
- + and − under a selected gate change its number of inputs; swaps keep bubbles in place
- Drag a wire by its end to move that end to another pin; drop a dragged wire on another wire to tap its signal or feed what it fed
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 11:26:59 +00:00
if ( mod && key === 'p' ) {
e . preventDefault ( )
ed . exportSheet ( 'print' )
return
}
if ( mod && key === 'f' ) {
e . preventDefault ( )
ed . dialog . value = 'search'
return
}
2026-10-17 10:49:38 +00:00
if ( mod && key === 'z' ) {
e . preventDefault ( )
if ( e . shiftKey ) ed . redo ( )
else ed . undo ( )
} else if ( mod && key === 'y' ) {
e . preventDefault ( )
ed . redo ( )
} else if ( mod && key === 'c' ) ed . copy ( )
else if ( mod && key === 'v' ) ed . paste ( )
else if ( mod && key === 'd' ) {
e . preventDefault ( )
ed . duplicate ( )
2026-10-21 08:39:54 +00:00
} else if ( mod && key === 'g' ) {
e . preventDefault ( )
2026-10-21 09:21:35 +00:00
if ( e . shiftKey ) ed . startCable ( )
else ed . bundleSelected ( )
2026-10-17 10:49:38 +00:00
} else if ( mod && key === 'a' ) {
e . preventDefault ( )
ed . selectAll ( )
} else if ( e . key === 'Delete' || e . key === 'Backspace' ) {
e . preventDefault ( )
ed . deleteSelected ( )
} else if ( e . key === 'Escape' ) {
2026-10-21 08:39:54 +00:00
if ( ed . cabling . value ) {
ed . cabling . value = null
return
}
A input panels, automatic names, one-by-one wiring, tidy routing, truth table export
- Input panel part: rows of switches, buttons and clocks. "Attach input
panel" docks one to a component with a row per free input; it moves
with the component and follows its pins.
- Copies and new pins continue name series (D0 -> D1, A -> B); unnamed
switches, lamps and pins take the name of the component pin they are
wired to.
- Connecting: target pins are ringed, dropping on a part uses its next
free pin, click-then-click works, and "Connect one by one" (W) wires a
selection's pins in turn.
- Tidy wiring option and "Tidy all wires": sorted, evenly spaced columns
per gap, one trunk per signal, fewer crossings.
- Truth table full screen, CSV download, copy as Markdown, current row
highlighted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 17:17:25 +00:00
if ( ed . linking . value ) return ed . stopLinking ( )
R saves like a game: one save per project on every device, Load game in the menu, a pause menu, and a lean side panel
- Sync: when two devices changed the same project, the newer save wins
everywhere and the other becomes a savegame of it (new endpoint to keep
a savegame without replacing the save), never an "(other device)" copy.
A first visit keeps its starter unsaved until something changes, and
the main menu waits for the account's saves before anything starts.
- Main menu: Load game lists every save. In the editor, Esc with nothing
selected (or the project button) opens a pause menu: Resume, Save,
Save as copy, Load, Settings, How to play, Main menu. The projects
dialog is gone.
- Selection tab: name and transistors on top, one icon row (open,
duplicate, unlink, delete, more = the right-click menu), only the
settings that matter for the part; pins, component tools, keys, cable
and panel options fold away and remember it. X/Y fields removed.
The Circuit tab folds its component settings, transistor breakdown
and tools the same way.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 16:36:17 +00:00
// Nothing to cancel: Esc pauses, like in a game.
A pick pins for a cable, buttons on pointing, right-click on pins; docked panels move freely
- Pointing at a part shows its round buttons, as if it were selected; they
stay while the pointer goes to them.
- A box around some pins of one part (not over its middle), or Shift +
click on pins, picks exactly those pins: a cable plug on them, wire them
one by one, invert or unwire them, from buttons beside them or a
right-click.
- Right-click on a pin offers what can be done right there first: split a
component's cable socket into wires (or join), pull a cable out of a cable
end, invert an input.
- A docked panel moves both ways now: moved up or down off its component's
pins it lets go and stays a panel of its own (rows and wires kept);
moved sideways it stays docked.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-27 12:34:16 +00:00
if ( ! ed . placing . value && ! ed . selection . value . length && ! ed . wireSel . value . length && ! ed . pinSel . value ) return ed . pause ( )
2026-10-17 10:49:38 +00:00
ed . placing . value = null
A component faces, project library with share links, fine-grained wire editing
- Lamps and hex displays inside a component show on its box with their
labels, lit by that instance's state; Counter 4 example shows its count.
- Several projects per browser; share links at /p/<id> that the creator's
edits save to automatically, others get their own copy. Export, open a
file as project, or add a file's components to the open project.
- Wires: drag any segment or corner, Alt+drag for a new bend, Ctrl+drag to
branch, double-click selects the whole signal, multi-select, arrow keys,
colour tags.
- Share-link API (POST/GET/PUT /api/p) on Nitro fs storage in data/, mounted
as a volume on edgerealm.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-17 11:21:49 +00:00
ed . clearSelection ( )
} else if ( ARROWS [ e . key ] ) {
e . preventDefault ( )
const [ dx , dy ] = ARROWS [ e . key ] !
const step = e . shiftKey ? 4 : 1
nudge ( dx * step , dy * step )
2026-10-17 10:49:38 +00:00
} else if ( e . key === ' ' ) {
e . preventDefault ( )
2026-10-23 10:43:08 +00:00
if ( ! e . repeat ) spaceTap = { at : performance . now ( ) }
2026-10-17 10:49:38 +00:00
spaceDown . value = true
} else if ( e . key === 'Enter' && ed . selection . value . length === 1 ) {
const n = nodeMap . value . get ( ed . selection . value [ 0 ] ! )
if ( n ? . kind === 'chip' && n . chip ) ed . open ( n . chip )
A input panels, automatic names, one-by-one wiring, tidy routing, truth table export
- Input panel part: rows of switches, buttons and clocks. "Attach input
panel" docks one to a component with a row per free input; it moves
with the component and follows its pins.
- Copies and new pins continue name series (D0 -> D1, A -> B); unnamed
switches, lamps and pins take the name of the component pin they are
wired to.
- Connecting: target pins are ringed, dropping on a part uses its next
free pin, click-then-click works, and "Connect one by one" (W) wires a
selection's pins in turn.
- Tidy wiring option and "Tidy all wires": sorted, evenly spaced columns
per gap, one trunk per signal, fewer crossings.
- Truth table full screen, CSV download, copy as Markdown, current row
highlighted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 17:17:25 +00:00
} else if ( ! mod && ! e . altKey && key === 'w' && ed . selection . value . length ) ed . startLinking ( ed . selection . value , e . shiftKey ? 'in' : undefined )
else if ( ! mod && ! e . altKey && key === 'f' ) fit ( )
R Panels: This and Pins on the left, the selection on the right
The left panel is about the circuit you are in: This (challenge and
Check on top, problems, name, statistics, truth table, as a component,
transistors, tools) and Pins. The selection gets its own panel on the
right, there only while something is selected, with its settings and
actions such as making a component out of it. The bars follow the
canvas width and drop labels when it gets narrow.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 18:38:17 +00:00
else if ( ! mod && ! e . altKey && e . key === '[' ) ed . togglePanel ( )
2026-10-17 10:49:38 +00:00
else if ( ! mod && ! e . altKey && e . key === '?' ) ed . showHelp . value = ! ed . showHelp . value
A campaign with unlocks, synthesised sound, puzzles and the puzzle of the week
- Campaign projects start with NAND only; challenges open along a
dependency chain, each solution becomes a usable part, and basic parts
unlock on the way. Locked parts and challenges say what opens them.
- Sound effects made with Web Audio: place, connect, switches, buttons,
delete, clock ticks (opt-in), solve, fail, unlock, record. Mute and
volume in the top bar and Display settings.
- Publish any circuit as a puzzle link; only its behaviour is shared.
The server re-runs the checks on submitted solutions, counts their
transistors and keeps each player's best; the board shows a histogram
and your place. A generated puzzle of the week for everyone.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 17:54:57 +00:00
else if ( ! mod && ! e . altKey && QUICK [ key ] && ed . canPlaceKind ( QUICK [ key ] ! ) ) ed . placing . value = { kind : QUICK [ key ] ! }
2026-10-17 10:49:38 +00:00
}
function onKeyUp ( e : KeyboardEvent ) {
2026-10-23 10:43:08 +00:00
if ( e . key === ' ' ) {
spaceDown . value = false
// A tap, not a hold for moving the view: the search box with recent parts and actions.
if ( spaceTap && performance . now ( ) - spaceTap . at < 350 && ! quick . value ) openQuickAdd ( )
spaceTap = null
}
A settings for every part, overlap-free wiring with crossing styles, accounts with sync
- Clicking anything opens its settings: swap parts in place (wires stay on
matching pins), clock frequency per clock, keyboard keys for switches and
buttons, lamp/display colours, note sizes, component names on the canvas,
position, unlink all wires, unpack a component, make an independent copy.
- Wires of different signals never share a line: auto routes pick free
columns or detours, remaining clashes go on separate lanes. Crossings drawn
as bow, triangle, bridge, gap or plain.
- Accounts (email + scrypt password, httpOnly session) with two-way project
sync and conflict copies; per-account limits; cross-site writes refused.
- Compatibility suite: a project and both browser-storage layouts from
release a241adc must load and compute identically.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-20 11:09:37 +00:00
const key = e . key . toLowerCase ( )
for ( const n of def . value . nodes ) if ( n . kind === 'button' && n . key === key ) ed . press ( n , false )
2026-10-21 09:51:45 +00:00
for ( const [ n , r ] of boundRows ( key ) ) if ( r . type === 'button' ) ed . pressRow ( n , r , false )
}
/** Panel rows bound to a key. */
function boundRows ( key : string ) : [ CircuitNode , PanelRow ] [ ] {
const out : [ CircuitNode , PanelRow ] [ ] = [ ]
for ( const n of def . value . nodes ) if ( n . kind === 'panel' ) for ( const r of n . rows ? ? [ ] ) if ( r . key === key ) out . push ( [ n , r ] )
return out
2026-10-17 10:49:38 +00:00
}
// ── Overlays ────────────────────────────────────────────────────────
A input panels, automatic names, one-by-one wiring, tidy routing, truth table export
- Input panel part: rows of switches, buttons and clocks. "Attach input
panel" docks one to a component with a row per free input; it moves
with the component and follows its pins.
- Copies and new pins continue name series (D0 -> D1, A -> B); unnamed
switches, lamps and pins take the name of the component pin they are
wired to.
- Connecting: target pins are ringed, dropping on a part uses its next
free pin, click-then-click works, and "Connect one by one" (W) wires a
selection's pins in turn.
- Tidy wiring option and "Tidy all wires": sorted, evenly spaced columns
per gap, one trunk per signal, fewer crossings.
- Truth table full screen, CSV download, copy as Markdown, current row
highlighted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 17:17:25 +00:00
/** The wire being drawn: dragged from a pin, or following the mouse after a click on a pin. */
const pending = computed ( ( ) => {
2026-10-17 10:49:38 +00:00
const d = drag . value
A input panels, automatic names, one-by-one wiring, tidy routing, truth table export
- Input panel part: rows of switches, buttons and clocks. "Attach input
panel" docks one to a component with a row per free input; it moves
with the component and follows its pins.
- Copies and new pins continue name series (D0 -> D1, A -> B); unnamed
switches, lamps and pins take the name of the component pin they are
wired to.
- Connecting: target pins are ringed, dropping on a part uses its next
free pin, click-then-click works, and "Connect one by one" (W) wires a
selection's pins in turn.
- Tidy wiring option and "Tidy all wires": sorted, evenly spaced columns
per gap, one trunk per signal, fewer crossings.
- Truth table full screen, CSV download, copy as Markdown, current row
highlighted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 17:17:25 +00:00
if ( d ? . kind === 'wire' ) return d . moved ? { node : d . node , pin : d . pin , dir : d . dir , cur : d . cur , branch : d . branch } : null
const l = ed . linking . value
const end = l ? . queue [ l . at ]
return end && cursor . value ? { node : end . node , pin : end . pin , dir : end . dir , cur : cursor . value , branch : undefined } : null
} )
const tempWire = computed ( ( ) => {
const d = pending . value
if ( ! d ) return null
2026-10-17 10:49:38 +00:00
const n = nodeMap . value . get ( d . node )
if ( ! n ) return null
A input panels, automatic names, one-by-one wiring, tidy routing, truth table export
- Input panel part: rows of switches, buttons and clocks. "Attach input
panel" docks one to a component with a row per free input; it moves
with the component and follows its pins.
- Copies and new pins continue name series (D0 -> D1, A -> B); unnamed
switches, lamps and pins take the name of the component pin they are
wired to.
- Connecting: target pins are ringed, dropping on a part uses its next
free pin, click-then-click works, and "Connect one by one" (W) wires a
selection's pins in turn.
- Tidy wiring option and "Tidy all wires": sorted, evenly spaced columns
per gap, one trunk per signal, fewer crossings.
- Truth table full screen, CSV download, copy as Markdown, current row
highlighted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 17:17:25 +00:00
const p = pinPos ( n , shapes . value . get ( n . id ) ! , d . pin , d . dir )
if ( ! p ) return null
const want = d . dir === 'out' ? 'in' : 'out'
BF split ports: no wire against the cable, pins that stay put, lines kept on unpack
A wire dropped on a socket with a cable in it only takes a line coming
out; the lines going in are the cable's, so it no longer drives one
against the cable. Wired by hand anyway, the check calls that an error,
like a signal sent by two parts. A line going in with neither a wire nor
a cable gets the usual "not connected (reads 0)" warning and marker.
While a wire is drawn over a socket it ends on the socket, where it goes
when let go, not on the pin below. Splitting or joining a port no longer
moves the pins on the other side of the box. Pins on their usual edge
come first, so a wire dropped on the box body takes those, and the cable
button only offers pins whose cable end sits outside the box.
Unpacking a component joins wires on its split lines to the parts that
used the line inside; wires that had nowhere to go are counted in a
notice. Docked panels line up with the moved ports when a project is
opened, not at the next edit.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 17:38:32 +00:00
// Over a port's socket the wire ends there, as it does when let go (the port splits into its lines).
const socket = drag . value ? . kind === 'wire' && drag . value . replace ? undefined : socketAt ( d )
const target = socket ? null : targetAt ( d . cur , want , ed . pinKind ( d . node , d . pin , d . dir ) )
2026-10-17 10:49:38 +00:00
let end : Pt = [ Math . round ( d . cur [ 0 ] ) , Math . round ( d . cur [ 1 ] ) ]
2026-10-22 16:59:56 +00:00
// The side the far end faces: a snapped pin's own, else the usual one.
let endFace : 1 | - 1 = want === 'in' ? - 1 : 1
BF split ports: no wire against the cable, pins that stay put, lines kept on unpack
A wire dropped on a socket with a cable in it only takes a line coming
out; the lines going in are the cable's, so it no longer drives one
against the cable. Wired by hand anyway, the check calls that an error,
like a signal sent by two parts. A line going in with neither a wire nor
a cable gets the usual "not connected (reads 0)" warning and marker.
While a wire is drawn over a socket it ends on the socket, where it goes
when let go, not on the pin below. Splitting or joining a port no longer
moves the pins on the other side of the box. Pins on their usual edge
come first, so a wire dropped on the box body takes those, and the cable
button only offers pins whose cable end sits outside the box.
Unpacking a component joins wires on its split lines to the parts that
used the line inside; wires that had nowhere to go are counted in a
notice. Docked panels line up with the moved ports when a project is
opened, not at the next edit.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 17:38:32 +00:00
if ( socket ) {
end = [ socket . x , socket . y ]
endFace = socket . face
} else if ( target ) {
2026-10-17 10:49:38 +00:00
const tn = nodeMap . value . get ( target . node ) !
A input panels, automatic names, one-by-one wiring, tidy routing, truth table export
- Input panel part: rows of switches, buttons and clocks. "Attach input
panel" docks one to a component with a row per free input; it moves
with the component and follows its pins.
- Copies and new pins continue name series (D0 -> D1, A -> B); unnamed
switches, lamps and pins take the name of the component pin they are
wired to.
- Connecting: target pins are ringed, dropping on a part uses its next
free pin, click-then-click works, and "Connect one by one" (W) wires a
selection's pins in turn.
- Tidy wiring option and "Tidy all wires": sorted, evenly spaced columns
per gap, one trunk per signal, fewer crossings.
- Truth table full screen, CSV download, copy as Markdown, current row
highlighted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 17:17:25 +00:00
const tp = pinPos ( tn , shapes . value . get ( tn . id ) ! , target . pin , want ) !
2026-10-17 10:49:38 +00:00
end = [ tp . x , tp . y ]
2026-10-22 16:59:56 +00:00
endFace = tp . face
2026-10-17 10:49:38 +00:00
}
A component faces, project library with share links, fine-grained wire editing
- Lamps and hex displays inside a component show on its box with their
labels, lit by that instance's state; Counter 4 example shows its count.
- Several projects per browser; share links at /p/<id> that the creator's
edits save to automatically, others get their own copy. Export, open a
file as project, or add a file's components to the open project.
- Wires: drag any segment or corner, Alt+drag for a new bend, Ctrl+drag to
branch, double-click selects the whole signal, multi-select, arrow keys,
colour tags.
- Share-link API (POST/GET/PUT /api/p) on Nitro fs storage in data/, mounted
as a volume on edgerealm.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-17 11:21:49 +00:00
const pts =
d . dir === 'out'
2026-10-22 16:59:56 +00:00
? routeWire ( [ p . x , p . y ] , end , d . branch && branchTo ( d . branch , [ p . x , p . y ] , end ) , p . face , endFace )
: routeWire ( end , [ p . x , p . y ] , undefined , endFace , p . face )
BF split ports: no wire against the cable, pins that stay put, lines kept on unpack
A wire dropped on a socket with a cable in it only takes a line coming
out; the lines going in are the cable's, so it no longer drives one
against the cable. Wired by hand anyway, the check calls that an error,
like a signal sent by two parts. A line going in with neither a wire nor
a cable gets the usual "not connected (reads 0)" warning and marker.
While a wire is drawn over a socket it ends on the socket, where it goes
when let go, not on the pin below. Splitting or joining a port no longer
moves the pins on the other side of the box. Pins on their usual edge
come first, so a wire dropped on the box body takes those, and the cable
button only offers pins whose cable end sits outside the box.
Unpacking a component joins wires on its split lines to the parts that
used the line inside; wires that had nowhere to go are counted in a
notice. Docked panels line up with the moved ports when a project is
opened, not at the next edit.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 17:38:32 +00:00
return { d : toPath ( pts ) , snapped : ! ! ( socket || target ) , end }
A input panels, automatic names, one-by-one wiring, tidy routing, truth table export
- Input panel part: rows of switches, buttons and clocks. "Attach input
panel" docks one to a component with a row per free input; it moves
with the component and follows its pins.
- Copies and new pins continue name series (D0 -> D1, A -> B); unnamed
switches, lamps and pins take the name of the component pin they are
wired to.
- Connecting: target pins are ringed, dropping on a part uses its next
free pin, click-then-click works, and "Connect one by one" (W) wires a
selection's pins in turn.
- Tidy wiring option and "Tidy all wires": sorted, evenly spaced columns
per gap, one trunk per signal, fewer crossings.
- Truth table full screen, CSV download, copy as Markdown, current row
highlighted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 17:17:25 +00:00
} )
A Loxone-style working aids: named signals, inverted inputs, a project check, values on cables, search, printable sheets; wire ends move by dragging
- Send signal / Use signal: name a signal (CLK, RESET) once and use it anywhere in the circuit without a wire; selecting one lights up all of them, a use with no sender shows dashed
- Inverted inputs: Alt + click an input (or the menu/settings) puts a bubble on it; it reads the signal inverted through one NAND, counted in every transistor total
- Check (Circuit tab): open inputs, parts that drive nothing, duplicate pin names, unsent or doubly sent signals, loops that never settle; click one to show it. Open inputs get an orange marker on the canvas. Components no other circuit uses are listed with a delete
- Cables show the number they carry (= 13 · 0x0D); hovering a wire tells where it runs and its value
- Ctrl+F finds parts, signals, panel rows, notes and components in every circuit, with where each component is used
- Ctrl+P prints the circuit as a sheet with a title block on white paper (or save as PDF); also as an SVG file
- + and − under a selected gate change its number of inputs; swaps keep bubbles in place
- Drag a wire by its end to move that end to another pin; drop a dragged wire on another wire to tap its signal or feed what it fed
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 11:26:59 +00:00
const isCable = ( w : Wire ) => nodeMap . value . get ( w . from . node ) ? . kind === 'bundle'
/ * *
* A wire being drawn and dropped on another wire ( not on a pin ) : one that
* needs a signal takes that wire ' s signal ; one that carries a signal feeds
* what that wire fed , in its place .
* /
function wireDrop ( d : { node : string ; pin : string ; dir : 'in' | 'out' ; cur : Pt ; replace ? : string } ) {
2026-10-22 16:59:56 +00:00
if ( targetAt ( d . cur , d . dir === 'out' ? 'in' : 'out' , ed . pinKind ( d . node , d . pin , d . dir ) ) ) return null
const bus = ed . pinKind ( d . node , d . pin , d . dir )
A Loxone-style working aids: named signals, inverted inputs, a project check, values on cables, search, printable sheets; wire ends move by dragging
- Send signal / Use signal: name a signal (CLK, RESET) once and use it anywhere in the circuit without a wire; selecting one lights up all of them, a use with no sender shows dashed
- Inverted inputs: Alt + click an input (or the menu/settings) puts a bubble on it; it reads the signal inverted through one NAND, counted in every transistor total
- Check (Circuit tab): open inputs, parts that drive nothing, duplicate pin names, unsent or doubly sent signals, loops that never settle; click one to show it. Open inputs get an orange marker on the canvas. Components no other circuit uses are listed with a delete
- Cables show the number they carry (= 13 · 0x0D); hovering a wire tells where it runs and its value
- Ctrl+F finds parts, signals, panel rows, notes and components in every circuit, with where each component is used
- Ctrl+P prints the circuit as a sheet with a title block on white paper (or save as PDF); also as an SVG file
- + and − under a selected gate change its number of inputs; swaps keep bubbles in place
- Drag a wire by its end to move that end to another pin; drop a dragged wire on another wire to tap its signal or feed what it fed
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 11:26:59 +00:00
for ( let i = routes . value . length - 1 ; i >= 0 ; i -- ) {
const r = routes . value [ i ] !
2026-10-22 16:59:56 +00:00
if ( r . wire . id === d . replace || r . kind !== bus ) continue
A Loxone-style working aids: named signals, inverted inputs, a project check, values on cables, search, printable sheets; wire ends move by dragging
- Send signal / Use signal: name a signal (CLK, RESET) once and use it anywhere in the circuit without a wire; selecting one lights up all of them, a use with no sender shows dashed
- Inverted inputs: Alt + click an input (or the menu/settings) puts a bubble on it; it reads the signal inverted through one NAND, counted in every transistor total
- Check (Circuit tab): open inputs, parts that drive nothing, duplicate pin names, unsent or doubly sent signals, loops that never settle; click one to show it. Open inputs get an orange marker on the canvas. Components no other circuit uses are listed with a delete
- Cables show the number they carry (= 13 · 0x0D); hovering a wire tells where it runs and its value
- Ctrl+F finds parts, signals, panel rows, notes and components in every circuit, with where each component is used
- Ctrl+P prints the circuit as a sheet with a title block on white paper (or save as PDF); also as an SVG file
- + and − under a selected gate change its number of inputs; swaps keep bubbles in place
- Drag a wire by its end to move that end to another pin; drop a dragged wire on another wire to tap its signal or feed what it fed
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 11:26:59 +00:00
if ( d . dir === 'in' ? r . wire . to . node === d . node && r . wire . to . pin === d . pin : r . wire . from . node === d . node && r . wire . from . pin === d . pin ) continue
const seg = segmentAt ( r . pts , d . cur , 0.35 )
if ( seg < 0 ) continue
return { route : r , seg , pin : d . dir === 'in' ? r . wire . from : r . wire . to }
}
return null
}
/** The wire a wire being drawn would drop onto, shown highlighted. */
const dropWire = computed ( ( ) => {
const d = pending . value
return d ? ( wireDrop ( { ... d , replace : drag . value ? . kind === 'wire' ? drag . value . replace : undefined } ) ? . route . wire . id ? ? null ) : null
} )
/** The wire whose end is being moved: drawn faint while it follows the mouse. */
const movingWire = computed ( ( ) => ( drag . value ? . kind === 'wire' && drag . value . moved ? ( drag . value . replace ? ? null ) : null ) )
const hoverWire = ref < string | null > ( null )
/** Grips on the ends of the wire under the mouse (or selected): drag one to move that end to another pin. */
const grips = computed ( ( ) => {
if ( drag . value ) return [ ]
const ids = new Set ( [ ... ed . wireSel . value . slice ( 0 , 8 ) , ... ( hoverWire . value ? [ hoverWire . value ] : [ ] ) ] )
return routes . value
. filter ( r => ids . has ( r . wire . id ) && ! r . bits )
. flatMap ( r =>
( [ 'from' , 'to' ] as const ) . flatMap ( end => {
const p = endGrip ( r . pts , end )
return p ? [ { wire : r . wire . id , end , x : p [ 0 ] , y : p [ 1 ] } ] : [ ]
} ) ,
)
} )
A input panels, automatic names, one-by-one wiring, tidy routing, truth table export
- Input panel part: rows of switches, buttons and clocks. "Attach input
panel" docks one to a component with a row per free input; it moves
with the component and follows its pins.
- Copies and new pins continue name series (D0 -> D1, A -> B); unnamed
switches, lamps and pins take the name of the component pin they are
wired to.
- Connecting: target pins are ringed, dropping on a part uses its next
free pin, click-then-click works, and "Connect one by one" (W) wires a
selection's pins in turn.
- Tidy wiring option and "Tidy all wires": sorted, evenly spaced columns
per gap, one trunk per signal, fewer crossings.
- Truth table full screen, CSV download, copy as Markdown, current row
highlighted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 17:17:25 +00:00
/** Pins a wire being drawn can go to: free ones stand out, taken ones would be replaced. */
const targets = computed ( ( ) => {
const d = pending . value
if ( ! d ) return [ ]
const want = d . dir === 'out' ? 'in' : 'out'
2026-10-22 16:59:56 +00:00
const bus = ed . pinKind ( d . node , d . pin , d . dir )
A input panels, automatic names, one-by-one wiring, tidy routing, truth table export
- Input panel part: rows of switches, buttons and clocks. "Attach input
panel" docks one to a component with a row per free input; it moves
with the component and follows its pins.
- Copies and new pins continue name series (D0 -> D1, A -> B); unnamed
switches, lamps and pins take the name of the component pin they are
wired to.
- Connecting: target pins are ringed, dropping on a part uses its next
free pin, click-then-click works, and "Connect one by one" (W) wires a
selection's pins in turn.
- Tidy wiring option and "Tidy all wires": sorted, evenly spaced columns
per gap, one trunk per signal, fewer crossings.
- Truth table full screen, CSV download, copy as Markdown, current row
highlighted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 17:17:25 +00:00
const taken = linked . value [ want ]
const out : { x : number ; y : number ; free : boolean } [ ] = [ ]
for ( const n of def . value . nodes ) {
const s = shapes . value . get ( n . id ) !
for ( const p of want === 'in' ? s . inputs : s . outputs ) {
2026-10-22 16:59:56 +00:00
if ( pinKindOf ( p ) !== bus ) continue
A input panels, automatic names, one-by-one wiring, tidy routing, truth table export
- Input panel part: rows of switches, buttons and clocks. "Attach input
panel" docks one to a component with a row per free input; it moves
with the component and follows its pins.
- Copies and new pins continue name series (D0 -> D1, A -> B); unnamed
switches, lamps and pins take the name of the component pin they are
wired to.
- Connecting: target pins are ringed, dropping on a part uses its next
free pin, click-then-click works, and "Connect one by one" (W) wires a
selection's pins in turn.
- Tidy wiring option and "Tidy all wires": sorted, evenly spaced columns
per gap, one trunk per signal, fewer crossings.
- Truth table full screen, CSV download, copy as Markdown, current row
highlighted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 17:17:25 +00:00
// An output can always take one more wire; an input only has room for one.
out . push ( { x : n . x + p . dx , y : n . y + p . dy , free : want === 'out' || ! taken . has ( ` ${ n . id } : ${ p . key } ` ) } )
}
}
A ports on top of the box, split into lines to wire by hand
On a component's box every connector port now sits at the very top of its
side, above the single pins, in auto and hand-drawn boxes alike. A port
can be split on one placed component (its settings or right click: Split
… into lines): right below the socket the box then gets a pin per line,
named after the line, so lines can be wired by hand without an adapter.
Lines going into the component are inputs, lines coming out outputs, each
facing out of its side; a bar in the type's colour ties them to the
socket. A cable still plugs into the socket at the same time. Dropping a
single wire on a socket (or clicking one while connecting) splits the
port and takes the first free line that runs that way. Join … lines
takes the line pins and their wires away again, as one undo step.
A line wired by hand joins the same net the cable's line reaches inside;
a wire and a cable on one line both drive it, and the check says so.
Line pins are left out of the open-input warning, docked panels and
bubbles; docked panels no longer get a row for a port's socket either.
Saved as an optional list on the placed component (splitPorts); without
it a box only has its ports moved to the top.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 17:08:27 +00:00
// A single wire can go onto a port's socket too: the port splits into its lines.
if ( ! bus ) for ( const s of openSockets . value [ want ] ) out . push ( { x : s . x , y : s . y , free : true } )
2026-10-26 21:45:47 +00:00
// A cable pulled out of a cable end can also be let go on free single pins: its other end lands on them.
if ( pullable ( d ) ) {
for ( const n of def . value . nodes ) {
const s = shapes . value . get ( n . id ) !
for ( const p of want === 'in' ? s . inputs : s . outputs ) {
if ( ! pinKindOf ( p ) && ( want === 'out' || ! taken . has ( ` ${ n . id } : ${ p . key } ` ) ) ) out . push ( { x : n . x + p . dx , y : n . y + p . dy , free : true } )
}
}
}
A input panels, automatic names, one-by-one wiring, tidy routing, truth table export
- Input panel part: rows of switches, buttons and clocks. "Attach input
panel" docks one to a component with a row per free input; it moves
with the component and follows its pins.
- Copies and new pins continue name series (D0 -> D1, A -> B); unnamed
switches, lamps and pins take the name of the component pin they are
wired to.
- Connecting: target pins are ringed, dropping on a part uses its next
free pin, click-then-click works, and "Connect one by one" (W) wires a
selection's pins in turn.
- Tidy wiring option and "Tidy all wires": sorted, evenly spaced columns
per gap, one trunk per signal, fewer crossings.
- Truth table full screen, CSV download, copy as Markdown, current row
highlighted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 17:17:25 +00:00
return out
} )
/** Numbers on the pins still waiting in "connect one by one". */
const queueBadges = computed ( ( ) => {
const l = ed . linking . value
if ( ! l || l . queue . length < 2 ) return [ ]
return l . queue . flatMap ( ( e , i ) => {
if ( i < l . at ) return [ ]
const n = nodeMap . value . get ( e . node )
const p = n && pinPos ( n , shapes . value . get ( n . id ) ! , e . pin , e . dir )
return p ? [ { x : p . x + ( e . dir === 'out' ? 0.75 : - 0.75 ) , y : p . y - 0.55 , n : i + 1 , current : i === l . at } ] : [ ]
} )
2026-10-17 10:49:38 +00:00
} )
const boxRect = computed ( ( ) => {
const d = drag . value
if ( d ? . kind !== 'box' ) return null
return {
x : Math . min ( d . start [ 0 ] , d . cur [ 0 ] ) * G ,
y : Math . min ( d . start [ 1 ] , d . cur [ 1 ] ) * G ,
width : Math . abs ( d . cur [ 0 ] - d . start [ 0 ] ) * G ,
height : Math . abs ( d . cur [ 1 ] - d . start [ 1 ] ) * G ,
2026-10-21 09:08:32 +00:00
// Right to left: everything the box touches (drawn green, as in CAD programs).
class : d . cur [ 0 ] < d . start [ 0 ] ? 'box-select crossing' : 'box-select' ,
2026-10-17 10:49:38 +00:00
}
} )
A component faces, project library with share links, fine-grained wire editing
- Lamps and hex displays inside a component show on its box with their
labels, lit by that instance's state; Counter 4 example shows its count.
- Several projects per browser; share links at /p/<id> that the creator's
edits save to automatically, others get their own copy. Export, open a
file as project, or add a file's components to the open project.
- Wires: drag any segment or corner, Alt+drag for a new bend, Ctrl+drag to
branch, double-click selects the whole signal, multi-select, arrow keys,
colour tags.
- Share-link API (POST/GET/PUT /api/p) on Nitro fs storage in data/, mounted
as a volume on edgerealm.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-17 11:21:49 +00:00
/** Corner handles of the selected wires. */
const handles = computed ( ( ) =>
routes . value
. filter ( r => wireSelected . value . has ( r . wire . id ) )
. flatMap ( r => r . pts . slice ( 1 , - 1 ) . map ( ( p , i ) => ( { wire : r . wire . id , i : i + 1 , x : p [ 0 ] , y : p [ 1 ] } ) ) ) ,
)
2026-10-17 10:49:38 +00:00
const gridSize = computed ( ( ) => G * view . value . zoom )
const flow = computed ( ( ) => ed . project . value . settings . flow )
2026-10-21 08:39:54 +00:00
/** Preview while placing a cable: its start (where you clicked or the mouse) and its end. */
const cableGhost = computed ( ( ) => {
const c = ed . cabling . value
if ( ! c || ! cursor . value ) return null
const at : Pt = [ Math . round ( cursor . value [ 0 ] ) , Math . round ( cursor . value [ 1 ] ) ]
const bits = c . wires . length
const mid = Math . floor ( ( bits - 1 ) / 2 )
const end = ( kind : 'bundle' | 'split' , p : Pt ) : CircuitNode => ( { id : ` ghost- ${ kind } ` , kind , bits , x : p [ 0 ] , y : p [ 1 ] - mid } )
if ( ! c . start ) return { nodes : [ end ( 'bundle' , at ) ] , line : '' }
return { nodes : [ end ( 'bundle' , c . start ) , end ( 'split' , at ) ] , line : toPath ( routeWire ( c . start , at ) ) }
} )
A Loxone-style working aids: named signals, inverted inputs, a project check, values on cables, search, printable sheets; wire ends move by dragging
- Send signal / Use signal: name a signal (CLK, RESET) once and use it anywhere in the circuit without a wire; selecting one lights up all of them, a use with no sender shows dashed
- Inverted inputs: Alt + click an input (or the menu/settings) puts a bubble on it; it reads the signal inverted through one NAND, counted in every transistor total
- Check (Circuit tab): open inputs, parts that drive nothing, duplicate pin names, unsent or doubly sent signals, loops that never settle; click one to show it. Open inputs get an orange marker on the canvas. Components no other circuit uses are listed with a delete
- Cables show the number they carry (= 13 · 0x0D); hovering a wire tells where it runs and its value
- Ctrl+F finds parts, signals, panel rows, notes and components in every circuit, with where each component is used
- Ctrl+P prints the circuit as a sheet with a title block on white paper (or save as PDF); also as an SVG file
- + and − under a selected gate change its number of inputs; swaps keep bubbles in place
- Drag a wire by its end to move that end to another pin; drop a dragged wire on another wire to tap its signal or feed what it fed
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 11:26:59 +00:00
// ── Sheets ──────────────────────────────────────────────────────────
const content = ref < SVGGElement > ( )
/** The open circuit as a sheet with a title block: printed on white paper, or saved as SVG like on screen. */
watch (
( ) => ed . sheetRequest . value ? . n ,
( ) => {
const req = ed . sheetRequest . value
if ( ! req || ! content . value ) return
if ( ! def . value . nodes . length ) return ed . notify ( 'Nothing to print: the circuit is empty' , 'error' )
const b = bounds ( def . value . nodes )
for ( const r of routes . value ) {
for ( const [ x , y ] of r . pts ) {
b . x0 = Math . min ( b . x0 , x )
b . x1 = Math . max ( b . x1 , x )
b . y0 = Math . min ( b . y0 , y )
b . y1 = Math . max ( b . y1 , y )
}
}
const m = 2
const box = { x : ( b . x0 - m ) * G , y : ( b . y0 - m ) * G , w : ( b . x1 - b . x0 + 2 * m ) * G , h : ( b . y1 - b . y0 + 2 * m ) * G }
// Without the selection, so the sheet shows the circuit as it is.
const keep = { nodes : ed . selection . value , wires : ed . wireSel . value }
ed . selection . value = [ ]
ed . wireSel . value = [ ]
nextTick ( ( ) => {
const info = { project : ed . meta . value ? . name ? ? ed . project . value . name ? ? 'Project' , circuit : def . value . name , date : new Date ( ) , box }
if ( req . mode === 'print' ) printSheet ( sheetSvg ( content . value ! , { ... info , paper : true } ) , ` ${ info . project } - ${ info . circuit } ` )
else downloadSheet ( sheetSvg ( content . value ! , info ) , info . circuit )
ed . selection . value = keep . nodes
ed . wireSel . value = keep . wires
} )
} ,
)
A finer component boxes, a regrouped parts list with keyboard search, a real green for wires and cables
- Box designer: drag pins up or down to open gaps between groups; size (+/−) and turn (R) lamps, displays, screens and drawings; pixels belong to named screens, each placed on its own; displays of the components inside can be shown on the box (off unless ticked); a list of everything the box can show, each optional; the box grows to hold what it shows
- Lamps and displays deep inside placed components light up on the box
- Parts list: one search box for parts and components (letters in order match too), recently placed parts first, grouped Logic / Inputs / Outputs / Wiring / Notes, then components by group; groups fold away
- Keys: / searches the parts list (Enter starts placing), Shift+A or Ctrl+K adds a part at the mouse
- Wires and cables get a green; the default swatch shows grey, as the default really is
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-22 04:48:42 +00:00
// ── Quick add ───────────────────────────────────────────────────────
/** The quick-add box: where it opened on screen and on the canvas. */
const quick = ref < { x : number ; y : number ; at : Pt } | null > ( null )
let lastClient = { x : 0 , y : 0 }
R Top bar like the parts bar, no left panel
The parts panel on the left is gone: pinned parts sit at the start of the
bottom bar, components open from the pencil in its Components list (or a
double-click), examples load from there too. The side panel moved to the
left. The top bar floats across the whole width: menu with the project,
Main and the way into the open component instead of the circuit
selector, Challenges in a drop-down, clock, search, undo, settings,
share and account. / and the bar's search open quick add.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 18:17:41 +00:00
function openQuickAdd ( centre = false ) {
A finer component boxes, a regrouped parts list with keyboard search, a real green for wires and cables
- Box designer: drag pins up or down to open gaps between groups; size (+/−) and turn (R) lamps, displays, screens and drawings; pixels belong to named screens, each placed on its own; displays of the components inside can be shown on the box (off unless ticked); a list of everything the box can show, each optional; the box grows to hold what it shows
- Lamps and displays deep inside placed components light up on the box
- Parts list: one search box for parts and components (letters in order match too), recently placed parts first, grouped Logic / Inputs / Outputs / Wiring / Notes, then components by group; groups fold away
- Keys: / searches the parts list (Enter starts placing), Shift+A or Ctrl+K adds a part at the mouse
- Wires and cables get a green; the default swatch shows grey, as the default really is
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-22 04:48:42 +00:00
const r = root . value ! . getBoundingClientRect ( )
R Top bar like the parts bar, no left panel
The parts panel on the left is gone: pinned parts sit at the start of the
bottom bar, components open from the pencil in its Components list (or a
double-click), examples load from there too. The side panel moved to the
left. The top bar floats across the whole width: menu with the project,
Main and the way into the open component instead of the circuit
selector, Challenges in a drop-down, clock, search, undo, settings,
share and account. / and the bar's search open quick add.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 18:17:41 +00:00
const inside = ! centre && lastClient . x >= r . left && lastClient . x <= r . right && lastClient . y >= r . top && lastClient . y <= r . bottom
A finer component boxes, a regrouped parts list with keyboard search, a real green for wires and cables
- Box designer: drag pins up or down to open gaps between groups; size (+/−) and turn (R) lamps, displays, screens and drawings; pixels belong to named screens, each placed on its own; displays of the components inside can be shown on the box (off unless ticked); a list of everything the box can show, each optional; the box grows to hold what it shows
- Lamps and displays deep inside placed components light up on the box
- Parts list: one search box for parts and components (letters in order match too), recently placed parts first, grouped Logic / Inputs / Outputs / Wiring / Notes, then components by group; groups fold away
- Keys: / searches the parts list (Enter starts placing), Shift+A or Ctrl+K adds a part at the mouse
- Wires and cables get a green; the default swatch shows grey, as the default really is
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-22 04:48:42 +00:00
const x = inside ? lastClient . x : r . left + r . width / 2
const y = inside ? lastClient . y : r . top + r . height / 3
quick . value = { x , y , at : toWorld ( { clientX : x , clientY : y } ) }
}
R Top bar like the parts bar, no left panel
The parts panel on the left is gone: pinned parts sit at the start of the
bottom bar, components open from the pencil in its Components list (or a
double-click), examples load from there too. The side panel moved to the
left. The top bar floats across the whole width: menu with the project,
Main and the way into the open component instead of the circuit
selector, Challenges in a drop-down, clock, search, undo, settings,
share and account. / and the bar's search open quick add.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 18:17:41 +00:00
// The search button in the parts bar opens it in the middle of the canvas.
watch ( ed . partSearch , ( ) => openQuickAdd ( true ) )
A finer component boxes, a regrouped parts list with keyboard search, a real green for wires and cables
- Box designer: drag pins up or down to open gaps between groups; size (+/−) and turn (R) lamps, displays, screens and drawings; pixels belong to named screens, each placed on its own; displays of the components inside can be shown on the box (off unless ticked); a list of everything the box can show, each optional; the box grows to hold what it shows
- Lamps and displays deep inside placed components light up on the box
- Parts list: one search box for parts and components (letters in order match too), recently placed parts first, grouped Logic / Inputs / Outputs / Wiring / Notes, then components by group; groups fold away
- Keys: / searches the parts list (Enter starts placing), Shift+A or Ctrl+K adds a part at the mouse
- Wires and cables get a green; the default swatch shows grey, as the default really is
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-22 04:48:42 +00:00
function onQuickPick ( p : { kind : CircuitNode [ 'kind' ] ; chip ? : string } ) {
const q = quick . value
quick . value = null
if ( ! q ) return
const { node , links } = landing ( p , q . at , false )
ed . addNode ( p , node . x , node . y , links )
}
A right-click menu for parts, wires and the canvas, "Wire them all to" as cards, plugged latches in plain greys
- Right click (or the menu key) shows what can be done with what is under the pointer: one part (open, rename, change to, inputs, colour, speed, panels, unpack, plug and unplug, cable colour), several parts (wire them all to with live preview, connect one by one, switches, change all, arrange, keep only, make a component), wires (bundle, colour, whole signal, straighten, remove cable) or empty canvas (paste here, add a part here, select all, fit, tidy, undo); right drag still moves the view
- "Wire them all to": a card per part, each fit a strip of its pins, and which wire goes where for the fit pointed at
- Plugged cable ends no longer look selected: grey connector, steel clips
- Icons named in menus are bundled for the browser too
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 10:33:30 +00:00
// ── Context menu ────────────────────────────────────────────────────
const menu = ref < { x : number ; y : number ; entries : MenuEntry [ ] ; keyboard ? : boolean } | null > ( null )
const { build } = useMenu ( )
const canvasOps : CanvasOps = {
fit ,
place : ( kind , at ) => {
const [ x , y ] = originFor ( { kind } , at )
ed . addNode ( { kind } , x , y )
} ,
}
/ * *
* Right click : on a part or wire it selects that ( unless it is in the
* selection already ) and shows what can be done with the selection ; on
* empty canvas , what can go there .
* /
function openMenuAt ( target : Element , at : Pt , x : number , y : number ) {
const nodeId = target . closest ( '[data-node]' ) ? . getAttribute ( 'data-node' )
const wireId = target . closest ( '[data-wire]' ) ? . getAttribute ( 'data-wire' )
const junction = target . closest ( '[data-junction]' ) ? . getAttribute ( 'data-junction' )
A pick pins for a cable, buttons on pointing, right-click on pins; docked panels move freely
- Pointing at a part shows its round buttons, as if it were selected; they
stay while the pointer goes to them.
- A box around some pins of one part (not over its middle), or Shift +
click on pins, picks exactly those pins: a cable plug on them, wire them
one by one, invert or unwire them, from buttons beside them or a
right-click.
- Right-click on a pin offers what can be done right there first: split a
component's cable socket into wires (or join), pull a cable out of a cable
end, invert an input.
- A docked panel moves both ways now: moved up or down off its component's
pins it lets go and stays a panel of its own (rows and wires kept);
moved sideways it stays docked.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-27 12:34:16 +00:00
// On a picked pin the picked pins stay picked (selecting the part would put them down).
const onPicked = ! ! ed . pinSel . value && ed . pinSel . value . node === nodeId && ed . pinSel . value . pins . includes ( target . closest ( '[data-pin]' ) ? . getAttribute ( 'data-pin' ) ? ? '' )
A right-click menu for parts, wires and the canvas, "Wire them all to" as cards, plugged latches in plain greys
- Right click (or the menu key) shows what can be done with what is under the pointer: one part (open, rename, change to, inputs, colour, speed, panels, unpack, plug and unplug, cable colour), several parts (wire them all to with live preview, connect one by one, switches, change all, arrange, keep only, make a component), wires (bundle, colour, whole signal, straighten, remove cable) or empty canvas (paste here, add a part here, select all, fit, tidy, undo); right drag still moves the view
- "Wire them all to": a card per part, each fit a strip of its pins, and which wire goes where for the fit pointed at
- Plugged cable ends no longer look selected: grey connector, steel clips
- Icons named in menus are bundled for the browser too
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 10:33:30 +00:00
if ( nodeId && nodeMap . value . has ( nodeId ) ) {
A pick pins for a cable, buttons on pointing, right-click on pins; docked panels move freely
- Pointing at a part shows its round buttons, as if it were selected; they
stay while the pointer goes to them.
- A box around some pins of one part (not over its middle), or Shift +
click on pins, picks exactly those pins: a cable plug on them, wire them
one by one, invert or unwire them, from buttons beside them or a
right-click.
- Right-click on a pin offers what can be done right there first: split a
component's cable socket into wires (or join), pull a cable out of a cable
end, invert an input.
- A docked panel moves both ways now: moved up or down off its component's
pins it lets go and stays a panel of its own (rows and wires kept);
moved sideways it stays docked.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-27 12:34:16 +00:00
if ( ! selected . value . has ( nodeId ) && ! onPicked ) {
A right-click menu for parts, wires and the canvas, "Wire them all to" as cards, plugged latches in plain greys
- Right click (or the menu key) shows what can be done with what is under the pointer: one part (open, rename, change to, inputs, colour, speed, panels, unpack, plug and unplug, cable colour), several parts (wire them all to with live preview, connect one by one, switches, change all, arrange, keep only, make a component), wires (bundle, colour, whole signal, straighten, remove cable) or empty canvas (paste here, add a part here, select all, fit, tidy, undo); right drag still moves the view
- "Wire them all to": a card per part, each fit a strip of its pins, and which wire goes where for the fit pointed at
- Plugged cable ends no longer look selected: grey connector, steel clips
- Icons named in menus are bundled for the browser too
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 10:33:30 +00:00
ed . selection . value = [ nodeId ]
ed . wireSel . value = [ ]
}
} else if ( wireId ) {
if ( ! wireSelected . value . has ( wireId ) ) {
ed . wireSel . value = [ wireId ]
ed . selection . value = [ ]
}
} else if ( junction ) {
ed . wireSel . value = def . value . wires . filter ( w => ` ${ w . from . node } : ${ w . from . pin } ` === junction ) . map ( w => w . id )
ed . selection . value = [ ]
}
const onThing = ! ! ( nodeId || wireId || junction )
const entries = build ( onThing ? { kind : 'selection' } : { kind : 'canvas' , at } , canvasOps )
2026-10-23 10:27:12 +00:00
// On an input pin: its bubble first (the same as Alt + click, which some desktops take for themselves).
A pick pins for a cable, buttons on pointing, right-click on pins; docked panels move freely
- Pointing at a part shows its round buttons, as if it were selected; they
stay while the pointer goes to them.
- A box around some pins of one part (not over its middle), or Shift +
click on pins, picks exactly those pins: a cable plug on them, wire them
one by one, invert or unwire them, from buttons beside them or a
right-click.
- Right-click on a pin offers what can be done right there first: split a
component's cable socket into wires (or join), pull a cable out of a cable
end, invert an input.
- A docked panel moves both ways now: moved up or down off its component's
pins it lets go and stays a panel of its own (rows and wires kept);
moved sideways it stays docked.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-27 12:34:16 +00:00
const pinEl = target . closest ( '[data-pin]' )
const pin = pinEl ? . getAttribute ( 'data-pin' )
const dir = pinEl ? . getAttribute ( 'data-dir' ) as 'in' | 'out' | undefined
2026-10-23 10:27:12 +00:00
const n = nodeId ? nodeMap . value . get ( nodeId ) : undefined
A pick pins for a cable, buttons on pointing, right-click on pins; docked panels move freely
- Pointing at a part shows its round buttons, as if it were selected; they
stay while the pointer goes to them.
- A box around some pins of one part (not over its middle), or Shift +
click on pins, picks exactly those pins: a cable plug on them, wire them
one by one, invert or unwire them, from buttons beside them or a
right-click.
- Right-click on a pin offers what can be done right there first: split a
component's cable socket into wires (or join), pull a cable out of a cable
end, invert an input.
- A docked panel moves both ways now: moved up or down off its component's
pins it lets go and stays a panel of its own (rows and wires kept);
moved sideways it stays docked.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-27 12:34:16 +00:00
const here : MenuEntry [ ] = [ ]
if ( pin && dir && n ) {
const shape = shapes . value . get ( n . id ) !
const p = ( dir === 'in' ? shape . inputs : shape . outputs ) . find ( x => x . key === pin )
// A cable socket on a component: split it into its wires right here, or join them.
if ( p ? . conn && n . kind === 'chip' ) {
const split = ! ! n . splitPorts ? . includes ( pin )
here . push ( { label : split ? ` Join the ${ p . label } wires ` : ` Split ${ p . label } into wires here ` , icon : split ? 'lucide:merge' : 'lucide:split' , run : ( ) => ed . toggleSplit ( n , pin ) } )
}
// A cable end's cable pin: pull the cable out right here (plugging and taking apart are in the end's own menu below).
if ( p ? . bus && ( n . kind === 'bundle' || n . kind === 'split' ) ) {
const pull = endActions ( n ) . find ( x => x . key === 'pull' )
if ( pull ) here . push ( { label : 'Pull the cable out' , icon : pull . icon , run : ( ) => pull . run ( new PointerEvent ( 'pointerdown' ) ) } )
}
if ( dir === 'in' && ed . canInvert ( n , pin ) ) {
const on = n . invert ? . includes ( pin )
here . push ( { label : on ? 'Take the bubble off this input' : 'Invert this input' , icon : 'lucide:circle-dot' , keys : 'Alt+click' , run : ( ) => ed . toggleInvert ( n , pin ) } )
}
}
// Picked pins (right-clicked on one of them): what can be done with all of them.
const sel = ed . pinSel . value
if ( sel && n && sel . node === n . id && ( ! pin || sel . pins . includes ( pin ) ) ) {
const count = ` ${ sel . pins . length } ${ sel . dir === 'out' ? 'output' : 'input' } ${ sel . pins . length === 1 ? '' : 's' } `
here . unshift (
{ head : ` ${ count } picked ` } ,
... ( sel . pins . length >= 2 ? [ { label : 'A cable plug on them' , icon : sel . dir === 'out' ? 'lucide:merge' : 'lucide:split' , run : ( ) => ed . cablePicked ( ) } ] : [ ] ) ,
{ label : 'Wire them one by one' , icon : 'lucide:cable' , run : ( ) => ed . linkPicked ( ) } ,
... ( sel . dir === 'in' ? [ { label : 'Invert them' , icon : 'lucide:circle-dot' , run : ( ) => ed . invertPicked ( ) } ] : [ ] ) ,
{ label : 'Remove their wires' , icon : 'lucide:unlink' , danger : true , run : ( ) => ed . unwirePicked ( ) } ,
)
2026-10-23 10:27:12 +00:00
}
A pick pins for a cable, buttons on pointing, right-click on pins; docked panels move freely
- Pointing at a part shows its round buttons, as if it were selected; they
stay while the pointer goes to them.
- A box around some pins of one part (not over its middle), or Shift +
click on pins, picks exactly those pins: a cable plug on them, wire them
one by one, invert or unwire them, from buttons beside them or a
right-click.
- Right-click on a pin offers what can be done right there first: split a
component's cable socket into wires (or join), pull a cable out of a cable
end, invert an input.
- A docked panel moves both ways now: moved up or down off its component's
pins it lets go and stays a panel of its own (rows and wires kept);
moved sideways it stays docked.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-27 12:34:16 +00:00
if ( here . length ) entries . unshift ( ... here , 'sep' )
A right-click menu for parts, wires and the canvas, "Wire them all to" as cards, plugged latches in plain greys
- Right click (or the menu key) shows what can be done with what is under the pointer: one part (open, rename, change to, inputs, colour, speed, panels, unpack, plug and unplug, cable colour), several parts (wire them all to with live preview, connect one by one, switches, change all, arrange, keep only, make a component), wires (bundle, colour, whole signal, straighten, remove cable) or empty canvas (paste here, add a part here, select all, fit, tidy, undo); right drag still moves the view
- "Wire them all to": a card per part, each fit a strip of its pins, and which wire goes where for the fit pointed at
- Plugged cable ends no longer look selected: grey connector, steel clips
- Icons named in menus are bundled for the browser too
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 10:33:30 +00:00
menu . value = entries . length ? { x : x + 2 , y : y + 2 , entries } : null
}
/** The menu key (or Shift+F10): the menu for the selection, by its middle. */
function openMenuForSelection ( ) {
const r = root . value ! . getBoundingClientRect ( )
const ids = new Set ( ed . selection . value )
const nodes = def . value . nodes . filter ( n => ids . has ( n . id ) )
const v = view . value
let at : Pt = [ ( size . w / 2 - v . x ) / ( G * v . zoom ) , ( size . h / 2 - v . y ) / ( G * v . zoom ) ]
if ( nodes . length ) {
const b = bounds ( nodes )
at = [ ( b . x0 + b . x1 ) / 2 , ( b . y0 + b . y1 ) / 2 ]
}
const x = r . left + v . x + at [ 0 ] * G * v . zoom
const y = r . top + v . y + at [ 1 ] * G * v . zoom
const entries = build ( nodes . length || ed . wireSel . value . length ? { kind : 'selection' } : { kind : 'canvas' , at } , canvasOps )
menu . value = entries . length ? { x , y , entries , keyboard : true } : null
}
BF input panels are component inputs, cable ends plug in more reliably; A merge panels, hex pass-through, design a component's box
- Inside a component, the switch and button rows of its input panels are now input pins (in order with the other inputs, named after the rows); "Rows are component inputs" can be turned off per panel to keep the old fixed switches
- Select input panels, Merge: one panel with all rows, spacing and wires kept; circuits that place this one keep their wires
- Cable ends plug in more often: bundling orders the wires by the part a side runs to, an end with only some wires on a part still plugs, an end placed by hand next to the pins plugs, and dragging an end near its part shows green rings and plugs it on drop
- Hex displays pass their four bits on (outputs on the right), so they can sit in the middle of a bus
- Design the box: move lamps, displays, the screen and the name on a component's box, draw lines, boxes, circles and text in six colours, size it, leave things off; every placed copy shows it
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 11:49:29 +00:00
/ * *
* A free cable end dragged to within a square or so of where it would sit
2026-10-23 13:34:36 +00:00
* on its part ' s pins : the pins it would plug into . Any other part brought as
* close to where it would latch onto the part it is wired to : the pins it
* would latch onto .
BF input panels are component inputs, cable ends plug in more reliably; A merge panels, hex pass-through, design a component's box
- Inside a component, the switch and button rows of its input panels are now input pins (in order with the other inputs, named after the rows); "Rows are component inputs" can be turned off per panel to keep the old fixed switches
- Select input panels, Merge: one panel with all rows, spacing and wires kept; circuits that place this one keep their wires
- Cable ends plug in more often: bundling orders the wires by the part a side runs to, an end with only some wires on a part still plugs, an end placed by hand next to the pins plugs, and dragging an end near its part shows green rings and plugs it on drop
- Hex displays pass their four bits on (outputs on the right), so they can sit in the middle of a bus
- Design the box: move lamps, displays, the screen and the name on a component's box, draw lines, boxes, circles and text in six colours, size it, leave things off; every placed copy shows it
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 11:49:29 +00:00
* /
2026-10-26 17:21:34 +00:00
function plugNear ( n : CircuitNode ) : { part : string ; rings : Pt [ ] ; at : Pt } | null {
2026-10-23 13:34:36 +00:00
if ( n . kind !== 'bundle' && n . kind !== 'split' ) {
const host = ed . latchTargetOf ( { ... n , latch : undefined } )
const lay = host && latchLayout ( def . value , n , host , ed . getDef . value )
// Not onto a part that is latched onto this one (it moves along anyway).
if ( ! host || ! lay || ed . withFollowers ( [ n . id ] ) . has ( host . id ) || Math . hypot ( n . x - lay . x , n . y - lay . y ) > 1.6 ) return null
const s = shapes . value . get ( n . id ) !
const shared = def . value . wires . filter ( w => ( w . from . node === host . id && w . to . node === n . id ) || ( w . from . node === n . id && w . to . node === host . id ) )
const rings = shared
. map ( w => ( w . to . node === n . id ? s . inputs . find ( p => p . key === w . to . pin ) : s . outputs . find ( p => p . key === w . from . pin ) ) )
. filter ( p => ! ! p )
. map ( p => [ lay . x + p . dx , lay . y + p . dy ] as Pt )
2026-10-26 17:21:34 +00:00
return { part : host . id , rings , at : [ lay . x , lay . y ] }
2026-10-23 13:34:36 +00:00
}
if ( n . plug ) return null
BF input panels are component inputs, cable ends plug in more reliably; A merge panels, hex pass-through, design a component's box
- Inside a component, the switch and button rows of its input panels are now input pins (in order with the other inputs, named after the rows); "Rows are component inputs" can be turned off per panel to keep the old fixed switches
- Select input panels, Merge: one panel with all rows, spacing and wires kept; circuits that place this one keep their wires
- Cable ends plug in more often: bundling orders the wires by the part a side runs to, an end with only some wires on a part still plugs, an end placed by hand next to the pins plugs, and dragging an end near its part shows green rings and plugs it on drop
- Hex displays pass their four bits on (outputs on the right), so they can sit in the middle of a bus
- Design the box: move lamps, displays, the screen and the name on a component's box, draw lines, boxes, circles and text in six colours, size it, leave things off; every placed copy shows it
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 11:49:29 +00:00
const part = ed . plugTarget ( n )
const lay = part && plugLayout ( def . value , n , part , ed . getDef . value )
if ( ! part || ! lay || Math . hypot ( n . x - lay . x , n . y - lay . y ) > 1.6 ) return null
const x = n . kind === 'split' ? lay . x + 1 : lay . x
2026-10-26 17:21:34 +00:00
return { part : part . id , rings : lay . offsets . map ( o => [ x , lay . y + o ] as Pt ) , at : [ lay . x , lay . y ] }
BF input panels are component inputs, cable ends plug in more reliably; A merge panels, hex pass-through, design a component's box
- Inside a component, the switch and button rows of its input panels are now input pins (in order with the other inputs, named after the rows); "Rows are component inputs" can be turned off per panel to keep the old fixed switches
- Select input panels, Merge: one panel with all rows, spacing and wires kept; circuits that place this one keep their wires
- Cable ends plug in more often: bundling orders the wires by the part a side runs to, an end with only some wires on a part still plugs, an end placed by hand next to the pins plugs, and dragging an end near its part shows green rings and plugs it on drop
- Hex displays pass their four bits on (outputs on the right), so they can sit in the middle of a bus
- Design the box: move lamps, displays, the screen and the name on a component's box, draw lines, boxes, circles and text in six colours, size it, leave things off; every placed copy shows it
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 11:49:29 +00:00
}
2026-10-23 13:34:36 +00:00
/** Where latched parts touch their part: a contact strip along the joint, held by a clamp at each end. */
const latchMarks = computed ( ( ) =>
def . value . nodes . flatMap ( n => {
const seam = n . latch ? latchSeam ( def . value , n , ed . getDef . value ) : null
return seam ? [ { id : n . id , x : n . x + seam . x , y0 : n . y + seam . y0 , y1 : n . y + seam . y1 } ] : [ ]
} ) ,
)
A pick pins for a cable, buttons on pointing, right-click on pins; docked panels move freely
- Pointing at a part shows its round buttons, as if it were selected; they
stay while the pointer goes to them.
- A box around some pins of one part (not over its middle), or Shift +
click on pins, picks exactly those pins: a cable plug on them, wire them
one by one, invert or unwire them, from buttons beside them or a
right-click.
- Right-click on a pin offers what can be done right there first: split a
component's cable socket into wires (or join), pull a cable out of a cable
end, invert an input.
- A docked panel moves both ways now: moved up or down off its component's
pins it lets go and stays a panel of its own (rows and wires kept);
moved sideways it stays docked.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-27 12:34:16 +00:00
/** The picked pins, where they are. */
const pickedPins = computed ( ( ) => {
const sel = ed . pinSel . value
if ( ! sel ) return [ ]
const keep = new Set ( sel . pins )
return allPins . value . filter ( p => p . node === sel . node && p . dir === sel . dir && keep . has ( p . pin ) )
} )
2026-10-21 10:16:26 +00:00
/** Pins a dragged part will connect to when dropped, shown as green rings. */
const dropRings = computed ( ( ) => {
2026-10-21 12:21:40 +00:00
const g = ghostLanding . value
if ( g ? . links . length ) {
return g . links . map ( l => {
const end = l . from . node === 'ghost' ? { ... l . to , dir : 'in' } : { ... l . from , dir : 'out' }
return allPins . value . find ( p => p . node === end . node && p . pin === end . pin && p . dir === end . dir ) !
} ) . filter ( Boolean )
}
2026-10-21 10:16:26 +00:00
const d = drag . value
BF input panels are component inputs, cable ends plug in more reliably; A merge panels, hex pass-through, design a component's box
- Inside a component, the switch and button rows of its input panels are now input pins (in order with the other inputs, named after the rows); "Rows are component inputs" can be turned off per panel to keep the old fixed switches
- Select input panels, Merge: one panel with all rows, spacing and wires kept; circuits that place this one keep their wires
- Cable ends plug in more often: bundling orders the wires by the part a side runs to, an end with only some wires on a part still plugs, an end placed by hand next to the pins plugs, and dragging an end near its part shows green rings and plugs it on drop
- Hex displays pass their four bits on (outputs on the right), so they can sit in the middle of a bus
- Design the box: move lamps, displays, the screen and the name on a component's box, draw lines, boxes, circles and text in six colours, size it, leave things off; every placed copy shows it
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 11:49:29 +00:00
if ( d ? . kind === 'move' && d . plug ) return d . plug . rings . map ( ( [ x , y ] ) => ( { x , y } ) )
2026-10-21 10:16:26 +00:00
if ( d ? . kind !== 'move' || ! d . snap || ! d . still ) return [ ]
2026-10-26 17:21:34 +00:00
const moving = new Set ( d . orig . nodes . keys ( ) )
2026-10-21 10:16:26 +00:00
return d . snap . links . map ( l => {
const end = moving . has ( l . from . node ) ? { ... l . to , dir : 'in' } : { ... l . from , dir : 'out' }
return d . still ! . find ( p => p . node === end . node && p . pin === end . pin && p . dir === end . dir ) !
} ) . filter ( Boolean )
} )
/** Green boxes over the runs of pins the selection fits onto; hidden while dragging, wiring or placing. */
const fitShown = computed ( ( ) => ( drag . value || ed . linking . value || ed . placing . value || ed . cabling . value ? [ ] : ed . fits . value ) )
function pinAt ( ref : PinRef , dir : 'in' | 'out' ) : Pt | null {
const n = nodeMap . value . get ( ref . node )
const p = n && pinPos ( n , shapes . value . get ( n . id ) ! , ref . pin , dir )
return p ? [ p . x , p . y ] : null
}
/** The fit pointed at: its box and a line from each selected part to the pin it would get. */
const fitPreview = computed ( ( ) => {
const h = ed . fitHover . value
const spot = h && fitShown . value [ h . spot ]
if ( ! h || ! spot ) return null
const k = spot . mine . length
const pins = spot . pins . slice ( h . start , h . start + k )
const lines = spot . mine . map ( ( m , i ) => {
const a = pinAt ( m , spot . side === 'out' ? 'in' : 'out' )
const b = pins [ i ] !
return a ? ` M ${ a [ 0 ] * G } ${ a [ 1 ] * G } L ${ b . x * G } ${ b . y * G } ` : ''
} )
return { x : pins [ 0 ] ! . x , y0 : pins [ 0 ] ! . y , y1 : pins [ k - 1 ] ! . y , lines , pins }
} )
function onFitMove ( i : number , e : PointerEvent ) {
const spot = fitShown . value [ i ]
if ( spot ) ed . fitHover . value = { spot : i , start : fitStart ( spot , toWorld ( e ) [ 1 ] ) }
}
2026-10-17 10:49:38 +00:00
const cursorStyle = computed ( ( ) => {
if ( drag . value ? . kind === 'pan' ) return 'grabbing'
if ( spaceDown . value ) return 'grab'
if ( ed . placing . value ) return 'copy'
2026-10-21 08:39:54 +00:00
if ( ed . linking . value || ed . cabling . value ) return 'crosshair'
2026-10-17 10:49:38 +00:00
return 'default'
} )
defineExpose ( { fit , zoomAt } )
< / script >
< template >
< div
ref = "root"
class = "canvas"
: style = "{ cursor: cursorStyle }"
@ pointerdown = "onPointerDown"
@ pointermove = "onPointerMove"
@ pointerup = "onPointerUp"
@ pointercancel = "onPointerUp"
A pick pins for a cable, buttons on pointing, right-click on pins; docked panels move freely
- Pointing at a part shows its round buttons, as if it were selected; they
stay while the pointer goes to them.
- A box around some pins of one part (not over its middle), or Shift +
click on pins, picks exactly those pins: a cable plug on them, wire them
one by one, invert or unwire them, from buttons beside them or a
right-click.
- Right-click on a pin offers what can be done right there first: split a
component's cable socket into wires (or join), pull a cable out of a cable
end, invert an input.
- A docked panel moves both ways now: moved up or down off its component's
pins it lets go and stays a panel of its own (rows and wires kept);
moved sideways it stays docked.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-27 12:34:16 +00:00
@ pointerleave = "(cursor = null), trackHover(null)"
2026-10-17 10:49:38 +00:00
@ wheel . prevent = "onWheel"
@ contextmenu . prevent
2026-10-21 12:21:40 +00:00
@ dragover . prevent = "onDragOver"
@ dragleave = "onDragLeave"
2026-10-17 10:49:38 +00:00
@ drop . prevent = "onDrop"
>
< svg width = "100%" height = "100%" >
< defs >
< pattern id = "grid-dots" :width ="gridSize" :height ="gridSize" patternUnits = "userSpaceOnUse" :x ="view.x" :y ="view.y" >
< circle :cx ="0.75" :cy ="0.75" : r = "view.zoom > 0.5 ? 0.9 : 0.6" class = "grid-dot" / >
< / pattern >
< pattern id = "grid-major" : width = "gridSize * 8" : height = "gridSize * 8" patternUnits = "userSpaceOnUse" :x ="view.x" :y ="view.y" >
< circle :cx ="0.75" :cy ="0.75" r = "1.4" class = "grid-major" / >
< / pattern >
< / defs >
2026-10-21 08:09:43 +00:00
< rect v -if = " gridSize > = 5 " width=" 100 % " height=" 100 % " fill=" url ( # grid - dots ) " / >
< rect v -if = " gridSize * 8 > = 6 " width=" 100 % " height=" 100 % " fill=" url ( # grid - major ) " / >
2026-10-17 10:49:38 +00:00
A Loxone-style working aids: named signals, inverted inputs, a project check, values on cables, search, printable sheets; wire ends move by dragging
- Send signal / Use signal: name a signal (CLK, RESET) once and use it anywhere in the circuit without a wire; selecting one lights up all of them, a use with no sender shows dashed
- Inverted inputs: Alt + click an input (or the menu/settings) puts a bubble on it; it reads the signal inverted through one NAND, counted in every transistor total
- Check (Circuit tab): open inputs, parts that drive nothing, duplicate pin names, unsent or doubly sent signals, loops that never settle; click one to show it. Open inputs get an orange marker on the canvas. Components no other circuit uses are listed with a delete
- Cables show the number they carry (= 13 · 0x0D); hovering a wire tells where it runs and its value
- Ctrl+F finds parts, signals, panel rows, notes and components in every circuit, with where each component is used
- Ctrl+P prints the circuit as a sheet with a title block on white paper (or save as PDF); also as an SVG file
- + and − under a selected gate change its number of inputs; swaps keep bubbles in place
- Drag a wire by its end to move that end to another pin; drop a dragged wire on another wire to tap its signal or feed what it fed
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 11:26:59 +00:00
< g ref = "content" : transform = "`translate(${view.x} ${view.y}) scale(${view.zoom})`" >
2026-10-17 10:49:38 +00:00
< g class = "wires" >
2026-10-23 12:57:16 +00:00
<!-- Cables ( ribbons , and cables between connector ports ) : a sleeve , a core , a line per wire -- >
< template v-for ="grp in cableGroups" :key="grp[0]!.src" >
< g v-for ="r in grp" :key="`h${r.wire.id}`" class="wire" :class="wireClass(r)" >
< path v -if = " wireSelected.has ( r.wire.id ) " :d ="r.d" class = "wire-halo" : style = "{ strokeWidth: `${r.sleeve! + 9}px` }" / >
2026-10-21 08:39:54 +00:00
< path :d ="r.d" class = "cable-sleeve" : style = "{ strokeWidth: `${r.sleeve! + 3}px` }" / >
2026-10-23 12:57:16 +00:00
< / g >
< g v-for ="r in grp" :key="`c${r.wire.id}`" class="wire" :class="wireClass(r)" >
2026-10-21 08:39:54 +00:00
< path :d ="r.d" class = "cable-core" : style = "{ strokeWidth: `${r.sleeve}px` }" / >
2026-10-23 12:57:16 +00:00
< / g >
< g v-for ="r in grp" :key="`l${r.wire.id}`" class="wire" :class="wireClass(r)" >
2026-10-21 08:39:54 +00:00
< path
2026-10-23 12:57:16 +00:00
v - for = "l in r.lanes ?? []"
2026-10-21 08:39:54 +00:00
: key = "l.i"
: d = "l.d"
class = "lane"
: class = "[l.color ? `c-${l.color}` : '', { on: ed.val(r.wire.from.node, `b${l.i}`) === 1 }]"
/ >
2026-10-23 12:57:16 +00:00
< / g >
< / template >
< g v-for ="r in routes" :key="r.wire.id" class="wire" :class="wireClass(r)" >
< template v-if ="!r.port && !r.lanes" >
< path v -if = " wireSelected.has ( r.wire.id ) " :d ="r.d" class = "wire-halo" : style = "r.sleeve ? { strokeWidth: `${r.sleeve + 9}px` } : undefined" / >
2026-10-21 08:39:54 +00:00
< path :d ="r.d" class = "wire-line" / >
< path v -if = " flow & & srcVal ( r.src ) = = = 1 " :d ="r.d" class = "wire-flow" / >
< / template >
2026-10-17 10:49:38 +00:00
< path
v - for = "(p, i) in r.pts.slice(0, -1)"
: key = "i"
: d = "`M${p[0] * G} ${p[1] * G}L${r.pts[i + 1]![0] * G} ${r.pts[i + 1]![1] * G}`"
class = "wire-hit"
A component faces, project library with share links, fine-grained wire editing
- Lamps and hex displays inside a component show on its box with their
labels, lit by that instance's state; Counter 4 example shows its count.
- Several projects per browser; share links at /p/<id> that the creator's
edits save to automatically, others get their own copy. Export, open a
file as project, or add a file's components to the open project.
- Wires: drag any segment or corner, Alt+drag for a new bend, Ctrl+drag to
branch, double-click selects the whole signal, multi-select, arrow keys,
colour tags.
- Share-link API (POST/GET/PUT /api/p) on Nitro fs storage in data/, mounted
as a volume on edgerealm.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-17 11:21:49 +00:00
: class = "{ vertical: p[0] === r.pts[i + 1]![0] }"
2026-10-21 08:39:54 +00:00
: style = "r.sleeve ? { strokeWidth: `${Math.max(10, r.sleeve + 4)}px` } : undefined"
2026-10-17 10:49:38 +00:00
: data - wire = "r.wire.id"
: data - seg = "i"
A Loxone-style working aids: named signals, inverted inputs, a project check, values on cables, search, printable sheets; wire ends move by dragging
- Send signal / Use signal: name a signal (CLK, RESET) once and use it anywhere in the circuit without a wire; selecting one lights up all of them, a use with no sender shows dashed
- Inverted inputs: Alt + click an input (or the menu/settings) puts a bubble on it; it reads the signal inverted through one NAND, counted in every transistor total
- Check (Circuit tab): open inputs, parts that drive nothing, duplicate pin names, unsent or doubly sent signals, loops that never settle; click one to show it. Open inputs get an orange marker on the canvas. Components no other circuit uses are listed with a delete
- Cables show the number they carry (= 13 · 0x0D); hovering a wire tells where it runs and its value
- Ctrl+F finds parts, signals, panel rows, notes and components in every circuit, with where each component is used
- Ctrl+P prints the circuit as a sheet with a title block on white paper (or save as PDF); also as an SVG file
- + and − under a selected gate change its number of inputs; swaps keep bubbles in place
- Drag a wire by its end to move that end to another pin; drop a dragged wire on another wire to tap its signal or feed what it fed
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 11:26:59 +00:00
@ pointerenter = "(hoverSrc = r.src), (hoverWire = r.wire.id)"
@ pointerleave = "(hoverSrc = null), (hoverWire = null)"
2026-10-17 10:49:38 +00:00
/ >
2026-10-20 17:29:16 +00:00
< g v-if ="r.bits && r.mark" class="cable-mark" :transform="`translate(${r.mark[0] * G} ${r.mark[1] * G})`" >
2026-10-21 08:39:54 +00:00
< path : d = "r.sleeve ? `M-4 ${r.sleeve / 2 + 3}L4 ${-r.sleeve / 2 - 3}` : 'M-4 6L4 -6'" / >
< text x = "6" : y = "r.sleeve ? -r.sleeve / 2 - 4 : -6" > { { r . bits } } < / text >
A Loxone-style working aids: named signals, inverted inputs, a project check, values on cables, search, printable sheets; wire ends move by dragging
- Send signal / Use signal: name a signal (CLK, RESET) once and use it anywhere in the circuit without a wire; selecting one lights up all of them, a use with no sender shows dashed
- Inverted inputs: Alt + click an input (or the menu/settings) puts a bubble on it; it reads the signal inverted through one NAND, counted in every transistor total
- Check (Circuit tab): open inputs, parts that drive nothing, duplicate pin names, unsent or doubly sent signals, loops that never settle; click one to show it. Open inputs get an orange marker on the canvas. Components no other circuit uses are listed with a delete
- Cables show the number they carry (= 13 · 0x0D); hovering a wire tells where it runs and its value
- Ctrl+F finds parts, signals, panel rows, notes and components in every circuit, with where each component is used
- Ctrl+P prints the circuit as a sheet with a title block on white paper (or save as PDF); also as an SVG file
- + and − under a selected gate change its number of inputs; swaps keep bubbles in place
- Drag a wire by its end to move that end to another pin; drop a dragged wire on another wire to tap its signal or feed what it fed
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 11:26:59 +00:00
< text x = "6" : y = "r.sleeve ? r.sleeve / 2 + 11 : 14" class = "cable-value" > = { { cableValue ( r ) ? . dec } } < / text >
2026-10-20 17:29:16 +00:00
< / g >
2026-10-22 16:59:56 +00:00
< g v-if ="r.port && r.mark" class="cable-mark port-mark" :transform="`translate(${r.mark[0] * G} ${r.mark[1] * G})`" >
< text text -anchor = " middle " : y = "-r.sleeve! / 2 - 5" > { { r . port . name } } < / text >
< / g >
A Loxone-style working aids: named signals, inverted inputs, a project check, values on cables, search, printable sheets; wire ends move by dragging
- Send signal / Use signal: name a signal (CLK, RESET) once and use it anywhere in the circuit without a wire; selecting one lights up all of them, a use with no sender shows dashed
- Inverted inputs: Alt + click an input (or the menu/settings) puts a bubble on it; it reads the signal inverted through one NAND, counted in every transistor total
- Check (Circuit tab): open inputs, parts that drive nothing, duplicate pin names, unsent or doubly sent signals, loops that never settle; click one to show it. Open inputs get an orange marker on the canvas. Components no other circuit uses are listed with a delete
- Cables show the number they carry (= 13 · 0x0D); hovering a wire tells where it runs and its value
- Ctrl+F finds parts, signals, panel rows, notes and components in every circuit, with where each component is used
- Ctrl+P prints the circuit as a sheet with a title block on white paper (or save as PDF); also as an SVG file
- + and − under a selected gate change its number of inputs; swaps keep bubbles in place
- Drag a wire by its end to move that end to another pin; drop a dragged wire on another wire to tap its signal or feed what it fed
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 11:26:59 +00:00
< title v-if ="hoverWire === r.wire.id" > {{ wireTip ( r ) }} < / title >
2026-10-17 10:49:38 +00:00
< / g >
BF jumps always on top of what they cross; R circuit commands in a menu on its name, the side panel only says what it is
A jump is drawn once more over every line, so a cable that arches over
another is never hidden under it, whatever order they are drawn in. Cable
labels sit on the longest stretch no other line crosses.
The circuit's name in the top bar opens what can be done with it: tidy
its wires or every circuit's, design its box, duplicate, delete, print,
export SVG, publish as a puzzle. The This panel keeps what the circuit is:
its health, its numbers (the transistors tile opens their breakdown), its
truth table and how it looks as a part. Unused components are a tab of
the Components list in the parts bar, with a delete button on each.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-23 13:12:43 +00:00
<!-- Jumps once more on top : a line always lies over what it jumps -- >
< template v-for ="r in routes" :key="`p${r.wire.id}`" >
< g v-if ="r.patches?.length" class="wire jump" :class="wireClass(r)" >
< template v-for ="(p, n) in r.patches" :key ="n" >
< template v-if ="r.lanes || r.port" >
< path :d ="p.d" class = "cable-sleeve" : style = "{ strokeWidth: `${r.sleeve! + 3}px` }" / >
< path :d ="p.d" class = "cable-core" : style = "{ strokeWidth: `${r.sleeve}px` }" / >
< path
v - for = "l in p.lanes"
: key = "l.i"
: d = "l.d"
class = "lane"
: class = "[l.color ? `c-${l.color}` : '', { on: ed.val(r.wire.from.node, `b${l.i}`) === 1 }]"
/ >
< / template >
< path v -else :d ="p.d" class = "wire-line" / >
< / template >
< / g >
< / template >
A component faces, project library with share links, fine-grained wire editing
- Lamps and hex displays inside a component show on its box with their
labels, lit by that instance's state; Counter 4 example shows its count.
- Several projects per browser; share links at /p/<id> that the creator's
edits save to automatically, others get their own copy. Export, open a
file as project, or add a file's components to the open project.
- Wires: drag any segment or corner, Alt+drag for a new bend, Ctrl+drag to
branch, double-click selects the whole signal, multi-select, arrow keys,
colour tags.
- Share-link API (POST/GET/PUT /api/p) on Nitro fs storage in data/, mounted
as a volume on edgerealm.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-17 11:21:49 +00:00
< g v-for ="(j, i) in junctions" :key="`j${i}`" class="wire" :class="[j.color ? `c-${j.color}` : '', { on: srcVal(j.src) === 1 }]" >
A settings for every part, overlap-free wiring with crossing styles, accounts with sync
- Clicking anything opens its settings: swap parts in place (wires stay on
matching pins), clock frequency per clock, keyboard keys for switches and
buttons, lamp/display colours, note sizes, component names on the canvas,
position, unlink all wires, unpack a component, make an independent copy.
- Wires of different signals never share a line: auto routes pick free
columns or detours, remaining clashes go on separate lanes. Crossings drawn
as bow, triangle, bridge, gap or plain.
- Accounts (email + scrypt password, httpOnly session) with two-way project
sync and conflict copies; per-account limits; cross-site writes refused.
- Compatibility suite: a project and both browser-storage layouts from
release a241adc must load and compute identically.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-20 11:09:37 +00:00
< circle : cx = "j.x * G" : cy = "j.y * G" r = "3.2" class = "junction" :data-junction ="j.src" / >
A component faces, project library with share links, fine-grained wire editing
- Lamps and hex displays inside a component show on its box with their
labels, lit by that instance's state; Counter 4 example shows its count.
- Several projects per browser; share links at /p/<id> that the creator's
edits save to automatically, others get their own copy. Export, open a
file as project, or add a file's components to the open project.
- Wires: drag any segment or corner, Alt+drag for a new bend, Ctrl+drag to
branch, double-click selects the whole signal, multi-select, arrow keys,
colour tags.
- Share-link API (POST/GET/PUT /api/p) on Nitro fs storage in data/, mounted
as a volume on edgerealm.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-17 11:21:49 +00:00
< / g >
2026-10-17 10:49:38 +00:00
< / g >
< EditorNodeView
v - for = "n in def.nodes"
: key = "n.id"
: node = "n"
: shape = "shapes.get(n.id)!"
: selected = "selected.has(n.id)"
2026-10-20 18:09:23 +00:00
: through = "linked.out.has(`${n.id}:q`) && (n.kind === 'lamp' || n.kind === 'output')"
2026-10-20 18:15:38 +00:00
: hint = "hints.get(n.id)"
A Loxone-style working aids: named signals, inverted inputs, a project check, values on cables, search, printable sheets; wire ends move by dragging
- Send signal / Use signal: name a signal (CLK, RESET) once and use it anywhere in the circuit without a wire; selecting one lights up all of them, a use with no sender shows dashed
- Inverted inputs: Alt + click an input (or the menu/settings) puts a bubble on it; it reads the signal inverted through one NAND, counted in every transistor total
- Check (Circuit tab): open inputs, parts that drive nothing, duplicate pin names, unsent or doubly sent signals, loops that never settle; click one to show it. Open inputs get an orange marker on the canvas. Components no other circuit uses are listed with a delete
- Cables show the number they carry (= 13 · 0x0D); hovering a wire tells where it runs and its value
- Ctrl+F finds parts, signals, panel rows, notes and components in every circuit, with where each component is used
- Ctrl+P prints the circuit as a sheet with a title block on white paper (or save as PDF); also as an SVG file
- + and − under a selected gate change its number of inputs; swaps keep bubbles in place
- Drag a wire by its end to move that end to another pin; drop a dragged wire on another wire to tap its signal or feed what it fed
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 11:26:59 +00:00
: linked = "!!signalSel && (n.kind === 'tag' || n.kind === 'ref') && n.label?.trim() === signalSel"
: open = "openPins.get(n.id)"
2026-10-17 10:49:38 +00:00
/ >
2026-10-23 13:34:36 +00:00
< g v-for ="m in latchMarks" :key="`latch-${m.id}`" class="part-latch" >
< path : d = "`M${m.x * G} ${(m.y0 - 0.35) * G}V${(m.y1 + 0.35) * G}`" class = "contact" / >
< rect : x = "m.x * G - 0.3 * G" : y = "(m.y0 - 0.5) * G - 3" : width = "0.6 * G" :height ="5" rx = "1.5" / >
< rect : x = "m.x * G - 0.3 * G" : y = "(m.y1 + 0.5) * G - 2" : width = "0.6 * G" :height ="5" rx = "1.5" / >
< / g >
A Loxone-style working aids: named signals, inverted inputs, a project check, values on cables, search, printable sheets; wire ends move by dragging
- Send signal / Use signal: name a signal (CLK, RESET) once and use it anywhere in the circuit without a wire; selecting one lights up all of them, a use with no sender shows dashed
- Inverted inputs: Alt + click an input (or the menu/settings) puts a bubble on it; it reads the signal inverted through one NAND, counted in every transistor total
- Check (Circuit tab): open inputs, parts that drive nothing, duplicate pin names, unsent or doubly sent signals, loops that never settle; click one to show it. Open inputs get an orange marker on the canvas. Components no other circuit uses are listed with a delete
- Cables show the number they carry (= 13 · 0x0D); hovering a wire tells where it runs and its value
- Ctrl+F finds parts, signals, panel rows, notes and components in every circuit, with where each component is used
- Ctrl+P prints the circuit as a sheet with a title block on white paper (or save as PDF); also as an SVG file
- + and − under a selected gate change its number of inputs; swaps keep bubbles in place
- Drag a wire by its end to move that end to another pin; drop a dragged wire on another wire to tap its signal or feed what it fed
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 11:26:59 +00:00
< circle
v - for = "g in grips"
: key = "`${g.wire}-${g.end}`"
: cx = "g.x * G"
: cy = "g.y * G"
r = "4"
class = "wire-grip"
: data - wire = "g.wire"
: data - end = "g.end"
@ pointerenter = "hoverWire = g.wire"
@ pointerleave = "hoverWire = null"
>
< title > Drag to move this end to another pin < / title >
< / circle >
A component faces, project library with share links, fine-grained wire editing
- Lamps and hex displays inside a component show on its box with their
labels, lit by that instance's state; Counter 4 example shows its count.
- Several projects per browser; share links at /p/<id> that the creator's
edits save to automatically, others get their own copy. Export, open a
file as project, or add a file's components to the open project.
- Wires: drag any segment or corner, Alt+drag for a new bend, Ctrl+drag to
branch, double-click selects the whole signal, multi-select, arrow keys,
colour tags.
- Share-link API (POST/GET/PUT /api/p) on Nitro fs storage in data/, mounted
as a volume on edgerealm.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-17 11:21:49 +00:00
< rect
v - for = "h in handles"
: key = "`${h.wire}-${h.i}`"
: x = "h.x * G - 3.5"
: y = "h.y * G - 3.5"
width = "7"
height = "7"
rx = "1.5"
class = "corner-handle"
: data - wire = "h.wire"
: data - corner = "h.i"
/ >
2026-10-21 10:16:26 +00:00
< g v-if ="fitShown.length" class="fits" >
< rect
v - for = "(f, i) in fitShown"
: key = "`f${i}`"
: x = "(f.pins[0]!.x - 0.45) * G"
: y = "(f.pins[0]!.y - 0.5) * G"
: width = "0.9 * G"
: height = "(f.pins[f.pins.length - 1]!.y - f.pins[0]!.y + 1) * G"
rx = "4"
class = "fit-strip"
: class = "{ active: ed.fitHover.value?.spot === i }"
: data - fit = "i"
@ pointermove = "onFitMove(i, $event)"
@ pointerleave = "ed.fitHover.value = null"
/ >
< template v-if ="fitPreview" >
< path v -for = " ( l , i ) in fitPreview.lines " :key ="`fl${i}`" :d ="l" class = "fit-line" / >
< rect
: x = "(fitPreview.x - 0.55) * G"
: y = "(fitPreview.y0 - 0.55) * G"
: width = "1.1 * G"
: height = "(fitPreview.y1 - fitPreview.y0 + 1.1) * G"
rx = "5"
class = "fit-window"
/ >
< circle v -for = " ( p , i ) in fitPreview.pins " :key ="`fp${i}`" : cx = "p.x * G" : cy = "p.y * G" r = "4.5" class = "fit-pin" / >
< / template >
< / g >
< circle v -for = " ( p , i ) in dropRings " :key ="`d${i}`" : cx = "p.x * G" : cy = "p.y * G" r = "7" class = "drop-ring" / >
A pick pins for a cable, buttons on pointing, right-click on pins; docked panels move freely
- Pointing at a part shows its round buttons, as if it were selected; they
stay while the pointer goes to them.
- A box around some pins of one part (not over its middle), or Shift +
click on pins, picks exactly those pins: a cable plug on them, wire them
one by one, invert or unwire them, from buttons beside them or a
right-click.
- Right-click on a pin offers what can be done right there first: split a
component's cable socket into wires (or join), pull a cable out of a cable
end, invert an input.
- A docked panel moves both ways now: moved up or down off its component's
pins it lets go and stays a panel of its own (rows and wires kept);
moved sideways it stays docked.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-27 12:34:16 +00:00
< circle v -for = " p in pickedPins " :key ="`pk${p.pin}`" : cx = "p.x * G" : cy = "p.y * G" r = "6.5" class = "picked-pin" / >
2026-10-21 12:21:40 +00:00
< g
2026-10-26 21:45:47 +00:00
v - for = "b in actionButtons"
: key = "b.key"
2026-10-21 12:21:40 +00:00
class = "cable-btn"
2026-10-26 21:45:47 +00:00
: data - action = "b.key"
: transform = "`translate(${b.x * G} ${b.y * G})${b.flip ? ' scale(-1 1)' : ''}`"
2026-10-21 12:21:40 +00:00
>
2026-10-26 21:45:47 +00:00
< title > { { b . title } } < / title >
2026-10-21 12:21:40 +00:00
< circle r = "9" / >
2026-10-26 21:45:47 +00:00
< foreignObject v-if ="b.icon" x="-6" y="-6" width="12" height="12" > < Icon :name ="b.icon" class = "cable-btn-icon" / > < / foreignObject >
< path v -else d = "M-4.5 -4.5L1.5 0M-4.5 0H1.5M-4.5 4.5L1.5 0M1.5 0H5" / >
2026-10-21 12:21:40 +00:00
< / g >
2026-10-21 10:16:26 +00:00
A input panels, automatic names, one-by-one wiring, tidy routing, truth table export
- Input panel part: rows of switches, buttons and clocks. "Attach input
panel" docks one to a component with a row per free input; it moves
with the component and follows its pins.
- Copies and new pins continue name series (D0 -> D1, A -> B); unnamed
switches, lamps and pins take the name of the component pin they are
wired to.
- Connecting: target pins are ringed, dropping on a part uses its next
free pin, click-then-click works, and "Connect one by one" (W) wires a
selection's pins in turn.
- Tidy wiring option and "Tidy all wires": sorted, evenly spaced columns
per gap, one trunk per signal, fewer crossings.
- Truth table full screen, CSV download, copy as Markdown, current row
highlighted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 17:17:25 +00:00
< g class = "targets" >
< circle v -for = " ( t , i ) in targets " :key ="`t${i}`" : cx = "t.x * G" : cy = "t.y * G" r = "5.5" class = "pin-target" : class = "{ taken: !t.free }" / >
< / g >
2026-10-17 10:49:38 +00:00
< path v -if = " tempWire " :d ="tempWire.d" class = "temp-wire" : class = "{ snapped: tempWire.snapped }" / >
A input panels, automatic names, one-by-one wiring, tidy routing, truth table export
- Input panel part: rows of switches, buttons and clocks. "Attach input
panel" docks one to a component with a row per free input; it moves
with the component and follows its pins.
- Copies and new pins continue name series (D0 -> D1, A -> B); unnamed
switches, lamps and pins take the name of the component pin they are
wired to.
- Connecting: target pins are ringed, dropping on a part uses its next
free pin, click-then-click works, and "Connect one by one" (W) wires a
selection's pins in turn.
- Tidy wiring option and "Tidy all wires": sorted, evenly spaced columns
per gap, one trunk per signal, fewer crossings.
- Truth table full screen, CSV download, copy as Markdown, current row
highlighted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 17:17:25 +00:00
< circle v -if = " tempWire ? .snapped " : cx = "tempWire.end[0] * G" : cy = "tempWire.end[1] * G" r = "6.5" class = "pin-snap" / >
< g v-for ="b in queueBadges" :key="`q${b.n}`" class="queue-badge" :class="{ current: b.current }" >
< rect : x = "b.x * G - 7" : y = "b.y * G - 6" width = "14" height = "12" rx = "3" / >
< text : x = "b.x * G" : y = "b.y * G + 3.5" text -anchor = " middle " > { { b . n } } < / text >
< / g >
2026-10-17 10:49:38 +00:00
< EditorNodeView v -if = " ghost " :node ="ghost" :shape ="ed.shape(ghost)" :selected ="false" ghost / >
2026-10-21 08:39:54 +00:00
< template v-if ="cableGhost" >
< path v -if = " cableGhost.line " :d ="cableGhost.line" class = "temp-wire" / >
< EditorNodeView v -for = " g in cableGhost.nodes " :key ="g.id" :node ="g" :shape ="ed.shape(g)" :selected ="false" ghost / >
< / template >
2026-10-21 09:08:32 +00:00
< rect v -if = " boxRect " v -bind = " boxRect " / >
2026-10-17 10:49:38 +00:00
< / g >
< / svg >
2026-10-23 10:43:08 +00:00
< EditorQuickAdd v -if = " quick " :x ="quick.x" :y ="quick.y" @pick ="onQuickPick" @fit ="fit" @ close = "quick = null" / >
A right-click menu for parts, wires and the canvas, "Wire them all to" as cards, plugged latches in plain greys
- Right click (or the menu key) shows what can be done with what is under the pointer: one part (open, rename, change to, inputs, colour, speed, panels, unpack, plug and unplug, cable colour), several parts (wire them all to with live preview, connect one by one, switches, change all, arrange, keep only, make a component), wires (bundle, colour, whole signal, straighten, remove cable) or empty canvas (paste here, add a part here, select all, fit, tidy, undo); right drag still moves the view
- "Wire them all to": a card per part, each fit a strip of its pins, and which wire goes where for the fit pointed at
- Plugged cable ends no longer look selected: grey connector, steel clips
- Icons named in menus are bundled for the browser too
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 10:33:30 +00:00
< EditorContextMenu v -if = " menu " :x ="menu.x" :y ="menu.y" :entries ="menu.entries" :keyboard ="menu.keyboard" @ close = "menu = null" / >
2026-10-17 10:49:38 +00:00
< div v-if ="!def.nodes.length" class="empty-hint" >
< p class = "font-semibold" > Empty circuit < / p >
< p > Drag parts in from the left , or press < kbd > N < / kbd > for a NAND gate . < / p >
< / div >
< div class = "zoom-controls" @ pointerdown.stop >
< button title = "Zoom out" @ click = "zoomAt(1 / 1.25)" > < Icon name = "lucide:minus" / > < / button >
< span class = "tabular-nums" > { { Math . round ( view . zoom * 100 ) } } % < / span >
< button title = "Zoom in" @click ="zoomAt(1.25)" > < Icon name = "lucide:plus" / > < / button >
< button title = "Fit to screen (F)" @click ="fit" > < Icon name = "lucide:scan" / > < / button >
< / div >
< / div >
< / template >