@biolibs/bionet-panels 0.0.0-stage → 0.2.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.
- package/README.md +89 -2
- package/dist/freezer.d.ts +21 -0
- package/dist/freezer.d.ts.map +1 -0
- package/dist/freezer.js +32 -0
- package/dist/freezer.js.map +1 -0
- package/dist/history.d.ts +14 -0
- package/dist/history.d.ts.map +1 -0
- package/dist/history.js +48 -0
- package/dist/history.js.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/parts.d.ts +36 -0
- package/dist/parts.d.ts.map +1 -0
- package/dist/parts.js +61 -0
- package/dist/parts.js.map +1 -0
- package/dist/people.d.ts +3 -0
- package/dist/people.d.ts.map +1 -0
- package/dist/people.js +15 -0
- package/dist/people.js.map +1 -0
- package/dist/public.d.ts +77 -0
- package/dist/public.d.ts.map +1 -0
- package/dist/public.js +73 -0
- package/dist/public.js.map +1 -0
- package/dist/sharing.d.ts +12 -0
- package/dist/sharing.d.ts.map +1 -0
- package/dist/sharing.js +35 -0
- package/dist/sharing.js.map +1 -0
- package/dist/window.d.ts +21 -0
- package/dist/window.d.ts.map +1 -0
- package/dist/window.js +72 -0
- package/dist/window.js.map +1 -0
- package/package.json +55 -4
- package/panels.css +61 -0
- package/src/freezer.tsx +101 -0
- package/src/history.tsx +70 -0
- package/src/index.ts +30 -0
- package/src/parts.tsx +80 -0
- package/src/people.tsx +52 -0
- package/src/public.tsx +175 -0
- package/src/sharing.tsx +71 -0
- package/src/window.tsx +136 -0
package/README.md
CHANGED
|
@@ -1,3 +1,90 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @biolibs/bionet-panels
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The parts of a Bionet lab application, ready to place: the freezer, the people, the history, what
|
|
4
|
+
other labs are shown, and a whole window that puts them together. Light and dark.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm install @biolibs/bionet-panels @biolibs/bionet-react @biolibs/bionet-client @biolibs/bionet-theme react
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## A whole application
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
import "@biolibs/bionet-theme/theme.css";
|
|
16
|
+
import "@biolibs/bionet-panels/panels.css";
|
|
17
|
+
import { sourceOf } from "@biolibs/bionet-client";
|
|
18
|
+
import { LabProvider } from "@biolibs/bionet-react";
|
|
19
|
+
import { LabWindow } from "@biolibs/bionet-panels";
|
|
20
|
+
|
|
21
|
+
<LabProvider source={sourceOf(lab)}>
|
|
22
|
+
<LabWindow />
|
|
23
|
+
</LabProvider>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
`LabWindow` takes a person through the places they can be: nobody has said who is at the device, the
|
|
27
|
+
device is in no lab, the device is waiting to be let into one, and then the lab itself.
|
|
28
|
+
|
|
29
|
+
## The panels on their own
|
|
30
|
+
|
|
31
|
+
| Panel | Shows |
|
|
32
|
+
|---|---|
|
|
33
|
+
| `Freezer` | Every part and its tubes: use or add, count, retire, put on offer, add a part or a tube |
|
|
34
|
+
| `People` | The roster, and for a keeper the way to add somebody and the invitation to send |
|
|
35
|
+
| `History` | Every signed change, newest first, in words, with what became of it |
|
|
36
|
+
| `Sharing` | What other labs are shown, a button to publish it, and the lab's web peer |
|
|
37
|
+
| `SyncStatus`, `Trouble`, `DeviceKey` | The small pieces |
|
|
38
|
+
|
|
39
|
+
Each reads the lab through `@biolibs/bionet-react`, so it goes anywhere inside a `LabProvider`. The
|
|
40
|
+
styles apply only inside an element with the class `bionet`, which `LabWindow` supplies; put a panel
|
|
41
|
+
used on its own inside one:
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
<div className="bionet"><Freezer /></div>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Every colour comes from `@biolibs/bionet-theme`, and no rule reaches outside `.bionet`.
|
|
48
|
+
|
|
49
|
+
## A lab's public page
|
|
50
|
+
|
|
51
|
+
What a lab shows the world, and what it can see of another lab. These take what was fetched and
|
|
52
|
+
checked as plain values, so they can be drawn on a server:
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
import { fetchInventory, originMatches, readInventory, verifyInventory } from "@biolibs/bionet";
|
|
56
|
+
import { Held, LabPage, PeerAnswered, PeerSilent } from "@biolibs/bionet-panels";
|
|
57
|
+
|
|
58
|
+
const mine = readInventory(published);
|
|
59
|
+
const checks = await verifyInventory(mine);
|
|
60
|
+
|
|
61
|
+
<LabPage name="The Wren Lab" note="A worked example, not a real freezer.">
|
|
62
|
+
<Held parts={mine.inventory.parts} checks={checks} origin={ORIGIN}
|
|
63
|
+
bound={originMatches(mine.inventory.lab.origin, ORIGIN)} />
|
|
64
|
+
<h2>What we can see of The Thistle Lab</h2>
|
|
65
|
+
<PeerAnswered found={await fetchInventory(PEER)} mine={mine.inventory.parts} />
|
|
66
|
+
</LabPage>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
| Piece | Shows |
|
|
70
|
+
|---|---|
|
|
71
|
+
| `LabPage` | The frame: the mark, the lab's name, a line about what it is |
|
|
72
|
+
| `Held` | What the lab holds, and what the signature over that list settles |
|
|
73
|
+
| `PeerAnswered` | Another lab that answered: what it has that this one does not, and what both have, by checksum |
|
|
74
|
+
| `PeerSilent` | Another lab that did not answer, said without accusing it |
|
|
75
|
+
| `PartsTable`, `WhatASignatureSettles` | The pieces those are made of |
|
|
76
|
+
|
|
77
|
+
They carry the wording as well as the markup. What a signature settles, and what it does not, has to
|
|
78
|
+
be said the same way on every lab's page.
|
|
79
|
+
|
|
80
|
+
Everything else in this package uses hooks and is marked `"use client"`, for frameworks that draw on
|
|
81
|
+
a server first.
|
|
82
|
+
|
|
83
|
+
## Testing
|
|
84
|
+
|
|
85
|
+
`test/panels.test.ts` renders each panel to text against a real lab, and checks that the stylesheet
|
|
86
|
+
stays inside `.bionet` and uses only the theme's colours.
|
|
87
|
+
|
|
88
|
+
## License
|
|
89
|
+
|
|
90
|
+
MIT
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** The freezer: every part, its tubes, and what can be done to them. */
|
|
2
|
+
import type { ItemState, PartState } from "@biolibs/bionet";
|
|
3
|
+
/**
|
|
4
|
+
* How much of an item there is, with its unit.
|
|
5
|
+
*
|
|
6
|
+
* @param item - The item.
|
|
7
|
+
* @returns Something like `7 µL`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const amountOf: (item: Pick<ItemState, "amount" | "unit">) => string;
|
|
10
|
+
/** Every part with its tubes, and a form to add a part. Draws nothing until the lab has arrived. */
|
|
11
|
+
export declare function Freezer(): import("react").JSX.Element | null;
|
|
12
|
+
/** One part and its tubes. */
|
|
13
|
+
export declare function PartCard({ part, items }: {
|
|
14
|
+
part: PartState;
|
|
15
|
+
items: ItemState[];
|
|
16
|
+
}): import("react").JSX.Element;
|
|
17
|
+
/** One tube: how much there is, and the ways to change that. */
|
|
18
|
+
export declare function ItemRow({ item }: {
|
|
19
|
+
item: ItemState;
|
|
20
|
+
}): import("react").JSX.Element;
|
|
21
|
+
//# sourceMappingURL=freezer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"freezer.d.ts","sourceRoot":"","sources":["../src/freezer.tsx"],"names":[],"mappings":"AAEA,wEAAwE;AACxE,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAM5D;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAAI,MAAM,IAAI,CAAC,SAAS,EAAE,QAAQ,GAAG,MAAM,CAAC,KAAG,MAAsE,CAAC;AAE3I,oGAAoG;AACpG,wBAAgB,OAAO,uCAoBtB;AAED,8BAA8B;AAC9B,wBAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,SAAS,EAAE,CAAA;CAAE,+BA4BhF;AAED,gEAAgE;AAChE,wBAAgB,OAAO,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,+BA4BpD"}
|
package/dist/freezer.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useAct, useLab } from "@biolibs/bionet-react";
|
|
4
|
+
import { Ask } from "./parts.js";
|
|
5
|
+
const whole = (data, name) => Number(String(data.get(name) ?? "").trim());
|
|
6
|
+
/**
|
|
7
|
+
* How much of an item there is, with its unit.
|
|
8
|
+
*
|
|
9
|
+
* @param item - The item.
|
|
10
|
+
* @returns Something like `7 µL`.
|
|
11
|
+
*/
|
|
12
|
+
export const amountOf = (item) => `${item.amount}${item.unit === null ? "" : ` ${item.unit}`}`;
|
|
13
|
+
/** Every part with its tubes, and a form to add a part. Draws nothing until the lab has arrived. */
|
|
14
|
+
export function Freezer() {
|
|
15
|
+
const lab = useLab()?.lab;
|
|
16
|
+
const act = useAct();
|
|
17
|
+
if (lab === null || lab === undefined)
|
|
18
|
+
return null;
|
|
19
|
+
return (_jsxs(_Fragment, { children: [lab.parts.length === 0 && _jsx("p", { className: "empty", children: "Nothing in the freezer yet. Add the first part below." }), lab.parts.map((part) => _jsx(PartCard, { part: part, items: lab.items.filter((item) => item.part === part.checksum) }, part.checksum)), _jsxs("section", { className: "card", children: [_jsx("h2", { children: "Add a part" }), _jsx("p", { className: "dim small", children: "A part is a molecule, known by the checksum of its sequence. Two people adding the same sequence get the same part, whatever each calls it." }), _jsxs(Ask, { onAsk: (data) => act("addPart", { name: String(data.get("name") ?? ""), sequence: String(data.get("sequence") ?? ""), circular: data.get("circular") === "on" }), className: "stack", children: [_jsxs("label", { children: ["Name", _jsx("input", { name: "name", placeholder: "pUC19", required: true, maxLength: 200 })] }), _jsxs("label", { children: ["Sequence", _jsx("textarea", { name: "sequence", placeholder: "GGATCACAGTCTACACTGCTCACTCC\u2026", required: true, rows: 3, spellCheck: false })] }), _jsxs("label", { className: "check", children: [_jsx("input", { type: "checkbox", name: "circular" }), " It is a circle"] }), _jsx("button", { type: "submit", children: "Add part" })] })] })] }));
|
|
20
|
+
}
|
|
21
|
+
/** One part and its tubes. */
|
|
22
|
+
export function PartCard({ part, items }) {
|
|
23
|
+
const act = useAct();
|
|
24
|
+
const live = items.filter((item) => !item.retired);
|
|
25
|
+
return (_jsxs("section", { className: "card part", children: [_jsxs("div", { className: "parthead", children: [_jsxs("div", { children: [_jsx("h2", { children: part.name }), _jsxs("p", { className: "dim small", children: [part.length, " bp", part.circular ? " · circular" : "", " \u00B7 ", _jsxs("code", { children: [part.checksum.slice(0, 26), "\u2026"] })] })] }), _jsxs("label", { className: "check", title: "Whether other labs are told this part can be asked for", children: [_jsx("input", { type: "checkbox", checked: part.offered, onChange: (event) => void act("offer", { part: part.checksum, available: event.target.checked }) }), "On offer to other labs"] })] }), live.length === 0 ? _jsx("p", { className: "dim small", children: "No tubes of this." }) : (_jsxs("table", { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "Tube" }), _jsx("th", { children: "Amount" }), _jsx("th", { children: "Use or add" }), _jsx("th", { children: "Count" }), _jsx("th", {})] }) }), _jsx("tbody", { children: live.map((item) => _jsx(ItemRow, { item: item }, item.item)) })] })), _jsxs(Ask, { onAsk: (data) => act("addItem", { part: part.checksum, amount: whole(data, "amount"), unit: String(data.get("unit") ?? "") }), className: "row tight", children: [_jsx("input", { name: "amount", type: "number", min: 0, step: 1, placeholder: "Amount", required: true }), _jsx("input", { name: "unit", placeholder: "Unit, e.g. \u00B5L", maxLength: 20 }), _jsx("button", { type: "submit", className: "quiet", children: "Add a tube" })] })] }));
|
|
26
|
+
}
|
|
27
|
+
/** One tube: how much there is, and the ways to change that. */
|
|
28
|
+
export function ItemRow({ item }) {
|
|
29
|
+
const act = useAct();
|
|
30
|
+
return (_jsxs("tr", { className: item.needsRecount ? "flagged" : undefined, children: [_jsx("td", { children: _jsxs("code", { children: [item.item.slice(0, 10), "\u2026"] }) }), _jsxs("td", { children: [_jsx("strong", { children: amountOf(item) }), item.needsRecount && _jsx("span", { className: "badge", title: "The log has lost track of this tube: it went below zero, or two people counted it at once.", children: "needs a count" })] }), _jsx("td", { children: _jsxs("div", { className: "row tight", children: [_jsx("button", { type: "button", className: "quiet", onClick: () => void act("adjust", { item: item.item, by: -1 }), children: "\u22121" }), _jsx("button", { type: "button", className: "quiet", onClick: () => void act("adjust", { item: item.item, by: 1 }), children: "+1" }), _jsxs(Ask, { onAsk: (data) => act("adjust", { item: item.item, by: whole(data, "by") }), className: "row tight", children: [_jsx("input", { name: "by", type: "number", step: 1, placeholder: "\u00B1", required: true, className: "num", "aria-label": "Change by" }), _jsx("button", { type: "submit", className: "quiet", children: "Apply" })] })] }) }), _jsx("td", { children: _jsxs(Ask, { onAsk: (data) => act("recount", { item: item.item, amount: whole(data, "amount") }), className: "row tight", children: [_jsx("input", { name: "amount", type: "number", min: 0, step: 1, placeholder: "There is", required: true, className: "num", "aria-label": "Amount there is" }), _jsx("button", { type: "submit", className: "quiet", children: "Set" })] }) }), _jsx("td", { children: _jsx("button", { type: "button", className: "plain", onClick: () => void act("retire", { item: item.item }), children: "retire" }) })] }));
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=freezer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"freezer.js","sourceRoot":"","sources":["../src/freezer.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAIb,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEjC,MAAM,KAAK,GAAG,CAAC,IAAc,EAAE,IAAY,EAAU,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,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C,SAAS,EAAC,KAAK,gBAAY,WAAW,GAAG,EAC1G,iBAAQ,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,OAAO,sBAAe,IAClD,IACF,GACH,EACL,uBACE,MAAC,GAAG,IAAC,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,SAAS,EAAC,WAAW,aAC7G,gBAAO,IAAI,EAAC,QAAQ,EAAC,IAAI,EAAC,QAAQ,EAAC,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,WAAW,EAAC,UAAU,EAAC,QAAQ,QAAC,SAAS,EAAC,KAAK,gBAAY,iBAAiB,GAAG,EACnI,iBAAQ,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,OAAO,oBAAa,IAChD,GACH,EACL,uBAAI,iBAAQ,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,OAAO,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,GAAG,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,uBAAiB,GAAK,IACrH,CACN,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { EntryView, LabView } from "@biolibs/bionet-client";
|
|
2
|
+
/**
|
|
3
|
+
* What one change was, in words.
|
|
4
|
+
*
|
|
5
|
+
* @param entry - The change.
|
|
6
|
+
* @param lab - The lab, to name the parts, tubes and people it refers to.
|
|
7
|
+
* @returns A phrase that follows the name of whoever made it, like `used 2 µL of a tube of f1`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function describeEntry(entry: Pick<EntryView, "op">, lab: Pick<LabView, "parts" | "items" | "roster">): string;
|
|
10
|
+
/** Every change, newest first, with what became of each. Draws nothing until the lab has arrived. */
|
|
11
|
+
export declare function History({ first }: {
|
|
12
|
+
first?: number;
|
|
13
|
+
}): import("react").JSX.Element | null;
|
|
14
|
+
//# sourceMappingURL=history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../src/history.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAGjE;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC,GAAG,MAAM,CAwBpH;AAED,qGAAqG;AACrG,wBAAgB,OAAO,CAAC,EAAE,KAAU,EAAE,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,sCA4BzD"}
|
package/dist/history.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
/** The history: every signed change, and what became of it. */
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { useLab } from "@biolibs/bionet-react";
|
|
6
|
+
/**
|
|
7
|
+
* What one change was, in words.
|
|
8
|
+
*
|
|
9
|
+
* @param entry - The change.
|
|
10
|
+
* @param lab - The lab, to name the parts, tubes and people it refers to.
|
|
11
|
+
* @returns A phrase that follows the name of whoever made it, like `used 2 µL of a tube of f1`.
|
|
12
|
+
*/
|
|
13
|
+
export function describeEntry(entry, lab) {
|
|
14
|
+
const op = entry.op;
|
|
15
|
+
const part = (checksum) => lab.parts.find((one) => one.checksum === checksum)?.name ?? "a part";
|
|
16
|
+
const tube = (id) => {
|
|
17
|
+
const item = lab.items.find((one) => one.item === id);
|
|
18
|
+
return item === undefined ? "a tube" : `a tube of ${part(item.part)}`;
|
|
19
|
+
};
|
|
20
|
+
const unit = (id) => lab.items.find((one) => one.item === id)?.unit ?? "";
|
|
21
|
+
const who = (key) => lab.roster.find((one) => one.key === key)?.person ?? "a device";
|
|
22
|
+
const tidy = (words) => words.replace(/\s+/g, " ").trim();
|
|
23
|
+
switch (op.type) {
|
|
24
|
+
case "roster.found": return `founded ${String(op["name"])}`;
|
|
25
|
+
case "roster.add": return `added ${String(op["person"])} as a ${String(op["role"])}`;
|
|
26
|
+
case "roster.remove": return `removed ${who(op["key"])}`;
|
|
27
|
+
case "roster.role": return `made ${who(op["key"])} a ${String(op["role"])}`;
|
|
28
|
+
case "part.add": return `added the part ${String(op["name"])}`;
|
|
29
|
+
case "part.offer": return op["available"] === true ? `put ${part(op["part"])} on offer` : `took ${part(op["part"])} off offer`;
|
|
30
|
+
case "item.add": return tidy(`added ${tube(op["item"])}, ${String(op["amount"])} ${String(op["unit"] ?? "")}`);
|
|
31
|
+
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
|
+
case "item.recount": return tidy(`counted ${String(op["amount"])} ${unit(op["item"])} in ${tube(op["item"])}`);
|
|
33
|
+
case "item.retire": return `retired ${tube(op["item"])}`;
|
|
34
|
+
case "field.set": return `set ${String(op["field"])} to ${String(op["value"])}`;
|
|
35
|
+
default: return `did something this version does not know (${op.type})`;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/** Every change, newest first, with what became of each. Draws nothing until the lab has arrived. */
|
|
39
|
+
export function History({ first = 40 }) {
|
|
40
|
+
const lab = useLab()?.lab;
|
|
41
|
+
const [all, setAll] = useState(false);
|
|
42
|
+
if (lab === null || lab === undefined)
|
|
43
|
+
return null;
|
|
44
|
+
const newest = [...lab.entries].reverse();
|
|
45
|
+
const shown = all ? newest : newest.slice(0, first);
|
|
46
|
+
return (_jsxs("section", { className: "card", children: [_jsx("h2", { children: "Everything that has happened" }), _jsx("p", { className: "dim small", children: "Each line is one signed change. The time is what the signer's computer said, which is a claim; the order is worked out from what each person had seen." }), lab.overlaps.length > 0 && _jsxs("p", { className: "note", children: [lab.overlaps.length, " ", lab.overlaps.length === 1 ? "pair of changes was" : "pairs of changes were", " made without knowledge of each other. One of each stood; both are below."] }), lab.waiting > 0 && _jsxs("p", { className: "note", children: [lab.waiting, " ", lab.waiting === 1 ? "change is" : "changes are", " waiting on others that have not arrived yet."] }), _jsxs("table", { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "When" }), _jsx("th", { children: "Who" }), _jsx("th", { children: "What" }), _jsx("th", {})] }) }), _jsx("tbody", { children: shown.map((entry) => (_jsxs("tr", { className: entry.status === "applied" ? undefined : "gone", children: [_jsx("td", { className: "dim nowrap", children: new Date(entry.signedAt).toLocaleString(undefined, { dateStyle: "medium", timeStyle: "short" }) }), _jsx("td", { children: entry.signer ?? lab.roster.find((one) => one.key === entry.author)?.person ?? "unknown" }), _jsx("td", { children: describeEntry(entry, lab) }), _jsx("td", { children: entry.status !== "applied" && _jsx("span", { className: "badge", title: entry.reason ?? "", children: entry.status }) })] }, entry.id))) })] }), !all && newest.length > shown.length && _jsxs("button", { type: "button", className: "quiet", onClick: () => setAll(true), children: ["Show all ", newest.length] })] }));
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.js","sourceRoot":"","sources":["../src/history.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,+DAA+D;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,KAA4B,EAAE,GAAgD;IAC1G,MAAM,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC;IACpB,MAAM,I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1G,KAAK,CAAC,EAAE,CAKZ,CACN,CAAC,GACI,IACF,EACP,CAAC,GAAG,IAAI,MAAM,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,kBAAQ,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,OAAO,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,0BAAY,MAAM,CAAC,MAAM,IAAU,IACvI,CACX,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* `@biolibs/bionet-panels`: the parts of a Bionet lab application, ready to place.
|
|
4
|
+
*
|
|
5
|
+
* Each panel reads the lab through `@biolibs/bionet-react`, so it goes anywhere inside a
|
|
6
|
+
* `LabProvider`, and takes its colours from `@biolibs/bionet-theme`, so it follows a light or dark
|
|
7
|
+
* theme. `LabWindow` is all of them put together: a whole application in one component.
|
|
8
|
+
*
|
|
9
|
+
* Import `@biolibs/bionet-theme/theme.css` and `@biolibs/bionet-panels/panels.css` once. The panels'
|
|
10
|
+
* styles apply only inside an element with the class `bionet`, which `LabWindow` supplies; put a
|
|
11
|
+
* panel used on its own inside one.
|
|
12
|
+
*
|
|
13
|
+
* - `window.tsx` — `LabWindow`, and the screens before there is a lab
|
|
14
|
+
* - `freezer.tsx` — parts, tubes, amounts
|
|
15
|
+
* - `people.tsx` — the roster, and letting somebody in
|
|
16
|
+
* - `history.tsx` — every signed change, and what became of it
|
|
17
|
+
* - `sharing.tsx` — what other labs are shown, and the lab's web peer
|
|
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.
|
|
23
|
+
*/
|
|
24
|
+
export * from "./window.js";
|
|
25
|
+
export * from "./freezer.js";
|
|
26
|
+
export * from "./people.js";
|
|
27
|
+
export * from "./history.js";
|
|
28
|
+
export * from "./sharing.js";
|
|
29
|
+
export * from "./parts.js";
|
|
30
|
+
export * from "./public.js";
|
|
31
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* `@biolibs/bionet-panels`: the parts of a Bionet lab application, ready to place.
|
|
4
|
+
*
|
|
5
|
+
* Each panel reads the lab through `@biolibs/bionet-react`, so it goes anywhere inside a
|
|
6
|
+
* `LabProvider`, and takes its colours from `@biolibs/bionet-theme`, so it follows a light or dark
|
|
7
|
+
* theme. `LabWindow` is all of them put together: a whole application in one component.
|
|
8
|
+
*
|
|
9
|
+
* Import `@biolibs/bionet-theme/theme.css` and `@biolibs/bionet-panels/panels.css` once. The panels'
|
|
10
|
+
* styles apply only inside an element with the class `bionet`, which `LabWindow` supplies; put a
|
|
11
|
+
* panel used on its own inside one.
|
|
12
|
+
*
|
|
13
|
+
* - `window.tsx` — `LabWindow`, and the screens before there is a lab
|
|
14
|
+
* - `freezer.tsx` — parts, tubes, amounts
|
|
15
|
+
* - `people.tsx` — the roster, and letting somebody in
|
|
16
|
+
* - `history.tsx` — every signed change, and what became of it
|
|
17
|
+
* - `sharing.tsx` — what other labs are shown, and the lab's web peer
|
|
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.
|
|
23
|
+
*/
|
|
24
|
+
export * from "./window.js";
|
|
25
|
+
export * from "./freezer.js";
|
|
26
|
+
export * from "./people.js";
|
|
27
|
+
export * from "./history.js";
|
|
28
|
+
export * from "./sharing.js";
|
|
29
|
+
export * from "./parts.js";
|
|
30
|
+
export * from "./public.js";
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
package/dist/parts.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** The small pieces the panels are made of. */
|
|
2
|
+
import { type ReactNode } from "react";
|
|
3
|
+
import type { LabSnapshot, PeerView } from "@biolibs/bionet-client";
|
|
4
|
+
/** How to put words on the clipboard. A host that cannot use the browser's own way supplies one. */
|
|
5
|
+
export declare const CopyContext: import("react").Context<(words: string) => Promise<void>>;
|
|
6
|
+
/** A form that asks for one thing and clears itself if it worked. */
|
|
7
|
+
export declare function Ask({ onAsk, children, className }: {
|
|
8
|
+
onAsk: (data: FormData) => Promise<{
|
|
9
|
+
ok: boolean;
|
|
10
|
+
}>;
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
className?: string;
|
|
13
|
+
}): import("react").JSX.Element;
|
|
14
|
+
/** A button that copies some words and says that it did. */
|
|
15
|
+
export declare function Copy({ words, label }: {
|
|
16
|
+
words: string;
|
|
17
|
+
label?: string;
|
|
18
|
+
}): import("react").JSX.Element;
|
|
19
|
+
/** The last change that was refused, with a way to put it away. Draws nothing when there is none. */
|
|
20
|
+
export declare function Trouble(): import("react").JSX.Element | null;
|
|
21
|
+
/**
|
|
22
|
+
* How the connection to the lab's peer is going, in the words a person would want.
|
|
23
|
+
*
|
|
24
|
+
* @param peer - The connection.
|
|
25
|
+
* @returns One line.
|
|
26
|
+
*/
|
|
27
|
+
export declare function syncWords(peer: PeerView): string;
|
|
28
|
+
/** A dot and a line saying how the connection to the lab's peer is going. */
|
|
29
|
+
export declare function SyncStatus({ peer }: {
|
|
30
|
+
peer: PeerView;
|
|
31
|
+
}): import("react").JSX.Element;
|
|
32
|
+
/** This device's key, to be sent to a keeper. */
|
|
33
|
+
export declare function DeviceKey({ device }: {
|
|
34
|
+
device: LabSnapshot["device"];
|
|
35
|
+
}): import("react").JSX.Element;
|
|
36
|
+
//# sourceMappingURL=parts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parts.d.ts","sourceRoot":"","sources":["../src/parts.tsx"],"names":[],"mappings":"AAEA,+CAA+C;AAC/C,OAAO,EAAuD,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5F,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAGpE,oGAAoG;AACpG,eAAO,MAAM,WAAW,kCAAyB,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAkD,CAAC;AAE5H,qEAAqE;AACrE,wBAAgB,GAAG,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE;IAAE,KAAK,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,OAAO,CAAC;QAAE,EAAE,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAAC,QAAQ,EAAE,SAAS,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,+BAWnJ;AAED,4DAA4D;AAC5D,wBAAgB,IAAI,CAAC,EAAE,KAAK,EAAE,KAAc,EAAE,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,+BAQhF;AAED,qGAAqG;AACrG,wBAAgB,OAAO,uCAItB;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAUhD;AAED,6EAA6E;AAC7E,wBAAgB,UAAU,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,+BAOtD;AAED,iDAAiD;AACjD,wBAAgB,SAAS,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAA;CAAE,+BAQtE"}
|
package/dist/parts.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
/** The small pieces the panels are made of. */
|
|
4
|
+
import { createContext, useContext, useState } from "react";
|
|
5
|
+
import { useTrouble } from "@biolibs/bionet-react";
|
|
6
|
+
/** How to put words on the clipboard. A host that cannot use the browser's own way supplies one. */
|
|
7
|
+
export const CopyContext = createContext((words) => navigator.clipboard.writeText(words));
|
|
8
|
+
/** A form that asks for one thing and clears itself if it worked. */
|
|
9
|
+
export function Ask({ onAsk, children, className }) {
|
|
10
|
+
const [busy, setBusy] = useState(false);
|
|
11
|
+
const submit = async (event) => {
|
|
12
|
+
event.preventDefault();
|
|
13
|
+
const form = event.currentTarget;
|
|
14
|
+
setBusy(true);
|
|
15
|
+
const { ok } = await onAsk(new FormData(form));
|
|
16
|
+
setBusy(false);
|
|
17
|
+
if (ok)
|
|
18
|
+
form.reset();
|
|
19
|
+
};
|
|
20
|
+
return _jsx("form", { className: className, onSubmit: submit, "aria-busy": busy, children: _jsx("fieldset", { disabled: busy, children: children }) });
|
|
21
|
+
}
|
|
22
|
+
/** A button that copies some words and says that it did. */
|
|
23
|
+
export function Copy({ words, label = "Copy" }) {
|
|
24
|
+
const copy = useContext(CopyContext);
|
|
25
|
+
const [done, setDone] = useState(false);
|
|
26
|
+
return (_jsx("button", { type: "button", className: "quiet", onClick: () => { void copy(words).then(() => { setDone(true); setTimeout(() => setDone(false), 1500); }); }, children: done ? "Copied" : label }));
|
|
27
|
+
}
|
|
28
|
+
/** The last change that was refused, with a way to put it away. Draws nothing when there is none. */
|
|
29
|
+
export function Trouble() {
|
|
30
|
+
const { trouble, dismiss } = useTrouble();
|
|
31
|
+
if (trouble === null)
|
|
32
|
+
return null;
|
|
33
|
+
return _jsxs("p", { role: "alert", className: "trouble", children: [trouble, _jsx("button", { type: "button", className: "plain", onClick: dismiss, children: "dismiss" })] });
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* How the connection to the lab's peer is going, in the words a person would want.
|
|
37
|
+
*
|
|
38
|
+
* @param peer - The connection.
|
|
39
|
+
* @returns One line.
|
|
40
|
+
*/
|
|
41
|
+
export function syncWords(peer) {
|
|
42
|
+
const waiting = peer.pending === 0 ? "" : ` · ${peer.pending} ${peer.pending === 1 ? "change" : "changes"} to send`;
|
|
43
|
+
if (peer.url === null)
|
|
44
|
+
return "No peer set · working on this device only";
|
|
45
|
+
switch (peer.status) {
|
|
46
|
+
case "synced": return "In step with the lab";
|
|
47
|
+
case "syncing": return "Syncing…";
|
|
48
|
+
case "connecting": return `Reaching the lab's peer…${waiting}`;
|
|
49
|
+
case "waiting": return "Waiting to be let in";
|
|
50
|
+
default: return `Offline${waiting}`;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/** A dot and a line saying how the connection to the lab's peer is going. */
|
|
54
|
+
export function SyncStatus({ peer }) {
|
|
55
|
+
return (_jsxs("div", { className: "sync", title: peer.problem ?? peer.url ?? "", children: [_jsx("span", { className: `dot ${peer.url === null ? "offline" : peer.status}` }), _jsx("span", { children: syncWords(peer) })] }));
|
|
56
|
+
}
|
|
57
|
+
/** This device's key, to be sent to a keeper. */
|
|
58
|
+
export function DeviceKey({ device }) {
|
|
59
|
+
return (_jsxs("div", { className: "keybox", children: [_jsxs("div", { children: [_jsx("span", { className: "label", children: "This device's key" }), _jsx(Copy, { words: device.key, label: "Copy key" })] }), _jsx("code", { className: "wrap", children: device.key }), _jsxs("p", { className: "dim small", children: ["Fingerprint ", _jsx("code", { children: device.fingerprint }), ". It is safe to send: it lets a lab recognise this device, and nothing else."] })] }));
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=parts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parts.js","sourceRoot":"","sources":["../src/parts.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,+CAA+C;AAC/C,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAkC,MAAM,OAAO,CAAC;AAE5F,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,oGAAoG;AACpG,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAmC,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;AAE5H,qEAAqE;AACrE,MAAM,UAAU,GAAG,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAoG;IAClJ,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACxC,MAAM,MAAM,GAAG,KAAK,EAAE,KAAiC,EAAE,EAAE;QACzD,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,MAAM,IAAI,GAAG,KAAK,CAAC,aAAa,CAAC;QACjC,OAAO,CAAC,IAAI,CAAC,CAAC;QACd,MAAM,EAAE,EAAE,EAAE,GAAG,MAAM,KAAK,CAAC,I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AAS,EAAC,OAAO,kCAAyB,EAAA,KAAC,IAAI,IAAC,KAAK,EAAE,MAAM,CAAC,GAAG,EAAE,KAAK,EAAC,UAAU,GAAG,IAAM,EACvG,eAAM,SAAS,EAAC,MAAM,YAAE,MAAM,CAAC,GAAG,GAAQ,EAC1C,aAAG,SAAS,EAAC,WAAW,6BAAa,yBAAO,MAAM,CAAC,WAAW,GAAQ,oFAAgF,IAClJ,CACP,CAAC;AACJ,CAAC"}
|
package/dist/people.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"people.d.ts","sourceRoot":"","sources":["../src/people.tsx"],"names":[],"mappings":"AAMA,qGAAqG;AACrG,wBAAgB,MAAM,uCA4CrB"}
|
package/dist/people.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
/** The people: who is in the lab, and letting somebody in. */
|
|
4
|
+
import { useAct, useLab } from "@biolibs/bionet-react";
|
|
5
|
+
import { Ask, Copy } from "./parts.js";
|
|
6
|
+
/** The roster, and for a keeper the way to add somebody. Draws nothing until the lab has arrived. */
|
|
7
|
+
export function People() {
|
|
8
|
+
const state = useLab();
|
|
9
|
+
const act = useAct();
|
|
10
|
+
const lab = state?.lab;
|
|
11
|
+
if (state === null || lab === null || lab === undefined)
|
|
12
|
+
return null;
|
|
13
|
+
return (_jsxs(_Fragment, { children: [_jsxs("section", { className: "card", children: [_jsx("h2", { children: "Who is in the lab" }), _jsxs("table", { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "Person" }), _jsx("th", { children: "Role" }), _jsx("th", { children: "Device" }), _jsx("th", {})] }) }), _jsx("tbody", { children: lab.roster.map((one) => (_jsxs("tr", { className: one.removed === null ? undefined : "gone", children: [_jsxs("td", { children: [one.person, one.you && _jsx("span", { className: "badge calm", children: "this device" })] }), _jsx("td", { children: one.removed !== null ? "removed" : one.founder ? "keeper · founder" : one.role }), _jsx("td", { children: _jsx("code", { children: one.fingerprint }) }), _jsx("td", { children: one.removed !== null && _jsxs("span", { className: "dim small", children: ["log kept up to entry ", one.removed.cutoff + 1] }) })] }, one.key))) })] }), _jsx("p", { className: "dim small", children: "A device is known by its key. One person with two computers appears twice, once for each." })] }), lab.keeper ? (_jsxs("section", { className: "card", children: [_jsx("h2", { children: "Add somebody" }), _jsx("p", { className: "dim small", children: "Ask them for their device's key, add it here, and send them the invitation. Their app fills in once this change has reached the lab's peer." }), _jsxs(Ask, { onAsk: (data) => act("addMember", { key: String(data.get("key") ?? ""), person: String(data.get("person") ?? ""), role: String(data.get("role") ?? "member") }), className: "stack", children: [_jsxs("label", { children: ["Their device's key", _jsx("input", { name: "key", placeholder: "43 letters and digits", required: true, spellCheck: false })] }), _jsxs("label", { children: ["Their name", _jsx("input", { name: "person", required: true, maxLength: 200 })] }), _jsxs("label", { children: ["As", _jsxs("select", { name: "role", children: [_jsx("option", { value: "member", children: "a member, who can change the freezer" }), _jsx("option", { value: "keeper", children: "a keeper, who can also change who is in the lab" })] })] }), _jsx("button", { type: "submit", children: "Add to the lab" })] }), state.peer.invite !== null ? (_jsxs("div", { className: "keybox", children: [_jsxs("div", { children: [_jsx("span", { className: "label", children: "Invitation to send them" }), _jsx(Copy, { words: state.peer.invite, label: "Copy invitation" })] }), _jsx("code", { className: "wrap", children: state.peer.invite })] })) : _jsx("p", { className: "dim small", children: "Set the lab's web peer under Sharing to have an invitation to send." })] })) : _jsx("p", { className: "dim small", children: "Only a keeper can change who is in the lab." })] }));
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=people.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"people.js","sourceRoot":"","sources":["../src/people.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,8DAA8D;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;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C,CAAC,CAAC,YAAG,SAAS,EAAC,WAAW,oFAAwE,IAC5F,CACX,CAAC,CAAC,CAAC,YAAG,SAAS,EAAC,WAAW,4DAAgD,IAC3E,CACJ,CAAC;AACJ,CAAC"}
|
package/dist/public.d.ts
ADDED
|
@@ -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;
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