@peers-app/peers-ui 0.34.14 → 0.34.15

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 (122) hide show
  1. package/dist/apps-home/app-menu.d.ts +1 -2
  2. package/dist/apps-home/app-menu.js +29 -25
  3. package/dist/command-palette/command-palette-ui.js +13 -12
  4. package/dist/components/autocomplete-chips.d.ts +18 -0
  5. package/dist/components/autocomplete-chips.js +49 -0
  6. package/dist/components/autocomplete.d.ts +88 -0
  7. package/dist/components/autocomplete.js +346 -0
  8. package/dist/components/confirm-button.d.ts +26 -0
  9. package/dist/components/confirm-button.js +55 -0
  10. package/dist/components/data-grid/autocomplete.d.ts +1 -31
  11. package/dist/components/data-grid/autocomplete.js +5 -197
  12. package/dist/components/empty-state.d.ts +16 -0
  13. package/dist/components/empty-state.js +16 -0
  14. package/dist/components/group-switcher.d.ts +3 -3
  15. package/dist/components/group-switcher.js +22 -17
  16. package/dist/components/inline-create-form.d.ts +22 -0
  17. package/dist/components/inline-create-form.js +56 -0
  18. package/dist/components/list-row.d.ts +33 -0
  19. package/dist/components/list-row.js +30 -0
  20. package/dist/components/list-screen.d.ts +31 -3
  21. package/dist/components/list-screen.js +61 -28
  22. package/dist/components/markdown-editor/format-bar.js +15 -40
  23. package/dist/components/markdown-editor/link-plugin.js +38 -9
  24. package/dist/components/markdown-editor/selection-bar-place.d.ts +37 -0
  25. package/dist/components/markdown-editor/selection-bar-place.js +107 -0
  26. package/dist/components/menu-button.d.ts +34 -0
  27. package/dist/components/menu-button.js +66 -0
  28. package/dist/components/screen-header.d.ts +35 -0
  29. package/dist/components/screen-header.js +30 -0
  30. package/dist/components/search-field.d.ts +22 -0
  31. package/dist/components/search-field.js +22 -0
  32. package/dist/components/segmented-control.d.ts +25 -0
  33. package/dist/components/segmented-control.js +18 -0
  34. package/dist/components/typeahead.d.ts +9 -0
  35. package/dist/components/typeahead.js +7 -0
  36. package/dist/groups/groups-client.d.ts +23 -1
  37. package/dist/groups/groups-client.js +31 -0
  38. package/dist/index.d.ts +10 -0
  39. package/dist/index.js +14 -1
  40. package/dist/isolated-screens/config.js +1 -9
  41. package/dist/isolated-screens/folder-picker-control.d.ts +57 -0
  42. package/dist/isolated-screens/folder-picker-control.js +217 -0
  43. package/dist/isolated-screens/folder-picker-host.d.ts +57 -0
  44. package/dist/isolated-screens/folder-picker-host.js +178 -0
  45. package/dist/isolated-screens/folder-picker-protocol.d.ts +75 -0
  46. package/dist/isolated-screens/folder-picker-protocol.js +104 -0
  47. package/dist/isolated-screens/frame-bridge.js +8 -0
  48. package/dist/isolated-screens/frame-document.js +2 -1
  49. package/dist/isolated-screens/frame-microphone.d.ts +55 -0
  50. package/dist/isolated-screens/frame-microphone.js +265 -0
  51. package/dist/isolated-screens/frame-permissions.d.ts +19 -0
  52. package/dist/isolated-screens/frame-permissions.js +32 -0
  53. package/dist/isolated-screens/frame-protocol.d.ts +26 -0
  54. package/dist/isolated-screens/frame-protocol.js +9 -0
  55. package/dist/isolated-screens/frame-pvars.d.ts +27 -0
  56. package/dist/isolated-screens/frame-pvars.js +101 -14
  57. package/dist/isolated-screens/global-widgets.d.ts +1 -2
  58. package/dist/isolated-screens/index.d.ts +2 -0
  59. package/dist/isolated-screens/index.js +3 -1
  60. package/dist/isolated-screens/isolated-screen.d.ts +21 -0
  61. package/dist/isolated-screens/isolated-screen.js +88 -5
  62. package/dist/isolated-screens/local-folder-picker.d.ts +55 -0
  63. package/dist/isolated-screens/local-folder-picker.js +143 -0
  64. package/dist/isolated-screens/microphone-host.d.ts +110 -0
  65. package/dist/isolated-screens/microphone-host.js +397 -0
  66. package/dist/isolated-screens/microphone-prompt.d.ts +20 -0
  67. package/dist/isolated-screens/microphone-prompt.js +60 -0
  68. package/dist/isolated-screens/piece-frames.js +5 -94
  69. package/dist/isolated-screens/piece-reach.d.ts +1 -0
  70. package/dist/isolated-screens/port-channel.d.ts +21 -11
  71. package/dist/isolated-screens/port-channel.js +15 -5
  72. package/dist/isolated-screens/slot-rect.d.ts +38 -0
  73. package/dist/isolated-screens/slot-rect.js +121 -0
  74. package/dist/isolated-screens/test-ports.d.ts +17 -0
  75. package/dist/isolated-screens/test-ports.js +25 -3
  76. package/dist/mentions/mention-chooser.js +1 -1
  77. package/dist/notifications/notifications-screen.js +1 -1
  78. package/dist/screens/data-explorer/data-explorer.d.ts +1 -0
  79. package/dist/screens/data-explorer/data-explorer.js +28 -10
  80. package/dist/screens/data-explorer/query-executor.d.ts +1 -0
  81. package/dist/screens/data-explorer/query-executor.js +3 -1
  82. package/dist/screens/groups/group-list.d.ts +13 -3
  83. package/dist/screens/groups/group-list.js +88 -11
  84. package/dist/screens/identity/identity-routes.d.ts +16 -0
  85. package/dist/screens/identity/identity-routes.js +27 -10
  86. package/dist/screens/identity/identity-screen.js +4 -1
  87. package/dist/screens/invites/activity-view.d.ts +3 -1
  88. package/dist/screens/invites/activity-view.js +7 -3
  89. package/dist/screens/invites/pending-invites-list.d.ts +8 -4
  90. package/dist/screens/invites/pending-invites-list.js +44 -45
  91. package/dist/screens/network-viewer/graph/network-graph-controls.js +3 -3
  92. package/dist/screens/packages/local-folder-grants-panel.d.ts +2 -0
  93. package/dist/screens/packages/local-folder-grants-panel.js +1 -1
  94. package/dist/screens/packages/package-info.js +2 -1
  95. package/dist/screens/packages/package-list.d.ts +2 -2
  96. package/dist/screens/packages/package-list.js +89 -105
  97. package/dist/screens/packages/package-microphone-panel.d.ts +14 -0
  98. package/dist/screens/packages/package-microphone-panel.js +62 -0
  99. package/dist/screens/packages/package-runtime-status.d.ts +10 -2
  100. package/dist/screens/packages/package-runtime-status.js +17 -4
  101. package/dist/screens/peer-types/peer-type-details.js +3 -2
  102. package/dist/screens/peer-types/peer-type-list.d.ts +1 -1
  103. package/dist/screens/peer-types/peer-type-list.js +4 -4
  104. package/dist/screens/settings/settings-page.js +1 -4
  105. package/dist/screens/tools/tool-details.js +2 -1
  106. package/dist/screens/tools/tool-list.d.ts +1 -1
  107. package/dist/screens/tools/tool-list.js +22 -60
  108. package/dist/screens/variables/variable-details.js +5 -4
  109. package/dist/screens/variables/variable-list.d.ts +17 -0
  110. package/dist/screens/variables/variable-list.js +72 -28
  111. package/dist/tabs-layout/network-status-details.d.ts +4 -4
  112. package/dist/tabs-layout/network-status-details.js +6 -5
  113. package/dist/tabs-layout/network-status-indicator.d.ts +1 -0
  114. package/dist/tabs-layout/network-status-indicator.js +1 -0
  115. package/dist/tabs-layout/tab-bar-shortcuts.d.ts +46 -0
  116. package/dist/tabs-layout/tab-bar-shortcuts.js +140 -0
  117. package/dist/tabs-layout/tabs-layout.js +11 -9
  118. package/dist/theme.css +326 -6
  119. package/dist/ui-contracts/popover-surface.d.ts +3 -0
  120. package/dist/ui-contracts/popover-surface.js +6 -3
  121. package/dist/ui-defaults/list-screen.js +10 -4
  122. package/package.json +3 -3
@@ -4,14 +4,21 @@ exports.PackageList = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const peers_sdk_1 = require("@peers-app/peers-sdk");
6
6
  const react_1 = require("react");
7
- const input_1 = require("../../components/input");
7
+ const current_group_name_1 = require("../../apps-home/current-group-name");
8
+ const icon_1 = require("../../components/icon");
9
+ const inline_create_form_1 = require("../../components/inline-create-form");
8
10
  const lazy_list_1 = require("../../components/lazy-list");
11
+ const list_row_1 = require("../../components/list-row");
12
+ const list_screen_1 = require("../../components/list-screen");
9
13
  const loading_indicator_1 = require("../../components/loading-indicator");
10
- const tooltip_1 = require("../../components/tooltip");
14
+ const menu_button_1 = require("../../components/menu-button");
15
+ const screen_header_1 = require("../../components/screen-header");
16
+ const search_field_1 = require("../../components/search-field");
11
17
  const delegates_ipc_1 = require("../../delegates/delegates-ipc");
12
18
  const globals_1 = require("../../globals");
13
19
  const hooks_1 = require("../../hooks");
14
20
  const host_shell_consumer_1 = require("../../host-shell/host-shell-consumer");
21
+ const app_catalog_1 = require("../../ui-router/app-catalog");
15
22
  const ui_loader_1 = require("../../ui-router/ui-loader");
16
23
  const local_folder_grants_panel_1 = require("./local-folder-grants-panel");
17
24
  const package_helpers_1 = require("./package-helpers");
@@ -24,14 +31,7 @@ function tagBadgeClass(tag) {
24
31
  return "text-bg-warning";
25
32
  return "text-bg-success";
26
33
  }
27
- function updateBadgeClass(level) {
28
- if (level === "major")
29
- return "text-bg-danger";
30
- if (level === "minor")
31
- return "text-bg-warning";
32
- return "text-bg-info";
33
- }
34
- const PackageRow = ({ pkg, onUpdated }) => {
34
+ const PackageRow = ({ pkg, app, onUpdated, }) => {
35
35
  const [updating, setUpdating] = (0, react_1.useState)(false);
36
36
  const [devicePrefs] = (0, hooks_1.useObservable)((0, peers_sdk_1.packagePrefsVar)(pkg.packageId));
37
37
  const effective = (0, peers_sdk_1.getEffectivePackagePrefs)(pkg, devicePrefs);
@@ -140,35 +140,67 @@ const PackageRow = ({ pkg, onUpdated }) => {
140
140
  setUpdating(false);
141
141
  }
142
142
  }
143
- return ((0, jsx_runtime_1.jsxs)("div", { className: "container-fluid pb-4 d-flex align-items-center", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex-grow-1", style: { minWidth: 0 }, children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-box-fill" }), "\u00A0\u00A0", (0, jsx_runtime_1.jsx)("a", { href: `#packages/${pkg.packageId}`, children: pkg.name }), (0, jsx_runtime_1.jsx)("span", { className: "ms-2", children: (0, jsx_runtime_1.jsx)(package_runtime_status_1.PackageRuntimeBadge, { packageId: pkg.packageId }) }), isDeviceOverridden && ((0, jsx_runtime_1.jsx)("span", { className: "text-warning ms-1", title: "This device is using a different version than the group", children: (0, jsx_runtime_1.jsx)("i", { className: "bi bi-pc-display" }) })), status && ((0, jsx_runtime_1.jsxs)("span", { className: "ms-2", children: [(0, jsx_runtime_1.jsxs)("small", { className: "text-muted", children: ["v", status.activePv.version] }), status.activePv.versionTag && ((0, jsx_runtime_1.jsx)("span", { className: `badge ms-1 ${tagBadgeClass(status.activePv.versionTag)}`, style: { fontSize: "0.65em" }, children: status.activePv.versionTag })), hasUpdate ? ((0, jsx_runtime_1.jsxs)("span", { className: `badge ms-1 ${updateBadgeClass(status.newerLevel)}`, style: { fontSize: "0.65em" }, children: ["v", status.newestPv?.version, " available"] })) : isOnDev && hasGroupRelease ? ((0, jsx_runtime_1.jsxs)("span", { className: "badge ms-1 text-bg-secondary", style: { fontSize: "0.65em" }, children: ["release: v", status.groupReleasePv?.version] })) : ((0, jsx_runtime_1.jsx)("span", { className: "badge ms-1 text-bg-success", style: { fontSize: "0.65em" }, children: "up to date" }))] })), (0, jsx_runtime_1.jsx)(tooltip_1.Tooltip, { markdownContent: pkg.description, positions: ["bottom", "top", "right", "left"] })] }), hasUpdate && ((0, jsx_runtime_1.jsxs)("button", { className: "btn btn-sm btn-outline-primary ms-2 text-nowrap", disabled: updating, onClick: handleUpdate, children: [updating ? ((0, jsx_runtime_1.jsx)("span", { className: "spinner-border spinner-border-sm me-1" })) : ((0, jsx_runtime_1.jsx)("i", { className: "bi bi-arrow-up-circle me-1" })), "Update"] })), isOnDev && hasGroupRelease && ((0, jsx_runtime_1.jsxs)("button", { className: "btn btn-sm btn-outline-secondary ms-2 text-nowrap", disabled: updating, onClick: handleUseRelease, children: [updating ? ((0, jsx_runtime_1.jsx)("span", { className: "spinner-border spinner-border-sm me-1" })) : ((0, jsx_runtime_1.jsx)("i", { className: "bi bi-box-arrow-in-right me-1" })), "Use Release"] })), hasDevVersion && ((0, jsx_runtime_1.jsxs)("button", { className: "btn btn-sm btn-outline-danger ms-2 text-nowrap", disabled: updating, onClick: handleUseDev, children: [updating ? ((0, jsx_runtime_1.jsx)("span", { className: "spinner-border spinner-border-sm me-1" })) : ((0, jsx_runtime_1.jsx)("i", { className: "bi bi-tools me-1" })), "Use Dev"] }))] }));
143
+ const spinner = (0, jsx_runtime_1.jsx)("span", { className: "spinner-border spinner-border-sm me-1", "aria-hidden": "true" });
144
+ const actions = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [hasUpdate && ((0, jsx_runtime_1.jsxs)("button", { type: "button", className: "btn btn-sm btn-outline-primary text-nowrap", disabled: updating, onClick: handleUpdate, children: [updating ? spinner : (0, jsx_runtime_1.jsx)("i", { className: "bi-arrow-up-circle me-1", "aria-hidden": "true" }), "Update"] })), isOnDev && hasGroupRelease && ((0, jsx_runtime_1.jsxs)("button", { type: "button", className: "btn btn-sm btn-outline-secondary text-nowrap", disabled: updating, onClick: handleUseRelease, children: [updating ? spinner : (0, jsx_runtime_1.jsx)("i", { className: "bi-box-arrow-in-right me-1", "aria-hidden": "true" }), "Use Release"] })), hasDevVersion && ((0, jsx_runtime_1.jsxs)("button", { type: "button", className: "btn btn-sm btn-outline-danger text-nowrap", disabled: updating, onClick: handleUseDev, children: [updating ? spinner : (0, jsx_runtime_1.jsx)("i", { className: "bi-tools me-1", "aria-hidden": "true" }), "Use Dev"] }))] }));
145
+ const tag = status?.activePv.versionTag;
146
+ return ((0, jsx_runtime_1.jsx)(list_row_1.ListRow, { href: `#packages/${pkg.packageId}`, icon: (0, jsx_runtime_1.jsx)(icon_1.Icon, { icon: app?.iconClassName ?? "bi-box-fill" }), tileClassName: `is-app peers-app-color-${app?.color ?? "system"}`, title: pkg.name, description: (0, list_screen_1.firstLineOf)(pkg.description), badges: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(package_runtime_status_1.PackageRuntimeBadge, { packageId: pkg.packageId, unlessRunning: true }), isDeviceOverridden && ((0, jsx_runtime_1.jsxs)("span", { className: "badge text-bg-secondary", title: "This device is using a different version than the group", children: [(0, jsx_runtime_1.jsx)("i", { className: "bi-pc-display me-1", "aria-hidden": "true" }), "this device"] })), status && (0, jsx_runtime_1.jsxs)("span", { className: "badge peers-fact-badge", children: ["v", status.activePv.version] }), tag && (0, jsx_runtime_1.jsx)("span", { className: `badge ${tagBadgeClass(tag)}`, children: tag }), hasUpdate ? ((0, jsx_runtime_1.jsxs)("span", { className: "badge rounded-pill border border-primary text-primary", children: ["v", status?.newestPv?.version, " available"] })) : (isOnDev &&
147
+ hasGroupRelease && ((0, jsx_runtime_1.jsxs)("span", { className: "badge text-bg-secondary", children: ["release: v", status?.groupReleasePv?.version] })))] }), actions: hasUpdate || (isOnDev && hasGroupRelease) || hasDevVersion ? actions : undefined }));
144
148
  };
