@peers-app/peers-ui 0.33.12 → 0.33.13

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.
@@ -33,82 +33,105 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.findMentionQuery = findMentionQuery;
36
37
  exports.parseQuery = parseQuery;
37
38
  exports.pickerOptions = pickerOptions;
38
39
  exports.sharedKinds = sharedKinds;
39
40
  exports.MentionsPlugin = MentionsPlugin;
40
41
  const jsx_runtime_1 = require("react/jsx-runtime");
42
+ const code_1 = require("@lexical/code");
43
+ const link_1 = require("@lexical/link");
41
44
  const LexicalComposerContext_1 = require("@lexical/react/LexicalComposerContext");
42
45
  const LexicalTypeaheadMenuPlugin_1 = require("@lexical/react/LexicalTypeaheadMenuPlugin");
46
+ const utils_1 = require("@lexical/utils");
43
47
  const peers_sdk_1 = require("@peers-app/peers-sdk");
44
48
  const lexical_1 = require("lexical");
45
49
  const react_1 = require("react");
46
50
  const ReactDOM = __importStar(require("react-dom"));
51
+ const use_observable_1 = require("../../hooks/use-observable");
47
52
  const mentions_client_1 = require("../../mentions/mentions-client");
48
53
  const mention_node_1 = require("./mention-node");
49
54
  const mention_preview_card_1 = require("./mention-preview-card");
55
+ // ---- Finding a query: a trigger, at the start of a word, then what's typed up to the caret. ----
56
+ /** Punctuation that ends a query, unless a join allows it (from Lexical's mentions example). */
50
57
  const PUNCTUATION = "\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;";
51
- const NAME = `\\b[A-Z][^\\s${PUNCTUATION}]`;
52
- const DocumentMentionsRegex = {
53
- NAME,
54
- PUNCTUATION,
55
- };
56
- const PUNC = DocumentMentionsRegex.PUNCTUATION;
57
- // `@` or `<` starts the picker (Mark, 2026-11-14: `<` as well as `@`); `@kind:` narrows the search
58
- // to one kind.
59
- const TRIGGERS = "@<";
60
- // Chars we expect to see in a mention (non-space, non-punctuation).
61
- const VALID_CHARS = `[^${TRIGGERS}${PUNC}\\s]`;
62
- // Non-standard series of chars. Each series must be preceded and followed by
63
- // a valid char.
64
- const VALID_JOINS = "(?:" +
65
- "\\.[ |$]|" + // E.g. "r. " in "Mr. Smith"
66
- " |" + // E.g. " " in "Josh Duck"
67
- "[" +
68
- PUNC +
69
- "]|" + // E.g. "-' in "Salier-Hellendag"
70
- ")";
58
+ /**
59
+ * What may come between a query's characters: a space ("Josh Duck"), punctuation
60
+ * ("Salier-Hellendag"), or ". " ("Mr. Smith").
61
+ */
62
+ const VALID_JOINS = `(?:\\.[ |$]| |[${PUNCTUATION}]|)`;
63
+ /** The most characters a query may have, each with an optional join after it. */
71
64
  const LENGTH_LIMIT = 75;
72
- const AtSignMentionsRegex = new RegExp("(^|\\s|\\()(" +
73
- "[" +
74
- TRIGGERS +
75
- "]" +
76
- "((?:" +
77
- VALID_CHARS +
78
- VALID_JOINS +
79
- "){0," +
80
- LENGTH_LIMIT +
81
- "})" +
82
- ")$");
83
- // 50 is the longest alias length limit.
84
- const ALIAS_LENGTH_LIMIT = 50;
85
- // Regex used to match alias.
86
- const AtSignMentionsRegexAliasRegex = new RegExp("(^|\\s|\\()(" +
87
- "[" +
88
- TRIGGERS +
89
- "]" +
90
- "((?:" +
91
- VALID_CHARS +
92
- "){0," +
93
- ALIAS_LENGTH_LIMIT +
94
- "})" +
95
- ")$");
65
+ const patternsByTriggers = new Map();
66
+ /**
67
+ * The regex that finds a query ending at the caret, for a set of triggers, built once per set. A
68
+ * trigger counts at the start of the text, or after whitespace or `(`: group 1 is what came before
69
+ * it, group 2 the trigger and the query, group 3 the query.
70
+ *
71
+ * @param triggers - The characters that open the picker, such as `@`, `<` and `#`.
72
+ */
73
+ function triggerPattern(triggers) {
74
+ const chars = triggers.join("").replace(/[\\\]^-]/g, "\\$&");
75
+ let pattern = patternsByTriggers.get(chars);
76
+ if (!pattern) {
77
+ const validChars = `[^${chars}${PUNCTUATION}\\s]`;
78
+ pattern = new RegExp(`(^|\\s|\\()([${chars}]((?:${validChars}${VALID_JOINS}){0,${LENGTH_LIMIT}}))$`);
79
+ patternsByTriggers.set(chars, pattern);
80
+ }
81
+ return pattern;
82
+ }
83
+ /**
84
+ * The query ending at the caret, if the text before it has one: a trigger at the start of a
85
+ * word, then at least one character. A trigger on its own, or one followed by a space, isn't a
86
+ * query, so `# ` at the start of a line stays a heading.
87
+ *
88
+ * @param text - The text before the caret, in its text node.
89
+ * @param triggers - The characters that open the picker.
90
+ */
91
+ function findMentionQuery(text, triggers) {
92
+ const match = triggerPattern(triggers).exec(text);
93
+ if (!match || match[3].length < 1)
94
+ return null;
95
+ // The leading whitespace or `(` isn't part of what's replaced.
96
+ return {
97
+ leadOffset: match.index + match[1].length,
98
+ matchingString: match[2],
99
+ replaceableString: match[2],
100
+ };
101
+ }
102
+ /**
103
+ * Whether the caret is where a mention can't go: in code, where `#` and `@` are code
104
+ * (`#include`), or in a link's text, where a chip would be saved as its label.
105
+ */
106
+ function $caretInCodeOrLink() {
107
+ const selection = (0, lexical_1.$getSelection)();
108
+ if (!(0, lexical_1.$isRangeSelection)(selection))
109
+ return false;
110
+ const node = selection.anchor.getNode();
111
+ if ((0, lexical_1.$isTextNode)(node) && node.hasFormat("code"))
112
+ return true;
113
+ return (0, utils_1.$findMatchingParent)(node, (n) => (0, code_1.$isCodeNode)(n) || (0, link_1.$isLinkNode)(n)) !== null;
114
+ }
96
115
  /** Most suggestions shown. */
97
116
  const SUGGESTION_LIST_LENGTH_LIMIT = 10;
98
117
  /** How long typing pauses before a search. */
99
118
  const SEARCH_DEBOUNCE_MS = 120;
100
119
  /**
101
- * What the user typed after `@` or `<`: words, and a kind when it starts with `kind:`.
120
+ * What the user typed: the trigger, then words, and a kind filter when the words start with one
121
+ * word and a colon (`<tasks:shed`). System Mentions matches the filter loosely, and reads it as
122
+ * words when it names no kind.
102
123
  *
103
- * @param query - The text from the trigger on, such as `@task:garden`.
124
+ * @param query - The text from the trigger on, such as `<task:garden` or `#work`.
104
125
  */
105
126
  function parseQuery(query) {
106
- const typed = query.replace(/^[@<]/, "");
127
+ const trigger = query.charAt(0);
128
+ const typed = query.slice(1);
107
129
  const colon = typed.indexOf(":");
108
- const kind = colon > 0 ? typed.slice(0, colon).toLowerCase() : "";
109
- if ((0, peers_sdk_1.isMentionKind)(kind))
110
- return { text: typed.slice(colon + 1), kinds: [kind] };
111
- return { text: typed };
130
+ const kindFilter = colon > 0 ? typed.slice(0, colon) : "";
131
+ if (peers_sdk_1.MENTION_KIND_FILTER_PATTERN.test(kindFilter)) {
132
+ return { trigger, text: typed.slice(colon + 1), kindFilter };
133
+ }
134
+ return { trigger, text: typed };
112
135
  }
113
136
  /**
114
137
  * Search System Mentions as the user types: debounced, and a newer query replaces an older one,
@@ -147,12 +170,12 @@ function useMentionSearch(query, groupId) {
147
170
  return found;
148
171
  }
149
172
  /**
150
- * The result offered for a pasted id that matches nothing: a link to whatever has that id, or to
151
- * the kind the user typed before it (`<task:<id>`).
173
+ * The result offered for a pasted id that matches nothing: a link to whatever has that id
174
+ * (`peers://ref/<id>`), which comes alive if the record turns up later, whatever its kind.
152
175
  */
153
- function unknownIdResult(id, kind = peers_sdk_1.ANY_MENTION_KIND) {
176
+ function unknownIdResult(id) {
154
177
  return {
155
- kind,
178
+ kind: peers_sdk_1.ANY_MENTION_KIND,
156
179
  id,
157
180
  kindLabel: "Not found",
158
181
  title: id,
@@ -165,9 +188,10 @@ function unknownIdResult(id, kind = peers_sdk_1.ANY_MENTION_KIND) {
165
188
  * What the picker offers for a query, and whether one result should be taken without asking.
166
189
  *
167
190
  * - Words: the results, as they are.
168
- * - A pasted id (`@<id>` or `<<id>`), once its search has answered: the one record with that id,
169
- * taken at once; nothing found, a link to whatever has the id, taken at once; several records
170
- * (the same id in two kinds), offered to pick from. Before the answer, nothing.
191
+ * - A pasted id (after any trigger, such as `<<id>`), once its search has answered: the one
192
+ * record with that id, taken at once; nothing found, a link to whatever has the id, taken at
193
+ * once; several records (the same id in two kinds), offered to pick from. Before the answer,
194
+ * nothing.
171
195
  *
172
196
  * @param query - The text from the trigger on, or null when the picker is closed.
173
197
  * @param found - The latest search answer.
@@ -176,40 +200,17 @@ function unknownIdResult(id, kind = peers_sdk_1.ANY_MENTION_KIND) {
176
200
  function pickerOptions(query, found, declined) {
177
201
  if (!query)
178
202
  return { results: [] };
179
- const { text, kinds } = parseQuery(query);
203
+ const { text } = parseQuery(query);
180
204
  if (!(0, peers_sdk_1.looksLikeRecordId)(text))
181
205
  return { results: found.results };
182
206
  if (found.query !== query)
183
207
  return { results: [] };
184
208
  const exact = found.results.filter((r) => r.id === text);
185
- const results = exact.length ? exact : [unknownIdResult(text, kinds?.[0])];
209
+ const results = exact.length ? exact : [unknownIdResult(text)];
186
210
  if (results.length > 1 || declined === query)
187
211
  return { results };
188
212
  return { results, autoPick: results[0] };
189
213
  }
190
- function checkForAtSignMentions(text, minMatchLength) {
191
- let match = AtSignMentionsRegex.exec(text);
192
- if (match === null) {
193
- match = AtSignMentionsRegexAliasRegex.exec(text);
194
- }
195
- if (match !== null) {
196
- // The strategy ignores leading whitespace but we need to know it's
197
- // length to add it to the leadOffset
198
- const maybeLeadingWhitespace = match[1];
199
- const matchingString = match[3];
200
- if (matchingString.length >= minMatchLength) {
201
- return {
202
- leadOffset: match.index + maybeLeadingWhitespace.length,
203
- matchingString: match[2],
204
- replaceableString: match[2],
205
- };
206
- }
207
- }
208
- return null;
209
- }
210
- function getPossibleQueryMatch(text) {
211
- return checkForAtSignMentions(text, 1);
212
- }
213
214
  class MentionTypeaheadOption extends LexicalTypeaheadMenuPlugin_1.MenuOption {
214
215
  result;
215
216
  showPackage;
@@ -279,13 +280,28 @@ function previewSide(anchor) {
279
280
  return "is-preview-below";
280
281
  }
281
282
  /**
282
- * The mention picker, opened by `@` or `<`: people first, then records from every group the user
283
- * is in, through System Mentions, with a preview of the highlighted one. Picking one inserts a
284
- * mention chip labeled with the record's title. A pasted id becomes a chip at once: the record's,
285
- * or a dotted `?` chip for an id that matches nothing.
283
+ * The mention picker: `<` finds everything (people, then records from every group the user is
284
+ * in), `@` people only, and a trigger a mention source declares (`#`) that source's records,
285
+ * through System Mentions, with a preview of the highlighted one. `<tasks:` narrows to a kind.
286
+ * Picking one inserts a mention chip labeled with the record's title. A pasted id, after any
287
+ * trigger, becomes a chip at once: the record's, or a dotted `?` chip for an id that matches
288
+ * nothing. It doesn't open in code or in a link's text.
289
+ *
290
+ * The triggers come from System Mentions, which is asked when the editor is first focused, and
291
+ * moves them when packages change.
286
292
  */
287
293
  function MentionsPlugin(props) {
288
294
  const [editor] = (0, LexicalComposerContext_1.useLexicalComposerContext)();
295
+ const [triggers] = (0, use_observable_1.useObservable)(mentions_client_1.mentionTriggers);
296
+ // Learn the triggers when someone is about to type, not when the editor first shows.
297
+ (0, react_1.useEffect)(() => {
298
+ if (editor.getRootElement()?.contains(document.activeElement))
299
+ (0, mentions_client_1.followMentionTriggers)();
300
+ return editor.registerCommand(lexical_1.FOCUS_COMMAND, () => {
301
+ (0, mentions_client_1.followMentionTriggers)();
302
+ return false;
303
+ }, lexical_1.COMMAND_PRIORITY_LOW);
304
+ }, [editor]);
289
305
  const [queryString, setQueryString] = (0, react_1.useState)(null);
290
306
  const found = useMentionSearch(queryString, props.groupId);
291
307
  const { docGroup } = found;
@@ -326,12 +342,12 @@ function MentionsPlugin(props) {
326
342
  });
327
343
  }, [editor]);
328
344
  const checkForMentionMatch = (0, react_1.useCallback)((text) => {
329
- const slashMatch = checkForSlashTriggerMatch(text, editor);
330
- if (slashMatch !== null) {
345
+ if (checkForSlashTriggerMatch(text, editor) !== null)
331
346
  return null;
332
- }
333
- return getPossibleQueryMatch(text);
334
- }, [checkForSlashTriggerMatch, editor]);
347
+ if (editor.getEditorState().read($caretInCodeOrLink))
348
+ return null;
349
+ return findMentionQuery(text, triggers);
350
+ }, [checkForSlashTriggerMatch, editor, triggers]);
335
351
  return ((0, jsx_runtime_1.jsx)(LexicalTypeaheadMenuPlugin_1.LexicalTypeaheadMenuPlugin, { onQueryChange: (query) => {
336
352
  // Closing the menu (null) keeps it, so an undo right after doesn't pick it again.
337
353
  if (query !== null && query !== autoPicked.current)
@@ -1,19 +1,33 @@
1
- import { type IMentionPlace, type IMentionRef, type IMentionSearchResult, type IMentionsConsumer, type IMentionsSearchInput } from "@peers-app/peers-sdk";
1
+ import { type IMentionPlace, type IMentionRef, type IMentionSearchResult, type IMentionsConsumer, type IMentionsSearchInput, type Observable } from "@peers-app/peers-sdk";
2
2
  /** Shared handle for System Mentions on the local host. */
3
3
  export declare const mentionsContract: import("@peers-app/peers-sdk").IHostContractConsumer<IMentionsConsumer>;
4
4
  /**
5
5
  * Find records to mention: people, and records packages declare, best first.
6
6
  *
7
- * @param input - The words, optional kinds, the document's group, and a limit.
7
+ * @param input - The words, the trigger they were typed after, optional kinds, the document's
8
+ * group, and a limit.
8
9
  */
9
10
  export declare function searchMentions(input: IMentionsSearchInput): Promise<IMentionSearchResult[]>;
10
11
  /** The active group's id (the user's id for Personal). */
11
12
  export declare function activeGroupId(): Promise<string>;
13
+ /**
14
+ * The characters that open the mention picker: `@` (people) and `<` (everything), then each
15
+ * trigger a mention source declares, as System Mentions last listed them. Just `@` and `<` until
16
+ * it has answered. It's followed once {@link followMentionTriggers} has been called or a chip has
17
+ * resolved, and then moves only when packages change the sources.
18
+ */
19
+ export declare const mentionTriggers: Observable<readonly string[]>;
20
+ /**
21
+ * Start following System Mentions, if nothing has yet, so {@link mentionTriggers} is current.
22
+ * Cheap to call again; a failed connection is retried on the next call. The editor calls it when
23
+ * it's focused, so nothing is asked before someone is about to type.
24
+ */
25
+ export declare function followMentionTriggers(): void;
12
26
  /**
13
27
  * Moves whenever the cached places are dropped because a mentionable record may have changed;
14
28
  * mounted chips resolve again.
15
29
  */
16
- export declare const mentionsRevision: import("@peers-app/peers-sdk").Observable<number>;
30
+ export declare const mentionsRevision: Observable<number>;
17
31
  /**
18
32
  * A mention's place if it's already cached: the place, `null` when it's known to be nowhere the
19
33
  * user can read, or `undefined` when it hasn't been resolved since the last change.
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mentionsRevision = exports.mentionsContract = void 0;
3
+ exports.mentionsRevision = exports.mentionTriggers = exports.mentionsContract = void 0;
4
4
  exports.searchMentions = searchMentions;
5
5
  exports.activeGroupId = activeGroupId;
6
+ exports.followMentionTriggers = followMentionTriggers;
6
7
  exports.cachedMentionPlace = cachedMentionPlace;
7
8
  exports.resolveMentionPlace = resolveMentionPlace;
8
9
  exports.openMentionPlace = openMentionPlace;
@@ -16,7 +17,8 @@ exports.mentionsContract = (0, peers_sdk_1.hostContractConsumer)((0, peers_sdk_1
16
17
  /**
17
18
  * Find records to mention: people, and records packages declare, best first.
18
19
  *
19
- * @param input - The words, optional kinds, the document's group, and a limit.
20
+ * @param input - The words, the trigger they were typed after, optional kinds, the document's
21
+ * group, and a limit.
20
22
  */
21
23
  async function searchMentions(input) {
22
24
  const consumer = await exports.mentionsContract.get();
@@ -27,6 +29,28 @@ async function activeGroupId() {
27
29
  const userContext = await (0, peers_sdk_1.getUserContext)();
28
30
  return userContext.currentlyActiveGroupId() || userContext.userId;
29
31
  }
32
+ // ---- Triggers: which characters open the picker, kept current while System Mentions is followed. ----
33
+ /**
34
+ * The characters that open the mention picker: `@` (people) and `<` (everything), then each
35
+ * trigger a mention source declares, as System Mentions last listed them. Just `@` and `<` until
36
+ * it has answered. It's followed once {@link followMentionTriggers} has been called or a chip has
37
+ * resolved, and then moves only when packages change the sources.
38
+ */
39
+ exports.mentionTriggers = (0, peers_sdk_1.observable)((0, peers_sdk_1.mentionTriggersInUse)([]));
40
+ /**
41
+ * Start following System Mentions, if nothing has yet, so {@link mentionTriggers} is current.
42
+ * Cheap to call again; a failed connection is retried on the next call. The editor calls it when
43
+ * it's focused, so nothing is asked before someone is about to type.
44
+ */
45
+ function followMentionTriggers() {
46
+ watchSystemMentions();
47
+ }
48
+ /** Take a `triggers` value from System Mentions, keeping only characters this Peers knows. */
49
+ function takeTriggers(value) {
50
+ const next = (0, peers_sdk_1.mentionTriggersInUse)(Array.isArray(value) ? value : []);
51
+ if (next.join("") !== (0, exports.mentionTriggers)().join(""))
52
+ (0, exports.mentionTriggers)(next);
53
+ }
30
54
  // ---- Rendering: each ref's nearest place, batched and cached until System Mentions changes. ----
31
55
  /**
32
56
  * Moves whenever the cached places are dropped because a mentionable record may have changed;
@@ -54,7 +78,11 @@ function dropCache() {
54
78
  }
55
79
  (0, exports.mentionsRevision)((0, exports.mentionsRevision)() + 1);
56
80
  }
57
- function watchChanges() {
81
+ /**
82
+ * Follow the current System Mentions consumer: its `changes` drop the cached places, and its
83
+ * `triggers` set {@link mentionTriggers}. A new host connection is followed the same way.
84
+ */
85
+ function watchSystemMentions() {
58
86
  if (!watchingTransport) {
59
87
  watchingTransport = true;
60
88
  // A new host connection brings a new consumer: watch its `changes`, and resolve again.
@@ -62,7 +90,7 @@ function watchChanges() {
62
90
  watching = undefined;
63
91
  if (transport) {
64
92
  dropCache();
65
- watchChanges();
93
+ watchSystemMentions();
66
94
  }
67
95
  }, { emitCurrent: false });
68
96
  }
@@ -74,7 +102,7 @@ function watchChanges() {
74
102
  .then((consumer) => {
75
103
  if (watching !== attempt)
76
104
  return;
77
- const { changes } = consumer.observables;
105
+ const { changes, triggers } = consumer.observables;
78
106
  let seen = changes();
79
107
  changes.subscribe((value) => {
80
108
  if (value === seen)
@@ -82,6 +110,8 @@ function watchChanges() {
82
110
  seen = value;
83
111
  dropCache();
84
112
  });
113
+ takeTriggers(triggers());
114
+ triggers.subscribe(takeTriggers);
85
115
  })
86
116
  .catch((error) => {
87
117
  if (watching === attempt)
@@ -108,7 +138,7 @@ function cachedMentionPlace(ref, groupId = "") {
108
138
  * @param groupId - The document's group, or `""` when it isn't known.
109
139
  */
110
140
  function resolveMentionPlace(ref, groupId = "") {
111
- watchChanges();
141
+ watchSystemMentions();
112
142
  const key = keyOf(groupId, ref);
113
143
  const cached = cache.get(key);
114
144
  if (cached !== undefined)
@@ -88,7 +88,7 @@ const PackageInfo = (props) => {
88
88
  void (0, host_shell_consumer_1.openOnHost)(remoteRepoUrl);
89
89
  }, children: "Open Remote" })) : ((0, jsx_runtime_1.jsx)("button", { className: "btn btn-sm btn-link", onClick: () => {
90
90
  void navigator.clipboard?.writeText(remoteRepoUrl);
91
- }, children: "Copy" }))] })] }), (0, jsx_runtime_1.jsx)(input_1.Input, { value: pkg.qs.remoteRepo, className: "form-control mb-3 p-0 ps-2", disabled: true })] })) : null, (0, jsx_runtime_1.jsxs)("div", { className: "mt-2", children: [(0, jsx_runtime_1.jsxs)("small", { children: ["Update URL:", (0, jsx_runtime_1.jsx)("small", { children: (0, jsx_runtime_1.jsx)(tooltip_1.Tooltip, { markdownContent: `Base URL for remote package updates. Admin devices poll **<updateUrl>/latest-<tag>.json** on startup (for example **latest-stable.json**). Signed artifacts must be published to this host separately — for example via the publish-package tool or the peers-core full-release pipeline.` }) })] }), (0, jsx_runtime_1.jsx)(input_1.Input, { value: pkg.qs.updateUrl, className: "form-control mb-3 p-0 ps-2", placeholder: "https://example.com/my-package", title: "Update URL" })] }), (0, jsx_runtime_1.jsxs)("div", { className: "mt-2", children: [(0, jsx_runtime_1.jsx)("hr", {}), (0, jsx_runtime_1.jsxs)("small", { children: ["Version:", (0, jsx_runtime_1.jsx)(tooltip_1.Tooltip, { markdownContent: "The currently active version of this package. Manage versions in the Versions tab." })] }), activeVersion ? ((0, jsx_runtime_1.jsxs)("div", { className: "d-flex align-items-center mt-1 mb-3", children: [(0, jsx_runtime_1.jsxs)("strong", { className: "me-2", children: ["v", activeVersion.version] }), activeVersion.versionTag && ((0, jsx_runtime_1.jsx)("span", { className: `badge ${activeVersion.versionTag === "dev" ? "text-bg-danger" : activeVersion.versionTag.startsWith("beta") ? "text-bg-warning" : "text-bg-success"} me-2`, children: activeVersion.versionTag })), (0, jsx_runtime_1.jsx)("code", { className: "text-muted small me-2", children: activeVersion.packageVersionHash?.substring(0, 8) }), newerLevel === "uptodate" ? ((0, jsx_runtime_1.jsx)("span", { className: "badge text-bg-success", children: "Up to date" })) : newerLevel ? ((0, jsx_runtime_1.jsxs)("span", { className: `badge text-bg-${newerLevel === "major" ? "danger" : newerLevel === "minor" ? "warning" : "info"}`, children: ["Newer ", newerLevel, " version available"] })) : null] })) : ((0, jsx_runtime_1.jsx)("div", { className: "text-muted small mt-1 mb-3", children: "No active version" })), (0, jsx_runtime_1.jsxs)("div", { className: "mb-3", children: [(0, jsx_runtime_1.jsxs)("small", { children: ["Auto-Update Range:", (0, jsx_runtime_1.jsx)(tooltip_1.Tooltip, { markdownContent: "Controls which new versions are auto-activated for the group. When an admin device auto-upgrades, the group's active version advances for everyone. **Pinned** = never auto-update. **Patch** = same major.minor (e.g. 1.2.x). **Minor** = same major (e.g. 1.x.x). **Latest** = always auto-update to newest." })] }), (0, jsx_runtime_1.jsxs)("select", { className: "form-select form-select-sm", value: groupRange, onChange: (e) => saveFollowPolicy({
91
+ }, children: "Copy" }))] })] }), (0, jsx_runtime_1.jsx)(input_1.Input, { value: pkg.qs.remoteRepo, className: "form-control mb-3 p-0 ps-2", disabled: true })] })) : null, (0, jsx_runtime_1.jsxs)("div", { className: "mt-2", children: [(0, jsx_runtime_1.jsxs)("small", { children: ["Update URL:", (0, jsx_runtime_1.jsx)("small", { children: (0, jsx_runtime_1.jsx)(tooltip_1.Tooltip, { markdownContent: `Base URL for remote package updates. Admin devices poll **<updateUrl>/latest-<tag>.json** on startup (for example **latest-stable.json**). Signed artifacts must be published to this host separately — for example via the publish-package tool (Tasks uses \`scripts/publish-peers-core.mjs\`).` }) })] }), (0, jsx_runtime_1.jsx)(input_1.Input, { value: pkg.qs.updateUrl, className: "form-control mb-3 p-0 ps-2", placeholder: "https://example.com/my-package", title: "Update URL" })] }), (0, jsx_runtime_1.jsxs)("div", { className: "mt-2", children: [(0, jsx_runtime_1.jsx)("hr", {}), (0, jsx_runtime_1.jsxs)("small", { children: ["Version:", (0, jsx_runtime_1.jsx)(tooltip_1.Tooltip, { markdownContent: "The currently active version of this package. Manage versions in the Versions tab." })] }), activeVersion ? ((0, jsx_runtime_1.jsxs)("div", { className: "d-flex align-items-center mt-1 mb-3", children: [(0, jsx_runtime_1.jsxs)("strong", { className: "me-2", children: ["v", activeVersion.version] }), activeVersion.versionTag && ((0, jsx_runtime_1.jsx)("span", { className: `badge ${activeVersion.versionTag === "dev" ? "text-bg-danger" : activeVersion.versionTag.startsWith("beta") ? "text-bg-warning" : "text-bg-success"} me-2`, children: activeVersion.versionTag })), (0, jsx_runtime_1.jsx)("code", { className: "text-muted small me-2", children: activeVersion.packageVersionHash?.substring(0, 8) }), newerLevel === "uptodate" ? ((0, jsx_runtime_1.jsx)("span", { className: "badge text-bg-success", children: "Up to date" })) : newerLevel ? ((0, jsx_runtime_1.jsxs)("span", { className: `badge text-bg-${newerLevel === "major" ? "danger" : newerLevel === "minor" ? "warning" : "info"}`, children: ["Newer ", newerLevel, " version available"] })) : null] })) : ((0, jsx_runtime_1.jsx)("div", { className: "text-muted small mt-1 mb-3", children: "No active version" })), (0, jsx_runtime_1.jsxs)("div", { className: "mb-3", children: [(0, jsx_runtime_1.jsxs)("small", { children: ["Auto-Update Range:", (0, jsx_runtime_1.jsx)(tooltip_1.Tooltip, { markdownContent: "Controls which new versions are auto-activated for the group. When an admin device auto-upgrades, the group's active version advances for everyone. **Pinned** = never auto-update. **Patch** = same major.minor (e.g. 1.2.x). **Minor** = same major (e.g. 1.x.x). **Latest** = always auto-update to newest." })] }), (0, jsx_runtime_1.jsxs)("select", { className: "form-select form-select-sm", value: groupRange, onChange: (e) => saveFollowPolicy({
92
92
  versionFollowRange: e.target.value,
93
93
  }), children: [(0, jsx_runtime_1.jsx)("option", { value: "latest", children: "Latest (auto-update to newest)" }), (0, jsx_runtime_1.jsx)("option", { value: "minor", children: "Minor (same major version)" }), (0, jsx_runtime_1.jsx)("option", { value: "patch", children: "Patch (same major.minor version)" }), (0, jsx_runtime_1.jsx)("option", { value: "pinned", children: "Pinned (no auto-updates)" })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: `mb-3 ${groupRange === "pinned" ? "opacity-50" : ""}`, children: [(0, jsx_runtime_1.jsxs)("small", { children: ["Following:", (0, jsx_runtime_1.jsx)(tooltip_1.Tooltip, { markdownContent: "Which release channel the group follows. Devices using group settings will auto-upgrade within this channel. **Stable** = only fully promoted releases. **Stable + Beta** = also includes beta pre-releases for early testing." })] }), (0, jsx_runtime_1.jsxs)("select", { className: "form-select form-select-sm", value: groupFollowTags, disabled: groupRange === "pinned", onChange: (e) => saveFollowPolicy({
94
94
  followVersionTags: e.target.value === "stable" ? undefined : e.target.value,
@@ -5,8 +5,8 @@ interface IPackageRuntimeProps {
5
5
  /** Small badge with a package's runtime status on this device; renders nothing until known. */
6
6
  export declare const PackageRuntimeBadge: ({ packageId }: IPackageRuntimeProps) => import("react/jsx-runtime").JSX.Element;
7
7
  /**
8
- * Runtime status on this device: badge, running version, and the last load or worker
9
- * failure.
8
+ * Runtime status on this device: badge, running version, what a waiting version needs, and the
9
+ * last load or worker failure.
10
10
  */
11
11
  export declare const PackageRuntimeStatus: ({ packageId }: IPackageRuntimeProps) => import("react/jsx-runtime").JSX.Element | null;
12
12
  export {};
@@ -10,8 +10,8 @@ const PackageRuntimeBadge = ({ packageId }) => {
10
10
  };
11
11
  exports.PackageRuntimeBadge = PackageRuntimeBadge;
12
12
  /**
13
- * Runtime status on this device: badge, running version, and the last load or worker
14
- * failure.
13
+ * Runtime status on this device: badge, running version, what a waiting version needs, and the
14
+ * last load or worker failure.
15
15
  */
16
16
  const PackageRuntimeStatus = ({ packageId }) => {
17
17
  const state = (0, packages_ipc_1.usePackageRuntimeStates)()?.[packageId];
@@ -19,7 +19,7 @@ const PackageRuntimeStatus = ({ packageId }) => {
19
19
  return null;
20
20
  const running = state.running;
21
21
  const workerError = state.worker?.lastWorkerError;
22
- return ((0, jsx_runtime_1.jsxs)("div", { className: "mb-3", "data-testid": "package-runtime-status", children: [(0, jsx_runtime_1.jsxs)("div", { className: "d-flex align-items-center gap-2", children: [(0, jsx_runtime_1.jsx)(RuntimeBadge, { state: state }), running?.version ? ((0, jsx_runtime_1.jsxs)("span", { className: "text-muted small", children: ["Running v", running.version, running.versionTag ? ` (${running.versionTag})` : "", " on this device"] })) : state.reason ? ((0, jsx_runtime_1.jsx)("span", { className: "text-muted small", children: state.reason })) : null] }), state.status === "failed" && state.lastError ? ((0, jsx_runtime_1.jsx)(RuntimeError, { title: state.lastError.version
22
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "mb-3", "data-testid": "package-runtime-status", children: [(0, jsx_runtime_1.jsxs)("div", { className: "d-flex align-items-center gap-2", children: [(0, jsx_runtime_1.jsx)(RuntimeBadge, { state: state }), running?.version ? ((0, jsx_runtime_1.jsxs)("span", { className: "text-muted small", children: ["Running v", running.version, running.versionTag ? ` (${running.versionTag})` : "", " on this device"] })) : state.reason ? ((0, jsx_runtime_1.jsx)("span", { className: "text-muted small", children: state.reason })) : null] }), state.status === "waiting" && running && state.reason ? ((0, jsx_runtime_1.jsxs)("div", { className: "small text-muted mt-1", "data-testid": "package-runtime-waiting", children: [state.waiting?.version ? `v${state.waiting.version}: ` : "", state.reason, ". It starts by itself once one is running here."] })) : null, state.status === "failed" && state.lastError ? ((0, jsx_runtime_1.jsx)(RuntimeError, { title: state.lastError.version
23
23
  ? `Loading v${state.lastError.version} failed`
24
24
  : "Loading this package failed", message: state.lastError.message })) : null, workerError ? ((0, jsx_runtime_1.jsx)(RuntimeError, { title: "The package worker failed", message: workerError.message })) : null] }));
25
25
  };
@@ -0,0 +1,31 @@
1
+ import { type IContractProviderToAdd, type IPackageMissingContract } from "@peers-app/peers-sdk";
2
+ /** What a package that waits shows: its whole screen, or a line where it's embedded. */
3
+ interface IPackageWaitingProps {
4
+ /** The waiting package. */
5
+ packageId: string;
6
+ /** The contracts it waits for, from its runtime state. */
7
+ missing: readonly IPackageMissingContract[];
8
+ }
9
+ /**
10
+ * The system screen a package shows in place of its own while it waits for a contract it
11
+ * requires: what it needs, why it can't start, and the packages that provide it, to add from
12
+ * here. Once one runs here the package starts by itself, and its own screen replaces this one.
13
+ */
14
+ export declare function PackageWaitingScreen({ packageId, missing }: IPackageWaitingProps): import("react/jsx-runtime").JSX.Element;
15
+ /**
16
+ * The line a waiting package shows where another screen embeds one of its parts: what it waits
17
+ * for, and a way to open it and see why.
18
+ */
19
+ export declare function PackageWaitingNotice({ packageId, missing }: IPackageWaitingProps): import("react/jsx-runtime").JSX.Element;
20
+ /**
21
+ * The packages to add, in order, so a provider starts as soon as it's added: what it needs first
22
+ * (the first provider listed for each of its needs, recursively), the provider last. `unmet` names
23
+ * the needs no group has a provider for, so adding it would leave it waiting.
24
+ *
25
+ * @param entry - The provider to add.
26
+ */
27
+ export declare function providersToAdd(entry: IContractProviderToAdd): {
28
+ add: IContractProviderToAdd[];
29
+ unmet: string[];
30
+ };
31
+ export {};