diff --git a/README.md b/README.md
index d3aa84e..d0f5f65 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,7 @@ Nuxt 4 (client-only editor, `ssr: false`), Tailwind CSS v4, Lucide icons via `@n
- Gates with more inputs: a placed AND, OR, XOR, NAND or NOR (built in, from the examples, or your own) has an "Inputs" setting from 2 to 16. The wide version is a component built as a balanced tree of the two-input gate (NAND and NOR as the plain gate plus a final inverted one), made once per gate and width in "Wide gates" and reused; transistors count honestly and changes to the two-input gate carry through. Which gates qualify is read off their truth table ([app/lib/logic/wide.ts](app/lib/logic/wide.ts)).
- Campaign (Projects → New campaign): you start with NAND, inputs, outputs, lamps and notes, and no examples. Each challenge opens once the ones it builds on are solved (NOT → AND, OR, SR Latch → …), and your own solution becomes a part you can place. Other basic parts unlock on the way: constants with NOT, the input panel with AND, hex display and pixel with the decoder, cables with Adder 2, the button with the SR latch, the clock with the D latch. Rules in [app/lib/logic/progress.ts](app/lib/logic/progress.ts). Sandbox projects keep everything open.
- Puzzles: "Publish as puzzle" (This circuit) turns a circuit into a link `/puzzle/`. Only its behaviour is published, as a truth table, or for circuits with memory as a run of input changes from power-on; the circuit stays private. Whoever opens the link gets the puzzle in their project, sees the target and the author's transistor count, and after a pass their solution goes to the server, which re-runs the checks and counts the transistors itself (with a fixed work budget) and keeps each player's best. The board shows everyone's transistor counts and your place. The puzzle of the week is generated from the ISO week, the same for everyone: three or four inputs, one or two outputs, each depending on every input. Players are anonymous ids per browser.
-- Library: everyone's published components in one public list (bottom bar → Components → Library, Space, or the main menu), searchable by name, description and author, each with its transistors, pins and what it uses. "Publish to the library…" in the menu on a circuit's name sends it with every component it uses and their connector types, under your leaderboard name; the server checks it like any project and counts transistors and pins itself. Publishing again from the same browser makes the next version of the same entry; only that browser has the entry's edit key, so only it can update or remove it. "Add" brings an entry into the open project and starts placing it: what the project has in exactly that form already is used as it is, the rest comes with new ids (a name that is taken gets a number) and connector types join one with the same lines. The This panel says where a component came from and offers a newer version, which replaces it in place. Challenge circuits and puzzle solutions are never published. A campaign can only add what is built from parts it has earned, and its challenges take none of it: they are solved with your own work. Logic in [app/lib/logic/library.ts](app/lib/logic/library.ts).
+- Library: everyone's published components in one public list (bottom bar → Components → Library, Space, or the main menu), searchable by name, description and author, each with its transistors, pins and what it uses. "Publish to the library…" in the menu on a circuit's name sends it with every component it uses and their connector types, under your leaderboard name; the server checks it like any project and counts transistors and pins itself. Publishing the same component again from the same browser and project makes the next version of the same entry; only that browser has the entry's edit key, so only it can update or remove it. "Add" brings an entry into the open project and starts placing it: what the project has in exactly that form already is used as it is, the rest comes with new ids (a name that is taken gets a number) and connector types join one with the same lines. The This panel says where a component came from and offers a newer version, which replaces it in place; what came along with the old version goes once nothing else uses it. Another entry's component is never reused, so updating one entry leaves the others as they were. Challenges and puzzles, and components with a solution anywhere inside, are never published. A campaign takes nothing from the library: it is built from your own work. Logic in [app/lib/logic/library.ts](app/lib/logic/library.ts).
- Sound (speaker in the top bar; volume and clock ticks in Settings, the gear in the top bar): clicks for placing, wiring, switches and buttons, a tick per clock cycle up to 8 Hz (off by default), and jingles for a solve, a failed check, unlocks and new records. All synthesised with Web Audio, no sound files ([app/lib/audio.ts](app/lib/audio.ts)).
- Transistors: every component shows how many it takes, counted as a CMOS NAND (4 transistors) per gate at every depth: in the palette, its settings and the circuit stats. Each challenge keeps your record, the fewest transistors of any passing solution, and says so when you beat it.
- Cables: a bundle gathers 2 to 32 wires into one cable, a split fans it out again in the same order; one bundle can feed several splits. Select the wires (a box across them, or Shift + click) and press "Bundle into cable" or Ctrl+G: the cable starts right after the sources on their middle row and ends right before the targets on theirs, so the wires keep running as they did (backwards too); an end steps aside when another part is in the way. "Place the ends yourself…" (Ctrl+Shift+G) lets you click where it starts and ends, with a preview; Esc cancels. "Unlink all" on a bundle or split removes only the wires going in or out; the cable stays. Drag the bundle and split later to move the ends. Up to 16 wires, the cable is drawn as a ribbon: each wire is its own thin line inside, in its own colour, lit while it carries a 1. The sleeve starts neutral and gets its own colour (cable or bundle/split settings). "Remove cable" turns it back into single wires. A cable end only joins another cable end, and the cable shows its width.
@@ -66,7 +66,7 @@ The editor UI is in [app/components/editor/](app/components/editor/) with state
## Library
-[server/api/library/](server/api/library/): `POST /api/library` publishes `{ player, root, components, connectors }` and returns `{ id, key, version }`; `PUT /api/library/:id` with header `x-edit-key` publishes the next version; `DELETE /api/library/:id` with the key takes it out. `GET /api/library?q=` lists every entry, newest first, narrowed to those with every word in name, description, group or author; `GET /api/library/:id` returns one with its components (`?meta`: without). Each entry is one JSON file in `data/library/entries/`, plus `data/library/index` for the list (both in the daily backup). Only a SHA-256 of the key is stored; authors show by their leaderboard name, never by their player id. Limits: 1 MB per entry, 30 publishes per IP per 10 minutes, 20,000 entries.
+[server/api/library/](server/api/library/): `POST /api/library` publishes `{ player, root, components, connectors }` and returns `{ id, key, version }`; `PUT /api/library/:id` with header `x-edit-key` publishes the next version; `DELETE /api/library/:id` with the key takes it out. `GET /api/library?q=` lists every entry, newest first, narrowed to those with every word in name, description, group or author; `GET /api/library/:id` returns one with its components (`?meta`: without). Each entry is one JSON file in `data/library/entries/`, plus `data/library/index` for the list (both in the daily backup). Only a SHA-256 of the key is stored; authors show by their leaderboard name, never by their player id. Challenge and library marks are dropped from what comes in, and the list keeps only short texts, pin counts and the first 16 pin names a side, so it stays small. Limits: 1 MB per entry, 30 publishes per IP per 10 minutes, 20,000 entries.
## Accounts
diff --git a/app/assets/css/main.css b/app/assets/css/main.css
index a338339..bdbd4e3 100644
--- a/app/assets/css/main.css
+++ b/app/assets/css/main.css
@@ -3437,15 +3437,6 @@ kbd {
font-size: 11px;
}
-.lib-lock {
- display: flex;
- align-items: center;
- gap: 5px;
- margin-top: 6px;
- font-size: 12px;
- color: #e8a23a;
-}
-
.lib-actions {
display: flex;
flex-direction: column;
diff --git a/app/components/editor/CircuitPane.vue b/app/components/editor/CircuitPane.vue
index 0b18a77..2b9f2fd 100644
--- a/app/components/editor/CircuitPane.vue
+++ b/app/components/editor/CircuitPane.vue
@@ -7,6 +7,7 @@
import { TRANSISTORS_PER_NAND } from '~/lib/logic/analyze'
import { transistorBreakdown } from '~/lib/logic/bulk'
import { chipPins } from '~/lib/logic/geometry'
+import { importProblem } from '~/lib/logic/library'
import { usages } from '~/lib/logic/ops'
import type { SymbolKind } from '~/lib/logic/types'
@@ -51,13 +52,13 @@ const origin = computed(() => {
if (!f) return ''
return f.inside ? `Came along with a component from the library by ${f.author || 'Anonymous'}` : `From the library by ${f.author || 'Anonymous'}, version ${f.version}`
})
-/** A newer version of it in the library, to update to. */
+/** A newer version of it in the library, to update to (not in a campaign, which takes nothing from the library). */
const newer = ref(null)
watch(
() => [def.value.id, def.value.from] as const,
async ([id, f]) => {
newer.value = null
- if (!f || f.inside || ed.ownEntry(def.value)) return
+ if (!f || f.inside || ed.ownEntry(def.value) || importProblem(ed.project.value)) return
const v = await ed.libraryVersion(f.id)
if (def.value.id === id && v !== null && v > f.version) newer.value = v
},
diff --git a/app/components/editor/Help.vue b/app/components/editor/Help.vue
index 689696c..9eb8061 100644
--- a/app/components/editor/Help.vue
+++ b/app/components/editor/Help.vue
@@ -27,7 +27,7 @@ const SHORTCUTS: [string, string][] = [
['Bar at the bottom', 'Point at a kind of part to see them all; click to place, drag onto the canvas, pin the ones you use most to the bar itself (right-click a pinned part to unpin it)'],
['Main (top bar)', 'Back to the main circuit; the names after it lead back to each component you entered'],
['[', 'Hide or show the panel on the left (This and Pins)'],
- ['Library (bottom bar: Components, or Space)', 'Components everyone published: search, add one to this project (what it uses comes along) and place it. Publish your own, or a new version, from the menu on the circuit’s name'],
+ ['Library (bottom bar: Components, or Space)', 'Components everyone published: search, add one to this project (what it uses comes along; not in a campaign) and place it. Publish your own, or a new version, from the menu on the circuit’s name'],
['Connectors (bottom bar)', 'Make a cable type of your own (HDMI, RJ45): its lines; place its Out and In ports; one cable joins them'],
['Select wires, Ctrl+G', 'Bundle them into one cable; an end whose wires all meet one part plugs straight into it'],
['Select a component, cable button beside its pins', 'A cable plugged onto S0–S3 (or any group); drop its free end on the next part\'s pins'],
diff --git a/app/components/editor/LibraryDialog.vue b/app/components/editor/LibraryDialog.vue
index 5af62f2..52fb02a 100644
--- a/app/components/editor/LibraryDialog.vue
+++ b/app/components/editor/LibraryDialog.vue
@@ -2,10 +2,9 @@
// The public library: components everyone published, newest first. Type to
// search names, descriptions and authors. "Add" brings one into the open
// project with everything it uses and starts placing it; entries published
-// from this browser can be taken out again.
+// from this browser can be taken out again. A campaign can look, not add.
import { shortCount } from '~/lib/logic/analyze'
-import { lockedKinds, type LibraryMeta } from '~/lib/logic/library'
-import { KIND_NAMES } from '~/lib/logic/progress'
+import { importProblem, type LibraryMeta } from '~/lib/logic/library'
const ed = useEditor()
const { place } = usePlace()
@@ -46,22 +45,23 @@ onBeforeUnmount(() => clearTimeout(timer))
const date = (t: number) => new Date(t).toLocaleDateString()
-/** A box with a stub per pin, inputs left and outputs right. */
+/** A box with a stub per pin (16 a side at most), inputs left and outputs right. */
function thumb(m: LibraryMeta) {
- const rows = Math.max(1, m.inputs.length, m.outputs.length)
+ const ins = Math.min(m.inputs, 16)
+ const outs = Math.min(m.outputs, 16)
+ const rows = Math.max(1, ins, outs)
const at = (n: number) => Array.from({ length: n }, (_, i) => 1 + i + (rows - n) / 2)
- return { box: `0 0 8 ${rows + 1}`, h: rows, ins: at(m.inputs.length), outs: at(m.outputs.length) }
+ return { box: `0 0 8 ${rows + 1}`, h: rows, ins: at(ins), outs: at(outs) }
}
-/** The entries with their pictures, whether they are yours, and the parts a campaign still lacks for them. */
-const shown = computed(() =>
- (entries.value ?? []).map(m => ({
- m,
- t: thumb(m),
- mine: m.id in ed.libKeys.value,
- missing: lockedKinds(ed.project.value, m.kinds).map(k => KIND_NAMES[k] ?? k),
- })),
-)
+/** Pin names for a tooltip, with a mark when there are more than the listing keeps. */
+const pinList = (names: string[], n: number) => names.join(', ') + (n > names.length ? ', …' : '')
+
+/** The entries with their pictures, and whether they are yours. */
+const shown = computed(() => (entries.value ?? []).map(m => ({ m, t: thumb(m), mine: m.id in ed.libKeys.value })))
+
+/** Why nothing can be added to this project (a campaign); null when it can. */
+const blocked = computed(() => importProblem(ed.project.value))
async function add(m: LibraryMeta) {
busy.value = m.id
@@ -117,9 +117,7 @@ function onKey(e: KeyboardEvent) {
-
- In a campaign you can add what is built from parts you have earned. Challenges are still yours to solve: nothing from the library goes into them.
-
+
{{ blocked }}.
{{ error }}
{{ error ? '' : 'Loading…' }}
@@ -127,7 +125,7 @@ function onKey(e: KeyboardEvent) {
{{ query.trim() ? `Nothing called "${query.trim()}" yet.` : 'Nothing published yet. Be the first: open a component and publish it from the menu on its name.' }}