145
149
  /**
146
- * Packages screen: search, create/import/install from the search box, local folder grants,
147
- * and the installed package list.
150
+ * Adds a package from a repository link (cloned here) or a package id (copied from another of
151
+ * your groups, or re-enabled), then opens it.
152
+ *
153
+ * @param text - What the user pasted.
154
+ * @throws When it's neither, or the add fails.
155
+ */
156
+ async function addPackage(text) {
157
+ if ((0, peers_sdk_1.isPackageRepositoryUrl)(text)) {
158
+ const { packageId } = await (await (0, packages_ipc_1.packagesTools)()).clonePackage({ url: text });
159
+ (0, globals_1.mainContentPath)(`packages/${packageId}`);
160
+ return;
161
+ }
162
+ if ((0, peers_sdk_1.isid)(text)) {
163
+ const { packageId } = await (await (0, packages_ipc_1.packagesTools)()).installPackage({ packageId: text });
164
+ (0, globals_1.mainContentPath)(`packages/${packageId}`);
165
+ void (0, delegates_ipc_1.offerDelegateAfterInstall)(packageId);
166
+ return;
167
+ }
168
+ throw new Error("That isn't a repository link or a package id. To start a package of your own, use New package.");
169
+ }
170
+ /**
171
+ * The Packages screen: the group's packages with their versions, a search box, New package,
172
+ * and in ⋯, adding one from a link or id and opening the packages folder.
148
173
  */
149
174
  const PackageList = () => {
150
- const [searchTextObs] = (0, react_1.useState)(() => (0, peers_sdk_1.observable)(""));
151
- const [searchText] = (0, hooks_1.useObservable)(searchTextObs);
152
- const addingPackage = (0, hooks_1.useObservableState)(false);
175
+ const [searchText, setSearchText] = (0, react_1.useState)("");
176
+ const [adding, setAdding] = (0, react_1.useState)(false);
153
177
  const refreshKey = (0, hooks_1.useObservableState)(0);
154
- const [cursorObs] = (0, react_1.useState)(() => (0, peers_sdk_1.observable)());
155
- const newCursor = (0, react_1.useCallback)(async () => {
156
- const cursor = await (0, peers_sdk_1.Packages)().cursor({
157
- $or: [
158
- { name: { $matchWords: searchText } },
159
- { description: { $matchWords: searchText } },
160
- { remoteRepo: { $matchWords: searchText } },
161
- ],
162
- }, { sortBy: ["-packageId"] });
163
- cursorObs(cursor);
164
- return cursor;
165
- }, [searchText, cursorObs]);
166
- (0, react_1.useEffect)(() => {
167
- void newCursor();
168
- }, [newCursor]);
178
+ const groupName = (0, current_group_name_1.useCurrentGroupName)();
179
+ const apps = (0, app_catalog_1.useAppCatalog)();
180
+ const appByPackage = (0, react_1.useMemo)(() => {
181
+ const byPackage = new Map();
182
+ for (const entry of apps) {
183
+ if (!byPackage.has(entry.packageId))
184
+ byPackage.set(entry.packageId, entry);
185
+ }
186
+ return byPackage;
187
+ }, [apps]);
188
+ const cursorRef = (0, react_1.useRef)();
189
+ const resetKey = `${searchText}_${refreshKey()}`;
169
190
  async function loadMore(existing) {
170
191
  const moreMatches = [];
171
- const cursor = cursorObs() || (await newCursor());
192
+ const key = resetKey;
193
+ let cursor = cursorRef.current?.key === key ? cursorRef.current.cursor : undefined;
194
+ if (!cursor) {
195
+ cursor = await (0, peers_sdk_1.Packages)().cursor({
196
+ $or: [
197
+ { name: { $matchWords: searchText } },
198
+ { description: { $matchWords: searchText } },
199
+ { remoteRepo: { $matchWords: searchText } },
200
+ ],
201
+ }, { sortBy: ["-packageId"] });
202
+ cursorRef.current = { key, cursor };
203
+ }
172
204
  for await (const nextRecord of cursor) {
173
205
  if (existing.find((e) => e.packageId === nextRecord.packageId))
174
206
  continue;
@@ -178,8 +210,8 @@ const PackageList = () => {
178
210
  if (moreMatches.length >= 50)
179
211
  break;
180
212
  }
181
- if (moreMatches.length === 0) {
182
- cursorObs(undefined);
213
+ if (moreMatches.length === 0 && cursorRef.current?.key === key) {
214
+ cursorRef.current = undefined;
183
215
  }
184
216
  if (!searchText.length && existing.length === 0 && moreMatches.length > 0) {
185
217
  const DEV_WITH_RELEASE_RANK = 0.5;
@@ -219,79 +251,31 @@ const PackageList = () => {
219
251
  }
220
252
  return moreMatches;
221
253
  }
222
- async function searchSubmit(evt) {
223
- if (evt.key !== "Enter")
224
- return;
225
- const name = searchText.trim();
226
- if (!name)
227
- return;
228
- if ((0, peers_sdk_1.isPackageRepositoryUrl)(name)) {
229
- if (!confirm(`Add remote package: ${name}`))
230
- return;
231
- try {
232
- addingPackage(true);
233
- const { packageId } = await (await (0, packages_ipc_1.packagesTools)()).clonePackage({ url: name });
234
- const pkg = await (0, peers_sdk_1.Packages)().get(packageId);
235
- if (pkg) {
236
- (0, globals_1.mainContentPath)(`packages/${packageId}`);
237
- }
238
- }
239
- catch (err) {
240
- let errMessage = err instanceof Error ? err.message : String(err);
241
- errMessage = errMessage.replace(/\s+/g, " ");
242
- confirm(`Error adding remote package: ${errMessage}`);
243
- }
244
- finally {
245
- addingPackage(false);
246
- }
247
- return;
248
- }
249
- // A package id re-enables that package, or copies it here from another of your contexts.
250
- if ((0, peers_sdk_1.isid)(name)) {
251
- if (!confirm(`Install package ${name} into this context`))
252
- return;
253
- try {
254
- addingPackage(true);
255
- const { packageId } = await (await (0, packages_ipc_1.packagesTools)()).installPackage({ packageId: name });
256
- (0, globals_1.mainContentPath)(`packages/${packageId}`);
257
- void (0, delegates_ipc_1.offerDelegateAfterInstall)(packageId);
258
- }
259
- catch (err) {
260
- confirm(`Error installing package: ${err instanceof Error ? err.message : String(err)}`);
261
- }
262
- finally {
263
- addingPackage(false);
264
- }
265
- return;
266
- }
267
- if (!confirm(`Create or import local package: ${searchText}`))
268
- return;
269
- try {
270
- addingPackage(true);
271
- const { packageId, warning } = await (await (0, packages_ipc_1.packagesTools)()).createPackage({ name });
272
- const pkg = await (0, peers_sdk_1.Packages)().get(packageId);
273
- if (pkg) {
274
- if (warning) {
275
- confirm(warning);
276
- }
277
- (0, globals_1.mainContentPath)(`packages/${packageId}`);
278
- }
279
- }
280
- catch (err) {
281
- confirm(`Error creating package: ${err instanceof Error ? err.message : String(err)}`);
282
- }
283
- finally {
284
- addingPackage(false);
285
- }
286
- }
287
- if (addingPackage()) {
288
- return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("div", { className: "container-fluid d-flex justify-content-center mt-5", children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-box-seam" }), "\u00A0 Adding Package"] }), (0, jsx_runtime_1.jsx)("div", { className: "container-fluid d-flex justify-content-center mt-2", children: (0, jsx_runtime_1.jsx)("div", { className: "progress", role: "progressbar", "aria-label": "Animated striped example", "aria-valuenow": 100, "aria-valuemin": 0, "aria-valuemax": 100, children: (0, jsx_runtime_1.jsx)("div", { className: "progress-bar progress-bar-striped progress-bar-animated", style: { width: 150 } }) }) })] }));
289
- }
290
- return ((0, jsx_runtime_1.jsxs)("div", { className: "container-fluid", children: [(0, jsx_runtime_1.jsxs)("div", { className: "input-group mt-3 mb-3", children: [(0, jsx_runtime_1.jsx)(input_1.Input, { value: searchTextObs, className: "form-control", placeholder: "Search, add, or create package", autoFocus: !!(0, globals_1.isDesktop)(), onKeyUp: (evt) => searchSubmit(evt) }), (0, jsx_runtime_1.jsx)("button", { className: "btn btn-outline-secondary dropdown-toggle sm", type: "button", "data-bs-toggle": "dropdown", "aria-expanded": "false", children: (0, jsx_runtime_1.jsx)("i", { className: "bi bi-plus-lg" }) }), (0, jsx_runtime_1.jsxs)("ul", { className: "dropdown-menu dropdown-menu-end", children: [(0, jsx_runtime_1.jsx)("li", { children: (0, jsx_runtime_1.jsx)("a", { className: "dropdown-item", href: "#packages/newlocal", children: "New Local Package" }) }), (0, jsx_runtime_1.jsx)("li", { children: (0, jsx_runtime_1.jsx)("a", { className: "dropdown-item disabled", href: "#", children: "Add Local Package" }) }), (0, jsx_runtime_1.jsx)("li", { children: (0, jsx_runtime_1.jsx)("a", { className: "dropdown-item disabled", href: "#", children: "Add Remote Package" }) }), (0, jsx_runtime_1.jsx)("li", { children: (0, jsx_runtime_1.jsx)("hr", { className: "dropdown-divider" }) }), (0, jsx_runtime_1.jsx)("li", { children: (0, jsx_runtime_1.jsx)("a", { className: "dropdown-item", onClick: () => void (0, host_shell_consumer_1.openOnHost)(peers_sdk_1.packagesRootDir), style: { cursor: "pointer" }, children: "Open Packages Directory" }) })] })] }), (0, jsx_runtime_1.jsx)(local_folder_grants_panel_1.LocalFolderGrantsPanel, {}), (0, jsx_runtime_1.jsx)("div", { className: "peers-list-container", children: (0, jsx_runtime_1.jsx)(lazy_list_1.LazyList, { resetTrigger: `${searchText}_${refreshKey()}`, loadMore: loadMore, scrollThreshold: 0.6, renderItems: (packages) => {
291
- return packages.map((pkg) => ((0, jsx_runtime_1.jsx)(PackageRow, { pkg: pkg, onUpdated: () => refreshKey(refreshKey() + 1) }, pkg.packageId)));
292
- }, loadingIndicator: (0, jsx_runtime_1.jsx)("div", { className: "d-flex justify-content-center", style: { height: 200 }, children: (0, jsx_runtime_1.jsx)(loading_indicator_1.LoadingIndicator, {}) }), endOfList: (0, jsx_runtime_1.jsx)("div", { className: "d-flex justify-content-center", style: { height: 200 } }) }) })] }));
254
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "container-xxl p-3", children: [(0, jsx_runtime_1.jsx)(screen_header_1.ScreenHeader, { icon: "bi-box-fill", title: "Packages", subtitle: groupName ? `The apps in ${groupName}, and their versions` : "Apps and their versions", actions: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("a", { href: "#packages/newlocal", className: "btn btn-outline-primary btn-sm text-nowrap", children: [(0, jsx_runtime_1.jsx)("i", { className: "bi-plus-lg me-1", "aria-hidden": "true" }), "New package"] }), (0, jsx_runtime_1.jsx)(menu_button_1.MenuButton, { items: [
255
+ {
256
+ label: "Add from a link or id…",
257
+ icon: "bi-link-45deg",
258
+ onSelect: () => setAdding(true),
259
+ },
260
+ {
261
+ label: "Open packages folder",
262
+ icon: "bi-folder2-open",
263
+ onSelect: () => void (0, host_shell_consumer_1.openOnHost)(peers_sdk_1.packagesRootDir),
264
+ },
265
+ ] })] }) }), adding && ((0, jsx_runtime_1.jsx)(inline_create_form_1.InlineCreateForm, { title: "Add a package", placeholder: "A repository link or a package id", submitLabel: "Add", onCancel: () => setAdding(false), onSubmit: async (text) => {
266
+ await addPackage(text);
267
+ setAdding(false);
268
+ } })), (0, jsx_runtime_1.jsx)(search_field_1.SearchField, { value: searchText, onChange: setSearchText, placeholder: "Search packages", autoFocus: !adding && !!(0, globals_1.isDesktop)() }), (0, jsx_runtime_1.jsx)("div", { className: "peers-list-container", children: (0, jsx_runtime_1.jsx)(lazy_list_1.LazyList, { resetTrigger: resetKey, loadMore: loadMore, scrollThreshold: 0.6, renderItems: (packages) => packages.length ? ((0, jsx_runtime_1.jsx)("div", { className: "list-group", children: packages.map((pkg) => ((0, jsx_runtime_1.jsx)(PackageRow, { pkg: pkg, app: appByPackage.get(pkg.packageId), onUpdated: () => refreshKey(refreshKey() + 1) }, pkg.packageId))) })) : null, loadingIndicator: (0, jsx_runtime_1.jsx)("div", { className: "d-flex justify-content-center", style: { height: 200 }, children: (0, jsx_runtime_1.jsx)(loading_indicator_1.LoadingIndicator, {}) }), endOfList: (0, jsx_runtime_1.jsx)("div", { style: { height: 24 } }) }) }), (0, jsx_runtime_1.jsx)(FolderGrants, {})] }));
293
269
  };
294
270
  exports.PackageList = PackageList;
271
+ /**
272
+ * The folders packages on this device may use, folded under the list: most people never need
273
+ * them, so they load only when opened.
274
+ */
275
+ function FolderGrants() {
276
+ const [open, setOpen] = (0, react_1.useState)(false);
277
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "mt-3", children: [(0, jsx_runtime_1.jsxs)("button", { type: "button", className: "btn btn-link btn-sm px-0 text-decoration-none text-body-secondary", "aria-expanded": open, onClick: () => setOpen(!open), children: [(0, jsx_runtime_1.jsx)("i", { className: `bi-chevron-${open ? "down" : "right"} me-1`, "aria-hidden": "true" }), (0, jsx_runtime_1.jsx)("i", { className: "bi-folder2 me-1", "aria-hidden": "true" }), "Folders packages may use"] }), open && ((0, jsx_runtime_1.jsx)("div", { className: "mt-2", children: (0, jsx_runtime_1.jsx)(local_folder_grants_panel_1.LocalFolderGrantsPanel, { hideTitle: true }) }))] }));
278
+ }
295
279
  (0, ui_loader_1.registerInternalPeersUI)({
296
280
  peersUIId: "00m5fre6r5m2p2wd1m4x6nx0b",
297
281
  component: exports.PackageList,
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Whether a package's screens may use the microphone on this device, with a switch: for a package
3
+ * whose selected version declares it (`pkg.microphone`), or that the person already answered
4
+ * about. Shows nothing for the rest.
5
+ *
6
+ * @param props.packageId - The package.
7
+ * @param props.packageName - Its name.
8
+ * @param props.packageVersionId - The selected version in the group the screen shows.
9
+ */
10
+ export declare function PackageMicrophonePanel(props: {
11
+ packageId: string;
12
+ packageName: string;
13
+ packageVersionId?: string;
14
+ }): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PackageMicrophonePanel = PackageMicrophonePanel;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const peers_sdk_1 = require("@peers-app/peers-sdk");
6
+ const react_1 = require("react");
7
+ const hooks_1 = require("../../hooks");
8
+ const frame_permissions_1 = require("../../isolated-screens/frame-permissions");
9
+ const microphone_host_1 = require("../../isolated-screens/microphone-host");
10
+ const piece_reach_1 = require("../../isolated-screens/piece-reach");
11
+ function loaded(list) {
12
+ return list.loadingPromise;
13
+ }
14
+ /**
15
+ * Whether a package's screens may use the microphone on this device, with a switch: for a package
16
+ * whose selected version declares it (`pkg.microphone`), or that the person already answered
17
+ * about. Shows nothing for the rest.
18
+ *
19
+ * @param props.packageId - The package.
20
+ * @param props.packageName - Its name.
21
+ * @param props.packageVersionId - The selected version in the group the screen shows.
22
+ */
23
+ function PackageMicrophonePanel(props) {
24
+ const { packageId, packageVersionId } = props;
25
+ const [reason, setReason] = (0, react_1.useState)();
26
+ const [allowed] = (0, hooks_1.useObservable)((0, frame_permissions_1.microphoneAllowedList)());
27
+ const [refused] = (0, hooks_1.useObservable)((0, frame_permissions_1.microphoneRefusedList)());
28
+ (0, react_1.useEffect)(() => {
29
+ let cancelled = false;
30
+ setReason(undefined);
31
+ void (async () => {
32
+ try {
33
+ await Promise.all([loaded((0, frame_permissions_1.microphoneAllowedList)()), loaded((0, frame_permissions_1.microphoneRefusedList)())]);
34
+ if (cancelled)
35
+ return;
36
+ // A stored answer can be changed as soon as both lists are ready, even without a manifest.
37
+ setReason("");
38
+ if (!packageVersionId)
39
+ return;
40
+ const { dataContextId } = await (0, peers_sdk_1.getDefaultDataContext)();
41
+ const manifest = await (0, piece_reach_1.readStoredManifest)(dataContextId, packageVersionId);
42
+ const declared = manifest?.microphone?.reason;
43
+ // A stale selection can name another package's version.
44
+ if (!cancelled && manifest?.packageId === packageId && typeof declared === "string") {
45
+ setReason(declared);
46
+ }
47
+ }
48
+ catch {
49
+ // A failed list load leaves the switch hidden. A failed manifest read keeps saved answers available.
50
+ }
51
+ })();
52
+ return () => {
53
+ cancelled = true;
54
+ };
55
+ }, [packageId, packageVersionId]);
56
+ const isRefused = Array.isArray(refused) && refused.includes(packageId);
57
+ const isAllowed = !isRefused && Array.isArray(allowed) && allowed.includes(packageId);
58
+ if (reason === undefined || (!reason && !isAllowed && !isRefused))
59
+ return null;
60
+ const id = `microphone-${packageId}`;
61
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "mt-2", "data-package-microphone": packageId, children: [(0, jsx_runtime_1.jsx)("hr", {}), (0, jsx_runtime_1.jsx)("small", { children: "Microphone (this device):" }), (0, jsx_runtime_1.jsxs)("div", { className: "form-check form-switch", children: [(0, jsx_runtime_1.jsx)("input", { id: id, className: "form-check-input", type: "checkbox", checked: isAllowed, onChange: (event) => (0, microphone_host_1.changeMicrophoneAnswer)(packageId, event.target.checked) }), (0, jsx_runtime_1.jsx)("label", { className: "form-check-label", htmlFor: id, children: isAllowed ? "Allowed" : isRefused ? "Not allowed" : "Not asked yet" })] }), (0, jsx_runtime_1.jsxs)("div", { className: "form-text", children: [reason ? `${props.packageName}: "${reason}" ` : "", isAllowed || isRefused ? ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-link btn-sm p-0 align-baseline", onClick: () => (0, microphone_host_1.changeMicrophoneAnswer)(packageId, undefined), children: "Ask again" })) : ("Peers asks the first time it listens.")] })] }));
62
+ }
@@ -2,8 +2,16 @@ interface IPackageRuntimeProps {
2
2
  /** Package to show. */
3
3
  packageId: string;
4
4
  }
5
- /** Small badge with a package's runtime status on this device; renders nothing until known. */
6
- export declare const PackageRuntimeBadge: ({ packageId }: IPackageRuntimeProps) => import("react/jsx-runtime").JSX.Element;
5
+ /**
6
+ * Small badge with a package's runtime status on this device; renders nothing until known.
7
+ *
8
+ * @param props.packageId - Package to show.
9
+ * @param props.unlessRunning - Hides the healthy running status in a list. Worker failures
10
+ * still show when the package itself is loaded.
11
+ */
12
+ export declare const PackageRuntimeBadge: ({ packageId, unlessRunning, }: IPackageRuntimeProps & {
13
+ unlessRunning?: boolean;
14
+ }) => import("react/jsx-runtime").JSX.Element | null;
7
15
  /**
8
16
  * Runtime status on this device: badge, running version, what a waiting version needs, and the
9
17
  * last load or worker failure.
@@ -3,10 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PackageRuntimeStatus = exports.PackageRuntimeBadge = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const packages_ipc_1 = require("./packages-ipc");
6
- /** Small badge with a package's runtime status on this device; renders nothing until known. */
7
- const PackageRuntimeBadge = ({ packageId }) => {
8
- const states = (0, packages_ipc_1.usePackageRuntimeStates)();
9
- return (0, jsx_runtime_1.jsx)(RuntimeBadge, { state: states?.[packageId] });
6
+ /**
7
+ * Small badge with a package's runtime status on this device; renders nothing until known.
8
+ *
9
+ * @param props.packageId - Package to show.
10
+ * @param props.unlessRunning - Hides the healthy running status in a list. Worker failures
11
+ * still show when the package itself is loaded.
12
+ */
13
+ const PackageRuntimeBadge = ({ packageId, unlessRunning, }) => {
14
+ const state = (0, packages_ipc_1.usePackageRuntimeStates)()?.[packageId];
15
+ if (unlessRunning && !state?.worker?.lastWorkerError) {
16
+ if (state?.status === "running")
17
+ return null;
18
+ if (state?.status === "unloaded") {
19
+ return ((0, jsx_runtime_1.jsx)("span", { className: "badge text-bg-secondary", title: state.reason, children: "Stopped" }));
20
+ }
21
+ }
22
+ return (0, jsx_runtime_1.jsx)(RuntimeBadge, { state: state });
10
23
  };
11
24
  exports.PackageRuntimeBadge = PackageRuntimeBadge;
12
25
  /**
@@ -11,6 +11,7 @@ const io_schema_1 = require("../../components/io-schema");
11
11
  const loading_indicator_1 = require("../../components/loading-indicator");
12
12
  const editor_inline_1 = require("../../components/markdown-editor/editor-inline");
13
13
  const save_button_1 = require("../../components/save-button");
14
+ const screen_header_1 = require("../../components/screen-header");
14
15
  const tabs_1 = require("../../components/tabs");
15
16
  const hooks_1 = require("../../hooks");
16
17
  const tabs_state_1 = require("../../tabs-layout/tabs-state");
@@ -41,7 +42,7 @@ const PeerTypeDetails = (props) => {
41
42
  if (!valueType) {
42
43
  return (0, jsx_runtime_1.jsx)(loading_indicator_1.LoadingIndicator, {});
43
44
  }
44
- return ((0, jsx_runtime_1.jsxs)("div", { className: "container-fluid p-3", children: [(0, jsx_runtime_1.jsxs)("div", { className: "d-flex", children: [(0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)("h4", { children: (0, jsx_runtime_1.jsx)("i", { className: "bi bi-code-square me-2" }) }) }), (0, jsx_runtime_1.jsx)("div", { className: "flex-grow-1", children: (0, jsx_runtime_1.jsx)("h4", { children: (0, jsx_runtime_1.jsx)(input_1.Input, { className: "border border-0", style: { width: "100%", outline: "none", backgroundColor: "transparent" }, value: valueType.qs.name }, valueType.peerTypeId) }) }), (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(save_button_1.SaveButton, { doc: valueType }, valueType.peerTypeId) })] }), (0, jsx_runtime_1.jsx)(tabs_1.Tabs, { tabs: [
45
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "container-fluid p-3", children: [(0, jsx_runtime_1.jsx)(screen_header_1.BackLink, { href: "#peer-types", label: "Types" }), (0, jsx_runtime_1.jsxs)("div", { className: "d-flex", children: [(0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)("h4", { children: (0, jsx_runtime_1.jsx)("i", { className: "bi bi-code-square me-2" }) }) }), (0, jsx_runtime_1.jsx)("div", { className: "flex-grow-1", children: (0, jsx_runtime_1.jsx)("h4", { children: (0, jsx_runtime_1.jsx)(input_1.Input, { className: "border border-0", style: { width: "100%", outline: "none", backgroundColor: "transparent" }, value: valueType.qs.name }, valueType.peerTypeId) }) }), (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(save_button_1.SaveButton, { doc: valueType }, valueType.peerTypeId) })] }), (0, jsx_runtime_1.jsx)(tabs_1.Tabs, { tabs: [
45
46
  {
46
47
  name: "Info",
47
48
  content: ((0, jsx_runtime_1.jsx)(tabs_1.ScreenTabBody, { children: (0, jsx_runtime_1.jsx)(VariableInfo, { valueType: valueType }) })),
@@ -56,7 +57,7 @@ exports.PeerTypeDetails = PeerTypeDetails;
56
57
  const VariableInfo = (props) => {
57
58
  const { valueType } = props;
58
59
  valueType.description = valueType.description || "";
59
- return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("small", { className: "text-body-secondary", children: "Name:" }), (0, jsx_runtime_1.jsx)(input_1.Input, { value: valueType.qs.name, className: "form-control mb-3 p-0 ps-2", placeholder: "Variable name", title: "Variable name" }), (0, jsx_runtime_1.jsx)("small", { className: "text-body-secondary", children: "Icon:" }), (0, jsx_runtime_1.jsx)(exports.PeerTypeIconField, { icon: valueType.qs.iconClass }), (0, jsx_runtime_1.jsx)("small", { className: "mt-2 text-body-secondary", children: "Description:" }), (0, jsx_runtime_1.jsx)(editor_inline_1.MarkdownEditorInline, { value: valueType.qs.description })] }));
60
+ return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("small", { className: "text-body-secondary", children: "Name:" }), (0, jsx_runtime_1.jsx)(input_1.Input, { value: valueType.qs.name, className: "form-control mb-3", placeholder: "Variable name", title: "Variable name" }), (0, jsx_runtime_1.jsx)("small", { className: "text-body-secondary", children: "Icon:" }), (0, jsx_runtime_1.jsx)(exports.PeerTypeIconField, { icon: valueType.qs.iconClass }), (0, jsx_runtime_1.jsx)("small", { className: "mt-2 text-body-secondary", children: "Description:" }), (0, jsx_runtime_1.jsx)(editor_inline_1.MarkdownEditorInline, { value: valueType.qs.description })] }));
60
61
  };
61
62
  const VariableSchema = (props) => {
62
63
  const { valueType } = props;
@@ -1,2 +1,2 @@
1
- /** The list of peer types, each with its icon and a link to edit it. */
1
+ /** The Types screen: every peer type, each with its icon, opening its editor. */
2
2
  export declare function PeerTypeLists(): import("react/jsx-runtime").JSX.Element;
@@ -4,11 +4,11 @@ exports.PeerTypeLists = PeerTypeLists;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const peers_sdk_1 = require("@peers-app/peers-sdk");
6
6
  const icon_1 = require("../../components/icon");
7
+ const list_row_1 = require("../../components/list-row");
7
8
  const list_screen_1 = require("../../components/list-screen");
8
- const markdown_with_mentions_1 = require("../../components/markdown-with-mentions");
9
9
  const globals_1 = require("../../globals");
10
10
  const ui_loader_1 = require("../../ui-router/ui-loader");
11
- /** The list of peer types, each with its icon and a link to edit it. */
11
+ /** The Types screen: every peer type, each with its icon, opening its editor. */
12
12
  function PeerTypeLists() {
13
13
  async function newRecord(name) {
14
14
  const peerTypeName = name.replace(/\s+/g, "_");
@@ -31,9 +31,9 @@ function PeerTypeLists() {
31
31
  };
32
32
  }
33
33
  function renderItem(item) {
34
- return ((0, jsx_runtime_1.jsxs)("div", { className: "container-fluid pb-4", children: [(0, jsx_runtime_1.jsx)(icon_1.Icon, { icon: item.iconClass, fallback: "bi:code-square" }), "\u00A0", (0, jsx_runtime_1.jsx)("a", { href: `#peer-types/${item.peerTypeId}`, children: item.name || "<empty-name>" }), (0, jsx_runtime_1.jsx)("div", { style: { paddingLeft: "20px" }, children: (0, jsx_runtime_1.jsx)(markdown_with_mentions_1.MarkdownWithMentions, { content: item.description || "" }) })] }, item.peerTypeId));
34
+ return ((0, jsx_runtime_1.jsx)(list_row_1.ListRow, { href: `#peer-types/${item.peerTypeId}`, icon: (0, jsx_runtime_1.jsx)(icon_1.Icon, { icon: item.iconClass, fallback: "bi:code-square" }), title: item.name || "(no name)", description: (0, list_screen_1.firstLineOf)(item.description) }, item.peerTypeId));
35
35
  }
36
- return ((0, jsx_runtime_1.jsx)(list_screen_1.ListScreen, { table: (0, peers_sdk_1.PeerTypes)(), newRecord: newRecord, getFilter: getFilter, sortBy: ["name"], renderItem: renderItem, placeholderName: "value type" }));
36
+ return ((0, jsx_runtime_1.jsx)(list_screen_1.ListScreen, { table: (0, peers_sdk_1.PeerTypes)(), newRecord: newRecord, getFilter: getFilter, sortBy: ["name"], renderItem: renderItem, placeholderName: "type", icon: "bi-code-square", title: "Types", subtitle: "The shapes of the values tools take and give back" }));
37
37
  }
38
38
  (0, ui_loader_1.registerInternalPeersUI)({
39
39
  peersUIId: "00m5fshz2g6ea23v8z6y0a1cj",
@@ -140,10 +140,7 @@ const PackagesRootDirectory = () => {
140
140
  };
141
141
  const ReloadPackagesOnPageRefresh = () => {
142
142
  (0, hooks_1.useObservable)(peers_sdk_1.reloadPackagesOnPageRefresh);
143
- return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("label", { htmlFor: "isPrimary", className: "form-label small mt-2 me-2", children: "Reload Packages on Page Load:" }), (0, jsx_runtime_1.jsx)("input", { type: "checkbox", checked: (0, peers_sdk_1.reloadPackagesOnPageRefresh)(), onChange: (e) => {
144
- const checked = e.target.checked;
145
- (0, peers_sdk_1.reloadPackagesOnPageRefresh)(checked);
146
- } }), (0, jsx_runtime_1.jsx)(tooltip_1.Tooltip, { markdownContent: `Checking this will reload all packages very time the page is loaded. Particularly useful while developing packages.` })] }));
143
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "form-check form-switch d-flex align-items-center gap-2 mb-3", children: [(0, jsx_runtime_1.jsx)("input", { id: "reload-packages-on-page-load", className: "form-check-input", type: "checkbox", role: "switch", checked: (0, peers_sdk_1.reloadPackagesOnPageRefresh)(), onChange: (e) => (0, peers_sdk_1.reloadPackagesOnPageRefresh)(e.target.checked) }), (0, jsx_runtime_1.jsx)("label", { htmlFor: "reload-packages-on-page-load", className: "form-check-label small", children: "Reload packages on page load" }), (0, jsx_runtime_1.jsx)(tooltip_1.Tooltip, { markdownContent: `Checking this will reload all packages very time the page is loaded. Particularly useful while developing packages.` })] }));
147
144
  };
148
145
  const ResetDeviceSyncInfos = () => {
149
146
  return ((0, jsx_runtime_1.jsx)("div", { className: "mt-3", children: (0, jsx_runtime_1.jsx)("button", { className: "btn btn-secondary btn-sm ms-2", onClick: async () => {
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ToolDetails = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const loading_indicator_1 = require("../../components/loading-indicator");
6
+ const screen_header_1 = require("../../components/screen-header");
6
7
  const tabs_1 = require("../../components/tabs");
7
8
  const hooks_1 = require("../../hooks");
8
9
  const tabs_state_1 = require("../../tabs-layout/tabs-state");
@@ -22,7 +23,7 @@ const ToolDetails = (props) => {
22
23
  if (!details)
23
24
  return (0, jsx_runtime_1.jsx)(loading_indicator_1.LoadingIndicator, {});
24
25
  const { row, entry } = details;
25
- return ((0, jsx_runtime_1.jsxs)("div", { className: "container-fluid p-3", children: [(0, jsx_runtime_1.jsxs)("h4", { children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-tools me-2" }), entry?.name ?? row.name] }), (0, jsx_runtime_1.jsx)(tabs_1.Tabs, { tabs: [
26
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "container-fluid p-3", children: [(0, jsx_runtime_1.jsx)(screen_header_1.BackLink, { href: "#tools", label: "Tools" }), (0, jsx_runtime_1.jsxs)("h4", { children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-tools me-2" }), entry?.name ?? row.name] }), (0, jsx_runtime_1.jsx)(tabs_1.Tabs, { tabs: [
26
27
  {
27
28
  name: "Info",
28
29
  content: ((0, jsx_runtime_1.jsx)(tabs_1.ScreenTabBody, { children: (0, jsx_runtime_1.jsx)(tool_info_1.ToolInfo, { tool: row, entry: entry }) })),
@@ -1,2 +1,2 @@
1
- /** Browse permanent tool catalog rows. */
1
+ /** The Tools screen: the permanent tool catalog, newest first, each opening its details. */
2
2
  export declare function ToolList(): import("react/jsx-runtime").JSX.Element;
@@ -3,65 +3,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ToolList = ToolList;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const peers_sdk_1 = require("@peers-app/peers-sdk");
6
- const react_1 = require("react");
7
- const input_1 = require("../../components/input");
8
- const lazy_list_1 = require("../../components/lazy-list");
9
- const loading_indicator_1 = require("../../components/loading-indicator");
10
- const markdown_with_mentions_1 = require("../../components/markdown-with-mentions");
11
- const globals_1 = require("../../globals");
12
- const hooks_1 = require("../../hooks");
13
- /** Browse permanent tool catalog rows. */
6
+ const list_row_1 = require("../../components/list-row");
7
+ const list_screen_1 = require("../../components/list-screen");
8
+ const ui_loader_1 = require("../../ui-router/ui-loader");
9
+ function getFilter(searchText) {
10
+ const words = searchText.trim();
11
+ return words ? { name: { $matchWords: words } } : {};
12
+ }
13
+ /** The Tools screen: the permanent tool catalog, newest first, each opening its details. */
14
14
  function ToolList() {
15
- const [searchTextObs] = (0, react_1.useState)(() => (0, peers_sdk_1.observable)(""));
16
- const [searchText] = (0, hooks_1.useObservable)(searchTextObs);
17
- const [cursorObs] = (0, react_1.useState)(() => (0, peers_sdk_1.observable)());
18
- const [cursorId] = (0, react_1.useState)(() => (0, peers_sdk_1.observable)((0, peers_sdk_1.newid)()));
19
- async function newCursor() {
20
- let cursor;
21
- const _searchText = searchText.trim();
22
- if (_searchText) {
23
- cursor = await (0, peers_sdk_1.Tools)().cursor({ name: { $matchWords: _searchText } }, { sortBy: ["-toolId"] });
24
- }
25
- else {
26
- cursor = await (0, peers_sdk_1.Tools)().cursor(undefined, { sortBy: ["-toolId"] });
27
- }
28
- cursorObs(cursor);
29
- cursorId((0, peers_sdk_1.newid)());
30
- return cursor;
31
- }
32
- (0, react_1.useEffect)(() => {
33
- const sub = searchTextObs.subscribe(() => {
34
- cursorObs(undefined);
35
- cursorId((0, peers_sdk_1.newid)());
36
- });
37
- return () => sub.dispose();
38
- }, [cursorId, cursorObs, searchTextObs.subscribe]);
39
- async function loadMore(existingTools) {
40
- const moreMatches = [];
41
- const cursor = cursorObs() || (await newCursor());
42
- for await (const tool of cursor) {
43
- if (existingTools.find((w) => w.toolId === tool.toolId))
44
- continue;
45
- moreMatches.push(tool);
46
- if (searchText.length && moreMatches.length > 5)
47
- break;
48
- if (moreMatches.length >= 50)
49
- break;
50
- }
51
- if (moreMatches.length === 0) {
52
- cursorObs(undefined);
53
- }
54
- return moreMatches;
55
- }
56
- return ((0, jsx_runtime_1.jsxs)("div", { className: "container-fluid", children: [(0, jsx_runtime_1.jsx)(input_1.Input, { value: searchTextObs, className: "form-control mt-3", style: { marginBottom: "10px" }, placeholder: "Search tools", autoFocus: !!(0, globals_1.isDesktop)() }), (0, jsx_runtime_1.jsx)("div", { className: "peers-list-container", children: (0, jsx_runtime_1.jsx)(lazy_list_1.LazyList, { loadMore: loadMore, scrollThreshold: 0.6, renderItems: (tools) => {
57
- return tools.map((tool) => {
58
- let markdownContent = `${tool.usageDescription}\n\n---\n\n${tool.detailedDescription ?? ""}`;
59
- const maxLen = 500;
60
- if (markdownContent.length > maxLen) {
61
- markdownContent = `${markdownContent.substring(0, maxLen)}...`;
62
- }
63
- markdownContent = markdownContent.replace(/\n\n---\n\n$/, "");
64
- return ((0, jsx_runtime_1.jsxs)("div", { className: "container-fluid pb-4", children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-tools" }), "\u00A0", (0, jsx_runtime_1.jsx)("a", { href: `#tools/${tool.toolId}`, children: tool.name }), (0, jsx_runtime_1.jsx)("div", { style: { paddingLeft: "20px" }, children: (0, jsx_runtime_1.jsx)(markdown_with_mentions_1.MarkdownWithMentions, { content: markdownContent }) })] }, tool.toolId));
65
- });
66
- }, loadingIndicator: (0, jsx_runtime_1.jsx)("div", { className: "d-flex justify-content-center", style: { height: 200 }, children: (0, jsx_runtime_1.jsx)(loading_indicator_1.LoadingIndicator, {}) }), endOfList: (0, jsx_runtime_1.jsx)("div", { className: "d-flex justify-content-center", style: { height: 200 } }) }, cursorId()) })] }));
15
+ return ((0, jsx_runtime_1.jsx)(list_screen_1.ListScreen, { table: (0, peers_sdk_1.Tools)(), getFilter: getFilter, sortBy: ["-toolId"], renderItem: (tool) => ((0, jsx_runtime_1.jsx)(list_row_1.ListRow, { href: `#tools/${tool.toolId}`, icon: (0, jsx_runtime_1.jsx)("i", { className: "bi-tools" }), title: tool.name, description: (0, list_screen_1.firstLineOf)(tool.usageDescription), badges: tool.contractVersion ? ((0, jsx_runtime_1.jsxs)("span", { className: "badge peers-fact-badge", children: ["v", tool.contractVersion] })) : undefined }, tool.toolId)), placeholderName: "tool", icon: "bi-tools", title: "Tools", subtitle: "What apps, agents and other devices can ask Peers and your apps to do" }));
67
16
  }
17
+ // Registered, so it comes before the fallback list every one-part path gets (ui-defaults).
18
+ (0, ui_loader_1.registerInternalPeersUI)({
19
+ peersUIId: "00mxav2slq5n2svu8miloe38u",
20
+ component: ToolList,
21
+ routes: [
22
+ {
23
+ // Saved tabs from the removed tool-test screens fall back to the catalog.
24
+ isMatch: (_props, context) => context.path === "tools" || /^tools\/tests(?:\/|$)/.test(context.path),
25
+ uiCategory: "screen",
26
+ priority: 2,
27
+ },
28
+ ],
29
+ });