@biolibs/bionet-panels 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/README.md +46 -0
  2. package/dist/backup.d.ts +10 -0
  3. package/dist/backup.d.ts.map +1 -0
  4. package/dist/backup.js +50 -0
  5. package/dist/backup.js.map +1 -0
  6. package/dist/freezer.d.ts.map +1 -1
  7. package/dist/freezer.js +4 -2
  8. package/dist/freezer.js.map +1 -1
  9. package/dist/history.d.ts +1 -1
  10. package/dist/history.d.ts.map +1 -1
  11. package/dist/history.js +12 -0
  12. package/dist/history.js.map +1 -1
  13. package/dist/index.d.ts +7 -0
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +7 -0
  16. package/dist/index.js.map +1 -1
  17. package/dist/parts.d.ts.map +1 -1
  18. package/dist/parts.js +1 -0
  19. package/dist/parts.js.map +1 -1
  20. package/dist/people.d.ts.map +1 -1
  21. package/dist/people.js +3 -1
  22. package/dist/people.js.map +1 -1
  23. package/dist/places.d.ts +41 -0
  24. package/dist/places.d.ts.map +1 -0
  25. package/dist/places.js +96 -0
  26. package/dist/places.js.map +1 -0
  27. package/dist/public.d.ts +77 -0
  28. package/dist/public.d.ts.map +1 -0
  29. package/dist/public.js +73 -0
  30. package/dist/public.js.map +1 -0
  31. package/dist/sharing.d.ts.map +1 -1
  32. package/dist/sharing.js +1 -0
  33. package/dist/sharing.js.map +1 -1
  34. package/dist/window.d.ts +29 -6
  35. package/dist/window.d.ts.map +1 -1
  36. package/dist/window.js +19 -10
  37. package/dist/window.js.map +1 -1
  38. package/package.json +6 -4
  39. package/panels.css +13 -0
  40. package/src/backup.tsx +72 -0
  41. package/src/freezer.tsx +5 -1
  42. package/src/history.tsx +14 -1
  43. package/src/index.ts +7 -0
  44. package/src/parts.tsx +2 -0
  45. package/src/people.tsx +4 -0
  46. package/src/places.tsx +170 -0
  47. package/src/public.tsx +175 -0
  48. package/src/sharing.tsx +2 -0
  49. package/src/window.tsx +34 -10
