@peers-app/peers-ui 0.34.6 → 0.34.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/dist/components/markdown-editor/editor.d.ts +5 -4
  2. package/dist/components/markdown-editor/editor.js +10 -145
  3. package/dist/components/markdown-editor/lexical-editor.d.ts +3 -0
  4. package/dist/components/markdown-editor/lexical-editor.js +153 -0
  5. package/dist/components/markdown-render.d.ts +8 -0
  6. package/dist/components/markdown-render.js +143 -0
  7. package/dist/components/markdown-with-mentions.d.ts +1 -1
  8. package/dist/components/markdown-with-mentions.js +7 -129
  9. package/dist/components/trust-level-dropdown.d.ts +6 -1
  10. package/dist/components/trust-level-dropdown.js +43 -14
  11. package/dist/isolated-screens/focus-relay.d.ts +24 -0
  12. package/dist/isolated-screens/focus-relay.js +104 -0
  13. package/dist/isolated-screens/frame-document.d.ts +7 -0
  14. package/dist/isolated-screens/frame-document.js +11 -1
  15. package/dist/isolated-screens/frame-protocol.d.ts +26 -0
  16. package/dist/isolated-screens/frame-protocol.js +21 -0
  17. package/dist/isolated-screens/frame-runtime.js +47 -14
  18. package/dist/isolated-screens/isolated-screen.d.ts +6 -0
  19. package/dist/isolated-screens/isolated-screen.js +40 -3
  20. package/dist/isolated-screens/piece-frames.js +57 -5
  21. package/dist/isolated-screens/piece-reach.js +17 -6
  22. package/dist/lazy-module.d.ts +17 -0
  23. package/dist/lazy-module.js +26 -0
  24. package/dist/operator-console/console-session.js +1 -9
  25. package/dist/screens/groups/group-members.js +7 -17
  26. package/dist/screens/invites/accept-invite.js +15 -4
  27. package/dist/ui-contracts/piece-height.d.ts +8 -2
  28. package/dist/ui-contracts/piece-height.js +6 -1
  29. package/dist/ui-contracts/piece.js +1 -1
  30. package/package.json +4 -3
@@ -11,6 +11,7 @@ const implement_piece_1 = require("../ui-contracts/implement-piece");
11
11
  const piece_height_1 = require("../ui-contracts/piece-height");
12
12
  const piece_host_1 = require("../ui-contracts/piece-host");
13
13
  const popover_surface_1 = require("../ui-contracts/popover-surface");
14
+ const focus_relay_1 = require("./focus-relay");
14
15
  const frame_component_1 = require("./frame-component");
15
16
  const frame_protocol_1 = require("./frame-protocol");
16
17
  const frame_realm_1 = require("./frame-realm");
@@ -72,6 +73,10 @@ function dispatchEscape(target, key) {
72
73
  }));
73
74
  }
74
75
  const inlineComponents = new Map();
