BF library: no solutions inside, nothing into a campaign, marks only from the entry, a small listing, updates clear what they replace
A component with a challenge or puzzle solution anywhere inside stays private, not only a challenge circuit itself, so wrapping a solution in a part of its own no longer publishes it. A campaign takes nothing from the library: Add and "Get version" are off there, with a line saying why. A library part could be duplicated, published again or taken apart into a solution, so a check on placing was not enough. Library marks come only from the entry being added. The server drops the marks a publisher sends, and whether an entry is yours depends only on the key this browser keeps for that project and component, so a part claiming to be someone's entry can't be published over it. The listing keeps pin counts and the first 16 pin names a side, short, and a group of 40 characters at most, so it stays small whatever is sent. "Get version" clears away what came along with the old version once nothing else uses it, and the new parts take its names. Adding never reuses another entry's component, so updating one entry leaves the others as they were. Wire corner points that aren't number pairs are dropped when a project, link or library entry is read, so a circuit can always be drawn. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
7d6b0f8fad
commit
b823e8fef9
|
|
@ -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)).
|
- 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.
|
- 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/<id>`. 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.
|
- Puzzles: "Publish as puzzle" (This circuit) turns a circuit into a link `/puzzle/<id>`. 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)).
|
- 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.
|
- 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.
|
- 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
|
## 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
|
## Accounts
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3437,15 +3437,6 @@ kbd {
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.lib-lock {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 5px;
|
|
||||||
margin-top: 6px;
|
|
||||||
font-size: 12px;
|
|
||||||
color: #e8a23a;
|
|
||||||
}
|
|
||||||
|
|
||||||
.lib-actions {
|
.lib-actions {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
import { TRANSISTORS_PER_NAND } from '~/lib/logic/analyze'
|
import { TRANSISTORS_PER_NAND } from '~/lib/logic/analyze'
|
||||||
import { transistorBreakdown } from '~/lib/logic/bulk'
|
import { transistorBreakdown } from '~/lib/logic/bulk'
|
||||||
import { chipPins } from '~/lib/logic/geometry'
|
import { chipPins } from '~/lib/logic/geometry'
|
||||||
|
import { importProblem } from '~/lib/logic/library'
|
||||||
import { usages } from '~/lib/logic/ops'
|
import { usages } from '~/lib/logic/ops'
|
||||||
import type { SymbolKind } from '~/lib/logic/types'
|
import type { SymbolKind } from '~/lib/logic/types'
|
||||||
|
|
||||||
|
|
@ -51,13 +52,13 @@ const origin = computed(() => {
|
||||||
if (!f) return ''
|
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}`
|
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<number | null>(null)
|
const newer = ref<number | null>(null)
|
||||||
watch(
|
watch(
|
||||||
() => [def.value.id, def.value.from] as const,
|
() => [def.value.id, def.value.from] as const,
|
||||||
async ([id, f]) => {
|
async ([id, f]) => {
|
||||||
newer.value = null
|
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)
|
const v = await ed.libraryVersion(f.id)
|
||||||
if (def.value.id === id && v !== null && v > f.version) newer.value = v
|
if (def.value.id === id && v !== null && v > f.version) newer.value = v
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -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)'],
|
['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'],
|
['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)'],
|
['[', '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'],
|
['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 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'],
|
['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'],
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,9 @@
|
||||||
// The public library: components everyone published, newest first. Type to
|
// The public library: components everyone published, newest first. Type to
|
||||||
// search names, descriptions and authors. "Add" brings one into the open
|
// search names, descriptions and authors. "Add" brings one into the open
|
||||||
// project with everything it uses and starts placing it; entries published
|
// 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 { shortCount } from '~/lib/logic/analyze'
|
||||||
import { lockedKinds, type LibraryMeta } from '~/lib/logic/library'
|
import { importProblem, type LibraryMeta } from '~/lib/logic/library'
|
||||||
import { KIND_NAMES } from '~/lib/logic/progress'
|
|
||||||
|
|
||||||
const ed = useEditor()
|
const ed = useEditor()
|
||||||
const { place } = usePlace()
|
const { place } = usePlace()
|
||||||
|
|
@ -46,22 +45,23 @@ onBeforeUnmount(() => clearTimeout(timer))
|
||||||
|
|
||||||
const date = (t: number) => new Date(t).toLocaleDateString()
|
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) {
|
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)
|
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. */
|
/** Pin names for a tooltip, with a mark when there are more than the listing keeps. */
|
||||||
const shown = computed(() =>
|
const pinList = (names: string[], n: number) => names.join(', ') + (n > names.length ? ', …' : '')
|
||||||
(entries.value ?? []).map(m => ({
|
|
||||||
m,
|
/** The entries with their pictures, and whether they are yours. */
|
||||||
t: thumb(m),
|
const shown = computed(() => (entries.value ?? []).map(m => ({ m, t: thumb(m), mine: m.id in ed.libKeys.value })))
|
||||||
mine: m.id in ed.libKeys.value,
|
|
||||||
missing: lockedKinds(ed.project.value, m.kinds).map(k => KIND_NAMES[k] ?? k),
|
/** 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) {
|
async function add(m: LibraryMeta) {
|
||||||
busy.value = m.id
|
busy.value = m.id
|
||||||
|
|
@ -117,9 +117,7 @@ function onKey(e: KeyboardEvent) {
|
||||||
<Icon name="lucide:search" class="size-3.5 text-(--muted)" />
|
<Icon name="lucide:search" class="size-3.5 text-(--muted)" />
|
||||||
<input ref="input" v-model="query" placeholder="Search by name, description or author…" />
|
<input ref="input" v-model="query" placeholder="Search by name, description or author…" />
|
||||||
</div>
|
</div>
|
||||||
<p v-if="ed.project.value.mode === 'campaign'" class="hint mt-2">
|
<p v-if="blocked" class="hint mt-2">{{ blocked }}.</p>
|
||||||
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.
|
|
||||||
</p>
|
|
||||||
<p v-if="error" class="result fail"><Icon name="lucide:circle-x" class="size-4 shrink-0" /> {{ error }}</p>
|
<p v-if="error" class="result fail"><Icon name="lucide:circle-x" class="size-4 shrink-0" /> {{ error }}</p>
|
||||||
|
|
||||||
<p v-if="entries === null" class="hint mt-3">{{ error ? '' : 'Loading…' }}</p>
|
<p v-if="entries === null" class="hint mt-3">{{ error ? '' : 'Loading…' }}</p>
|
||||||
|
|
@ -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.' }}
|
{{ 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.' }}
|
||||||
</p>
|
</p>
|
||||||
<ul v-else class="lib-list">
|
<ul v-else class="lib-list">
|
||||||
<li v-for="{ m, t, mine, missing } in shown" :key="m.id" class="lib-entry">
|
<li v-for="{ m, t, mine } in shown" :key="m.id" class="lib-entry">
|
||||||
<svg class="lib-thumb" :viewBox="t.box" preserveAspectRatio="xMidYMid meet" aria-hidden="true">
|
<svg class="lib-thumb" :viewBox="t.box" preserveAspectRatio="xMidYMid meet" aria-hidden="true">
|
||||||
<line v-for="(y, i) in t.ins" :key="`i${i}`" x1="0.6" :y1="y" x2="2" :y2="y" />
|
<line v-for="(y, i) in t.ins" :key="`i${i}`" x1="0.6" :y1="y" x2="2" :y2="y" />
|
||||||
<line v-for="(y, i) in t.outs" :key="`o${i}`" x1="6" :y1="y" x2="7.4" :y2="y" />
|
<line v-for="(y, i) in t.outs" :key="`o${i}`" x1="6" :y1="y" x2="7.4" :y2="y" />
|
||||||
|
|
@ -142,15 +140,14 @@ function onKey(e: KeyboardEvent) {
|
||||||
<p v-if="m.description" class="lib-desc">{{ m.description }}</p>
|
<p v-if="m.description" class="lib-desc">{{ m.description }}</p>
|
||||||
<div class="lib-stats">
|
<div class="lib-stats">
|
||||||
<span title="Transistors at every depth, 4 per NAND">{{ shortCount(m.transistors) }} transistors</span>
|
<span title="Transistors at every depth, 4 per NAND">{{ shortCount(m.transistors) }} transistors</span>
|
||||||
<span :title="m.inputs.join(', ')">{{ m.inputs.length }} in</span>
|
<span :title="pinList(m.inNames, m.inputs)">{{ m.inputs }} in</span>
|
||||||
<span :title="m.outputs.join(', ')">{{ m.outputs.length }} out</span>
|
<span :title="pinList(m.outNames, m.outputs)">{{ m.outputs }} out</span>
|
||||||
<span v-if="m.uses" title="Components it uses; they come along">{{ m.uses }} inside</span>
|
<span v-if="m.uses" title="Components it uses; they come along">{{ m.uses }} inside</span>
|
||||||
<span v-if="m.connectors">{{ m.connectors }} connector {{ m.connectors === 1 ? 'type' : 'types' }}</span>
|
<span v-if="m.connectors">{{ m.connectors }} connector {{ m.connectors === 1 ? 'type' : 'types' }}</span>
|
||||||
</div>
|
</div>
|
||||||
<p v-if="missing.length" class="lib-lock"><Icon name="lucide:lock" class="size-3.5 shrink-0" /> Needs parts you have not earned yet: {{ missing.join(', ') }}</p>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="lib-actions">
|
<div class="lib-actions">
|
||||||
<button class="btn btn-primary" :disabled="!!busy || missing.length > 0" title="Add it to this project and place it" @click="add(m)">
|
<button class="btn btn-primary" :disabled="!!busy || !!blocked" :title="blocked ?? 'Add it to this project and place it'" @click="add(m)">
|
||||||
<Icon name="lucide:plus" class="size-4" /> {{ busy === m.id ? 'Adding…' : 'Add' }}
|
<Icon name="lucide:plus" class="size-4" /> {{ busy === m.id ? 'Adding…' : 'Add' }}
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ import { apiId, makePuzzle, scoreSolution, weekKey, weeklyId } from '~/lib/logic
|
||||||
import { baseOf, MAX_GATE_INPUTS, NAND_BASE, wideGate } from '~/lib/logic/wide'
|
import { baseOf, MAX_GATE_INPUTS, NAND_BASE, wideGate } from '~/lib/logic/wide'
|
||||||
import { CHALLENGES, challengeSteps, type Challenge } from '~/lib/logic/challenges'
|
import { CHALLENGES, challengeSteps, type Challenge } from '~/lib/logic/challenges'
|
||||||
import { latchedTo, latchInto, latchTarget, syncLatches } from '~/lib/logic/latch'
|
import { latchedTo, latchInto, latchTarget, syncLatches } from '~/lib/logic/latch'
|
||||||
import { cleanBundle, closure, importBundle, kindsIn, LIBRARY_LIMITS, libraryBundle, lockedKinds, publishProblem, type LibraryBundle, type LibraryMeta } from '~/lib/logic/library'
|
import { cleanBundle, importBundle, importProblem, LIBRARY_LIMITS, libraryBundle, ownedEntry, publishProblem, type LibraryBundle, type LibraryMeta } from '~/lib/logic/library'
|
||||||
import { compile, INVERTIBLE, invertedPins, rowSource } from '~/lib/logic/compile'
|
import { compile, INVERTIBLE, invertedPins, rowSource } from '~/lib/logic/compile'
|
||||||
import { chipPins, MAX_BITS, panelOffsets, pinKindOf, shapeOf, type Pt } from '~/lib/logic/geometry'
|
import { chipPins, MAX_BITS, panelOffsets, pinKindOf, shapeOf, type Pt } from '~/lib/logic/geometry'
|
||||||
import { adoptName, continueSeries, newPinLabel, uniqueLabel, usedLabels } from '~/lib/logic/labels'
|
import { adoptName, continueSeries, newPinLabel, uniqueLabel, usedLabels } from '~/lib/logic/labels'
|
||||||
|
|
@ -523,13 +523,7 @@ function create() {
|
||||||
|
|
||||||
function canPlace(chipId: string) {
|
function canPlace(chipId: string) {
|
||||||
const d = getDef.value(chipId)
|
const d = getDef.value(chipId)
|
||||||
return !containsDef(project.value, chipId, def.value.id) && (!d || defUsable(project.value, d)) && !borrowed(chipId)
|
return !containsDef(project.value, chipId, def.value.id) && (!d || defUsable(project.value, d))
|
||||||
}
|
|
||||||
|
|
||||||
/** In a campaign, challenges are solved with your own work: nothing someone else published goes into them. */
|
|
||||||
function borrowed(chipId: string): boolean {
|
|
||||||
if (!isCampaign(project.value) || !def.value.challenge) return false
|
|
||||||
return closure(getDef.value, chipId).some(d => d.from && !libKeys.value[d.from.id])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** In a campaign, basic parts are earned; elsewhere everything can be placed. */
|
/** In a campaign, basic parts are earned; elsewhere everything can be placed. */
|
||||||
|
|
@ -1493,12 +1487,9 @@ function create() {
|
||||||
/** Edit keys of the library entries this browser published. */
|
/** Edit keys of the library entries this browser published. */
|
||||||
const libKeys = ref(libraryKeys())
|
const libKeys = ref(libraryKeys())
|
||||||
|
|
||||||
/** The library entry a component is, when this browser published it (and so can update or remove it). */
|
/** The library entry a component is, when this browser published it from here (and so can update or remove it). */
|
||||||
function ownEntry(d: ComponentDef | undefined): string | undefined {
|
function ownEntry(d: ComponentDef | undefined): string | undefined {
|
||||||
if (!d) return undefined
|
return d && ownedEntry(libKeys.value, meta.value.id, d.id)
|
||||||
if (d.from && !d.from.inside && libKeys.value[d.from.id]) return d.from.id
|
|
||||||
// Published from here, and the mark undone since.
|
|
||||||
return Object.entries(libKeys.value).find(([, k]) => k.project === meta.value.id && k.def === d.id)?.[0]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Why the open circuit can't go to the library; null when it can. */
|
/** Why the open circuit can't go to the library; null when it can. */
|
||||||
|
|
@ -1559,12 +1550,10 @@ function create() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchEntry(id: string): Promise<{ entry: LibraryMeta; bundle: LibraryBundle }> {
|
async function fetchEntry(id: string): Promise<{ entry: LibraryMeta; bundle: LibraryBundle }> {
|
||||||
|
const problem = importProblem(project.value)
|
||||||
|
if (problem) throw new Error(problem)
|
||||||
const res = await api<{ entry: LibraryMeta; bundle: unknown }>('GET', `/api/library/${encodeURIComponent(id)}`)
|
const res = await api<{ entry: LibraryMeta; bundle: unknown }>('GET', `/api/library/${encodeURIComponent(id)}`)
|
||||||
const bundle = cleanBundle(res.bundle)
|
return { entry: res.entry, bundle: cleanBundle(res.bundle) }
|
||||||
// A campaign earns its parts: only what could have been built with the parts earned so far comes in.
|
|
||||||
const locked = lockedKinds(project.value, kindsIn(bundle.components))
|
|
||||||
if (locked.length) throw new Error(`It uses parts this campaign has not earned yet: ${locked.map(k => KIND_NAMES[k] ?? k).join(', ')}`)
|
|
||||||
return { entry: res.entry, bundle }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const originOf = (entry: LibraryMeta): LibraryOrigin => ({ id: entry.id, version: entry.version, author: entry.author })
|
const originOf = (entry: LibraryMeta): LibraryOrigin => ({ id: entry.id, version: entry.version, author: entry.author })
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ export function usePlace() {
|
||||||
function place(kind: NodeKind, chip?: string, conn?: string) {
|
function place(kind: NodeKind, chip?: string, conn?: string) {
|
||||||
if (chip && !ed.canPlace(chip)) {
|
if (chip && !ed.canPlace(chip)) {
|
||||||
ed.play('error')
|
ed.play('error')
|
||||||
return ed.notify('That component cannot go in here (it is this circuit, contains it, is not solved yet, or is from the library and this is a campaign challenge)', 'error')
|
return ed.notify('That component cannot go in here (it is this circuit, contains it, or is not solved yet)', 'error')
|
||||||
}
|
}
|
||||||
if (!ed.canPlaceKind(kind)) {
|
if (!ed.canPlaceKind(kind)) {
|
||||||
ed.play('error')
|
ed.play('error')
|
||||||
|
|
|
||||||
|
|
@ -10,13 +10,17 @@ import { CHALLENGES } from './challenges'
|
||||||
import { MAX_DEPTH } from './compile'
|
import { MAX_DEPTH } from './compile'
|
||||||
import { chipPins, type DefLookup } from './geometry'
|
import { chipPins, type DefLookup } from './geometry'
|
||||||
import { containsDef, lookup, uid, uniqueName } from './ops'
|
import { containsDef, lookup, uid, uniqueName } from './ops'
|
||||||
import { KIND_NAMES, kindUnlocked } from './progress'
|
import { isCampaign, KIND_NAMES } from './progress'
|
||||||
import { toProject } from './project'
|
import { toProject } from './project'
|
||||||
import type { ComponentDef, ConnectorType, LibraryOrigin, NodeKind, Project } from './types'
|
import type { ComponentDef, ConnectorType, LibraryOrigin, Project } from './types'
|
||||||
import { NAND_BASE } from './wide'
|
import { NAND_BASE } from './wide'
|
||||||
|
|
||||||
/** Upper bounds for a published component: the request, its name and description. */
|
/**
|
||||||
export const LIBRARY_LIMITS = { bytes: 1_000_000, name: 60, description: 400 }
|
* Upper bounds for a published component: the request, its name,
|
||||||
|
* description and group, and the pin names the listing shows (how many per
|
||||||
|
* side, how long each).
|
||||||
|
*/
|
||||||
|
export const LIBRARY_LIMITS = { bytes: 1_000_000, name: 60, description: 400, group: 40, pinNames: 16, pinName: 24 }
|
||||||
|
|
||||||
/** What gets published: a component (`root`) and everything it uses, used ones first, with their connector types. */
|
/** What gets published: a component (`root`) and everything it uses, used ones first, with their connector types. */
|
||||||
export interface LibraryBundle {
|
export interface LibraryBundle {
|
||||||
|
|
@ -38,15 +42,16 @@ export interface LibraryMeta {
|
||||||
updated: number
|
updated: number
|
||||||
/** Transistors at every depth, 4 per NAND. */
|
/** Transistors at every depth, 4 per NAND. */
|
||||||
transistors: number
|
transistors: number
|
||||||
/** Pin names, top to bottom. */
|
/** Pins on each side. */
|
||||||
inputs: string[]
|
inputs: number
|
||||||
outputs: string[]
|
outputs: number
|
||||||
|
/** Names of the first pins on each side, top to bottom, shortened. */
|
||||||
|
inNames: string[]
|
||||||
|
outNames: string[]
|
||||||
/** Components it uses, at every depth; they come along. */
|
/** Components it uses, at every depth; they come along. */
|
||||||
uses: number
|
uses: number
|
||||||
/** Connector types that come along. */
|
/** Connector types that come along. */
|
||||||
connectors: number
|
connectors: number
|
||||||
/** Built-in parts used anywhere inside (a campaign has to have earned them). */
|
|
||||||
kinds: NodeKind[]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Deep copy that also works on Vue reactive proxies (structuredClone does not). */
|
/** Deep copy that also works on Vue reactive proxies (structuredClone does not). */
|
||||||
|
|
@ -81,20 +86,10 @@ function connectorsUsed(connectors: ConnectorType[] | undefined, defs: Component
|
||||||
return (connectors ?? []).filter(c => used.has(c.id))
|
return (connectors ?? []).filter(c => used.has(c.id))
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Built-in parts used anywhere in these components, in a fixed order. */
|
|
||||||
export function kindsIn(defs: ComponentDef[]): NodeKind[] {
|
|
||||||
return [...new Set(defs.flatMap(d => d.nodes.map(n => n.kind)))].filter(k => k !== 'chip').sort()
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Built-in parts a project has not earned yet (in a campaign), out of these. */
|
|
||||||
export function lockedKinds(project: Project, kinds: NodeKind[]): NodeKind[] {
|
|
||||||
return kinds.filter(k => !kindUnlocked(project, k))
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Why a component can't go to the library, in words; null when it can.
|
* Why a component can't go to the library, in words; null when it can.
|
||||||
* Challenges and puzzles stay private, so nobody gets the answer: neither
|
* Challenges and puzzles stay private, so nobody gets the answer: neither
|
||||||
* a challenge circuit itself nor a puzzle solution used inside.
|
* a challenge circuit itself nor a solution used anywhere inside it.
|
||||||
*/
|
*/
|
||||||
export function publishProblem(project: Project, defId: string): string | null {
|
export function publishProblem(project: Project, defId: string): string | null {
|
||||||
const get = lookup(project)
|
const get = lookup(project)
|
||||||
|
|
@ -102,21 +97,39 @@ export function publishProblem(project: Project, defId: string): string | null {
|
||||||
if (!def) return 'Circuit not found'
|
if (!def) return 'Circuit not found'
|
||||||
if (def.challenge) return 'Challenges and puzzles stay private, so nobody gets the answer'
|
if (def.challenge) return 'Challenges and puzzles stay private, so nobody gets the answer'
|
||||||
if (!def.nodes.length) return 'There is nothing in it yet'
|
if (!def.nodes.length) return 'There is nothing in it yet'
|
||||||
const puzzle = closure(get, defId).find(d => d.challenge && !CHALLENGES.some(c => c.id === d.challenge))
|
const solution = closure(get, defId).find(d => d.challenge)
|
||||||
if (puzzle) return `It uses your solution to the puzzle "${puzzle.name}", which stays private`
|
if (solution) return `It uses your solution to the ${CHALLENGES.some(c => c.id === solution.challenge) ? 'challenge' : 'puzzle'} "${solution.name}", which stays private`
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Why library entries can't be added to a project, in words; null when they
|
||||||
|
* can. A campaign is earned part by part, and a part from the library could
|
||||||
|
* be copied or taken apart into a solution, so a campaign takes none.
|
||||||
|
*/
|
||||||
|
export function importProblem(project: Project): string | null {
|
||||||
|
return isCampaign(project) ? 'A campaign is built from your own work: add library components to another project' : null
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The library entry a component is when this browser published it, from
|
||||||
|
* this very project and component; its key is in `keys`. The component's
|
||||||
|
* own mark never counts for this, since marks come along in files and links.
|
||||||
|
*/
|
||||||
|
export function ownedEntry(keys: Record<string, { project: string; def: string }>, projectId: string, defId: string): string | undefined {
|
||||||
|
return Object.entries(keys).find(([, k]) => k.project === projectId && k.def === defId)?.[0]
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* What publishing a component sends: copies of it and of what it uses,
|
* What publishing a component sends: copies of it and of what it uses,
|
||||||
* without challenge marks, and their connector types. Components it uses
|
* without challenge or library marks, and their connector types.
|
||||||
* keep their own library marks, so their authors stay named.
|
|
||||||
*/
|
*/
|
||||||
export function libraryBundle(project: Project, defId: string): LibraryBundle {
|
export function libraryBundle(project: Project, defId: string): LibraryBundle {
|
||||||
const components = clone(closure(lookup(project), defId))
|
const components = clone(closure(lookup(project), defId))
|
||||||
for (const d of components) delete d.challenge
|
for (const d of components) {
|
||||||
const root = components.find(d => d.id === defId)
|
delete d.challenge
|
||||||
if (root) delete root.from
|
delete d.from
|
||||||
|
}
|
||||||
const connectors = clone(connectorsUsed(project.connectors, components))
|
const connectors = clone(connectorsUsed(project.connectors, components))
|
||||||
return { root: defId, components, ...(connectors.length ? { connectors } : {}) }
|
return { root: defId, components, ...(connectors.length ? { connectors } : {}) }
|
||||||
}
|
}
|
||||||
|
|
@ -168,8 +181,9 @@ const KINDS = new Set<string>([...Object.keys(KIND_NAMES), 'chip'])
|
||||||
* Checks a bundle from outside with the same checks as any project, plus
|
* Checks a bundle from outside with the same checks as any project, plus
|
||||||
* the ones a part from a stranger needs: every node and wire well formed,
|
* the ones a part from a stranger needs: every node and wire well formed,
|
||||||
* nothing missing, nothing inside itself, nothing too big to run. Keeps only
|
* nothing missing, nothing inside itself, nothing too big to run. Keeps only
|
||||||
* the component and what it uses, and drops challenge marks. Throws with a
|
* the component and what it uses, and drops challenge and library marks:
|
||||||
* readable message.
|
* an entry's components are marked when they are added, never by whoever
|
||||||
|
* published them. Throws with a readable message.
|
||||||
*/
|
*/
|
||||||
export function cleanBundle(raw: unknown): LibraryBundle {
|
export function cleanBundle(raw: unknown): LibraryBundle {
|
||||||
const b = raw as Partial<LibraryBundle>
|
const b = raw as Partial<LibraryBundle>
|
||||||
|
|
@ -192,29 +206,38 @@ export function cleanBundle(raw: unknown): LibraryBundle {
|
||||||
const problem = nestingProblem(get, root.id)
|
const problem = nestingProblem(get, root.id)
|
||||||
if (problem) throw new Error(problem)
|
if (problem) throw new Error(problem)
|
||||||
const components = closure(get, root.id)
|
const components = closure(get, root.id)
|
||||||
for (const d of components) delete d.challenge
|
for (const d of components) {
|
||||||
delete root.from
|
delete d.challenge
|
||||||
|
delete d.from
|
||||||
|
}
|
||||||
root.name = root.name.trim().slice(0, LIBRARY_LIMITS.name) || 'Component'
|
root.name = root.name.trim().slice(0, LIBRARY_LIMITS.name) || 'Component'
|
||||||
if (root.description !== undefined) root.description = root.description.trim().slice(0, LIBRARY_LIMITS.description)
|
if (root.description !== undefined) root.description = root.description.trim().slice(0, LIBRARY_LIMITS.description)
|
||||||
|
if (root.group !== undefined) root.group = root.group.trim().slice(0, LIBRARY_LIMITS.group)
|
||||||
const connectors = connectorsUsed(p.connectors, components)
|
const connectors = connectorsUsed(p.connectors, components)
|
||||||
return { root: root.id, components, ...(connectors.length ? { connectors } : {}) }
|
return { root: root.id, components, ...(connectors.length ? { connectors } : {}) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/** What the listing says about a bundle, counted from the circuit itself so it can be trusted. */
|
/**
|
||||||
export function describeBundle(b: LibraryBundle): Pick<LibraryMeta, 'name' | 'description' | 'group' | 'transistors' | 'inputs' | 'outputs' | 'uses' | 'connectors' | 'kinds'> {
|
* What the listing says about a cleaned bundle, counted from the circuit
|
||||||
|
* itself so it can be trusted. Small whatever was sent: every entry's
|
||||||
|
* listing is read on each visit to the library.
|
||||||
|
*/
|
||||||
|
export function describeBundle(b: LibraryBundle): Pick<LibraryMeta, 'name' | 'description' | 'group' | 'transistors' | 'inputs' | 'outputs' | 'inNames' | 'outNames' | 'uses' | 'connectors'> {
|
||||||
const root = b.components.find(d => d.id === b.root)
|
const root = b.components.find(d => d.id === b.root)
|
||||||
if (!root) throw new Error('The component itself is missing')
|
if (!root) throw new Error('The component itself is missing')
|
||||||
const pins = chipPins(root)
|
const pins = chipPins(root)
|
||||||
|
const names = (list: { label: string }[]) => list.slice(0, LIBRARY_LIMITS.pinNames).map(p => p.label.slice(0, LIBRARY_LIMITS.pinName))
|
||||||
return {
|
return {
|
||||||
name: root.name,
|
name: root.name.slice(0, LIBRARY_LIMITS.name),
|
||||||
description: root.description ?? '',
|
description: (root.description ?? '').slice(0, LIBRARY_LIMITS.description),
|
||||||
group: root.group?.trim() ?? '',
|
group: (root.group ?? '').slice(0, LIBRARY_LIMITS.group),
|
||||||
transistors: (nandCounts(b.components).get(root.id) ?? 0) * TRANSISTORS_PER_NAND,
|
transistors: (nandCounts(b.components).get(root.id) ?? 0) * TRANSISTORS_PER_NAND,
|
||||||
inputs: pins.inputs.map(p => p.label),
|
inputs: pins.inputs.length,
|
||||||
outputs: pins.outputs.map(p => p.label),
|
outputs: pins.outputs.length,
|
||||||
|
inNames: names(pins.inputs),
|
||||||
|
outNames: names(pins.outputs),
|
||||||
uses: b.components.length - 1,
|
uses: b.components.length - 1,
|
||||||
connectors: b.connectors?.length ?? 0,
|
connectors: b.connectors?.length ?? 0,
|
||||||
kinds: kindsIn(b.components),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -240,10 +263,12 @@ const CONTENT = ['symbol', 'description', 'face', 'wide', 'design', 'nodes', 'wi
|
||||||
* taken. A connector type joins the project's type of the same id or name
|
* taken. A connector type joins the project's type of the same id or name
|
||||||
* when their lines match, and comes in as a new type otherwise. The entry's
|
* when their lines match, and comes in as a new type otherwise. The entry's
|
||||||
* component is marked with where it came from; the ones it uses are marked
|
* component is marked with where it came from; the ones it uses are marked
|
||||||
* as having come along, unless they carry a mark of their own.
|
* as having come along.
|
||||||
*
|
*
|
||||||
* With `replace` (a component here from the same entry), that component
|
* With `replace` (a component here from the same entry), that component
|
||||||
* takes the entry's new version instead, so every place it is used follows.
|
* takes the entry's new version instead, so every place it is used follows.
|
||||||
|
* What came along with the old version and is used nowhere else any more
|
||||||
|
* goes, and the parts that replace it take its names.
|
||||||
* Returns the id of the entry's component here and how many were added.
|
* Returns the id of the entry's component here and how many were added.
|
||||||
*/
|
*/
|
||||||
export function importBundle(project: Project, bundle: LibraryBundle, origin: LibraryOrigin, replace?: string): { root: string; added: number } {
|
export function importBundle(project: Project, bundle: LibraryBundle, origin: LibraryOrigin, replace?: string): { root: string; added: number } {
|
||||||
|
|
@ -264,17 +289,21 @@ export function importBundle(project: Project, bundle: LibraryBundle, origin: Li
|
||||||
}
|
}
|
||||||
|
|
||||||
// Components already here, by form. Not challenge attempts, which are
|
// Components already here, by form. Not challenge attempts, which are
|
||||||
// still being worked on, nor anything that contains the one being
|
// still being worked on; not another entry's component, which a newer
|
||||||
// replaced, or it would end up inside itself.
|
// version of that entry would change under this one; nor anything that
|
||||||
|
// contains the one being replaced, or it would end up inside itself.
|
||||||
const forms = new Map<string, string>()
|
const forms = new Map<string, string>()
|
||||||
for (const d of project.components) {
|
for (const d of project.components) {
|
||||||
if (d.challenge || (replace && containsDef(project, d.id, replace))) continue
|
if (d.challenge || (d.from && !d.from.inside && d.from.id !== origin.id) || (replace && containsDef(project, d.id, replace))) continue
|
||||||
const k = form(d)
|
const k = form(d)
|
||||||
if (!forms.has(k)) forms.set(k, d.id)
|
if (!forms.has(k)) forms.set(k, d.id)
|
||||||
}
|
}
|
||||||
const target = replace ? project.components.find(d => d.id === replace) : undefined
|
const target = replace ? project.components.find(d => d.id === replace) : undefined
|
||||||
|
// What came along with the version being replaced.
|
||||||
|
const before = target ? closure(lookup(project), target.id).filter(d => d.from?.inside && d.from.id === origin.id) : []
|
||||||
const byId = new Map(bundle.components.map(d => [d.id, d]))
|
const byId = new Map(bundle.components.map(d => [d.id, d]))
|
||||||
const ids = new Map<string, string>()
|
const ids = new Map<string, string>()
|
||||||
|
const fresh: { def: ComponentDef; name: string }[] = []
|
||||||
let root = ''
|
let root = ''
|
||||||
let added = 0
|
let added = 0
|
||||||
for (const d of closure(id => byId.get(id), bundle.root)) {
|
for (const d of closure(id => byId.get(id), bundle.root)) {
|
||||||
|
|
@ -286,8 +315,7 @@ export function importBundle(project: Project, bundle: LibraryBundle, origin: Li
|
||||||
if (copy.wide && copy.wide.base !== NAND_BASE) copy.wide.base = ids.get(copy.wide.base) ?? copy.wide.base
|
if (copy.wide && copy.wide.base !== NAND_BASE) copy.wide.base = ids.get(copy.wide.base) ?? copy.wide.base
|
||||||
delete copy.challenge
|
delete copy.challenge
|
||||||
const isRoot = d.id === bundle.root
|
const isRoot = d.id === bundle.root
|
||||||
if (isRoot) copy.from = { ...origin }
|
copy.from = isRoot ? { ...origin } : { ...origin, inside: true }
|
||||||
else copy.from ??= { ...origin, inside: true }
|
|
||||||
|
|
||||||
if (isRoot && target) {
|
if (isRoot && target) {
|
||||||
const t = target as unknown as Record<string, unknown>
|
const t = target as unknown as Record<string, unknown>
|
||||||
|
|
@ -316,8 +344,29 @@ export function importBundle(project: Project, bundle: LibraryBundle, origin: Li
|
||||||
project.components.push(copy)
|
project.components.push(copy)
|
||||||
forms.set(form(copy), copy.id)
|
forms.set(form(copy), copy.id)
|
||||||
ids.set(d.id, copy.id)
|
ids.set(d.id, copy.id)
|
||||||
|
fresh.push({ def: copy, name: d.name })
|
||||||
added++
|
added++
|
||||||
if (isRoot) root = copy.id
|
if (isRoot) root = copy.id
|
||||||
}
|
}
|
||||||
|
if (target) {
|
||||||
|
dropUnused(project, before)
|
||||||
|
for (const f of fresh) if (f.def.name !== f.name && !project.components.some(x => x.name.toLowerCase() === f.name.toLowerCase())) f.def.name = f.name
|
||||||
|
}
|
||||||
return { root, added }
|
return { root, added }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Removes those of these components that nothing uses (or has open), and then those only they used. */
|
||||||
|
function dropUnused(project: Project, defs: ComponentDef[]) {
|
||||||
|
const left = new Set(defs.map(d => d.id))
|
||||||
|
const used = (id: string) =>
|
||||||
|
id === project.openId || project.components.some(d => d.id !== id && (d.wide?.base === id || d.nodes.some(n => n.kind === 'chip' && n.chip === id)))
|
||||||
|
for (let gone = true; gone; ) {
|
||||||
|
gone = false
|
||||||
|
for (const id of left) {
|
||||||
|
if (used(id)) continue
|
||||||
|
project.components = project.components.filter(d => d.id !== id)
|
||||||
|
left.delete(id)
|
||||||
|
gone = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -117,6 +117,9 @@ function cleanOrigin(d: ComponentDef) {
|
||||||
d.from = { id: f.id, version: f.version!, author: typeof f.author === 'string' ? f.author.slice(0, 24) : '', ...(f.inside === true ? { inside: true } : {}) }
|
d.from = { id: f.id, version: f.version!, author: typeof f.author === 'string' ? f.author.slice(0, 24) : '', ...(f.inside === true ? { inside: true } : {}) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** A wire's corner points: [x, y] pairs of plain numbers, or the wire can't be drawn. */
|
||||||
|
const cornersOk = (pts: unknown) => Array.isArray(pts) && pts.every(p => Array.isArray(p) && p.length === 2 && p.every(v => typeof v === 'number' && Number.isFinite(v)))
|
||||||
|
|
||||||
/** Upper bounds for a project that comes from outside. */
|
/** Upper bounds for a project that comes from outside. */
|
||||||
export const LIMITS = { bytes: 2_000_000, components: 2_000, nodes: 100_000 }
|
export const LIMITS = { bytes: 2_000_000, components: 2_000, nodes: 100_000 }
|
||||||
|
|
||||||
|
|
@ -139,6 +142,7 @@ export function toProject(data: unknown): Project {
|
||||||
if (d.from !== undefined) cleanOrigin(d)
|
if (d.from !== undefined) cleanOrigin(d)
|
||||||
for (const n of d.nodes) cleanNode(n)
|
for (const n of d.nodes) cleanNode(n)
|
||||||
for (const w of d.wires) if (w.color && !WIRE_COLORS.includes(w.color)) delete w.color
|
for (const w of d.wires) if (w.color && !WIRE_COLORS.includes(w.color)) delete w.color
|
||||||
|
for (const w of d.wires) if (w.pts !== undefined && !cornersOk(w.pts)) delete w.pts
|
||||||
}
|
}
|
||||||
if (nodes > LIMITS.nodes) throw new Error('Project too large')
|
if (nodes > LIMITS.nodes) throw new Error('Project too large')
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ describe('library API', () => {
|
||||||
expect(list.total).toBe(1)
|
expect(list.total).toBe(1)
|
||||||
const [entry] = list.entries as Record<string, unknown>[]
|
const [entry] = list.entries as Record<string, unknown>[]
|
||||||
// Two half adders (XOR of 4 NANDs, AND of 2) and an OR of 3: 15 NANDs.
|
// Two half adders (XOR of 4 NANDs, AND of 2) and an OR of 3: 15 NANDs.
|
||||||
expect(entry).toMatchObject({ id, name: 'Full Adder', author: 'Ada', transistors: 60, inputs: ['A', 'B', 'Cin'], outputs: ['S', 'Cout'], uses: 5, version: 1 })
|
expect(entry).toMatchObject({ id, name: 'Full Adder', author: 'Ada', transistors: 60, inputs: 3, outputs: 2, inNames: ['A', 'B', 'Cin'], outNames: ['S', 'Cout'], uses: 5, version: 1 })
|
||||||
expect(JSON.stringify(list)).not.toContain(ADA)
|
expect(JSON.stringify(list)).not.toContain(ADA)
|
||||||
expect((await call('list', { query: { q: 'counter' } })).entries).toEqual([])
|
expect((await call('list', { query: { q: 'counter' } })).entries).toEqual([])
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { describe, expect, it } from 'vitest'
|
import { describe, expect, it } from 'vitest'
|
||||||
import { nandCounts, truthTable } from '../app/lib/logic/analyze'
|
import { nandCounts, truthTable } from '../app/lib/logic/analyze'
|
||||||
import { cleanBundle, closure, describeBundle, importBundle, kindsIn, libraryBundle, lockedKinds, publishProblem, type LibraryMeta } from '../app/lib/logic/library'
|
import { cleanBundle, closure, describeBundle, importBundle, importProblem, LIBRARY_LIMITS, libraryBundle, ownedEntry, publishProblem, type LibraryMeta } from '../app/lib/logic/library'
|
||||||
import { createProject, duplicateComponent, lookup, startChallenge } from '../app/lib/logic/ops'
|
import { createProject, duplicateComponent, lookup, startChallenge } from '../app/lib/logic/ops'
|
||||||
import { parseProject, toProject } from '../app/lib/logic/project'
|
import { parseProject, toProject } from '../app/lib/logic/project'
|
||||||
import { libraryKeys, setLibraryKey } from '../app/lib/logic/storage'
|
import { libraryKeys, setLibraryKey } from '../app/lib/logic/storage'
|
||||||
|
|
@ -66,19 +66,29 @@ describe('library: what goes along', () => {
|
||||||
expect(p.components.find(d => d.id === 'ex-xor')!.challenge).toBe('xor')
|
expect(p.components.find(d => d.id === 'ex-xor')!.challenge).toBe('xor')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('keeps challenges and puzzle solutions private', () => {
|
it('keeps challenges and puzzle solutions private, at any depth', () => {
|
||||||
const p = createProject({ examples: true })
|
const p = createProject({ examples: true })
|
||||||
const not = startChallenge(p, CHALLENGES.find(c => c.id === 'not')!)
|
const not = startChallenge(p, CHALLENGES.find(c => c.id === 'not')!)
|
||||||
expect(publishProblem(p, not.id)).toMatch(/private/)
|
expect(publishProblem(p, not.id)).toMatch(/private/)
|
||||||
expect(publishProblem(p, 'ex-add4')).toBeNull()
|
expect(publishProblem(p, 'ex-add4')).toBeNull()
|
||||||
// A solved built-in challenge may be used inside; a puzzle solution may not.
|
// A solution anywhere inside stays private too, a challenge's or a puzzle's.
|
||||||
p.components.find(d => d.id === 'ex-xor')!.challenge = 'xor'
|
p.components.find(d => d.id === 'ex-xor')!.challenge = 'xor'
|
||||||
expect(publishProblem(p, 'ex-add4')).toBeNull()
|
expect(publishProblem(p, 'ex-add4')).toMatch(/challenge "XOR"/)
|
||||||
p.components.find(d => d.id === 'ex-xor')!.challenge = 'pz:abc123'
|
p.components.find(d => d.id === 'ex-xor')!.challenge = 'pz:abc123'
|
||||||
expect(publishProblem(p, 'ex-add4')).toMatch(/puzzle "XOR"/)
|
expect(publishProblem(p, 'ex-add4')).toMatch(/puzzle "XOR"/)
|
||||||
p.components.push({ id: 'empty', name: 'Empty', symbol: 'box', nodes: [], wires: [] })
|
p.components.push({ id: 'empty', name: 'Empty', symbol: 'box', nodes: [], wires: [] })
|
||||||
expect(publishProblem(p, 'empty')).toMatch(/nothing/)
|
expect(publishProblem(p, 'empty')).toMatch(/nothing/)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('does not publish a solved challenge wrapped in a component of its own', () => {
|
||||||
|
const p = createProject({ examples: false, campaign: true })
|
||||||
|
const not = startChallenge(p, CHALLENGES.find(c => c.id === 'not')!)
|
||||||
|
not.nodes.push({ id: 'g', kind: 'nand', x: 8, y: 0 })
|
||||||
|
p.solved.push('not')
|
||||||
|
p.components.push({ id: 'wrap', name: 'Wrap', symbol: 'box', nodes: [{ id: 'c', kind: 'chip', chip: not.id, x: 0, y: 0 }], wires: [] })
|
||||||
|
expect(publishProblem(p, 'wrap')).toMatch(/challenge "NOT", which stays private/)
|
||||||
|
expect(publishProblem(p, not.id)).toMatch(/private/)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('library: checks on the server', () => {
|
describe('library: checks on the server', () => {
|
||||||
|
|
@ -89,8 +99,40 @@ describe('library: checks on the server', () => {
|
||||||
expect(b.components.map(d => d.id)).toEqual(closure(lookup(p), 'csend').map(d => d.id))
|
expect(b.components.map(d => d.id)).toEqual(closure(lookup(p), 'csend').map(d => d.id))
|
||||||
const meta = describeBundle(b)
|
const meta = describeBundle(b)
|
||||||
expect(meta.transistors).toBe(nandCounts(p.components).get('csend')! * 4)
|
expect(meta.transistors).toBe(nandCounts(p.components).get('csend')! * 4)
|
||||||
expect(meta).toMatchObject({ name: 'Sender', inputs: ['A', 'B'], outputs: [], uses: 1, connectors: 1 })
|
expect(meta).toMatchObject({ name: 'Sender', inputs: 2, outputs: 0, inNames: ['A', 'B'], outNames: [], uses: 1, connectors: 1 })
|
||||||
expect(meta.kinds).toEqual(['input', 'nand', 'output', 'portout'])
|
})
|
||||||
|
|
||||||
|
it('keeps the listing small whatever is sent', () => {
|
||||||
|
const p = createProject({ examples: true })
|
||||||
|
const b = JSON.parse(JSON.stringify(libraryBundle(p, 'ex-not')))
|
||||||
|
const root = b.components.find((d: ComponentDef) => d.id === 'ex-not')
|
||||||
|
root.group = 'g'.repeat(50_000)
|
||||||
|
root.description = 'd'.repeat(50_000)
|
||||||
|
root.nodes.find((n: { kind: string }) => n.kind === 'input').label = 'x'.repeat(500_000)
|
||||||
|
for (let i = 0; i < 200; i++) root.nodes.push({ id: `o${i}`, kind: 'output', x: 30, y: i, label: 'y'.repeat(1000) })
|
||||||
|
const clean = cleanBundle(b)
|
||||||
|
expect(clean.components.find(d => d.id === 'ex-not')!.group).toHaveLength(LIBRARY_LIMITS.group)
|
||||||
|
const meta = describeBundle(clean)
|
||||||
|
expect(meta).toMatchObject({ inputs: 1, outputs: 201 })
|
||||||
|
expect(meta.outNames).toHaveLength(LIBRARY_LIMITS.pinNames)
|
||||||
|
expect(meta.inNames[0]).toHaveLength(LIBRARY_LIMITS.pinName)
|
||||||
|
expect(JSON.stringify(meta).length).toBeLessThan(2000)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('drops corner points a wire could not be drawn with', () => {
|
||||||
|
const p = createProject({ examples: true })
|
||||||
|
const b = JSON.parse(JSON.stringify(libraryBundle(p, 'ex-ha')))
|
||||||
|
const ha = b.components.find((d: ComponentDef) => d.id === 'ex-ha')
|
||||||
|
const bent = ha.wires.filter((x: Wire) => x.pts)
|
||||||
|
expect(bent.length).toBeGreaterThan(1)
|
||||||
|
bent[0].pts = [null]
|
||||||
|
bent[1].pts = [[1, 'x']]
|
||||||
|
const clean = cleanBundle(b).components.find(d => d.id === 'ex-ha')!
|
||||||
|
expect(clean.wires.find(x => x.id === bent[0].id)!.pts).toBeUndefined()
|
||||||
|
expect(clean.wires.find(x => x.id === bent[1].id)!.pts).toBeUndefined()
|
||||||
|
// Corners that are fine stay, as in projects loaded from a file or link.
|
||||||
|
expect(clean.wires.filter(x => x.pts)).toHaveLength(bent.length - 2)
|
||||||
|
expect(toProject(JSON.parse(JSON.stringify(p))).components.find(d => d.id === 'ex-ha')!.wires).toEqual(p.components.find(d => d.id === 'ex-ha')!.wires)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('refuses missing parts, parts that contain themselves and broken nodes', () => {
|
it('refuses missing parts, parts that contain themselves and broken nodes', () => {
|
||||||
|
|
@ -163,12 +205,20 @@ describe('library: adding an entry to a project', () => {
|
||||||
expect(duplicateComponent(bob, res.root)!.from).toBeUndefined()
|
expect(duplicateComponent(bob, res.root)!.from).toBeUndefined()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('keeps the marks of library components used inside, so their authors stay named', () => {
|
it('marks what comes in only by the entry it came with, never by marks the publisher sent', () => {
|
||||||
const ada = createProject({ examples: true })
|
const ada = createProject({ examples: true })
|
||||||
ada.components.find(d => d.id === 'ex-xor')!.from = { id: 'Xor00001', version: 3, author: 'Cy' }
|
ada.components.find(d => d.id === 'ex-xor')!.from = { id: 'Xor00001', version: 3, author: 'Cy' }
|
||||||
|
expect(libraryBundle(ada, 'ex-ha').components.some(d => d.from)).toBe(false)
|
||||||
|
// Eve sends a part claiming to be Cy's entry; the server drops the claim.
|
||||||
|
const forged = JSON.parse(JSON.stringify(libraryBundle(ada, 'ex-ha')))
|
||||||
|
forged.components[0].from = { id: 'Xor00001', version: 3, author: 'Cy' }
|
||||||
|
const b = cleanBundle(forged)
|
||||||
|
expect(b.components.some(d => d.from)).toBe(false)
|
||||||
|
// And adding never keeps a mark that came with the bundle.
|
||||||
|
forged.components[0].from = { id: 'Xor00001', version: 3, author: 'Cy' }
|
||||||
const bob = createProject({ examples: false })
|
const bob = createProject({ examples: false })
|
||||||
importBundle(bob, published(ada, 'ex-ha'), origin)
|
importBundle(bob, forged, origin)
|
||||||
expect(bob.components.find(d => d.name === 'XOR')!.from).toEqual({ id: 'Xor00001', version: 3, author: 'Cy' })
|
for (const d of bob.components.filter(d => d.from)) expect(d.from!.id).toBe(origin.id)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('uses what is here in the same form, and adds nothing for the same entry twice', () => {
|
it('uses what is here in the same form, and adds nothing for the same entry twice', () => {
|
||||||
|
|
@ -240,6 +290,54 @@ describe('library: adding an entry to a project', () => {
|
||||||
expect(main.nodes.find(n => n.id === 'u')!.chip).toBe(v1.root)
|
expect(main.nodes.find(n => n.id === 'u')!.chip).toBe(v1.root)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('clears away what came along with the old version, and the new parts take its names', () => {
|
||||||
|
const ada = createProject({ examples: true })
|
||||||
|
const bob = createProject({ examples: false })
|
||||||
|
const v1 = importBundle(bob, published(ada, 'ex-ha'), origin)
|
||||||
|
const oldXor = bob.components.find(d => d.name === 'XOR')!
|
||||||
|
// Version 2: Ada drew her XOR differently.
|
||||||
|
ada.components.find(d => d.id === 'ex-xor')!.nodes[0]!.y += 1
|
||||||
|
importBundle(bob, published(ada, 'ex-ha'), { ...origin, version: 2 }, v1.root)
|
||||||
|
expect(bob.components.map(d => d.name).sort()).toEqual(['AND', 'Half Adder', 'Main', 'NOT', 'XOR'])
|
||||||
|
expect(bob.components.some(d => d.id === oldXor.id)).toBe(false)
|
||||||
|
expect(rows(bob, v1.root)).toEqual(rows(ada, 'ex-ha'))
|
||||||
|
// Updated again: still no "XOR 2".
|
||||||
|
ada.components.find(d => d.id === 'ex-xor')!.nodes[0]!.y += 1
|
||||||
|
importBundle(bob, published(ada, 'ex-ha'), { ...origin, version: 3 }, v1.root)
|
||||||
|
expect(bob.components.map(d => d.name).sort()).toEqual(['AND', 'Half Adder', 'Main', 'NOT', 'XOR'])
|
||||||
|
})
|
||||||
|
|
||||||
|
it('keeps an old part that is used elsewhere', () => {
|
||||||
|
const ada = createProject({ examples: true })
|
||||||
|
const bob = createProject({ examples: false })
|
||||||
|
const v1 = importBundle(bob, published(ada, 'ex-ha'), origin)
|
||||||
|
const oldXor = bob.components.find(d => d.name === 'XOR')!
|
||||||
|
bob.components.find(d => d.id === 'main')!.nodes.push({ id: 'x', kind: 'chip', chip: oldXor.id, x: 20, y: 0 })
|
||||||
|
ada.components.find(d => d.id === 'ex-xor')!.nodes[0]!.y += 1
|
||||||
|
importBundle(bob, published(ada, 'ex-ha'), { ...origin, version: 2 }, v1.root)
|
||||||
|
expect(bob.components.find(d => d.id === oldXor.id)!.name).toBe('XOR')
|
||||||
|
expect(bob.components.some(d => d.name === 'XOR 2')).toBe(true)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('never reuses another entry’s component, so updating one entry leaves the others as they were', () => {
|
||||||
|
const ada = createProject({ examples: true })
|
||||||
|
const bob = createProject({ examples: false })
|
||||||
|
// Bob has Ada's XOR entry; Carl's half adder holds an XOR exactly like it.
|
||||||
|
const xor = importBundle(bob, published(ada, 'ex-xor'), origin)
|
||||||
|
const carl = importBundle(bob, published(ada, 'ex-ha'), { id: 'Carl0001', version: 1, author: 'Carl' })
|
||||||
|
const carlsXor = closure(lookup(bob), carl.root).find(d => d.name.startsWith('XOR'))!
|
||||||
|
expect(carlsXor.id).not.toBe(xor.root)
|
||||||
|
expect(carlsXor.from).toEqual({ id: 'Carl0001', version: 1, author: 'Carl', inside: true })
|
||||||
|
// Ada's XOR, version 2, is an OR now: Carl's half adder still adds.
|
||||||
|
const v2 = createProject({ examples: true })
|
||||||
|
const x = v2.components.find(d => d.id === 'ex-xor')!
|
||||||
|
const or = v2.components.find(d => d.id === 'ex-or')!
|
||||||
|
Object.assign(x, { nodes: structuredClone(or.nodes), wires: structuredClone(or.wires) })
|
||||||
|
importBundle(bob, published(v2, 'ex-xor'), { ...origin, version: 2 }, xor.root)
|
||||||
|
expect(rows(bob, xor.root)).toEqual(rows(ada, 'ex-or'))
|
||||||
|
expect(rows(bob, carl.root)).toEqual(rows(ada, 'ex-ha'))
|
||||||
|
})
|
||||||
|
|
||||||
it('never reuses the component being updated inside its own new version', () => {
|
it('never reuses the component being updated inside its own new version', () => {
|
||||||
const bob = createProject({ examples: false })
|
const bob = createProject({ examples: false })
|
||||||
const ada = createProject({ examples: true })
|
const ada = createProject({ examples: true })
|
||||||
|
|
@ -254,16 +352,13 @@ describe('library: adding an entry to a project', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('library: campaign and old projects', () => {
|
describe('library: campaign and old projects', () => {
|
||||||
it('names the parts a campaign has not earned yet', () => {
|
it('adds nothing to a campaign, however far it is', () => {
|
||||||
const p = createProject({ examples: false, campaign: true })
|
const campaign = createProject({ examples: false, campaign: true })
|
||||||
const b = published(createProject({ examples: true }), 'ex-cnt4')
|
expect(importProblem(campaign)).toMatch(/campaign/)
|
||||||
// The counter's display and the constant 1 in its incrementer.
|
campaign.solved.push(...CHALLENGES.map(c => c.id))
|
||||||
expect(lockedKinds(p, kindsIn(b.components))).toEqual(['hex', 'high'])
|
expect(importProblem(campaign)).toMatch(/campaign/)
|
||||||
p.solved.push('not')
|
expect(importProblem(createProject({ examples: true }))).toBeNull()
|
||||||
expect(lockedKinds(p, kindsIn(b.components))).toEqual(['hex'])
|
expect(importProblem({ ...createProject({ examples: false }), mode: 'challenges' })).toBeNull()
|
||||||
p.solved.push('dec2')
|
|
||||||
expect(lockedKinds(p, kindsIn(b.components))).toEqual([])
|
|
||||||
expect(lockedKinds(createProject({ examples: false }), ['clock', 'portin'])).toEqual([])
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('loads projects without library marks as before, and drops broken marks', () => {
|
it('loads projects without library marks as before, and drops broken marks', () => {
|
||||||
|
|
@ -296,6 +391,25 @@ describe('library keys in the browser', () => {
|
||||||
map.set('logigate:library-keys', 'not json')
|
map.set('logigate:library-keys', 'not json')
|
||||||
expect(libraryKeys()).toEqual({})
|
expect(libraryKeys()).toEqual({})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('owns an entry only where it was published from, whatever a component’s mark says', () => {
|
||||||
|
const keys = { Lib12345: { key: 'secret', project: 'p1', def: 'c1' } }
|
||||||
|
expect(ownedEntry(keys, 'p1', 'c1')).toBe('Lib12345')
|
||||||
|
// The same component in another project, or another component here, is not it.
|
||||||
|
expect(ownedEntry(keys, 'p2', 'c1')).toBeUndefined()
|
||||||
|
expect(ownedEntry(keys, 'p1', 'c2')).toBeUndefined()
|
||||||
|
// A part that came in claiming to be Ada's entry stays someone else's: adding
|
||||||
|
// Eve's entry marks it as Eve's, and only the key record counts anyway.
|
||||||
|
const ada = createProject({ examples: true })
|
||||||
|
const forged = JSON.parse(JSON.stringify(libraryBundle(ada, 'ex-and')))
|
||||||
|
forged.components[0].from = { id: 'Lib12345', version: 1, author: 'Ada' }
|
||||||
|
const p = createProject({ examples: false })
|
||||||
|
const res = importBundle(p, cleanBundle(forged), { id: 'Eve00001', version: 1, author: 'Eve' })
|
||||||
|
for (const d of closure(lookup(p), res.root)) {
|
||||||
|
expect(d.from!.id).toBe('Eve00001')
|
||||||
|
expect(ownedEntry(keys, 'p1', d.id)).toBeUndefined()
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('library listing', () => {
|
describe('library listing', () => {
|
||||||
|
|
@ -308,11 +422,12 @@ describe('library listing', () => {
|
||||||
created: 0,
|
created: 0,
|
||||||
updated,
|
updated,
|
||||||
transistors: 8,
|
transistors: 8,
|
||||||
inputs: ['A'],
|
inputs: 1,
|
||||||
outputs: ['Q'],
|
outputs: 1,
|
||||||
|
inNames: ['A'],
|
||||||
|
outNames: ['Q'],
|
||||||
uses: 0,
|
uses: 0,
|
||||||
connectors: 0,
|
connectors: 0,
|
||||||
kinds: ['nand'],
|
|
||||||
player,
|
player,
|
||||||
})
|
})
|
||||||
const names = { 'player-ada-0001': 'Ada' }
|
const names = { 'player-ada-0001': 'Ada' }
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue