@biolibs/bionet-panels 0.0.0-stage → 0.1.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 +55 -2
- package/dist/freezer.d.ts +21 -0
- package/dist/freezer.d.ts.map +1 -0
- package/dist/freezer.js +31 -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 +47 -0
- package/dist/history.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -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 +60 -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 +14 -0
- package/dist/people.js.map +1 -0
- package/dist/sharing.d.ts +12 -0
- package/dist/sharing.d.ts.map +1 -0
- package/dist/sharing.js +34 -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 +71 -0
- package/dist/window.js.map +1 -0
- package/package.json +54 -4
- package/panels.css +55 -0
- package/src/freezer.tsx +99 -0
- package/src/history.tsx +68 -0
- package/src/index.ts +25 -0
- package/src/parts.tsx +78 -0
- package/src/people.tsx +50 -0
- package/src/sharing.tsx +69 -0
- package/src/window.tsx +134 -0
package/README.md
CHANGED
|
@@ -1,3 +1,56 @@
|
|
|
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
|
+
## Testing
|
|
50
|
+
|
|
51
|
+
`test/panels.test.ts` renders each panel to text against a real lab, and checks that the stylesheet
|
|
52
|
+
stays inside `.bionet` and uses only the theme's colours.
|
|
53
|
+
|
|
54
|
+
## License
|
|
55
|
+
|
|
56
|
+
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":"AAAA,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,31 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useAct, useLab } from "@biolibs/bionet-react";
|
|
3
|
+
import { Ask } from "./parts.js";
|
|
4
|
+
const whole = (data, name) => Number(String(data.get(name) ?? "").trim());
|
|
5
|
+
/**
|
|
6
|
+
* How much of an item there is, with its unit.
|
|
7
|
+
*
|
|
8
|
+
* @param item - The item.
|
|
9
|
+
* @returns Something like `7 µL`.
|
|
10
|
+
*/
|
|
11
|
+
export const amountOf = (item) => `${item.amount}${item.unit === null ? "" : ` ${item.unit}`}`;
|
|
12
|
+
/** Every part with its tubes, and a form to add a part. Draws nothing until the lab has arrived. */
|
|
13
|
+
export function Freezer() {
|
|
14
|
+
const lab = useLab()?.lab;
|
|
15
|
+
const act = useAct();
|
|
16
|
+
if (lab === null || lab === undefined)
|
|
17
|
+
return null;
|
|
18
|
+
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" })] })] })] }));
|
|
19
|
+
}
|
|
20
|
+
/** One part and its tubes. */
|
|
21
|
+
export function PartCard({ part, items }) {
|
|
22
|
+
const act = useAct();
|
|
23
|
+
const live = items.filter((item) => !item.retired);
|
|
24
|
+
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" })] })] }));
|
|
25
|
+
}
|
|
26
|
+
/** One tube: how much there is, and the ways to change that. */
|
|
27
|
+
export function ItemRow({ item }) {
|
|
28
|
+
const act = useAct();
|
|
29
|
+
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" }) })] }));
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=freezer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"freezer.js","sourceRoot":"","sources":["../src/freezer.tsx"],"names":[],"mappings":";AAEA,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,CAAC,GAAG,CAAC,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K,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":"AAEA,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,47 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/** The history: every signed change, and what became of it. */
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { useLab } from "@biolibs/bionet-react";
|
|
5
|
+
/**
|
|
6
|
+
* What one change was, in words.
|
|
7
|
+
*
|
|
8
|
+
* @param entry - The change.
|
|
9
|
+
* @param lab - The lab, to name the parts, tubes and people it refers to.
|
|
10
|
+
* @returns A phrase that follows the name of whoever made it, like `used 2 µL of a tube of f1`.
|
|
11
|
+
*/
|
|
12
|
+
export function describeEntry(entry, lab) {
|
|
13
|
+
const op = entry.op;
|
|
14
|
+
const part = (checksum) => lab.parts.find((one) => one.checksum === checksum)?.name ?? "a part";
|
|
15
|
+
const tube = (id) => {
|
|
16
|
+
const item = lab.items.find((one) => one.item === id);
|
|
17
|
+
return item === undefined ? "a tube" : `a tube of ${part(item.part)}`;
|
|
18
|
+
};
|
|
19
|
+
const unit = (id) => lab.items.find((one) => one.item === id)?.unit ?? "";
|
|
20
|
+
const who = (key) => lab.roster.find((one) => one.key === key)?.person ?? "a device";
|
|
21
|
+
const tidy = (words) => words.replace(/\s+/g, " ").trim();
|
|
22
|
+
switch (op.type) {
|
|
23
|
+
case "roster.found": return `founded ${String(op["name"])}`;
|
|
24
|
+
case "roster.add": return `added ${String(op["person"])} as a ${String(op["role"])}`;
|
|
25
|
+
case "roster.remove": return `removed ${who(op["key"])}`;
|
|
26
|
+
case "roster.role": return `made ${who(op["key"])} a ${String(op["role"])}`;
|
|
27
|
+
case "part.add": return `added the part ${String(op["name"])}`;
|
|
28
|
+
case "part.offer": return op["available"] === true ? `put ${part(op["part"])} on offer` : `took ${part(op["part"])} off offer`;
|
|
29
|
+
case "item.add": return tidy(`added ${tube(op["item"])}, ${String(op["amount"])} ${String(op["unit"] ?? "")}`);
|
|
30
|
+
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"])}`);
|
|
31
|
+
case "item.recount": return tidy(`counted ${String(op["amount"])} ${unit(op["item"])} in ${tube(op["item"])}`);
|
|
32
|
+
case "item.retire": return `retired ${tube(op["item"])}`;
|
|
33
|
+
case "field.set": return `set ${String(op["field"])} to ${String(op["value"])}`;
|
|
34
|
+
default: return `did something this version does not know (${op.type})`;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/** Every change, newest first, with what became of each. Draws nothing until the lab has arrived. */
|
|
38
|
+
export function History({ first = 40 }) {
|
|
39
|
+
const lab = useLab()?.lab;
|
|
40
|
+
const [all, setAll] = useState(false);
|
|
41
|
+
if (lab === null || lab === undefined)
|
|
42
|
+
return null;
|
|
43
|
+
const newest = [...lab.entries].reverse();
|
|
44
|
+
const shown = all ? newest : newest.slice(0, first);
|
|
45
|
+
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] })] }));
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.js","sourceRoot":"","sources":["../src/history.tsx"],"names":[],"mappings":";AAAA,+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,IAAI,GAAG,CAAC,QAAiB,EAAU,EAAE,CAAC,GAAG,CAAC,K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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,26 @@
|
|
|
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
|
+
*/
|
|
20
|
+
export * from "./window.js";
|
|
21
|
+
export * from "./freezer.js";
|
|
22
|
+
export * from "./people.js";
|
|
23
|
+
export * from "./history.js";
|
|
24
|
+
export * from "./sharing.js";
|
|
25
|
+
export * from "./parts.js";
|
|
26
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
*/
|
|
20
|
+
export * from "./window.js";
|
|
21
|
+
export * from "./freezer.js";
|
|
22
|
+
export * from "./people.js";
|
|
23
|
+
export * from "./history.js";
|
|
24
|
+
export * from "./sharing.js";
|
|
25
|
+
export * from "./parts.js";
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,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":"AAAA,+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,60 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/** The small pieces the panels are made of. */
|
|
3
|
+
import { createContext, useContext, useState } from "react";
|
|
4
|
+
import { useTrouble } from "@biolibs/bionet-react";
|
|
5
|
+
/** How to put words on the clipboard. A host that cannot use the browser's own way supplies one. */
|
|
6
|
+
export const CopyContext = createContext((words) => navigator.clipboard.writeText(words));
|
|
7
|
+
/** A form that asks for one thing and clears itself if it worked. */
|
|
8
|
+
export function Ask({ onAsk, children, className }) {
|
|
9
|
+
const [busy, setBusy] = useState(false);
|
|
10
|
+
const submit = async (event) => {
|
|
11
|
+
event.preventDefault();
|
|
12
|
+
const form = event.currentTarget;
|
|
13
|
+
setBusy(true);
|
|
14
|
+
const { ok } = await onAsk(new FormData(form));
|
|
15
|
+
setBusy(false);
|
|
16
|
+
if (ok)
|
|
17
|
+
form.reset();
|
|
18
|
+
};
|
|
19
|
+
return _jsx("form", { className: className, onSubmit: submit, "aria-busy": busy, children: _jsx("fieldset", { disabled: busy, children: children }) });
|
|
20
|
+
}
|
|
21
|
+
/** A button that copies some words and says that it did. */
|
|
22
|
+
export function Copy({ words, label = "Copy" }) {
|
|
23
|
+
const copy = useContext(CopyContext);
|
|
24
|
+
const [done, setDone] = useState(false);
|
|
25
|
+
return (_jsx("button", { type: "button", className: "quiet", onClick: () => { void copy(words).then(() => { setDone(true); setTimeout(() => setDone(false), 1500); }); }, children: done ? "Copied" : label }));
|
|
26
|
+
}
|
|
27
|
+
/** The last change that was refused, with a way to put it away. Draws nothing when there is none. */
|
|
28
|
+
export function Trouble() {
|
|
29
|
+
const { trouble, dismiss } = useTrouble();
|
|
30
|
+
if (trouble === null)
|
|
31
|
+
return null;
|
|
32
|
+
return _jsxs("p", { role: "alert", className: "trouble", children: [trouble, _jsx("button", { type: "button", className: "plain", onClick: dismiss, children: "dismiss" })] });
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* How the connection to the lab's peer is going, in the words a person would want.
|
|
36
|
+
*
|
|
37
|
+
* @param peer - The connection.
|
|
38
|
+
* @returns One line.
|
|
39
|
+
*/
|
|
40
|
+
export function syncWords(peer) {
|
|
41
|
+
const waiting = peer.pending === 0 ? "" : ` · ${peer.pending} ${peer.pending === 1 ? "change" : "changes"} to send`;
|
|
42
|
+
if (peer.url === null)
|
|
43
|
+
return "No peer set · working on this device only";
|
|
44
|
+
switch (peer.status) {
|
|
45
|
+
case "synced": return "In step with the lab";
|
|
46
|
+
case "syncing": return "Syncing…";
|
|
47
|
+
case "connecting": return `Reaching the lab's peer…${waiting}`;
|
|
48
|
+
case "waiting": return "Waiting to be let in";
|
|
49
|
+
default: return `Offline${waiting}`;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/** A dot and a line saying how the connection to the lab's peer is going. */
|
|
53
|
+
export function SyncStatus({ peer }) {
|
|
54
|
+
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) })] }));
|
|
55
|
+
}
|
|
56
|
+
/** This device's key, to be sent to a keeper. */
|
|
57
|
+
export function DeviceKey({ device }) {
|
|
58
|
+
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."] })] }));
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=parts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parts.js","sourceRoot":"","sources":["../src/parts.tsx"],"names":[],"mapp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QAClC,KAAK,YAAY,CAAC,CAAC,OAAO,2BAA2B,OAAO,EAAE,CAAC;QAC/D,KAAK,SAAS,CAAC,CAAC,OAAO,sBAAsB,CAAC;QAC9C,OAAO,CAAC,CAAC,OAAO,UAAU,OAAO,EAAE,CAAC;IACtC,CAAC;AACH,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,UAAU,CAAC,EAAE,IAAI,EAAsB;IACrD,OAAO,CACL,eAAK,SAAS,EAAC,MAAM,EAAC,KAAK,EAAE,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,GAAG,IAAI,EAAE,aACzD,eAAM,SAAS,EAAE,OAAO,IAAI,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,GAAI,EACzE,yBAAO,SAAS,CAAC,IAAI,CAAC,GAAQ,IAC1B,CACP,CAAC;AACJ,CAAC;AAED,iDAAiD;AACjD,MAAM,UAAU,SAAS,CAAC,EAAE,MAAM,EAAqC;IACrE,OAAO,CACL,eAAK,SAAS,EAAC,QAAQ,aACrB,0BAAK,eAAM,SAAS,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":"AAIA,qGAAqG;AACrG,wBAAgB,MAAM,uCA4CrB"}
|
package/dist/people.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/** The people: who is in the lab, and letting somebody in. */
|
|
3
|
+
import { useAct, useLab } from "@biolibs/bionet-react";
|
|
4
|
+
import { Ask, Copy } from "./parts.js";
|
|
5
|
+
/** The roster, and for a keeper the way to add somebody. Draws nothing until the lab has arrived. */
|
|
6
|
+
export function People() {
|
|
7
|
+
const state = useLab();
|
|
8
|
+
const act = useAct();
|
|
9
|
+
const lab = state?.lab;
|
|
10
|
+
if (state === null || lab === null || lab === undefined)
|
|
11
|
+
return null;
|
|
12
|
+
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." })] }));
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=people.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"people.js","sourceRoot":"","sources":["../src/people.tsx"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,qGAAqG;AACrG,MAAM,UAAU,MAAM;IACpB,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC;IACvB,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC;IACrB,MAAM,GAAG,GAAG,KAAK,EAAE,GAAG,CAAC;IACvB,IAAI,KAAK,KAAK,IAAI,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACrE,OAAO,CACL,8BACE,mBAAS,SAAS,EAAC,MAAM,aACvB,6CAA0B,EAC1B,4BACE,0BAAO,yBAAI,kCAAe,EAAA,gCAAa,EAAA,kCAAe,EAAA,cAAM,IAAK,GAAQ,EACzE,0BACG,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CACvB,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AAC,QAAQ,QAAC,UAAU,EAAE,KAAK,GAAI,IAAQ,EACrH,0CAAiB,gBAAO,IAAI,EAAC,QAAQ,EAAC,QAAQ,QAAC,SAAS,EAAE,GAAG,GAAI,IAAQ,EACzE,kCAAS,kBAAQ,IAAI,EAAC,MAAM,aAAC,iBAAQ,KAAK,EAAC,QAAQ,qDAA8C,EAAA,iBAAQ,KAAK,EAAC,QAAQ,gEAAyD,IAAS,IAAQ,EACjM,iBAAQ,IAAI,EAAC,QAAQ,+BAAwB,IACzC,EACL,KAAK,CAAC,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,CAC5B,eAAK,SAAS,EAAC,QAAQ,aACrB,0BAAK,eAAM,SAAS,EAAC,OAAO,wCAA+B,EAAA,KAAC,IAAI,IAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,EAAC,iBAAiB,GAAG,IAAM,EAC3H,eAAM,SAAS,EAAC,MAAM,YAAE,KAAK,CAAC,IAAI,CAAC,MAAM,GAAQ,IAC7C,CACP,CAAC,CAAC,CAAC,YAAG,SAAS,EAAC,WAAW,oFAAwE,IAC5F,CACX,CAAC,CAAC,CAAC,YAAG,SAAS,EAAC,WAAW,4DAAgD,IAC3E,CACJ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ItemState, PartState } from "@biolibs/bionet";
|
|
2
|
+
/**
|
|
3
|
+
* The parts other labs would be shown: those with a tube that has not been retired and is not empty.
|
|
4
|
+
*
|
|
5
|
+
* @param parts - Every part.
|
|
6
|
+
* @param items - Every item.
|
|
7
|
+
* @returns The parts that would be listed, in order.
|
|
8
|
+
*/
|
|
9
|
+
export declare function listedParts(parts: readonly PartState[], items: readonly ItemState[]): PartState[];
|
|
10
|
+
/** What would be published, a button to publish it, and the peer's settings. Draws nothing until the lab has arrived. */
|
|
11
|
+
export declare function Sharing(): import("react").JSX.Element | null;
|
|
12
|
+
//# sourceMappingURL=sharing.d.ts.map
|
|
@@ -0,0 +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"}
|
package/dist/sharing.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/** Sharing: what other labs are shown, and the lab's web peer. */
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { useAct, useLab } from "@biolibs/bionet-react";
|
|
5
|
+
import { Ask, Copy } from "./parts.js";
|
|
6
|
+
/**
|
|
7
|
+
* The parts other labs would be shown: those with a tube that has not been retired and is not empty.
|
|
8
|
+
*
|
|
9
|
+
* @param parts - Every part.
|
|
10
|
+
* @param items - Every item.
|
|
11
|
+
* @returns The parts that would be listed, in order.
|
|
12
|
+
*/
|
|
13
|
+
export function listedParts(parts, items) {
|
|
14
|
+
const inStock = new Set(items.filter((item) => !item.retired && item.amount > 0).map((item) => item.part));
|
|
15
|
+
return parts.filter((part) => inStock.has(part.checksum));
|
|
16
|
+
}
|
|
17
|
+
/** What would be published, a button to publish it, and the peer's settings. Draws nothing until the lab has arrived. */
|
|
18
|
+
export function Sharing() {
|
|
19
|
+
const state = useLab();
|
|
20
|
+
const act = useAct();
|
|
21
|
+
const [said, setSaid] = useState(null);
|
|
22
|
+
const lab = state?.lab;
|
|
23
|
+
if (state === null || lab === null || lab === undefined)
|
|
24
|
+
return null;
|
|
25
|
+
const listed = listedParts(lab.parts, lab.items);
|
|
26
|
+
const publish = async () => {
|
|
27
|
+
setSaid("Publishing…");
|
|
28
|
+
const answer = await act("publish");
|
|
29
|
+
const result = answer.ok ? answer.result : { ok: false, reason: answer.error, parts: 0 };
|
|
30
|
+
setSaid(result.ok ? `Published: ${result.parts} ${result.parts === 1 ? "part" : "parts"}, signed by this device.` : `Not published. ${result.reason ?? ""}`);
|
|
31
|
+
};
|
|
32
|
+
return (_jsxs(_Fragment, { children: [_jsxs("section", { className: "card", children: [_jsx("h2", { children: "What other labs are shown" }), _jsx("p", { className: "dim small", children: "Only this: which parts the lab has in stock, and whether each can be asked for. Tubes, amounts and who did what stay inside the lab." }), listed.length === 0 ? _jsx("p", { className: "dim", children: "Nothing would be listed: no part has a tube with anything in it." }) : (_jsxs("table", { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "Part" }), _jsx("th", { children: "Length" }), _jsx("th", { children: "Other labs may ask for it" })] }) }), _jsx("tbody", { children: listed.map((part) => _jsxs("tr", { children: [_jsx("td", { children: part.name }), _jsxs("td", { children: [part.length, " bp"] }), _jsx("td", { children: part.offered ? "yes" : "no" })] }, part.checksum)) })] })), _jsxs("div", { className: "row", children: [_jsx("button", { type: "button", onClick: () => void publish(), disabled: state.peer.url === null, children: "Publish this" }), said !== null && _jsx("span", { className: "small", children: said })] }), _jsxs("p", { className: "dim small", children: [state.peer.origin === null ? "Set the lab's web peer below to have somewhere to publish." : _jsxs(_Fragment, { children: ["Published at ", _jsxs("code", { children: [state.peer.origin, "/.well-known/bionet.json"] }), ", signed by this device's key."] }), state.published !== null && _jsxs(_Fragment, { children: [" Last published from this device ", new Date(state.published).toLocaleString(), "."] })] })] }), _jsxs("section", { className: "card", children: [_jsx("h2", { children: "The lab's web peer" }), _jsx("p", { className: "dim small", children: "A server at the lab's address that holds a copy of the lab and passes changes between members who are never online together. It has no key, so it cannot change anything." }), _jsxs(Ask, { onAsk: (data) => act("setPeer", String(data.get("peer") ?? "")), className: "row", children: [_jsx("input", { name: "peer", placeholder: "wss://your-lab.example/sync", defaultValue: state.peer.url ?? "", spellCheck: false }), _jsx("button", { type: "submit", className: "quiet", children: "Use this peer" })] }), state.peer.problem !== null && _jsx("p", { className: "note", children: state.peer.problem }), _jsxs("div", { className: "keybox", children: [_jsxs("div", { children: [_jsx("span", { className: "label", children: "This lab's ID" }), lab.id !== null && _jsx(Copy, { words: lab.id, label: "Copy ID" })] }), _jsx("code", { className: "wrap", children: lab.id }), _jsxs("p", { className: "dim small", children: ["Whoever runs the lab's peer sets this as ", _jsx("code", { children: "BIONET_LAB" }), ", so that it serves this lab and no other."] })] })] })] }));
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=sharing.js.map
|
|
@@ -0,0 +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,EA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,KAAK,CAAC,IAAI,CAAC,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
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** The four things a member looks at. */
|
|
2
|
+
export declare const TABS: readonly ["freezer", "people", "history", "sharing"];
|
|
3
|
+
/** One of them. */
|
|
4
|
+
export type Tab = (typeof TABS)[number];
|
|
5
|
+
/**
|
|
6
|
+
* The window.
|
|
7
|
+
*
|
|
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.
|
|
10
|
+
*/
|
|
11
|
+
export declare function LabWindow({ tab: first, copy }: {
|
|
12
|
+
tab?: Tab;
|
|
13
|
+
copy?: (words: string) => Promise<void>;
|
|
14
|
+
}): import("react").JSX.Element;
|
|
15
|
+
/** Asking who is at this device, before anything else. */
|
|
16
|
+
export declare function Who(): import("react").JSX.Element;
|
|
17
|
+
/** Founding a lab, or joining one. */
|
|
18
|
+
export declare function NoLab(): import("react").JSX.Element | null;
|
|
19
|
+
/** Waiting for a keeper to add this device. */
|
|
20
|
+
export declare function Waiting(): import("react").JSX.Element | null;
|
|
21
|
+
//# sourceMappingURL=window.d.ts.map
|
|
@@ -0,0 +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"}
|
package/dist/window.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* A whole lab application, in one component.
|
|
4
|
+
*
|
|
5
|
+
* It holds no state of its own about the lab. It is told the lab as it stands, every time it
|
|
6
|
+
* changes, and draws it; a button asks for one thing to be done and waits to be told how the lab
|
|
7
|
+
* changed. So what is on screen is always what the signed logs say, and never what a form hoped.
|
|
8
|
+
*
|
|
9
|
+
* It walks a person through the three places they can be: nobody has said who is at this device,
|
|
10
|
+
* the device is in no lab, the device is waiting to be let into one — and then the lab itself.
|
|
11
|
+
*/
|
|
12
|
+
import { useState } from "react";
|
|
13
|
+
import { Logo, Mark, useAct, useLab } from "@biolibs/bionet-react";
|
|
14
|
+
import { Freezer } from "./freezer.js";
|
|
15
|
+
import { History } from "./history.js";
|
|
16
|
+
import { Ask, CopyContext, DeviceKey, SyncStatus, Trouble } from "./parts.js";
|
|
17
|
+
import { People } from "./people.js";
|
|
18
|
+
import { Sharing } from "./sharing.js";
|
|
19
|
+
/** The four things a member looks at. */
|
|
20
|
+
export const TABS = ["freezer", "people", "history", "sharing"];
|
|
21
|
+
/**
|
|
22
|
+
* The window.
|
|
23
|
+
*
|
|
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.
|
|
26
|
+
*/
|
|
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 }) });
|
|
30
|
+
}
|
|
31
|
+
function Body({ first }) {
|
|
32
|
+
const state = useLab();
|
|
33
|
+
const [tab, setTab] = useState(first);
|
|
34
|
+
if (state === null)
|
|
35
|
+
return _jsx("main", { className: "centre", children: _jsx("p", { className: "dim", children: "Opening the lab\u2026" }) });
|
|
36
|
+
if (state.device.person === null)
|
|
37
|
+
return _jsxs("main", { className: "centre", children: [_jsx(Logo, {}), _jsx(Trouble, {}), _jsx(Who, {})] });
|
|
38
|
+
if (state.lab === null)
|
|
39
|
+
return _jsxs("main", { className: "centre", children: [_jsx(Logo, {}), _jsx(Trouble, {}), _jsx(NoLab, {})] });
|
|
40
|
+
if (!state.lab.member)
|
|
41
|
+
return _jsxs("main", { className: "centre", children: [_jsx(Logo, {}), _jsx(Trouble, {}), _jsx(Waiting, {})] });
|
|
42
|
+
const lab = state.lab;
|
|
43
|
+
const label = {
|
|
44
|
+
freezer: `Freezer · ${lab.items.filter((item) => !item.retired).length}`,
|
|
45
|
+
people: `People · ${lab.roster.filter((key) => key.removed === null).length}`,
|
|
46
|
+
history: `History · ${lab.entries.length}`,
|
|
47
|
+
sharing: "Sharing",
|
|
48
|
+
};
|
|
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, {})] })] }));
|
|
50
|
+
}
|
|
51
|
+
/** Asking who is at this device, before anything else. */
|
|
52
|
+
export function Who() {
|
|
53
|
+
const act = useAct();
|
|
54
|
+
return (_jsxs("section", { className: "card narrow", children: [_jsx("h1", { children: "Who is at this device?" }), _jsx("p", { className: "dim", children: "Every change you make is signed by a key made on this device, and shown to your lab under this name. The key never leaves this computer." }), _jsxs(Ask, { onAsk: (data) => act("setPerson", String(data.get("name") ?? "")), className: "row", children: [_jsx("input", { name: "name", placeholder: "Your name", autoFocus: true, required: true, maxLength: 200 }), _jsx("button", { type: "submit", children: "Continue" })] })] }));
|
|
55
|
+
}
|
|
56
|
+
/** Founding a lab, or joining one. */
|
|
57
|
+
export function NoLab() {
|
|
58
|
+
const state = useLab();
|
|
59
|
+
const act = useAct();
|
|
60
|
+
if (state === null)
|
|
61
|
+
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" })] })] })] }));
|
|
63
|
+
}
|
|
64
|
+
/** Waiting for a keeper to add this device. */
|
|
65
|
+
export function Waiting() {
|
|
66
|
+
const state = useLab();
|
|
67
|
+
if (state === null)
|
|
68
|
+
return null;
|
|
69
|
+
return (_jsxs("section", { className: "card narrow", children: [_jsx("h1", { children: "Waiting to be let in" }), _jsx("p", { children: "This device has asked to join a lab, and none of the lab has been sent to it yet. A keeper has to add this device's key, and then it arrives on its own." }), _jsx(DeviceKey, { device: state.device }), _jsx(SyncStatus, { peer: state.peer }), state.peer.problem !== null && _jsx("p", { className: "dim small", children: state.peer.problem })] }));
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=window.js.map
|