76
+ /** Keep hooks used by the embedder's loading view on its own mount. */
77
+ function LoadingView({ render }) {
78
+ return render();
79
+ }
75
80
  /**
76
81
  * In the host's window: the component that draws a piece in a frame for its provider.
77
82
  *
@@ -94,6 +99,9 @@ function inlinePieceComponent(available, name) {
94
99
  const [bundle, setBundle] = (0, react_1.useState)();
95
100
  const [size, setSize] = (0, react_1.useState)();
96
101
  const [failed, setFailed] = (0, react_1.useState)();
102
+ // The embedder's loading view shows until the piece's frame has drawn the piece.
103
+ const loading = (0, react_1.useContext)(piece_height_1.PieceLoadingContext);
104
+ const [drawn, setDrawn] = (0, react_1.useState)(false);
97
105
  const latest = (0, react_1.useRef)(props);
98
106
  latest.current = props;
99
107
  (0, react_1.useEffect)(() => {
@@ -117,6 +125,7 @@ function inlinePieceComponent(available, name) {
117
125
  onClose: () => latest.current.close(),
118
126
  onSize: (height, width) => setSize({ height, width }),
119
127
  onFailed: (message) => setFailed(message),
128
+ onDrawn: () => setDrawn(true),
120
129
  // On the frame's box, inside any popover around it.
121
130
  onKey: (key) => dispatchEscape(box.current, key),
122
131
  }), []);
@@ -125,13 +134,17 @@ function inlinePieceComponent(available, name) {
125
134
  throw bundle;
126
135
  if (failed !== undefined)
127
136
  throw new Error(failed);
128
- if (!bundle)
137
+ if (!bundle) {
138
+ if (loading)
139
+ return (0, jsx_runtime_1.jsx)(LoadingView, { render: loading });
129
140
  return ((0, jsx_runtime_1.jsx)("div", { className: "peers-piece-loading", "aria-busy": "true", style: { minHeight: 24, width: inPopover ? popoverStartWidth(maxWidth) : undefined } }));
141
+ }
130
142
  const PackageFrame = (0, frame_component_1.packageFrameComponent)();
131
- return ((0, jsx_runtime_1.jsx)("div", { ref: box, style: {
143
+ return ((0, jsx_runtime_1.jsxs)("div", { ref: box, style: {
144
+ position: "relative",
132
145
  width: inPopover ? (size?.width ?? popoverStartWidth(maxWidth)) : "100%",
133
146
  height: mode === "content" ? (size?.height ?? 24) : "100%",
134
- }, children: (0, jsx_runtime_1.jsx)(PackageFrame, { pkg: bundle.pkg, bundle: bundle, content: content, pieceEvents: events, label: bundle.pkg.name }) }));
147
+ }, children: [(0, jsx_runtime_1.jsx)(PackageFrame, { pkg: bundle.pkg, bundle: bundle, content: content, pieceEvents: events, label: bundle.pkg.name }), loading && !drawn ? ((0, jsx_runtime_1.jsx)("div", { style: LOADING_OVER_FRAME, children: (0, jsx_runtime_1.jsx)(LoadingView, { render: loading }) })) : null] }));
135
148
  }
136
149
  const component = InlineFramedPiece;
137
150
  inlineComponents.set(key, component);
@@ -175,6 +188,8 @@ function visibleClip(element, rect) {
175
188
  */
176
189
  const LAYOUT_EVENTS = ["load", "transitionend", "animationend"];
177
190
  const slotComponents = new Map();
