2026-10-17 10:49:38 +00:00
|
|
|
<script setup lang="ts">
|
2026-10-20 17:29:16 +00:00
|
|
|
import { cableKeys } from '~/lib/logic/compile'
|
|
|
|
|
import { cableBits, GRID as G, 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'
|
2026-10-21 09:08:32 +00:00
|
|
|
import { branchCorners, branchTo, moveCorner, moveSegment, routeTouchesBox, segmentDrag, splitDrag } from '~/lib/logic/wires'
|
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
|
|
|
import { circuitRoutes, findCrossings } 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-21 09:59:17 +00:00
|
|
|
import { LANE, ribbon, RIBBON_MAX } from '~/lib/logic/cables'
|
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
|
|
|
import { wirePath } from '~/lib/draw'
|
2026-10-20 18:15:38 +00:00
|
|
|
import { pinName } from '~/lib/logic/labels'
|
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-17 10:49:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const toPath = (pts: Pt[]) => pts.map(([x, y], i) => `${i ? 'L' : 'M'}${x * G} ${y * G}`).join('')
|
|
|
|
|
|
|
|
|
|
const routes = computed<Route[]>(() => {
|
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 routed = circuitRoutes(def.value, shapes.value, { tidy: !!ed.project.value.settings.tidy })
|
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 hops = new Map<number, Map<number, number[]>>()
|
|
|
|
|
for (const c of findCrossings(routed)) {
|
|
|
|
|
const segs = hops.get(c.wire) ?? hops.set(c.wire, new Map()).get(c.wire)!
|
|
|
|
|
segs.set(c.seg, [...(segs.get(c.seg) ?? []), c.x])
|
2026-10-17 10:49:38 +00:00
|
|
|
}
|
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 style = ed.project.value.settings.crossing ?? 'bow'
|
|
|
|
|
const byId = new Map(def.value.wires.map(w => [w.id, w]))
|
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)
|
|
|
|
|
const route: Route = { wire, pts: r.grid, draw: r.draw, d: wirePath(r.draw, hops.get(k), style), src: r.net }
|
|
|
|
|
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]))
|
|
|
|
|
route.d = toPath(r.draw)
|
|
|
|
|
route.lanes = ribbon(r.draw, route.bits).map((lane, i) => ({ i, d: toPath(lane), color: feed.get(`b${i}`) }))
|
|
|
|
|
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.
|
|
|
|
|
let best = 0
|
|
|
|
|
for (let i = 0; i < r.draw.length - 1; i++) {
|
|
|
|
|
const [ax, ay] = r.draw[i]!
|
|
|
|
|
const [bx, by] = r.draw[i + 1]!
|
|
|
|
|
const len = Math.abs(bx - ax) + Math.abs(by - ay)
|
|
|
|
|
if (len > best) {
|
|
|
|
|
best = len
|
|
|
|
|
route.mark = [(ax + bx) / 2, (ay + by) / 2]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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-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)
|
|
|
|
|
|
|
|
|
|
function originFor(p: { kind: CircuitNode['kind']; chip?: string }, at: Pt): Pt {
|
|
|
|
|
const b = ed.shape({ id: 'ghost', kind: p.kind, chip: p.chip, x: 0, y: 0 }).body
|
|
|
|
|
return [Math.round(at[0] - (b.x + b.w / 2)), Math.round(at[1] - (b.y + b.h / 2))]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const ghost = computed<CircuitNode | null>(() => {
|
|
|
|
|
const p = ed.placing.value
|
|
|
|
|
if (!p || !cursor.value) return null
|
|
|
|
|
const [x, y] = originFor(p, cursor.value)
|
|
|
|
|
return { id: 'ghost', kind: p.kind, chip: p.chip, x, y, label: p.kind === 'note' ? 'Note' : p.kind === 'input' ? '?' : undefined }
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
function onDrop(e: DragEvent) {
|
|
|
|
|
const raw = e.dataTransfer?.getData('application/x-logigate')
|
|
|
|
|
if (!raw) return
|
|
|
|
|
const p = JSON.parse(raw) as { kind: CircuitNode['kind']; chip?: string }
|
|
|
|
|
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-17 10:49:38 +00:00
|
|
|
const [x, y] = originFor(p, toWorld(e))
|
|
|
|
|
ed.addNode(p, x, y)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ── 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
|
|
|
|
|
orig: Map<string, Pt>
|
|
|
|
|
/** Docked panels moved without their component: they only slide sideways. */
|
|
|
|
|
lockY: Set<string>
|
|
|
|
|
wires: Map<Wire, Pt[]>
|
|
|
|
|
moved: boolean
|
|
|
|
|
node: CircuitNode
|
|
|
|
|
toggle: boolean
|
|
|
|
|
row?: PanelRow
|
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
|
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: 'wire'; node: string; pin: string; dir: 'in' | 'out'; start: Pt; cur: Pt; moved: boolean; branch?: 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
|
|
|
| { 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)
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Wires whose corner points travel with the nodes being moved. */
|
|
|
|
|
function wiresToShift(moving: Set<string>): Map<Wire, Pt[]> {
|
|
|
|
|
const out = new Map<Wire, Pt[]>()
|
|
|
|
|
for (const wire of def.value.wires) {
|
|
|
|
|
const both = moving.has(wire.from.node) && moving.has(wire.to.node)
|
|
|
|
|
if (wire.pts && (both || wireSelected.value.has(wire.id))) out.set(wire, wire.pts.map(p => [...p] as Pt))
|
|
|
|
|
}
|
|
|
|
|
return out
|
|
|
|
|
}
|
|
|
|
|
|
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)) {
|
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
|
|
|
|
|
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)
|
|
|
|
|
|
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) {
|
|
|
|
|
// Connecting: a click on a pin or a part wires the current pin there.
|
2026-10-20 17:29:16 +00:00
|
|
|
const target = targetAt(w, end.dir === 'out' ? 'in' : 'out', ed.isBus(end.node, end.pin, end.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
|
|
|
if (target) return ed.linkTo(target)
|
|
|
|
|
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')
|
|
|
|
|
}
|
|
|
|
|
const [x, y] = originFor(placing, w)
|
|
|
|
|
ed.addNode(placing, x, y)
|
|
|
|
|
if (!e.shiftKey && !placing.keep) ed.placing.value = null
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const target = e.target as Element
|
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]')
|
|
|
|
|
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])
|
2026-10-17 10:49:38 +00:00
|
|
|
const orig = new Map<string, 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
|
|
|
const lockY = new Set<string>()
|
2026-10-17 10:49:38 +00:00
|
|
|
for (const sid of ids) {
|
|
|
|
|
const n = nodeMap.value.get(sid)
|
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 (!n) continue
|
|
|
|
|
orig.set(sid, [n.x, n.y])
|
|
|
|
|
if (n.attach && !ids.has(n.attach)) lockY.add(sid)
|
|
|
|
|
}
|
|
|
|
|
drag.value = {
|
|
|
|
|
kind: 'move',
|
|
|
|
|
start: w,
|
|
|
|
|
orig,
|
|
|
|
|
lockY,
|
|
|
|
|
wires: wiresToShift(ids),
|
|
|
|
|
moved: false,
|
|
|
|
|
node,
|
|
|
|
|
toggle: (node.kind === 'input' || !!row) && !multi,
|
|
|
|
|
row,
|
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 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 index = Number(el.getAttribute('data-seg'))
|
|
|
|
|
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 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) {
|
|
|
|
|
const w = toWorld(e)
|
|
|
|
|
cursor.value = w
|
|
|
|
|
const d = drag.value
|
|
|
|
|
if (!d) return
|
|
|
|
|
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-21 10:16:26 +00:00
|
|
|
const moving = def.value.nodes.filter(n => d.orig.has(n.id))
|
|
|
|
|
d.still = dropPins(def.value, def.value.nodes.filter(n => !d.orig.has(n.id)), n => shapes.value.get(n.id)!)
|
|
|
|
|
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).
|
|
|
|
|
const at = d.from.map(p => ({ ...p, x: p.x + dx, y: d.lockY.has(p.node) ? p.y : p.y + dy }))
|
|
|
|
|
d.snap = e.altKey ? null : dropLinks(at, d.still, d.grabbed === 1 ? 1 : 0)
|
2026-10-17 10:49:38 +00:00
|
|
|
}
|
|
|
|
|
for (const [id, [x, y]] of d.orig) {
|
|
|
|
|
const n = nodeMap.value.get(id)
|
|
|
|
|
if (n) {
|
|
|
|
|
n.x = x + dx
|
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
|
|
|
n.y = d.lockY.has(id) ? y : y + dy
|
2026-10-17 10:49:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (const [wire, pts] of d.wires) wire.pts = pts.map(([x, y]) => [x + dx, y + dy])
|
|
|
|
|
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.
|
|
|
|
|
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
|
|
|
|
|
})
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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-20 17:29:16 +00:00
|
|
|
function targetAt(at: Pt, dir: 'in' | 'out', bus = false): 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-20 17:29:16 +00:00
|
|
|
if (!!p.bus !== 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-20 17:29:16 +00:00
|
|
|
const pins = (dir === 'in' ? shapes.value.get(n.id)!.inputs : shapes.value.get(n.id)!.outputs).filter(p => !!p.bus === 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 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)
|
2026-10-21 10:16:26 +00:00
|
|
|
if (d.moved && d.snap?.links.length) {
|
|
|
|
|
const [sx, sy] = d.snap.shift
|
|
|
|
|
for (const id of d.orig.keys()) {
|
|
|
|
|
const n = nodeMap.value.get(id)
|
|
|
|
|
if (!n) continue
|
|
|
|
|
n.x += sx
|
|
|
|
|
if (!d.lockY.has(id)) n.y += sy
|
|
|
|
|
}
|
|
|
|
|
for (const wire of d.wires.keys()) wire.pts = wire.pts?.map(([x, y]) => [x + sx, y + sy])
|
|
|
|
|
ed.unplugMoved(new Set(d.orig.keys()))
|
|
|
|
|
ed.connectMany(d.snap.links)
|
|
|
|
|
ed.commit(false)
|
|
|
|
|
} else if (d.moved) {
|
2026-10-21 09:51:45 +00:00
|
|
|
ed.unplugMoved(new Set(d.orig.keys()))
|
|
|
|
|
ed.commit(false)
|
|
|
|
|
} else if (d.toggle && d.row) ed.toggleRow(d.node, d.row)
|
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 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
|
|
|
|
|
}
|
2026-10-20 17:29:16 +00:00
|
|
|
const target = targetAt(d.cur, d.dir === 'out' ? 'in' : 'out', ed.isBus(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
|
|
|
if (!target) 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)
|
|
|
|
|
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-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
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onDoubleClick(node: CircuitNode) {
|
|
|
|
|
if (node.kind === 'chip' && node.chip) ed.open(node.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 (['input', 'output', 'lamp', 'button', 'note', 'hex', 'panel'].includes(node.kind)) {
|
2026-10-17 10:49:38 +00:00
|
|
|
ed.selection.value = [node.id]
|
|
|
|
|
ed.labelFocus.value++
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onWheel(e: WheelEvent) {
|
|
|
|
|
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-21 09:51:45 +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
|
|
|
for (const n of def.value.nodes) {
|
|
|
|
|
if (!ids.has(n.id)) continue
|
|
|
|
|
n.x += dx
|
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 (!n.attach || ids.has(n.attach)) n.y += dy
|
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) {
|
|
|
|
|
const both = ids.has(r.wire.from.node) && ids.has(r.wire.to.node)
|
|
|
|
|
if (wireSelected.value.has(r.wire.id)) {
|
|
|
|
|
const pts = r.wire.pts ?? r.pts.slice(1, -1)
|
|
|
|
|
r.wire.pts = pts.map(([x, y]) => [x + dx, y + dy])
|
|
|
|
|
} else if (both && r.wire.pts) {
|
|
|
|
|
r.wire.pts = r.wire.pts.map(([x, y]) => [x + dx, y + dy])
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ed.commit(false)
|
|
|
|
|
}
|
2026-10-17 10:49:38 +00:00
|
|
|
|
|
|
|
|
function onKey(e: KeyboardEvent) {
|
|
|
|
|
const el = e.target as HTMLElement
|
|
|
|
|
if (el.closest('input, textarea, select, [contenteditable]')) 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
|
|
|
|
|
}
|
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()
|
|
|
|
|
}
|
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
|
|
|
|
|
}
|
|
|
|
|
}
|
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()
|
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()
|
|
|
|
|
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()
|
2026-10-21 08:09:43 +00:00
|
|
|
else if (!mod && !e.altKey && e.key === '[') ed.toggleSidebar('left')
|
|
|
|
|
else if (!mod && !e.altKey && e.key === ']') ed.toggleSidebar('right')
|
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) {
|
|
|
|
|
if (e.key === ' ') spaceDown.value = false
|
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'
|
2026-10-20 17:29:16 +00:00
|
|
|
const target = targetAt(d.cur, want, ed.isBus(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])]
|
|
|
|
|
if (target) {
|
|
|
|
|
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]
|
|
|
|
|
}
|
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'
|
|
|
|
|
? routeWire([p.x, p.y], end, d.branch && branchTo(d.branch, [p.x, p.y], end))
|
|
|
|
|
: routeWire(end, [p.x, p.y])
|
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 { d: toPath(pts), snapped: !!target, end }
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
/** 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-20 17:29:16 +00:00
|
|
|
const bus = ed.isBus(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-20 17:29:16 +00:00
|
|
|
if (!!p.bus !== 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}`) })
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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 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')
|
|
|
|
|
if (nodeId && nodeMap.value.has(nodeId)) {
|
|
|
|
|
if (!selected.value.has(nodeId)) {
|
|
|
|
|
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)
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-21 10:16:26 +00:00
|
|
|
/** Pins a dragged part will connect to when dropped, shown as green rings. */
|
|
|
|
|
const dropRings = computed(() => {
|
|
|
|
|
const d = drag.value
|
|
|
|
|
if (d?.kind !== 'move' || !d.snap || !d.still) return []
|
|
|
|
|
const moving = new Set(d.orig.keys())
|
|
|
|
|
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"
|
|
|
|
|
@pointerleave="cursor = null"
|
|
|
|
|
@wheel.prevent="onWheel"
|
|
|
|
|
@contextmenu.prevent
|
|
|
|
|
@dragover.prevent
|
|
|
|
|
@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
|
|
|
|
|
|
|
|
<g :transform="`translate(${view.x} ${view.y}) scale(${view.zoom})`">
|
|
|
|
|
<g class="wires">
|
|
|
|
|
<g
|
|
|
|
|
v-for="r in routes"
|
|
|
|
|
:key="r.wire.id"
|
|
|
|
|
class="wire"
|
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="[
|
|
|
|
|
r.wire.color ? `c-${r.wire.color}` : '',
|
2026-10-20 17:29:16 +00:00
|
|
|
{ on: srcVal(r.src) === 1, selected: wireSelected.has(r.wire.id), hover: hoverSrc === r.src, cable: !!r.bits },
|
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-17 10:49:38 +00:00
|
|
|
>
|
2026-10-21 08:39:54 +00:00
|
|
|
<path v-if="wireSelected.has(r.wire.id)" :d="r.d" class="wire-halo" :style="r.sleeve ? { strokeWidth: `${r.sleeve + 9}px` } : undefined" />
|
|
|
|
|
<template v-if="r.lanes">
|
|
|
|
|
<!-- Ribbon cable: a sleeve in the cable's colour, one line per wire inside -->
|
|
|
|
|
<path :d="r.d" class="cable-sleeve" :style="{ strokeWidth: `${r.sleeve! + 3}px` }" />
|
|
|
|
|
<path :d="r.d" class="cable-core" :style="{ strokeWidth: `${r.sleeve}px` }" />
|
|
|
|
|
<path
|
|
|
|
|
v-for="l in r.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>
|
|
|
|
|
<template v-else>
|
|
|
|
|
<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 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
|
|
|
@pointerenter="hoverSrc = r.src"
|
|
|
|
|
@pointerleave="hoverSrc = 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>
|
2026-10-20 17:29:16 +00:00
|
|
|
</g>
|
2026-10-17 10:49:38 +00:00
|
|
|
</g>
|
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)"
|
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
|
|
|
<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 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>
|
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>
|