@x-tech-laboratories/x-app 0.114.0 → 0.114.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/web/react/states.js +31 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -147,7 +147,7 @@ an app moves over by changing the package name in its imports and its `x-libs-*`
|
|
|
147
147
|
| `web/prefs`, `web/react/prefs` | Remembered view settings that read as their default when stored corrupt, stale or of the wrong shape; `use_pref` keeps one as component state. |
|
|
148
148
|
| `web/selection`, `web/virtual`, `web/drag` | Picking rows with plain, Ctrl and Shift clicks from a fixed anchor, or as lists of ids with the anchor kept by id, the row an arrow or page key moves to; which rows of a long list a viewport needs; a badge such as "3 tasks" as the drag image. |
|
|
149
149
|
| `web/react/shell` | `Shell`: top bar with the brand and its icon and the app's `tools`; section links, or, once a section has `children`, a `SectionTree` of section rows folding open onto their items on `Tree`, the folded ones kept in the `sections_pref` pref and a folded section lit up in place of its hidden `active_item`; or the app's `views` as rows with their icons (from `web/react/icons`) in the sidebar's navigation, the one `active` names raised and marked as the current page, above the app's own sidebar in a `.sidebar-content` box, the sidebar then an aside so the views are its only navigation landmark, or that sidebar alone, scrolling above a foot pinned to the sidebar's bottom that holds the app's `sidebar_foot` rows, then the theme, the signed-in `user` linked to `user_href` with Sign out, and `settings` last; resizable; a `side_pane` docked on the right beside main ([A pane on the right](#a-pane-on-the-right)), its open state kept by `use_side_pane` in a pref; `brand_logo` for a full logo that already holds the name, drawn alone in its place; a `status_bar` at the foot of the window, toasts, dialogs and menus, with or without logins (no account row without a `user`, `logged_out` hiding the sidebar and tools), its phone menu held by the Shell or the app, and for app-like pages a `contained` window where only main scrolls and the brand heading the sidebar; `labels` for its own words in another language; `ThemeRow`, the theme as a sidebar row, `ThemeButton`, as an icon button, both drawing the system theme on a server and until the page is picked up, and `use_route`. |
|
|
150
|
-
| `web/react/layout`, `badges`, `states` | `PageHeading` with a subtitle, icon, banner, actions and a `level` for inside dialogs and panels; panels (`Section`, with a `level` for one inside a dialog or under another heading), `GroupSections`, a panel per group from `group_items` headed by its name and count, facts, tiles, cards, tabs, `Crumbs` with chevrons between steps that link, run a function or mark where the reader is, `PathText` for a path shown with the same chevrons, steppers, `FormRow` for a form's labelled fields, `FormGroup` folding part of a form under a summary line such as "More options", `SettingsPage` with an `Outline` beside its sections, settings rows, `RowActions` and `moved` for ordered lists, `SelectionBar` for picked rows, their count with its thousands separated; badges, `StateBadge` naming each state's text and tone and `ToneBadge` showing the state's own name in its tone, chips in an item's own colour, dashed or removable, `ColorDot` and `StatusPill`, a state dot with text and an action; `use_resource` with its `status` (idle until `enabled`, loading, loaded, failed), a `watch` that reloads it quietly, and its loading states, `Loaded` going by the status so a null result shows its `empty` slot or the children. |
|
|
150
|
+
| `web/react/layout`, `badges`, `states` | `PageHeading` with a subtitle, icon, banner, actions and a `level` for inside dialogs and panels; panels (`Section`, with a `level` for one inside a dialog or under another heading), `GroupSections`, a panel per group from `group_items` headed by its name and count, facts, tiles, cards, tabs, `Crumbs` with chevrons between steps that link, run a function or mark where the reader is, `PathText` for a path shown with the same chevrons, steppers, `FormRow` for a form's labelled fields, `FormGroup` folding part of a form under a summary line such as "More options", `SettingsPage` with an `Outline` beside its sections, settings rows, `RowActions` and `moved` for ordered lists, `SelectionBar` for picked rows, their count with its thousands separated; badges, `StateBadge` naming each state's text and tone and `ToneBadge` showing the state's own name in its tone, chips in an item's own colour, dashed or removable, `ColorDot` and `StatusPill`, a state dot with text and an action; `use_resource` with its `status` (idle until `enabled`, loading, loaded, failed), a `watch` that reloads it quietly (bumps during a load fold into one load after it), and its loading states, `Loaded` going by the status so a null result shows its `empty` slot or the children. |
|
|
151
151
|
| `web/react/sync_settings`, `backup_settings` | The settings rows every device shows: `SyncSettings`, the sync status, this device with its id and where others reach it, a pairing code to show when they can, each paired device with how it was last reached and Remove after a confirm, and a field to enter another device's code; `SyncButton`, the same status as a sidebar row with the changes waiting, syncing on a click or opening the settings when sync failed or no device is paired, and shown even then; `BackupSettings`, back up now, the daily schedule, and each backup to restore or delete after a confirm. |
|
|
152
152
|
| `web/react/connections` | `ConnectionSettings`: the Connections section of Settings, every daemon the app can talk to with the one in use marked Connected, Connect to switch, Rename and Remove (after a confirm) for daemons on other hosts, and a form to add one by address, name and password, asking for the code when the daemon does and offering to trust a certificate the device refuses given `certificates`. |
|
|
153
153
|
| `web/react/certificates` | `CertificateDialog`: what is wrong with a server's certificate in plain words, the certificate itself with its fingerprint, and Trust or Don't connect; `offer_certificate_trust` and `ask_to_trust_certificate` open it from anywhere, `with_certificate_prompt` wraps a fetch to ask and retry once, `SyncCertificatePrompt` asks whenever syncing with a paired device's https address fails over its certificate, and `TrustedCertificates` lists them to forget. |
|
package/dist/web/react/states.js
CHANGED
|
@@ -20,24 +20,53 @@ export function use_resource(work, dependencies, options = {}) {
|
|
|
20
20
|
const latest_work = useRef(work);
|
|
21
21
|
latest_work.current = work;
|
|
22
22
|
const generation = useRef(0);
|
|
23
|
-
|
|
23
|
+
// The load under way, and whether a quiet reload asked for while it ran is still owed.
|
|
24
|
+
const running = useRef(null);
|
|
25
|
+
const owed = useRef(false);
|
|
26
|
+
const load = useCallback((quiet) => {
|
|
24
27
|
const mine = ++generation.current;
|
|
25
28
|
if (!quiet)
|
|
26
29
|
set_state({ data: null, error: null, status: "loading" });
|
|
27
|
-
|
|
30
|
+
const settled = latest_work.current().then((data) => { if (mine === generation.current)
|
|
28
31
|
set_state({ data, error: null, status: "loaded" }); }, (error) => {
|
|
29
32
|
if (pass_login_needed(error) || mine !== generation.current)
|
|
30
33
|
return;
|
|
31
34
|
set_state((before) => quiet && before.data !== null ? before : { data: null, error, status: "failed" });
|
|
35
|
+
}).finally(() => {
|
|
36
|
+
if (running.current !== settled)
|
|
37
|
+
return;
|
|
38
|
+
running.current = null;
|
|
39
|
+
if (owed.current && mine === generation.current) {
|
|
40
|
+
owed.current = false;
|
|
41
|
+
void load(true);
|
|
42
|
+
}
|
|
32
43
|
});
|
|
44
|
+
running.current = settled;
|
|
45
|
+
return settled;
|
|
33
46
|
}, []);
|
|
47
|
+
// Quiet reloads asked for while a load runs become one more load once it settles, so a burst of changes on a slow server
|
|
48
|
+
// never stacks requests up behind each other.
|
|
49
|
+
const reload = useCallback((quiet = false) => {
|
|
50
|
+
if (quiet && running.current) {
|
|
51
|
+
owed.current = true;
|
|
52
|
+
return running.current;
|
|
53
|
+
}
|
|
54
|
+
owed.current = false;
|
|
55
|
+
return load(quiet);
|
|
56
|
+
}, [load]);
|
|
34
57
|
useEffect(() => {
|
|
35
58
|
if (enabled)
|
|
36
59
|
return void reload();
|
|
37
60
|
// Turning off drops the load under way and what it showed.
|
|
38
61
|
generation.current += 1;
|
|
62
|
+
owed.current = false;
|
|
39
63
|
set_state((before) => before.status === "idle" ? before : { data: null, error: null, status: "idle" });
|
|
40
64
|
}, [enabled, ...dependencies]);
|
|
65
|
+
// A page that has gone loads nothing more.
|
|
66
|
+
useEffect(() => () => {
|
|
67
|
+
generation.current += 1;
|
|
68
|
+
owed.current = false;
|
|
69
|
+
}, []);
|
|
41
70
|
useEffect(() => {
|
|
42
71
|
if (!options.refresh_in_milliseconds || !enabled)
|
|
43
72
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@x-tech-laboratories/x-app",
|
|
3
|
-
"version": "0.114.
|
|
3
|
+
"version": "0.114.1",
|
|
4
4
|
"description": "Code the X-apps share: agents and their long runs, passwords and sign-in, the Fastify server pieces, durations, and the web page's helpers and widgets",
|
|
5
5
|
"license": "GPL-3.0-or-later",
|
|
6
6
|
"repository": {
|