191
+ /** The embedder's loading view, over a piece's frame until the frame has drawn the piece. */
192
+ const LOADING_OVER_FRAME = { position: "absolute", inset: 0 };
178
193
  /**
179
194
  * Inside a framed screen: the component that holds a slot for a piece, which the host draws over
180
195
  * it in a frame for the provider.
@@ -196,6 +211,9 @@ function slotPieceComponent(available, name) {
196
211
  const slotRef = (0, react_1.useRef)(null);
197
212
  const [size, setSize] = (0, react_1.useState)();
198
213
  const [failed, setFailed] = (0, react_1.useState)();
214
+ // Keep the embedder's loading view in the slot until the host's frame reports its first draw.
215
+ const loading = (0, react_1.useContext)(piece_height_1.PieceLoadingContext);
216
+ const [drawn, setDrawn] = (0, react_1.useState)(false);
199
217
  const latest = (0, react_1.useRef)(props);
200
218
  latest.current = props;
201
219
  // The slot the host holds for this mount, once its mount request has been answered.
@@ -207,8 +225,27 @@ function slotPieceComponent(available, name) {
207
225
  // Each mount is a slot of its own, so a late answer to an earlier one never touches it.
208
226
  const slotId = (0, peers_sdk_1.newid)();
209
227
  let active = true;
228
+ setDrawn(false);
210
229
  const mine = (payload) => payload?.slotId === slotId;
211
230
  const stops = [
231
+ host.onNotify(frame_protocol_1.HostNotice.pieceDrawn, (payload) => {
232
+ if (!mine(payload))
233
+ return;
234
+ setDrawn(true);
235
+ // Focus that reached the slot first (Tab while the piece loaded, or a popover focusing
236
+ // it as it opened, whose Tab trap then refocuses it without a focus event) goes in now.
237
+ if (document.hasFocus() && document.activeElement === slotRef.current) {
238
+ host.notify(frame_protocol_1.FrameNotice.pieceFocus, { slotId, edge: "first" });
239
+ }
240
+ }),
241
+ // Tab left the piece drawn over this slot: on to the control after it, or back before it.
242
+ host.onNotify(frame_protocol_1.HostNotice.pieceFocusLeave, (payload) => {
243
+ const slot = slotRef.current;
244
+ // The host focused this screen as it sent this; focus the user moved since stays.
245
+ if (!mine(payload) || !slot || !document.hasFocus())
246
+ return;
247
+ (0, focus_relay_1.focusBeside)(slot, payload.direction === "previous" ? "previous" : "next");
248
+ }),
212
249
  host.onNotify(frame_protocol_1.HostNotice.pieceEmit, (payload) => {
213
250
  if (mine(payload))
214
251
  latest.current.emit[payload.name]?.(payload.payload);
@@ -336,10 +373,25 @@ function slotPieceComponent(available, name) {
336
373
  // The piece's error boundary shows the failure, with Retry.
337
374
  if (failed !== undefined)
338
375
  throw new Error(failed);
339
- return ((0, jsx_runtime_1.jsx)("div", { ref: slotRef, "data-peers-piece-slot": "", style: {
376
+ return (
377
+ // biome-ignore lint/a11y/noStaticElementInteractions: it stands in for the piece's frame, which the host draws over it, in the screen's Tab order.
378
+ (0, jsx_runtime_1.jsx)("div", { ref: slotRef, "data-peers-piece-slot": "",
379
+ // Tab stops here in the piece's place; the host moves focus into the piece's frame.
380
+ // biome-ignore lint/a11y/noNoninteractiveTabindex: as above; focus moves straight on into the frame.
381
+ tabIndex: 0, onFocus: (event) => {
382
+ const slotId = mounted.current;
383
+ // Until the piece has drawn its frame may have no controls, so focus waits here.
384
+ if (event.target !== event.currentTarget || !slotId || !drawn)
385
+ return;
386
+ const edge = (0, focus_relay_1.edgeEnteredFrom)(event.currentTarget, event.relatedTarget);
387
+ host?.notify(frame_protocol_1.FrameNotice.pieceFocus, { slotId, edge });
388
+ },
389
+ // A popover has no background of its own. The piece's frame paints it once drawn, and is
390
+ // clear before that, so the loading view shows; the slot paints it until then.
391
+ className: inPopover && !drawn ? "bg-body" : undefined, style: {
340
392
  width: inPopover ? (size?.width ?? popoverStartWidth(maxWidth)) : "100%",
341
393
  height: mode === "content" ? (size?.height ?? 24) : "100%",
342
- } }));
394
+ }, children: loading && !drawn ? (0, jsx_runtime_1.jsx)(LoadingView, { render: loading }) : null }));
343
395
  }
344
396
  const component = SlotFramedPiece;
345
397
  slotComponents.set(key, component);
@@ -5,9 +5,12 @@ const peers_sdk_1 = require("@peers-app/peers-sdk");
5
5
  /**
6
6
  * Whether a framed screen's package may embed a UI contract's pieces: it consumes that UI
7
7
  * contract version (`pkg.consumes`, kept in the manifest's `uiConsumes`), or provides it itself.
8
- * Read from the manifest this device stored for the screen's version, once per version.
8
+ * Read from the manifest this device stored for the screen's version, once per version. A version
9
+ * with no stored manifest yet (a folder-loaded dev build) is read again next time, since
10
+ * promoting it stores its manifest under the same version id.
9
11
  */
10
12
  const known = new Map();
13
+ /** The UI contract versions a manifest declares, or undefined when there's no manifest to read. */
11
14
  async function readDeclared(bundle) {
12
15
  const user = await (0, peers_sdk_1.getUserContext)();
13
16
  const dataContext = bundle.dataContextId === user.userId
@@ -19,17 +22,17 @@ async function readDeclared(bundle) {
19
22
  (0, peers_sdk_1.PackageVersions)(dataContext).get(bundle.packageVersionId),
20
23
  (0, peers_sdk_1.PackageVersionManifests)(dataContext).get(bundle.packageVersionId),
21
24
  ]);