@@ -0,0 +1,77 @@
1
+ /**
2
+ * What a lab shows the world, and what it can see of another lab.
3
+ *
4
+ * These are for a lab's public page. They take what was fetched and checked as plain values and
5
+ * draw it; none of them fetches, signs or holds state, so they can be drawn on a server.
6
+ *
7
+ * They also carry the wording. What a signature settles, and what it does not, has to be said the
8
+ * same way on every lab's page — a page that words it itself will sooner or later claim more than
9
+ * the checks support.
10
+ */
11
+ import type { ReactNode } from "react";
12
+ import { type FetchedInventory, type InventoryPart } from "@biolibs/bionet";
13
+ import type { SignatureCheck } from "@biolibs/opencloning";
14
+ /**
15
+ * The parts in one list whose checksums are not in another.
16
+ *
17
+ * @param mine - What this lab holds.
18
+ * @param theirs - What the other lab holds.
19
+ * @returns What they have that this lab does not. Names play no part: a part is its checksum.
20
+ */
21
+ export declare function onlyTheirs(mine: readonly InventoryPart[], theirs: readonly InventoryPart[]): InventoryPart[];
22
+ /**
23
+ * The parts two lists both hold, by checksum.
24
+ *
25
+ * @param mine - What this lab holds.
26
+ * @param theirs - What the other lab holds.
27
+ * @returns This lab's entries for the parts both have.
28
+ */
29
+ export declare function heldByBoth(mine: readonly InventoryPart[], theirs: readonly InventoryPart[]): InventoryPart[];
30
+ /**
31
+ * The frame of a lab's public page: the mark, the lab's name, and a line about what it is.
32
+ *
33
+ * @param props - `name` and `note` are the lab's; `children` is the rest of the page.
34
+ */
35
+ export declare function LabPage({ name, note, children }: {
36
+ name: string;
37
+ note?: string | null;
38
+ children: ReactNode;
39
+ }): import("react").JSX.Element;
40
+ /** A table of parts: name, length, and whether each is on offer. `checksums` adds that column. */
41
+ export declare function PartsTable({ parts, checksums }: {
42
+ parts: readonly InventoryPart[];
43
+ checksums?: boolean;
44
+ }): import("react").JSX.Element;
45
+ /**
46
+ * What this lab holds, and what the signature over that list settles.
47
+ *
48
+ * @param props - `parts` is the published list; `checks` is one check per signature over it;
49
+ * `origin` is the address this page is served from; `bound` is whether the list names that address.
50
+ */
51
+ export declare function Held({ parts, checks, origin, bound }: {
52
+ parts: readonly InventoryPart[];
53
+ checks: readonly SignatureCheck[];
54
+ origin: string;
55
+ bound: boolean;
56
+ }): import("react").JSX.Element;
57
+ /** The caveat every reader is owed, in the same words everywhere. */
58
+ export declare function WhatASignatureSettles(): import("react").JSX.Element;
59
+ /**
60
+ * Another lab that answered, beside what this lab holds.
61
+ *
62
+ * @param props - `found` is what was fetched from the other lab and checked; `mine` is this lab's list.
63
+ */
64
+ export declare function PeerAnswered({ found, mine }: {
65
+ found: FetchedInventory;
66
+ mine: readonly InventoryPart[];
67
+ }): import("react").JSX.Element;
68
+ /**
69
+ * Another lab that did not answer.
70
+ *
71
+ * @param props - `address` is where it was asked for; `why` is what went wrong.
72
+ */
73
+ export declare function PeerSilent({ address, why }: {
74
+ address: string;
75
+ why: string;
76
+ }): import("react").JSX.Element;
77
+ //# sourceMappingURL=public.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../src/public.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAW,KAAK,gBAAgB,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAG3D;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,SAAS,aAAa,EAAE,EAAE,MAAM,EAAE,SAAS,aAAa,EAAE,GAAG,aAAa,EAAE,CAG5G;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,SAAS,aAAa,EAAE,EAAE,MAAM,EAAE,SAAS,aAAa,EAAE,GAAG,aAAa,EAAE,CAG5G;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,QAAQ,EAAE,SAAS,CAAA;CAAE,+BAmB5G;AAED,kGAAkG;AAClG,wBAAgB,UAAU,CAAC,EAAE,KAAK,EAAE,SAAiB,EAAE,EAAE;IAAE,KAAK,EAAE,SAAS,aAAa,EAAE,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,+BAgBhH;AAED;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE;IACrD,KAAK,EAAE,SAAS,aAAa,EAAE,CAAC;IAAC,MAAM,EAAE,SAAS,cAAc,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAC;CACpG,+BAiBA;AAED,qEAAqE;AACrE,wBAAgB,qBAAqB,gCAQpC;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;IAAE,KAAK,EAAE,gBAAgB,CAAC;IAAC,IAAI,EAAE,SAAS,aAAa,EAAE,CAAA;CAAE,+BA6BxG;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,+BAW5E"}
package/dist/public.js ADDED
@@ -0,0 +1,73 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { settled } from "@biolibs/bionet";
3
+ import { Mark } from "@biolibs/bionet-react";
4
+ /**
5
+ * The parts in one list whose checksums are not in another.
6
+ *
7
+ * @param mine - What this lab holds.
8
+ * @param theirs - What the other lab holds.
9
+ * @returns What they have that this lab does not. Names play no part: a part is its checksum.
10
+ */
11
+ export function onlyTheirs(mine, theirs) {
12
+ const have = new Set(mine.map((part) => part.checksum));
13
+ return theirs.filter((part) => !have.has(part.checksum));
14
+ }
15
+ /**
16
+ * The parts two lists both hold, by checksum.
17
+ *
18
+ * @param mine - What this lab holds.
19
+ * @param theirs - What the other lab holds.
20
+ * @returns This lab's entries for the parts both have.
21
+ */
22
+ export function heldByBoth(mine, theirs) {
23
+ const have = new Set(theirs.map((part) => part.checksum));
24
+ return mine.filter((part) => have.has(part.checksum));
25
+ }
26
+ /**
27
+ * The frame of a lab's public page: the mark, the lab's name, and a line about what it is.
28
+ *
29
+ * @param props - `name` and `note` are the lab's; `children` is the rest of the page.
30
+ */
31
+ export function LabPage({ name, note, children }) {
32
+ return (_jsx("div", { className: "bionet", children: _jsxs("main", { className: "page", children: [_jsxs("div", { className: "title", children: [_jsx(Mark, { size: 40 }), _jsx("h1", { children: name })] }), note !== null && note !== undefined && _jsx("p", { className: "dim", children: note }), _jsxs("p", { className: "small dim", children: ["This lab publishes what it holds at", " ", _jsx("a", { href: "/.well-known/bionet.json", children: _jsx("code", { children: "/.well-known/bionet.json" }) }), ", signed, so that a cloning plan can be acted on and not just read. Parts are named by checksum, because a name agrees with nothing."] }), children] }) }));
33
+ }
34
+ /** A table of parts: name, length, and whether each is on offer. `checksums` adds that column. */
35
+ export function PartsTable({ parts, checksums = false }) {
36
+ return (_jsxs("table", { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "Part" }), _jsx("th", { children: "Length" }), checksums && _jsx("th", { children: "Checksum" }), _jsx("th", { children: "On offer" })] }) }), _jsx("tbody", { children: parts.map((part) => (_jsxs("tr", { children: [_jsxs("td", { children: [part.name, part.note !== null && _jsxs(_Fragment, { children: [_jsx("br", {}), _jsx("span", { className: "dim small", children: part.note })] })] }), _jsx("td", { className: "nowrap", children: _jsxs("code", { children: [part.length, " bp", part.circular ? " ○" : ""] }) }), checksums && _jsx("td", { className: "dim", children: _jsxs("code", { children: [part.checksum.slice(0, 22), "\u2026"] }) }), _jsx("td", { className: part.available ? "good" : "bad", children: part.available ? "yes" : "no" })] }, part.checksum))) })] }));
37
+ }
38
+ /**
39
+ * What this lab holds, and what the signature over that list settles.
40
+ *
41
+ * @param props - `parts` is the published list; `checks` is one check per signature over it;
42
+ * `origin` is the address this page is served from; `bound` is whether the list names that address.
43
+ */
44
+ export function Held({ parts, checks, origin, bound }) {
45
+ const holds = checks.length > 0 && checks.every((check) => check.ok);
46
+ return (_jsxs("section", { children: [_jsx("h2", { children: "What we hold" }), parts.length === 0 ? _jsx("p", { className: "dim", children: "Nothing is listed at the moment." }) : _jsx(PartsTable, { parts: parts, checksums: true }), _jsxs("p", { className: "small dim", children: [checks.length === 0 ? "This list is not signed, so it claims nothing about who published it." : (_jsxs(_Fragment, { children: ["Signed by ", checks.map((check) => _jsxs("code", { children: [check.fingerprint, " "] }, check.public_key)), holds ? "— the signature holds over this list as served." : "— the signature does not hold."] })), " ", "Bound to ", _jsx("code", { children: origin }), ": ", bound ? "yes" : "no", "."] })] }));
47
+ }
48
+ /** The caveat every reader is owed, in the same words everywhere. */
49
+ export function WhatASignatureSettles() {
50
+ return (_jsx("p", { className: "small dim", children: "None of that says this lab is who it says it is. The address does that work, and only as far as whoever typed it already trusted it. What a signature settles is that this list has not changed since it was published, and that it was published by whoever holds that key." }));
51
+ }
52
+ /**
53
+ * Another lab that answered, beside what this lab holds.
54
+ *
55
+ * @param props - `found` is what was fetched from the other lab and checked; `mine` is this lab's list.
56
+ */
57
+ export function PeerAnswered({ found, mine }) {
58
+ const theirs = found.signed.inventory.parts;
59
+ const only = onlyTheirs(mine, theirs);
60
+ const both = heldByBoth(mine, theirs);
61
+ return (_jsxs(_Fragment, { children: [_jsxs("p", { children: [_jsx("strong", { children: found.signed.inventory.lab.name }), " answered at ", _jsx("code", { children: found.origin }), " with", " ", theirs.length, " ", theirs.length === 1 ? "part" : "parts", ".", " ", settled(found)
62
+ ? _jsx("span", { className: "good", children: "Its signature holds and it was served from the address it names." })
63
+ : _jsx("span", { className: "bad", children: "Its signature or its address does not check out, so nothing below is settled." })] }), _jsx(WhatASignatureSettles, {}), _jsx("h3", { children: "What they have that we do not" }), only.length === 0 ? _jsx("p", { className: "small", children: "Nothing. Everything they list, we hold too." }) : _jsx(PartsTable, { parts: only }), _jsx("h3", { children: "What we both have" }), both.length === 0 ? _jsx("p", { className: "small", children: "Nothing in common, by checksum." }) : (_jsxs("p", { className: "small", children: [both.map((part) => _jsxs("code", { children: [part.name, " "] }, part.checksum)), "\u2014 matched by checksum, so it does not matter what either of us calls them."] })), _jsx("p", { className: "small dim", children: "Fetched from that lab when this page was drawn, not copied. Nothing here fetches a part: finding out who has a plasmid is as far as software goes, and the rest is an email and a padded envelope." })] }));
64
+ }
65
+ /**
66
+ * Another lab that did not answer.
67
+ *
68
+ * @param props - `address` is where it was asked for; `why` is what went wrong.
69
+ */
70
+ export function PeerSilent({ address, why }) {
71
+ return (_jsxs(_Fragment, { children: [_jsxs("p", { children: ["We point at ", _jsx("code", { children: address }), " and it did not answer."] }), _jsxs("p", { className: "small dim", children: ["The reason given was: ", why, ". A lab that cannot be reached is not a lab that is lying \u2014 it may be down, or moved, or never have existed. All this page can honestly say is that the address did not answer when it was asked."] })] }));
72
+ }
73
+ //# sourceMappingURL=public.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public.js","sourceRoot":"","sources":["../src/public.tsx"],"names":[],"mappings":";AAWA,OAAO,EAAE,OAAO,EAA6C,MAAM,iBAAiB,CAAC;AAErF,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAE7C;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,IAA8B,EAAE,MAAgC;IACzF,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IACxD,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,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C,CAAC,KAAC,UAAU,IAAC,KAAK,EAAE,IAAI,GAAI,EACvH,6CAA0B,EACzB,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,YAAG,SAAS,EAAC,OAAO,gDAAoC,CAAC,CAAC,CAAC,CAC9E,aAAG,SAAS,EAAC,OAAO,aACjB,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,2BAA2B,IAAI,CAAC,IAAI,UAAzB,IAAI,CAAC,QAAQ,CAAqB,CAAC,uFAEhE,CACL,EACD,YAAG,SAAS,EAAC,WAAW,mNAGpB,IACH,CACJ,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,EAAE,OAAO,EAAE,GAAG,EAAoC;IAC3E,OAAO,CACL,8BACE,wCAAe,yBAAO,OAAO,GAAQ,+BAA2B,EAChE,aAAG,SAAS,EAAC,WAAW,uCACC,GAAG,8MAGxB,IACH,CACJ,CAAC;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sharing.d.ts","sourceRoot":"","sources":["../src/sharing.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5D;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE,EAAE,KAAK,EAAE,SAAS,SAAS,EAAE,GAAG,SAAS,EAAE,CAGjG;AAED,yHAAyH;AACzH,wBAAgB,OAAO,uCAiDtB"}
1
+ {"version":3,"file":"sharing.d.ts","sourceRoot":"","sources":["../src/sharing.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5D;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE,EAAE,KAAK,EAAE,SAAS,SAAS,EAAE,GAAG,SAAS,EAAE,CAGjG;AAED,yHAAyH;AACzH,wBAAgB,OAAO,uCAiDtB"}
package/dist/sharing.js CHANGED
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
3
  /** Sharing: what other labs are shown, and the lab's web peer. */
3
4
  import { useState } from "react";
@@ -1 +1 @@
1
- {"version":3,"file":"sharing.js","sourceRoot":"","sources":["../src/sharing.tsx"],"names":[],"mappings":";AAAA,kEAAkE;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,KAA2B,EAAE,KAA2B;IAClF,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3G,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC5D,CAAC;AAED,yHAAyH;AACzH,MAAM,UAAU,OAAO;IACrB,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC;IACvB,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC;IACrB,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAAC,CAAC;IACtD,MAAM,GAAG,GAAG,KAAK,EAAE,GAAG,CAAC;IACvB,IAAI,KAAK,KAAK,IAAI,IAAI,GAAG,K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GAAG,IAAI,EAAE,EAAE,UAAU,EAAE,KAAK,GAAI,EACtH,iBAAQ,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,OAAO,8BAAuB,IAC1D,EACL,KAAK,CAAC,IAAI,CAAC,OAAO,KAAK,IAAI,IAAI,YAAG,SAAS,EAAC,MAAM,YAAE,KAAK,CAAC,IAAI,CAAC,OAAO,GAAK,EAC5E,eAAK,SAAS,EAAC,QAAQ,aACrB,0BAAK,eAAM,SAAS,EAAC,OAAO,8BAAqB,EAAC,GAAG,CAAC,EAAE,KAAK,IAAI,IAAI,KAAC,IAAI,IAAC,KAAK,EAAE,GAAG,CAAC,EAAE,EAAE,KAAK,EAAC,SAAS,GAAG,IAAO,EACnH,eAAM,SAAS,EAAC,MAAM,YAAE,GAAG,CAAC,EAAE,GAAQ,EACtC,aAAG,SAAS,EAAC,WAAW,0DAA0C,wCAAuB,kDAA8C,IACnI,IACE,IACT,CACJ,CAAC;AACJ,CAAC"}
package/dist/window.d.ts CHANGED
@@ -1,16 +1,39 @@
1
- /** The four things a member looks at. */
2
- export declare const TABS: readonly ["freezer", "people", "history", "sharing"];
1
+ /**
2
+ * A whole lab application, in one component.
3
+ *
4
+ * It holds no state of its own about the lab. It is told the lab as it stands, every time it
5
+ * changes, and draws it; a button asks for one thing to be done and waits to be told how the lab
6
+ * changed. So what is on screen is always what the signed logs say, and never what a form hoped.
7
+ *
8
+ * It walks a person through the three places they can be: nobody has said who is at this device,
9
+ * the device is in no lab, the device is waiting to be let into one — and then the lab itself.
10
+ */
11
+ import { type ReactNode } from "react";
12
+ /** The things a member looks at. */
13
+ export declare const TABS: readonly ["freezer", "places", "people", "history", "sharing"];
3
14
  /** One of them. */
4
15
  export type Tab = (typeof TABS)[number];
16
+ /** A view a host adds to the window beside its own, such as a drawing of the lab. */
17
+ export interface ExtraTab {
18
+ /** What tells it apart. */
19
+ id: string;
20
+ /** What its tab says. */
21
+ label: string;
22
+ /** What it shows. It is inside the lab's provider, so it may use the hooks. */
23
+ view: ReactNode;
24
+ }
5
25
  /**
6
26
  * The window.
7
27
  *
8
- * @param props - `tab` is which view to open on; `copy` puts words on the clipboard, for a host that
9
- * cannot use the browser's own way.
28
+ * @param props - `tab` is which view to open on; `copy` puts words on the clipboard and `save` hands
29
+ * over a file, for a host that cannot use the browser's own way; `extra` are views the host adds,
30
+ * shown after the window's own.
10
31
  */
11
- export declare function LabWindow({ tab: first, copy }: {
12
- tab?: Tab;
32
+ export declare function LabWindow({ tab: first, copy, save, extra }: {
33
+ tab?: Tab | string;
13
34
  copy?: (words: string) => Promise<void>;
35
+ save?: (name: string, text: string) => Promise<void>;
36
+ extra?: readonly ExtraTab[];
14
37
  }): import("react").JSX.Element;
15
38
  /** Asking who is at this device, before anything else. */
16
39
  export declare function Who(): import("react").JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"window.d.ts","sourceRoot":"","sources":["../src/window.tsx"],"names":[],"mappings":"AAkBA,yCAAyC;AACzC,eAAO,MAAM,IAAI,sDAAuD,CAAC;AAEzE,mBAAmB;AACnB,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;AAExC;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,EAAE,GAAG,EAAE,KAAiB,EAAE,IAAI,EAAE,EAAE;IAAE,GAAG,CAAC,EAAE,GAAG,CAAC;IAAC,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,+BAGjH;AA2CD,0DAA0D;AAC1D,wBAAgB,GAAG,gCAYlB;AAED,sCAAsC;AACtC,wBAAgB,KAAK,uCA0BpB;AAED,+CAA+C;AAC/C,wBAAgB,OAAO,uCAYtB"}
1
+ {"version":3,"file":"window.d.ts","sourceRoot":"","sources":["../src/window.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAUjD,oCAAoC;AACpC,eAAO,MAAM,IAAI,gEAAiE,CAAC;AAEnF,mBAAmB;AACnB,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;AAExC,qFAAqF;AACrF,MAAM,WAAW,QAAQ;IACvB,2BAA2B;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,yBAAyB;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,+EAA+E;IAC/E,IAAI,EAAE,SAAS,CAAC;CACjB;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,EAAE,GAAG,EAAE,KAAiB,EAAE,IAAI,EAAE,IAAI,EAAE,KAAU,EAAE,EAAE;IAC5E,GAAG,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAAC,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAAC,KAAK,CAAC,EAAE,SAAS,QAAQ,EAAE,CAAC;CAChJ,+BAKA;AA+CD,0DAA0D;AAC1D,wBAAgB,GAAG,gCAYlB;AAED,sCAAsC;AACtC,wBAAgB,KAAK,uCA2BpB;AAED,+CAA+C;AAC/C,wBAAgB,OAAO,uCAYtB"}
package/dist/window.js CHANGED
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
3
  /**
3
4
  * A whole lab application, in one component.
@@ -14,21 +15,28 @@ import { Logo, Mark, useAct, useLab } from "@biolibs/bionet-react";
14
15
  import { Freezer } from "./freezer.js";
15
16
  import { History } from "./history.js";
16
17
  import { Ask, CopyContext, DeviceKey, SyncStatus, Trouble } from "./parts.js";
18
+ import { RestoreKey, SaveContext } from "./backup.js";
17
19
  import { People } from "./people.js";
20
+ import { Places } from "./places.js";
18
21
  import { Sharing } from "./sharing.js";
19
- /** The four things a member looks at. */
20
- export const TABS = ["freezer", "people", "history", "sharing"];
22
+ /** The things a member looks at. */
23
+ export const TABS = ["freezer", "places", "people", "history", "sharing"];
21
24
  /**
22
25
  * The window.
23
26
  *
24
- * @param props - `tab` is which view to open on; `copy` puts words on the clipboard, for a host that
25
- * cannot use the browser's own way.
27
+ * @param props - `tab` is which view to open on; `copy` puts words on the clipboard and `save` hands
28
+ * over a file, for a host that cannot use the browser's own way; `extra` are views the host adds,
29
+ * shown after the window's own.
26
30
  */
27
- export function LabWindow({ tab: first = "freezer", copy }) {
28
- const window = _jsx(Body, { first: first });
29
- return _jsx("div", { className: "bionet", children: copy === undefined ? window : _jsx(CopyContext.Provider, { value: copy, children: window }) });
31
+ export function LabWindow({ tab: first = "freezer", copy, save, extra = [] }) {
32
+ let window = _jsx(Body, { first: first, extra: extra });
33
+ if (save !== undefined)
34
+ window = _jsx(SaveContext.Provider, { value: save, children: window });
35
+ if (copy !== undefined)
36
+ window = _jsx(CopyContext.Provider, { value: copy, children: window });
37
+ return _jsx("div", { className: "bionet", children: window });
30
38
  }
31
- function Body({ first }) {
39
+ function Body({ first, extra }) {
32
40
  const state = useLab();
33
41
  const [tab, setTab] = useState(first);
34
42
  if (state === null)
@@ -42,11 +50,12 @@ function Body({ first }) {
42
50
  const lab = state.lab;
43
51
  const label = {
44
52
  freezer: `Freezer · ${lab.items.filter((item) => !item.retired).length}`,
53
+ places: `Places · ${lab.places.filter((place) => !place.retired).length}`,
45
54
  people: `People · ${lab.roster.filter((key) => key.removed === null).length}`,
46
55
  history: `History · ${lab.entries.length}`,
47
56
  sharing: "Sharing",
48
57
  };
49
- return (_jsxs("div", { className: "shell", children: [_jsxs("header", { children: [_jsxs("div", { className: "title", children: [_jsx(Mark, { size: 34 }), _jsxs("div", { children: [_jsx("h1", { children: lab.name ?? "A lab" }), _jsxs("p", { className: "dim small", children: [state.device.person, " \u00B7 ", lab.keeper ? "keeper" : "member", " \u00B7 this device ", _jsx("code", { children: state.device.fingerprint })] })] })] }), _jsx(SyncStatus, { peer: state.peer })] }), _jsx("nav", { children: TABS.map((one) => _jsx("button", { type: "button", className: one === tab ? "tab on" : "tab", onClick: () => setTab(one), children: label[one] }, one)) }), _jsxs("main", { children: [_jsx(Trouble, {}), tab === "freezer" && _jsx(Freezer, {}), tab === "people" && _jsx(People, {}), tab === "history" && _jsx(History, {}), tab === "sharing" && _jsx(Sharing, {})] })] }));
58
+ return (_jsxs("div", { className: "shell", children: [_jsxs("header", { children: [_jsxs("div", { className: "title", children: [_jsx(Mark, { size: 34 }), _jsxs("div", { children: [_jsx("h1", { children: lab.name ?? "A lab" }), _jsxs("p", { className: "dim small", children: [state.device.person, " \u00B7 ", lab.keeper ? "keeper" : "member", " \u00B7 this device ", _jsx("code", { children: state.device.fingerprint })] })] })] }), _jsx(SyncStatus, { peer: state.peer })] }), _jsxs("nav", { children: [TABS.map((one) => _jsx("button", { type: "button", className: one === tab ? "tab on" : "tab", onClick: () => setTab(one), children: label[one] }, one)), extra.map((one) => _jsx("button", { type: "button", className: one.id === tab ? "tab on" : "tab", onClick: () => setTab(one.id), children: one.label }, one.id))] }), _jsxs("main", { children: [_jsx(Trouble, {}), tab === "freezer" && _jsx(Freezer, {}), tab === "places" && _jsx(Places, {}), tab === "people" && _jsx(People, {}), tab === "history" && _jsx(History, {}), tab === "sharing" && _jsx(Sharing, {}), extra.find((one) => one.id === tab)?.view] })] }));
50
59
  }
51
60
  /** Asking who is at this device, before anything else. */
52
61
  export function Who() {
@@ -59,7 +68,7 @@ export function NoLab() {
59
68
  const act = useAct();
60
69
  if (state === null)
61
70
  return null;
62
- return (_jsxs("div", { className: "pair", children: [_jsxs("section", { className: "card", children: [_jsx("h2", { children: "Found a lab" }), _jsx("p", { className: "dim", children: "You become its first keeper. It works on this device straight away, with or without a network." }), _jsxs(Ask, { onAsk: (data) => act("found", { name: String(data.get("name") ?? ""), peer: String(data.get("peer") ?? "") }), className: "stack", children: [_jsxs("label", { children: ["What is it called?", _jsx("input", { name: "name", placeholder: "The Wren Lab", required: true, maxLength: 200 })] }), _jsxs("label", { children: [_jsx("span", { children: "Its web peer, if it has one (optional)" }), _jsx("input", { name: "peer", placeholder: "wss://your-lab.example/sync" })] }), _jsx("button", { type: "submit", children: "Found the lab" })] })] }), _jsxs("section", { className: "card", children: [_jsx("h2", { children: "Join a lab" }), _jsx("p", { className: "dim", children: "Send a keeper this device's key, and paste the invitation they send back. The lab arrives once they have added you." }), _jsx(DeviceKey, { device: state.device }), _jsxs(Ask, { onAsk: (data) => act("join", String(data.get("invite") ?? "")), className: "stack", children: [_jsxs("label", { children: ["Invitation", _jsx("input", { name: "invite", placeholder: "wss://your-lab.example/sync#\u2026", required: true })] }), _jsx("button", { type: "submit", children: "Join" })] })] })] }));
71
+ return (_jsxs("div", { className: "pair", children: [_jsxs("section", { className: "card", children: [_jsx("h2", { children: "Found a lab" }), _jsx("p", { className: "dim", children: "You become its first keeper. It works on this device straight away, with or without a network." }), _jsxs(Ask, { onAsk: (data) => act("found", { name: String(data.get("name") ?? ""), peer: String(data.get("peer") ?? "") }), className: "stack", children: [_jsxs("label", { children: ["What is it called?", _jsx("input", { name: "name", placeholder: "The Wren Lab", required: true, maxLength: 200 })] }), _jsxs("label", { children: [_jsx("span", { children: "Its web peer, if it has one (optional)" }), _jsx("input", { name: "peer", placeholder: "wss://your-lab.example/sync" })] }), _jsx("button", { type: "submit", children: "Found the lab" })] })] }), _jsxs("section", { className: "card", children: [_jsx("h2", { children: "Join a lab" }), _jsx("p", { className: "dim", children: "Send a keeper this device's key, and paste the invitation they send back. The lab arrives once they have added you." }), _jsx(DeviceKey, { device: state.device }), _jsxs(Ask, { onAsk: (data) => act("join", String(data.get("invite") ?? "")), className: "stack", children: [_jsxs("label", { children: ["Invitation", _jsx("input", { name: "invite", placeholder: "wss://your-lab.example/sync#\u2026", required: true })] }), _jsx("button", { type: "submit", children: "Join" })] }), _jsx(RestoreKey, {})] })] }));
63
72
  }
64
73
  /** Waiting for a keeper to add this device. */
65
74
  export function Waiting() {
@@ -1 +1 @@
1
- {"version":3,"file":"window.js","sourceRoot":"","sources":["../src/window.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,yCAAyC;AACzC,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAU,CAAC;AAKzE;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,EAAE,GAAG,EAAE,KAAK,GAAG,SAAS,EAAE,IAAI,EAA0D;IAChH,MAAM,MAAM,GAAG,KAAC,IAAI,IAAC,KAAK,EAAE,KAAK,GAAI,CAAC;IACtC,OAAO,cAAK,SAAS,EAAC,QAAQ,YAAE,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAC,WAAW,CAAC,QAAQ,IAAC,KAAK,EAAE,IAAI,YAAG,MAAM,GAAwB,GAAO,CAAC;AAC1I,CAAC;AAED,SAAS,IAAI,CAAC,EAAE,KAAK,EAAkB;IACrC,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC;IACvB,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAM,KAAK,CAAC,CAA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AAC,OAAO,GAAK,IACzE,CACX,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -3,9 +3,11 @@
3
3
  "url": "https://github.com/matthewlovestocode/biolibs/issues"
4
4
  },
5
5
  "dependencies": {
6
- "@biolibs/bionet": "^1.2.0",
7
- "@biolibs/bionet-client": "^0.1.0",
8
- "@biolibs/bionet-react": "^0.1.0"
6
+ "@biolibs/bionet": "^1.3.0",
7
+ "@biolibs/bionet-client": "^0.2.0",
8
+ "@biolibs/bionet-react": "^0.2.0",
9
+ "@biolibs/bionet-space": "^0.2.0",
10
+ "@biolibs/opencloning": "^2.0.0"
9
11
  },
10
12
  "description": "The parts of a Bionet lab application, ready to place: the freezer, the people, the history, what other labs are shown, and a whole window that puts them together, in a light theme and a dark one",
11
13
  "engines": {
@@ -52,5 +54,5 @@
52
54
  ],
53
55
  "type": "module",
54
56
  "types": "dist/index.d.ts",
55
- "version": "0.1.0"
57
+ "version": "0.3.0"
56
58
  }
package/panels.css CHANGED
@@ -53,3 +53,16 @@
53
53
  .bionet .dot.waiting { background: var(--bionet-held) }
54
54
  .bionet .trouble { background: color-mix(in srgb, var(--bionet-attention) 12%, transparent); border: 1px solid var(--bionet-attention); border-radius: 8px; padding: .55rem .8rem; display: flex; justify-content: space-between; gap: 1rem }
55
55
  .bionet .note { border-left: 3px solid var(--bionet-held); padding: .1rem 0 .1rem .7rem; font-size: .9rem }
56
+ .bionet h3 { font-size: .92rem; margin: 1.2rem 0 .3rem }
57
+ .bionet a { color: inherit; text-decoration-color: var(--bionet-dim); text-underline-offset: 2px }
58
+ .bionet .good { color: var(--bionet-good) } .bionet .bad { color: var(--bionet-attention) }
59
+ .bionet main.page { max-width: 46rem; margin: 0 auto; padding: 3rem 1.25rem 6rem; overflow: visible; font-size: 15px; line-height: 1.65 }
60
+ .bionet main.page .title { margin-bottom: .6rem } .bionet main.page h1 { font-size: 1.6rem }
61
+ .bionet main.page h2 { font-size: 1.1rem; margin: 2.4rem 0 .6rem; padding-bottom: .3rem; border-bottom: 1px solid var(--bionet-rule) }
62
+ /* Places, where a tube is, and restoring a key. */
63
+ .bionet .where { display: grid; gap: .25rem }
64
+ .bionet .where select { max-width: 11rem }
65
+ .bionet .plainlist { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem }
66
+ .bionet details.restore { margin-top: .9rem }
67
+ .bionet details.restore summary { cursor: pointer; color: var(--bionet-dim) }
68
+ .bionet details.restore summary:hover { color: var(--bionet-ink) }
package/src/backup.tsx ADDED
@@ -0,0 +1,72 @@
1
+ "use client";
2
+
3
+ /** Keeping this device's key somewhere else, and taking one up again on a new device. */
4
+ import { createContext, useContext, useState } from "react";
5
+ import { useAct, useLab } from "@biolibs/bionet-react";
6
+ import { Ask } from "./parts.js";
7
+
8
+ /**
9
+ * How to hand the person a file to keep. A host that cannot use the browser's own way supplies one.
10
+ * The default offers it as a download.
11
+ */
12
+ export const SaveContext = createContext<(name: string, text: string) => Promise<void>>(async (name, text) => {
13
+ const link = document.createElement("a");
14
+ link.href = URL.createObjectURL(new Blob([text], { type: "application/json" }));
15
+ link.download = name;
16
+ link.click();
17
+ URL.revokeObjectURL(link.href);
18
+ });
19
+
20
+ /** Seal this device's key under a passphrase and hand it over as a file. */
21
+ export function BackUpKey() {
22
+ const state = useLab();
23
+ const act = useAct();
24
+ const save = useContext(SaveContext);
25
+ const [note, setNote] = useState<string | null>(null);
26
+ if (state === null) return null;
27
+ return (
28
+ <section className="card">
29
+ <h2>Back up this device's key</h2>
30
+ <p className="dim small">
31
+ Everything you sign is signed by a key that exists only on this computer. If the computer is lost, so is the key, and a lab with
32
+ nobody else in it is lost with it. This writes the key to a file, sealed under a passphrase. Keep the file somewhere that is not
33
+ this computer, and the passphrase somewhere that is not the file. Nothing here remembers the passphrase.
34
+ </p>
35
+ <Ask className="stack" onAsk={async (data) => {
36
+ setNote(null);
37
+ const [first, again] = [String(data.get("passphrase") ?? ""), String(data.get("again") ?? "")];
38
+ if (first !== again) { setNote("Those two passphrases are not the same."); return { ok: false }; }
39
+ const answer = await act("backUp", first);
40
+ if (!answer.ok) return answer;
41
+ await save(`bionet-key-${state.device.fingerprint}.json`, String(answer.result));
42
+ setNote("Sealed and handed over. Open it only on a new device, before that device joins a lab.");
43
+ return answer;
44
+ }}>
45
+ <label>Passphrase<input name="passphrase" type="password" required minLength={12} autoComplete="new-password" /></label>
46
+ <label>And again<input name="again" type="password" required minLength={12} autoComplete="new-password" /></label>
47
+ <button type="submit">Seal and save</button>
48
+ </Ask>
49
+ {note !== null && <p className="small" role="status">{note}</p>}
50
+ </section>
51
+ );
52
+ }
53
+
54
+ /** Take up a key from a backup, on a device that is not in a lab yet. */
55
+ export function RestoreKey() {
56
+ const act = useAct();
57
+ return (
58
+ <details className="restore">
59
+ <summary>Replacing a lost device? Restore its key</summary>
60
+ <p className="dim small">Choose the backup file and give its passphrase. This device then signs as the lost one did. Do this before joining, and only if the old device is really gone: one key on two devices writes two histories the lab cannot tell apart.</p>
61
+ <Ask className="stack" onAsk={async (data) => {
62
+ const file = data.get("backup");
63
+ const backup = file instanceof File ? await file.text() : "";
64
+ return act("restore", { backup, passphrase: String(data.get("passphrase") ?? "") });
65
+ }}>
66
+ <label>Backup file<input name="backup" type="file" accept="application/json,.json" required /></label>
67
+ <label>Passphrase<input name="passphrase" type="password" required autoComplete="off" /></label>
68
+ <button type="submit" className="quiet">Restore key</button>
69
+ </Ask>
70
+ </details>
71
+ );
72
+ }
package/src/freezer.tsx CHANGED
@@ -1,7 +1,10 @@
1
+ "use client";
2
+
1
3
  /** The freezer: every part, its tubes, and what can be done to them. */
2
4
  import type { ItemState, PartState } from "@biolibs/bionet";
3
5
  import { useAct, useLab } from "@biolibs/bionet-react";
4
6
  import { Ask } from "./parts.js";
7
+ import { PutItem } from "./places.js";
5
8
 
6
9
  const whole = (data: FormData, name: string): number => Number(String(data.get(name) ?? "").trim());
7
10
 
@@ -54,7 +57,7 @@ export function PartCard({ part, items }: { part: PartState; items: ItemState[]
54
57
  </div>
55
58
  {live.length === 0 ? <p className="dim small">No tubes of this.</p> : (
56
59
  <table>
57
- <thead><tr><th>Tube</th><th>Amount</th><th>Use or add</th><th>Count</th><th /></tr></thead>
60
+ <thead><tr><th>Tube</th><th>Amount</th><th>Where</th><th>Use or add</th><th>Count</th><th /></tr></thead>
58
61
  <tbody>{live.map((item) => <ItemRow key={item.item} item={item} />)}</tbody>
59
62
  </table>
60
63
  )}
@@ -77,6 +80,7 @@ export function ItemRow({ item }: { item: ItemState }) {
77
80
  <strong>{amountOf(item)}</strong>
78
81
  {item.needsRecount && <span className="badge" title="The log has lost track of this tube: it went below zero, or two people counted it at once.">needs a count</span>}
79
82
  </td>
83
+ <td><PutItem item={item} /></td>
80
84
  <td>
81
85
  <div className="row tight">
82
86
  <button type="button" className="quiet" onClick={() => void act("adjust", { item: item.item, by: -1 })}>−1</button>
package/src/history.tsx CHANGED
@@ -1,7 +1,10 @@
1
+ "use client";
2
+
1
3
  /** The history: every signed change, and what became of it. */
2
4
  import { useState } from "react";
3
5
  import type { EntryView, LabView } from "@biolibs/bionet-client";
4
6
  import { useLab } from "@biolibs/bionet-react";
7
+ import { slotName } from "@biolibs/bionet-space";
5
8
 
6
9
  /**
7
10
  * What one change was, in words.
@@ -10,7 +13,7 @@ import { useLab } from "@biolibs/bionet-react";
10
13
  * @param lab - The lab, to name the parts, tubes and people it refers to.
11
14
  * @returns A phrase that follows the name of whoever made it, like `used 2 µL of a tube of f1`.
12
15
  */
13
- export function describeEntry(entry: Pick<EntryView, "op">, lab: Pick<LabView, "parts" | "items" | "roster">): string {
16
+ export function describeEntry(entry: Pick<EntryView, "op">, lab: Pick<LabView, "parts" | "items" | "roster"> & Partial<Pick<LabView, "places">>): string {
14
17
  const op = entry.op;
15
18
  const part = (checksum: unknown): string => lab.parts.find((one) => one.checksum === checksum)?.name ?? "a part";
16
19
  const tube = (id: unknown): string => {
@@ -19,6 +22,7 @@ export function describeEntry(entry: Pick<EntryView, "op">, lab: Pick<LabView, "
19
22
  };
20
23
  const unit = (id: unknown): string => lab.items.find((one) => one.item === id)?.unit ?? "";
21
24
  const who = (key: unknown): string => lab.roster.find((one) => one.key === key)?.person ?? "a device";
25
+ const place = (id: unknown): string => lab.places?.find((one) => one.place === id)?.name ?? "a place";
22
26
  const tidy = (words: string): string => words.replace(/\s+/g, " ").trim();
23
27
  switch (op.type) {
24
28
  case "roster.found": return `founded ${String(op["name"])}`;
@@ -31,6 +35,15 @@ export function describeEntry(entry: Pick<EntryView, "op">, lab: Pick<LabView, "
31
35
  case "item.adjust": return tidy(`${Number(op["by"]) < 0 ? "used" : "added"} ${Math.abs(Number(op["by"]))} ${unit(op["item"])} ${Number(op["by"]) < 0 ? "of" : "to"} ${tube(op["item"])}`);
32
36
  case "item.recount": return tidy(`counted ${String(op["amount"])} ${unit(op["item"])} in ${tube(op["item"])}`);
33
37
  case "item.retire": return `retired ${tube(op["item"])}`;
38
+ case "place.add": return `added the ${String(op["kind"])} ${String(op["name"])}${op["parent"] === null ? "" : ` in ${place(op["parent"])}`}`;
39
+ case "place.move": return op["parent"] === null ? `took ${place(op["place"])} out of where it was` : `moved ${place(op["place"])} into ${place(op["parent"])}`;
40
+ case "place.stand": return op["standing"] === null ? `cleared where ${place(op["place"])} stands` : `said where ${place(op["place"])} stands`;
41
+ case "place.retire": return `retired ${place(op["place"])}`;
42
+ case "item.put": {
43
+ const slot = op["slot"] as { row: number; column: number } | null;
44
+ return op["place"] === null ? `took ${tube(op["item"])} out of where it was`
45
+ : `put ${tube(op["item"])} in ${place(op["place"])}${slot === null ? "" : `, ${slotName(slot)}`}`;
46
+ }
34
47
  case "field.set": return `set ${String(op["field"])} to ${String(op["value"])}`;
35
48
  default: return `did something this version does not know (${op.type})`;
36
49
  }
package/src/index.ts CHANGED
@@ -16,10 +16,17 @@
16
16
  * - `history.tsx` — every signed change, and what became of it
17
17
  * - `sharing.tsx` — what other labs are shown, and the lab's web peer
18
18
  * - `parts.tsx` — the small pieces they are made of
19
+ * - `public.tsx` — a lab's public page: what it holds, and what it can see of another lab
20
+ *
21
+ * Everything but `public.tsx` uses hooks and is marked `"use client"`, for frameworks that draw on a
22
+ * server first. The public page's pieces take plain values and can be drawn there.
19
23
  */
20
24
  export * from "./window.js";
21
25
  export * from "./freezer.js";
26
+ export * from "./places.js";
27
+ export * from "./backup.js";
22
28
  export * from "./people.js";
23
29
  export * from "./history.js";
24
30
  export * from "./sharing.js";
25
31
  export * from "./parts.js";
32
+ export * from "./public.js";
package/src/parts.tsx CHANGED
@@ -1,3 +1,5 @@
1
+ "use client";
2
+
1
3
  /** The small pieces the panels are made of. */
2
4
  import { createContext, useContext, useState, type FormEvent, type ReactNode } from "react";
3
5
  import type { LabSnapshot, PeerView } from "@biolibs/bionet-client";
package/src/people.tsx CHANGED
@@ -1,5 +1,8 @@
1
+ "use client";
2
+
1
3
  /** The people: who is in the lab, and letting somebody in. */
2
4
  import { useAct, useLab } from "@biolibs/bionet-react";
5
+ import { BackUpKey } from "./backup.js";
3
6
  import { Ask, Copy } from "./parts.js";
4
7
 
5
8
  /** The roster, and for a keeper the way to add somebody. Draws nothing until the lab has arrived. */
@@ -45,6 +48,7 @@ export function People() {
45
48
  ) : <p className="dim small">Set the lab's web peer under Sharing to have an invitation to send.</p>}
46
49
  </section>
47
50
  ) : <p className="dim small">Only a keeper can change who is in the lab.</p>}
51
+ <BackUpKey />
48
52
  </>
49
53
  );
50
54
  }