22
- const declared = new Set();
23
25
  if (!pv ||
24
26
  !row ||
25
27
  row.format !== peers_sdk_1.PACKAGE_VERSION_MANIFEST_FORMAT ||
26
28
  row.packageId !== pv.packageId ||
27
29
  row.packageBundleFileHash !== pv.packageBundleFileHash) {
28
- return declared;
30
+ return undefined;
29
31
  }
30
32
  const manifest = JSON.parse(row.manifest);
31
33
  if (!manifest || manifest.packageId !== pv.packageId || manifest.version !== pv.version)
32
- return declared;
34
+ return undefined;
35
+ const declared = new Set();
33
36
  for (const entry of manifest.uiConsumes ?? [])
34
37
  declared.add(`${entry.contractId}@${entry.version}`);
35
38
  for (const entry of (0, peers_sdk_1.providedContracts)(manifest.uiProvides ?? [])) {
@@ -48,9 +51,17 @@ async function consumesUIContract(bundle, contractId, version) {
48
51
  const key = `${bundle.dataContextId}:${bundle.packageVersionId}`;
49
52
  let declared = known.get(key);
50
53
  if (!declared) {
51
- declared = readDeclared(bundle);
54
+ const read = readDeclared(bundle);
55
+ declared = read.then((found) => found ?? new Set());
52
56
  known.set(key, declared);
53
- declared.catch(() => known.delete(key));
57
+ // Keep only a read that found the manifest; read again after a failure or a missing one.
58
+ read.then((found) => {
59
+ if (!found && known.get(key) === declared)
60
+ known.delete(key);
61
+ }, () => {
62
+ if (known.get(key) === declared)
63
+ known.delete(key);
64
+ });
54
65
  }
55
66
  return (await declared).has(`${contractId}@${version}`);
56
67
  }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Defer loading a module until it's first needed, so code most screens never use (the editor,
3
+ * the markdown renderer) isn't compiled and run when peers-ui loads. Every isolated screen and
4
+ * piece is a frame that loads peers-ui on its own, so whatever loads up front, every frame pays.
5
+ *
6
+ * `load` is a `require` inside a function. A bundler then runs that module on the first call:
7
+ * webpack (Electron) and esbuild for any module, Rollup (the PWA) for CommonJS ones only. Rollup
8
+ * runs ES modules (Lexical, react-markdown) up front wherever they're required.
9
+ *
10
+ * A module that throws while loading isn't loaded again: the bundlers keep what it had exported
11
+ * when it threw, so the component fails to draw until the page reloads (the screen's error
12
+ * boundary shows it). Under Jest and Node, the next call tries again.
13
+ *
14
+ * @param load - Loads the module, as `() => require("./x") as typeof import("./x")`.
15
+ * @returns A function that loads the module the first time it's called and returns it after.
16
+ */
17
+ export declare function lazyModule<T>(load: () => T): () => T;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.lazyModule = lazyModule;
4
+ /**
5
+ * Defer loading a module until it's first needed, so code most screens never use (the editor,
6
+ * the markdown renderer) isn't compiled and run when peers-ui loads. Every isolated screen and
7
+ * piece is a frame that loads peers-ui on its own, so whatever loads up front, every frame pays.
8
+ *
9
+ * `load` is a `require` inside a function. A bundler then runs that module on the first call:
10
+ * webpack (Electron) and esbuild for any module, Rollup (the PWA) for CommonJS ones only. Rollup
11
+ * runs ES modules (Lexical, react-markdown) up front wherever they're required.
12
+ *
13
+ * A module that throws while loading isn't loaded again: the bundlers keep what it had exported
14
+ * when it threw, so the component fails to draw until the page reloads (the screen's error
15
+ * boundary shows it). Under Jest and Node, the next call tries again.
16
+ *
17
+ * @param load - Loads the module, as `() => require("./x") as typeof import("./x")`.
18
+ * @returns A function that loads the module the first time it's called and returns it after.
19
+ */
20
+ function lazyModule(load) {
21
+ let loaded;
22
+ return () => {
23
+ loaded ??= { module: load() };
24
+ return loaded.module;
25
+ };
26
+ }
@@ -193,15 +193,6 @@ for (const [name, params] of Object.entries(CONSOLE_PARAMS)) {
193
193
  }
194
194
  /** The Console's own helpers, beside the session's, with their argument hints. */
195
195
  const consoleHelpers = {
196
- help: (0, repl_1.withCallInfo)(function help() {
197
- return CONSOLE_HELP_TEXT;
198
- }, {
199
- name: "help",
200
- kind: "helper",
201
- params: [],
202
- objectArgument: false,
203
- description: "How contracts, these helpers and the Console's keys are used.",
204
- }),
205
196
  print: (0, repl_1.withCallInfo)(function print(...values) {
206
197
  consolePrint(...values);
207
198
  }, {
@@ -240,6 +231,7 @@ async function open(transport) {
240
231
  scope: exports.consoleScope.values,
241
232
  print: (value) => printAt("log", [value], undefined),
242
233
  reserved: [...console_scope_1.CONSOLE_GLOBAL_NAMES, "print", "console", "clear", "$"],
234
+ helpText: CONSOLE_HELP_TEXT,
243
235
  });
244
236
  next.onChange = () => {
245
237
  (0, exports.consoleContext)(next.contextName);
@@ -25,9 +25,14 @@ const GroupMembersUI = (props) => {
25
25
  const members = await groupMembersTable.list({ deleted: { $ne: true } });
26
26
  // Get user details for each member using the group context
27
27
  const membersWithUsers = await Promise.all(members.map(async (member) => {
28
+ // A member whose profile or trust can't be read is listed by id, as one with no
29
+ // profile is, rather than leaving the whole list unloaded.
28
30
  const user = await (0, peers_sdk_1.getUserById)(member.userId, {
29
31
  currentDataContext: groupDataContext,
30
32
  includeTrustLevel: true,
33
+ }).catch((err) => {
34
+ console.error(`Failed to read group member ${member.userId}:`, err);
35
+ return undefined;
31
36
  });
32
37
  // If user found from external source, save to current group
33
38
  if (user && user.source !== "currentDataContext") {
@@ -46,22 +51,6 @@ const GroupMembersUI = (props) => {
46
51
  console.error("Failed to save user to group context:", saveErr);
47
52
  }
48
53
  }
49
- // TODO don't do it this way!!! Use group-specific trust level fetching
50
- if (user && !user.trustLevel) {
51
- const userCursor = await (0, peers_sdk_1.usersCursor)({ userId: member.userId }, { includeTrustLevel: true });
52
- const _user = await userCursor.next();
53
- user.trustLevel = _user?.trustLevel || user.trustLevel || peers_sdk_1.TrustLevel.Unknown;
54
- }
55
- // // Fetch trust level for this user in the group context
56
- // if (user) {
57
- // try {
58
- // const trustLevel = await getUserTrustLevel(groupDataContext, user.userId);
59
- // user.trustLevel = trustLevel;
60
- // } catch (err) {
61
- // console.error('Failed to get trust level:', err);
62
- // user.trustLevel = TrustLevel.Unknown;
63
- // }
64
- // }
65
54
  return {
66
55
  member,
67
56
  user: user || null,
@@ -89,9 +78,10 @@ const GroupMembersUI = (props) => {
89
78
  if (!group) {
90
79
  return null;
91
80
  }
92
- // Try to get founder user details
81
+ // Try to get founder user details. The banner shows only the name, so no trust is read.
93
82
  const founderUser = await (0, peers_sdk_1.getUserById)(group.founderUserId, {
94
83
  currentDataContext: groupDataContext,
84
+ includeTrustLevel: false,
95
85
  });
96
86
  return {
97
87
  group,
@@ -8,8 +8,13 @@ const qr_scanner_1 = require("../../components/qr-scanner");
8
8
  const globals_1 = require("../../globals");
9
9
  const invite_capture_1 = require("./invite-capture");
10
10
  const invites_ipc_1 = require("./invites-ipc");
11
+ /**
12
+ * The trust choices for a new contact. The first, `""`, sets no level, so they follow the default:
13
+ * New User for their first week, then Known (see `getUserTrust`). The others set a level.
14
+ */
11
15
  const TRUST_OPTIONS = [
12
- { value: peers_sdk_1.TrustLevel.NewUser, label: "New user (default)" },
16
+ { value: "", label: "Default: New user for a week, then Known" },
17
+ { value: peers_sdk_1.TrustLevel.NewUser, label: "New user" },
13
18
  { value: peers_sdk_1.TrustLevel.Known, label: "Known" },
14
19
  { value: peers_sdk_1.TrustLevel.Trusted, label: "Trusted" },
15
20
  ];
@@ -42,7 +47,7 @@ function AcceptInvite(props) {
42
47
  const [scanning, setScanning] = (0, react_1.useState)(false);
43
48
  const [preview, setPreview] = (0, react_1.useState)(undefined);
44
49
  const [result, setResult] = (0, react_1.useState)(undefined);
45
- const [trustLevel, setTrustLevel] = (0, react_1.useState)(peers_sdk_1.TrustLevel.NewUser);
50
+ const [trustLevel, setTrustLevel] = (0, react_1.useState)(undefined);
46
51
  const [busy, setBusy] = (0, react_1.useState)(false);
47
52
  const [error, setError] = (0, react_1.useState)("");
48
53
  const runPreview = (0, react_1.useCallback)(async (token) => {
@@ -51,6 +56,7 @@ function AcceptInvite(props) {
51
56
  try {
52
57
  const tools = await (0, invites_ipc_1.inviteTools)();
53
58
  const response = await tools.previewInvite({ token });
59
+ setTrustLevel(undefined);
54
60
  setPreview(response.preview);
55
61
  setText(token);
56
62
  }
@@ -120,7 +126,10 @@ function AcceptInvite(props) {
120
126
  setBusy(true);
121
127
  try {
122
128
  const tools = await (0, invites_ipc_1.inviteTools)();
123
- const response = await tools.acceptInvite({ token: text, trustLevel });
129
+ const response = await tools.acceptInvite({
130
+ token: text,
131
+ ...(preview?.knownContact || trustLevel === undefined ? {} : { trustLevel }),
132
+ });
124
133
  setResult(response.result);
125
134
  }
126
135
  catch (err) {
@@ -149,7 +158,9 @@ function AcceptInvite(props) {
149
158
  setError(message);
150
159
  } }), (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-outline-secondary mt-3", onClick: () => setScanning(false), children: "Cancel" })] }));
151
160
  }
152
- return ((0, jsx_runtime_1.jsx)("div", { style: { maxWidth: 520, margin: "0 auto" }, children: preview ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(PreviewCard, { preview: preview }), !preview.knownContact ? ((0, jsx_runtime_1.jsxs)("div", { className: "mb-3", children: [(0, jsx_runtime_1.jsxs)("label", { htmlFor: "invite-trust", className: "form-label small text-muted mb-1", children: ["Trust level for ", preview.inviter.displayName || "this contact"] }), (0, jsx_runtime_1.jsx)("select", { id: "invite-trust", className: "form-select form-select-sm", value: trustLevel, onChange: (event) => setTrustLevel(Number(event.target.value)), disabled: busy, children: TRUST_OPTIONS.map((option) => ((0, jsx_runtime_1.jsx)("option", { value: option.value, children: option.label }, option.value))) })] })) : null, error ? (0, jsx_runtime_1.jsx)("div", { className: "alert alert-danger py-2", children: error }) : null, (0, jsx_runtime_1.jsxs)("div", { className: "d-flex gap-2", children: [(0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-primary", disabled: busy || preview.expired || preview.group?.alreadyMember, onClick: () => void accept(), children: busy ? "Working…" : preview.type === "group" ? "Join" : "Accept" }), (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-outline-secondary", onClick: reset, children: "Back" })] })] })) : ((0, jsx_runtime_1.jsxs)("form", { onSubmit: (event) => {
161
+ return ((0, jsx_runtime_1.jsx)("div", { style: { maxWidth: 520, margin: "0 auto" }, children: preview ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(PreviewCard, { preview: preview }), !preview.knownContact ? ((0, jsx_runtime_1.jsxs)("div", { className: "mb-3", children: [(0, jsx_runtime_1.jsxs)("label", { htmlFor: "invite-trust", className: "form-label small text-muted mb-1", children: ["Trust level for ", preview.inviter.displayName || "this contact"] }), (0, jsx_runtime_1.jsx)("select", { id: "invite-trust", className: "form-select form-select-sm", value: trustLevel ?? "", onChange: (event) => setTrustLevel(event.target.value === ""
162
+ ? undefined
163
+ : Number(event.target.value)), disabled: busy, children: TRUST_OPTIONS.map((option) => ((0, jsx_runtime_1.jsx)("option", { value: option.value, children: option.label }, option.value))) })] })) : null, error ? (0, jsx_runtime_1.jsx)("div", { className: "alert alert-danger py-2", children: error }) : null, (0, jsx_runtime_1.jsxs)("div", { className: "d-flex gap-2", children: [(0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-primary", disabled: busy || preview.expired || preview.group?.alreadyMember, onClick: () => void accept(), children: busy ? "Working…" : preview.type === "group" ? "Join" : "Accept" }), (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-outline-secondary", onClick: reset, children: "Back" })] })] })) : ((0, jsx_runtime_1.jsxs)("form", { onSubmit: (event) => {
153
164
  event.preventDefault();
154
165
  void runPreview(text);
155
166
  }, children: [(0, jsx_runtime_1.jsx)("label", { htmlFor: "invite-text", className: "form-label", children: "Paste an invite link or code" }), (0, jsx_runtime_1.jsx)("textarea", { id: "invite-text", className: "form-control font-monospace mb-2", rows: 3, value: text, onChange: (event) => setText(event.target.value), placeholder: "https://peers.app/i#\u2026", disabled: busy, spellCheck: false }), error ? (0, jsx_runtime_1.jsx)("div", { className: "alert alert-danger py-2", children: error }) : null, (0, jsx_runtime_1.jsxs)("div", { className: "d-flex gap-2", children: [(0, jsx_runtime_1.jsx)("button", { type: "submit", className: "btn btn-primary", disabled: busy || !text.trim(), children: busy ? "Checking…" : "Continue" }), (0, qr_scanner_1.canScanQr)() ? ((0, jsx_runtime_1.jsxs)("button", { type: "button", className: "btn btn-outline-primary", disabled: busy, onClick: () => setScanning(true), children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-qr-code-scan me-1" }), "Scan QR"] })) : null] })] })) }));
@@ -1,9 +1,10 @@
1
+ import type React from "react";
1
2
  /**
2
3
  * How the box a piece draws in is sized: `fill` for a view that fills its embedder's box,
3
4
  * `content` for one that takes its own height, and for a popover. A piece drawn in a frame of its
4
5
  * own reads it to know whether to report its height.
5
6
  */
6
- export declare const PieceHeightContext: import("react").Context<"fill" | "content">;
7
+ export declare const PieceHeightContext: React.Context<"fill" | "content">;
7
8
  /** The size of the box a piece draws in. */
8
9
  export interface IPieceSize {
9
10
  /** Width in CSS pixels. */
@@ -15,4 +16,9 @@ export interface IPieceSize {
15
16
  * The measured size of the box a piece draws in, which `usePieceSize` reads. `<Piece>` measures
16
17
  * its box; a piece drawn in a frame of its own is measured inside that frame.
17
18
  */
18
- export declare const PieceSizeContext: import("react").Context<IPieceSize>;
19
+ export declare const PieceSizeContext: React.Context<IPieceSize>;
20
+ /**
21
+ * The embedder's `loading` view for the piece drawn here. A piece drawn in a frame of its own
22
+ * keeps showing it until that frame has drawn the piece.
23
+ */
24
+ export declare const PieceLoadingContext: React.Context<(() => React.ReactNode) | undefined>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PieceSizeContext = exports.PieceHeightContext = void 0;
3
+ exports.PieceLoadingContext = exports.PieceSizeContext = exports.PieceHeightContext = void 0;
4
4
  const react_1 = require("react");
5
5
  /**
6
6
  * How the box a piece draws in is sized: `fill` for a view that fills its embedder's box,
@@ -13,3 +13,8 @@ exports.PieceHeightContext = (0, react_1.createContext)("content");
13
13
  * its box; a piece drawn in a frame of its own is measured inside that frame.
14
14
  */
15
15
  exports.PieceSizeContext = (0, react_1.createContext)({ width: 0, height: 0 });
16
+ /**
17
+ * The embedder's `loading` view for the piece drawn here. A piece drawn in a frame of its own
18
+ * keeps showing it until that frame has drawn the piece.
19
+ */
20
+ exports.PieceLoadingContext = (0, react_1.createContext)(undefined);
@@ -225,7 +225,7 @@ function Piece(props) {
225
225
  return unavailable({ reason: "failed", message: checked.error, retry });
226
226
  }
227
227
  const Component = current.component;
228
- const body = ((0, jsx_runtime_1.jsx)(PieceErrorBoundary, { resetKey: Component, name: props.of.name, onRetry: retry, render: (value) => unavailable(value, true), children: (0, jsx_runtime_1.jsx)(PieceAncestry.Provider, { value: inside, children: (0, jsx_runtime_1.jsx)(Component, { props: checked?.value ?? {}, emit: emit ?? {}, close: () => closeRef.current?.(), groupId: available.dataContextId }) }) }, attempt));
228
+ const body = ((0, jsx_runtime_1.jsx)(PieceErrorBoundary, { resetKey: Component, name: props.of.name, onRetry: retry, render: (value) => unavailable(value, true), children: (0, jsx_runtime_1.jsx)(PieceAncestry.Provider, { value: inside, children: (0, jsx_runtime_1.jsx)(piece_height_1.PieceLoadingContext.Provider, { value: props.loading, children: (0, jsx_runtime_1.jsx)(Component, { props: checked?.value ?? {}, emit: emit ?? {}, close: () => closeRef.current?.(), groupId: available.dataContextId }) }) }) }, attempt));
229
229
  if (isPopover) {
230
230
  return ((0, jsx_runtime_1.jsx)(popover_surface_1.PopoverSurface, { anchor: props.anchor, label: props.label, onClose: () => closeRef.current?.(), children: (0, jsx_runtime_1.jsx)(piece_height_1.PieceHeightContext.Provider, { value: "content", children: body }) }));
231
231
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peers-app/peers-ui",
3
- "version": "0.34.6",
3
+ "version": "0.34.7",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/peers-app/peers-ui.git"
@@ -36,7 +36,7 @@
36
36
  "lint:fix": "biome check --write ."
37
37
  },
38
38
  "peerDependencies": {
39
- "@peers-app/peers-sdk": "^0.34.6",
39
+ "@peers-app/peers-sdk": "^0.34.7",
40
40
  "bootstrap": "^5.3.3",
41
41
  "react": "^18.0.0",
42
42
  "react-dom": "^18.0.0"
@@ -47,7 +47,7 @@
47
47
  "@babel/preset-react": "^7.24.1",
48
48
  "@babel/preset-typescript": "^7.27.1",
49
49
  "@biomejs/biome": "2.3.11",
50
- "@peers-app/peers-sdk": "0.34.6",
50
+ "@peers-app/peers-sdk": "0.34.7",
51
51
  "@testing-library/dom": "^10.4.0",
52
52
  "@testing-library/jest-dom": "^6.6.3",
53
53
  "@testing-library/react": "^16.3.0",
@@ -107,6 +107,7 @@
107
107
  "ml-tree-similarity": "^2.2.0",
108
108
  "moment": "^2.30.1",
109
109
  "moment-timezone": "^0.5.46",
110
+ "prismjs": "^1.30.0",
110
111
  "react-infinite-scroll-component": "^6.1.0",
111
112
  "react-markdown": "^9.0.1",
112
113
  "react-qr-code": "^2.2.0",