@vieo-io/ui 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -5
- package/dist/app-switcher.css +1 -0
- package/dist/controls.css +5 -0
- package/dist/core/index.d.ts +10 -0
- package/dist/core/index.js +9 -0
- package/dist/core/reveal.d.ts +10 -0
- package/dist/core/reveal.js +65 -0
- package/dist/core/search.d.ts +5 -0
- package/dist/core/search.js +12 -0
- package/dist/core/settingsSearch.d.ts +21 -0
- package/dist/core/settingsSearch.js +37 -0
- package/dist/core/update/build.d.ts +48 -0
- package/dist/core/update/build.js +90 -0
- package/dist/core/update/follow.d.ts +39 -0
- package/dist/core/update/follow.js +49 -0
- package/dist/core/update/notNow.d.ts +4 -0
- package/dist/core/update/notNow.js +18 -0
- package/dist/core/update/offer.d.ts +32 -0
- package/dist/core/update/offer.js +19 -0
- package/dist/core/update/reload.d.ts +12 -0
- package/dist/core/update/reload.js +16 -0
- package/dist/core/update/types.d.ts +33 -0
- package/dist/field.css +7 -0
- package/dist/react/index.d.ts +4 -0
- package/dist/react/index.js +4 -0
- package/dist/react/settingsSearch.d.ts +35 -0
- package/dist/react/settingsSearch.js +97 -0
- package/dist/react/update/Offer.d.ts +9 -0
- package/dist/react/update/Offer.js +4 -0
- package/dist/react/update/UpdateNotice.d.ts +37 -0
- package/dist/react/update/UpdateNotice.js +141 -0
- package/dist/react/update/hooks.d.ts +9 -0
- package/dist/react/update/hooks.js +51 -0
- package/dist/search.css +83 -0
- package/dist/setting.css +26 -0
- package/dist/shell.css +31 -0
- package/dist/{AppShell.d.ts → solid/AppShell.d.ts} +7 -0
- package/dist/{AppShell.jsx → solid/AppShell.jsx} +1 -1
- package/dist/{CommandPalette.d.ts → solid/CommandPalette.d.ts} +1 -1
- package/dist/{CommandPalette.jsx → solid/CommandPalette.jsx} +5 -10
- package/dist/{Dialog.jsx → solid/Dialog.jsx} +1 -1
- package/dist/{Icon.d.ts → solid/Icon.d.ts} +1 -1
- package/dist/{Icon.jsx → solid/Icon.jsx} +1 -1
- package/dist/{Listbox.jsx → solid/Listbox.jsx} +2 -2
- package/dist/{Menu.jsx → solid/Menu.jsx} +3 -3
- package/dist/{Popover.jsx → solid/Popover.jsx} +2 -2
- package/dist/{SegmentedControl.jsx → solid/SegmentedControl.jsx} +2 -2
- package/dist/{Sidebar.jsx → solid/Sidebar.jsx} +1 -1
- package/dist/{Tabs.jsx → solid/Tabs.jsx} +2 -2
- package/dist/{TextField.jsx → solid/TextField.jsx} +1 -1
- package/dist/{Toolbar.jsx → solid/Toolbar.jsx} +1 -1
- package/dist/{Tooltip.jsx → solid/Tooltip.jsx} +1 -1
- package/dist/{Tree.d.ts → solid/Tree.d.ts} +8 -1
- package/dist/{Tree.jsx → solid/Tree.jsx} +27 -8
- package/dist/{index.d.ts → solid/index.d.ts} +1 -1
- package/dist/{index.js → solid/index.js} +1 -1
- package/dist/solid/trigger.js +1 -0
- package/dist/styles.css +2 -0
- package/dist/toolbar.css +8 -0
- package/dist/tree.css +38 -1
- package/dist/update.css +118 -0
- package/package.json +39 -8
- /package/dist/{aria.d.ts → core/aria.d.ts} +0 -0
- /package/dist/{aria.js → core/aria.js} +0 -0
- /package/dist/{layers.d.ts → core/layers.d.ts} +0 -0
- /package/dist/{layers.js → core/layers.js} +0 -0
- /package/dist/{paths.d.ts → core/paths.d.ts} +0 -0
- /package/dist/{paths.js → core/paths.js} +0 -0
- /package/dist/{roving.d.ts → core/roving.d.ts} +0 -0
- /package/dist/{roving.js → core/roving.js} +0 -0
- /package/dist/{trigger.js → core/update/types.js} +0 -0
- /package/dist/{AppSwitcher.d.ts → solid/AppSwitcher.d.ts} +0 -0
- /package/dist/{AppSwitcher.jsx → solid/AppSwitcher.jsx} +0 -0
- /package/dist/{Badge.d.ts → solid/Badge.d.ts} +0 -0
- /package/dist/{Badge.jsx → solid/Badge.jsx} +0 -0
- /package/dist/{Button.d.ts → solid/Button.d.ts} +0 -0
- /package/dist/{Button.jsx → solid/Button.jsx} +0 -0
- /package/dist/{Checkbox.d.ts → solid/Checkbox.d.ts} +0 -0
- /package/dist/{Checkbox.jsx → solid/Checkbox.jsx} +0 -0
- /package/dist/{Dialog.d.ts → solid/Dialog.d.ts} +0 -0
- /package/dist/{EmptyState.d.ts → solid/EmptyState.d.ts} +0 -0
- /package/dist/{EmptyState.jsx → solid/EmptyState.jsx} +0 -0
- /package/dist/{IconButton.d.ts → solid/IconButton.d.ts} +0 -0
- /package/dist/{IconButton.jsx → solid/IconButton.jsx} +0 -0
- /package/dist/{Kbd.d.ts → solid/Kbd.d.ts} +0 -0
- /package/dist/{Kbd.jsx → solid/Kbd.jsx} +0 -0
- /package/dist/{Listbox.d.ts → solid/Listbox.d.ts} +0 -0
- /package/dist/{Menu.d.ts → solid/Menu.d.ts} +0 -0
- /package/dist/{ObjectCard.d.ts → solid/ObjectCard.d.ts} +0 -0
- /package/dist/{ObjectCard.jsx → solid/ObjectCard.jsx} +0 -0
- /package/dist/{Popover.d.ts → solid/Popover.d.ts} +0 -0
- /package/dist/{Resizer.d.ts → solid/Resizer.d.ts} +0 -0
- /package/dist/{Resizer.jsx → solid/Resizer.jsx} +0 -0
- /package/dist/{SegmentedControl.d.ts → solid/SegmentedControl.d.ts} +0 -0
- /package/dist/{Select.d.ts → solid/Select.d.ts} +0 -0
- /package/dist/{Select.jsx → solid/Select.jsx} +0 -0
- /package/dist/{SettingRow.d.ts → solid/SettingRow.d.ts} +0 -0
- /package/dist/{SettingRow.jsx → solid/SettingRow.jsx} +0 -0
- /package/dist/{Sidebar.d.ts → solid/Sidebar.d.ts} +0 -0
- /package/dist/{Switch.d.ts → solid/Switch.d.ts} +0 -0
- /package/dist/{Switch.jsx → solid/Switch.jsx} +0 -0
- /package/dist/{Tabs.d.ts → solid/Tabs.d.ts} +0 -0
- /package/dist/{TextField.d.ts → solid/TextField.d.ts} +0 -0
- /package/dist/{Toast.d.ts → solid/Toast.d.ts} +0 -0
- /package/dist/{Toast.jsx → solid/Toast.jsx} +0 -0
- /package/dist/{Toolbar.d.ts → solid/Toolbar.d.ts} +0 -0
- /package/dist/{Tooltip.d.ts → solid/Tooltip.d.ts} +0 -0
- /package/dist/{trigger.d.ts → solid/trigger.d.ts} +0 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** What an app's server says to a request to update itself. */
|
|
2
|
+
export type StartAnswer = 'started' | 'running' | 'current' | {
|
|
3
|
+
refused: string;
|
|
4
|
+
};
|
|
5
|
+
/** How the server's last update went, kept across the restart it causes. */
|
|
6
|
+
export type UpdateOutcome = {
|
|
7
|
+
state: 'current' | 'failed' | 'replaced' | 'running';
|
|
8
|
+
exit: number | null;
|
|
9
|
+
output: string;
|
|
10
|
+
from: string | null;
|
|
11
|
+
to: string | null;
|
|
12
|
+
/** Null for an outcome only the service manager reported. */
|
|
13
|
+
at: number | null;
|
|
14
|
+
};
|
|
15
|
+
/** An app's own update endpoint. */
|
|
16
|
+
export type UpdateSource = {
|
|
17
|
+
/** Rejects when the server cannot be reached, as while it restarts. */
|
|
18
|
+
read: () => Promise<UpdateStatus>;
|
|
19
|
+
start: (target: string) => Promise<StartAnswer>;
|
|
20
|
+
};
|
|
21
|
+
/** Each app's server reports its update in its own shape, and its {@link UpdateSource} maps it to this one. */
|
|
22
|
+
export type UpdateStatus = {
|
|
23
|
+
installed: string | null;
|
|
24
|
+
/** The newest release the server's package source has, or null without one, as for a checkout or a failed read. */
|
|
25
|
+
latest: string | null;
|
|
26
|
+
newer: boolean;
|
|
27
|
+
running: boolean;
|
|
28
|
+
/** Whether this viewer may start an update. */
|
|
29
|
+
mayStart: boolean;
|
|
30
|
+
/** How many things end when the server restarts, such as open terminals. */
|
|
31
|
+
blockers: number;
|
|
32
|
+
last: UpdateOutcome | null;
|
|
33
|
+
};
|
package/dist/field.css
CHANGED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { SettingsSearch, type SettingsSearchProps, SettingTargetProvider, useSettingTarget, } from './settingsSearch.js';
|
|
2
|
+
export { useStaleBuild, useUpdateStatus } from './update/hooks.js';
|
|
3
|
+
export { Offer } from './update/Offer.js';
|
|
4
|
+
export { type ReactOffer, UpdateNotice, type UpdateNoticeApp } from './update/UpdateNotice.js';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type SettingItem } from '../core/settingsSearch.js';
|
|
3
|
+
export type SettingsSearchProps<Item extends SettingItem> = {
|
|
4
|
+
items: readonly Item[];
|
|
5
|
+
/** Opens the item's section with `item.id` as the target, through the app's own router. */
|
|
6
|
+
onOpen: (item: Item) => void;
|
|
7
|
+
label?: string;
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
/** Shown in place of the results while the box is empty, usually the list of sections. */
|
|
10
|
+
children?: ReactNode;
|
|
11
|
+
};
|
|
12
|
+
type SettingTarget = {
|
|
13
|
+
target: string | undefined;
|
|
14
|
+
onReached: () => void;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* A search box over an app's settings, with the matching settings listed under it while it holds text.
|
|
18
|
+
* Up and Down move through them, Enter or a click opens one, Escape clears the box, and `/` focuses it from anywhere
|
|
19
|
+
* but a text field.
|
|
20
|
+
*/
|
|
21
|
+
export declare function SettingsSearch<Item extends SettingItem>({ items, onOpen, label, placeholder, children, }: SettingsSearchProps<Item>): import("react").JSX.Element;
|
|
22
|
+
/** Gives the row reached by a search its target, from the app's router, and clears it through `onReached`. */
|
|
23
|
+
export declare function SettingTargetProvider({ target, onReached, children, }: SettingTarget & {
|
|
24
|
+
children: ReactNode;
|
|
25
|
+
}): import("react").JSX.Element;
|
|
26
|
+
/**
|
|
27
|
+
* The props a setting's row spreads to be found by a search: its anchor, and a ref that reveals the row while it is
|
|
28
|
+
* mounted and the target.
|
|
29
|
+
*/
|
|
30
|
+
export declare function useSettingTarget(id: string): {
|
|
31
|
+
id: string;
|
|
32
|
+
ref: import("react").Dispatch<import("react").SetStateAction<HTMLElement | null>>;
|
|
33
|
+
tabIndex: number;
|
|
34
|
+
};
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useEffect, useId, useMemo, useRef, useState, } from 'react';
|
|
3
|
+
import { revealSetting } from '../core/reveal.js';
|
|
4
|
+
import { searchSettings, settingAnchor } from '../core/settingsSearch.js';
|
|
5
|
+
const SettingTargetContext = createContext({
|
|
6
|
+
target: undefined,
|
|
7
|
+
onReached: () => { },
|
|
8
|
+
});
|
|
9
|
+
/**
|
|
10
|
+
* A search box over an app's settings, with the matching settings listed under it while it holds text.
|
|
11
|
+
* Up and Down move through them, Enter or a click opens one, Escape clears the box, and `/` focuses it from anywhere
|
|
12
|
+
* but a text field.
|
|
13
|
+
*/
|
|
14
|
+
export function SettingsSearch({ items, onOpen, label = 'Search settings', placeholder = 'Search settings', children, }) {
|
|
15
|
+
const [query, setQuery] = useState('');
|
|
16
|
+
const [active, setActive] = useState(0);
|
|
17
|
+
const box = useRef(null);
|
|
18
|
+
const list = useId();
|
|
19
|
+
const results = useMemo(() => searchSettings(items, query), [items, query]);
|
|
20
|
+
const searching = query.trim() !== '';
|
|
21
|
+
const activeId = searching && results.length ? `${list}-${active}` : undefined;
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
const focusOnSlash = (event) => {
|
|
24
|
+
const modified = event.ctrlKey || event.metaKey || event.altKey;
|
|
25
|
+
if (event.key !== '/' || modified || holdsText(document.activeElement))
|
|
26
|
+
return;
|
|
27
|
+
event.preventDefault();
|
|
28
|
+
box.current?.focus();
|
|
29
|
+
};
|
|
30
|
+
document.addEventListener('keydown', focusOnSlash);
|
|
31
|
+
return () => document.removeEventListener('keydown', focusOnSlash);
|
|
32
|
+
}, []);
|
|
33
|
+
const open = (item) => {
|
|
34
|
+
setQuery('');
|
|
35
|
+
setActive(0);
|
|
36
|
+
onOpen(item);
|
|
37
|
+
};
|
|
38
|
+
const keyDown = (event) => {
|
|
39
|
+
if (event.key === 'Escape' && query) {
|
|
40
|
+
event.preventDefault();
|
|
41
|
+
event.nativeEvent.stopImmediatePropagation();
|
|
42
|
+
setQuery('');
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (!results.length)
|
|
46
|
+
return;
|
|
47
|
+
if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
|
48
|
+
event.preventDefault();
|
|
49
|
+
const step = event.key === 'ArrowDown' ? 1 : -1;
|
|
50
|
+
setActive(Math.min(results.length - 1, Math.max(0, active + step)));
|
|
51
|
+
}
|
|
52
|
+
const chosen = results[active];
|
|
53
|
+
if (event.key === 'Enter' && chosen) {
|
|
54
|
+
event.preventDefault();
|
|
55
|
+
open(chosen);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
return (_jsxs("div", { className: 'vds-settings-search', children: [_jsx("input", { ref: box, className: 'vds-settings-search__box', type: 'search', role: 'combobox', "aria-label": label, "aria-expanded": searching, "aria-controls": list, "aria-activedescendant": activeId, "aria-autocomplete": 'list', placeholder: placeholder, value: query, onChange: (event) => {
|
|
59
|
+
setQuery(event.target.value);
|
|
60
|
+
setActive(0);
|
|
61
|
+
}, onKeyDown: keyDown }), searching ? (_jsx(Results, { id: list, results: results, active: active, onOpen: open })) : (children)] }));
|
|
62
|
+
}
|
|
63
|
+
/** Gives the row reached by a search its target, from the app's router, and clears it through `onReached`. */
|
|
64
|
+
export function SettingTargetProvider({ target, onReached, children, }) {
|
|
65
|
+
const value = useMemo(() => ({ target, onReached }), [target, onReached]);
|
|
66
|
+
return _jsx(SettingTargetContext.Provider, { value: value, children: children });
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The props a setting's row spreads to be found by a search: its anchor, and a ref that reveals the row while it is
|
|
70
|
+
* mounted and the target.
|
|
71
|
+
*/
|
|
72
|
+
export function useSettingTarget(id) {
|
|
73
|
+
const { target, onReached } = useContext(SettingTargetContext);
|
|
74
|
+
const [element, setElement] = useState(null);
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
if (!element || target !== id)
|
|
77
|
+
return;
|
|
78
|
+
revealSetting(element, {
|
|
79
|
+
reducedMotion: matchMedia('(prefers-reduced-motion: reduce)').matches,
|
|
80
|
+
});
|
|
81
|
+
onReached();
|
|
82
|
+
}, [element, id, target, onReached]);
|
|
83
|
+
return { id: settingAnchor(id), ref: setElement, tabIndex: -1 };
|
|
84
|
+
}
|
|
85
|
+
function holdsText(element) {
|
|
86
|
+
if (element instanceof HTMLTextAreaElement || element instanceof HTMLSelectElement)
|
|
87
|
+
return true;
|
|
88
|
+
if (element instanceof HTMLInputElement)
|
|
89
|
+
return !['button', 'checkbox', 'radio', 'range', 'submit'].includes(element.type);
|
|
90
|
+
return element instanceof HTMLElement && element.isContentEditable;
|
|
91
|
+
}
|
|
92
|
+
function Results({ id, results, active, onOpen, }) {
|
|
93
|
+
if (!results.length) {
|
|
94
|
+
return (_jsx("p", { className: 'vds-settings-search__empty', role: 'status', children: "No settings found" }));
|
|
95
|
+
}
|
|
96
|
+
return (_jsx("div", { className: 'vds-settings-search__results', id: id, role: 'listbox', children: results.map((item, index) => (_jsxs("div", { id: `${id}-${index}`, className: 'vds-settings-search__result', role: 'option', "aria-selected": index === active, onMouseDown: (event) => event.preventDefault(), onClick: () => onOpen(item), children: [_jsx("span", { className: 'vds-settings-search__title', children: item.title }), _jsx("span", { className: 'vds-settings-search__section', children: item.sectionTitle })] }, item.id))) }));
|
|
97
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export function Offer({ text, whatsNew, id, label, onPress }) {
|
|
3
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { children: text }), _jsx("a", { href: whatsNew, children: "What\u2019s new" }), _jsx("button", { type: 'button', className: 'primary vieo-update-action', id: id, onClick: onPress, children: label })] }));
|
|
4
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type BuildWatch } from '../../core/update/build.js';
|
|
3
|
+
import { type AppOffer } from '../../core/update/offer.js';
|
|
4
|
+
import type { UpdateSource, UpdateStatus } from '../../core/update/types.js';
|
|
5
|
+
export type ReactOffer = AppOffer<ReactNode>;
|
|
6
|
+
export type UpdateNoticeApp = {
|
|
7
|
+
whatsNew: string;
|
|
8
|
+
/** The storage key that remembers which offer Not now was pressed for. */
|
|
9
|
+
notNowKey: string;
|
|
10
|
+
/** Asked before an update while the status has blockers. Resolves to whether to go ahead. */
|
|
11
|
+
confirm?: (status: UpdateStatus) => Promise<boolean>;
|
|
12
|
+
/** Runs before each reload that follows a pressed update. Resolves to true when it took the page elsewhere itself. */
|
|
13
|
+
afterUpdate?: () => Promise<boolean>;
|
|
14
|
+
reload?: () => void;
|
|
15
|
+
};
|
|
16
|
+
type UpdateNoticeProps = {
|
|
17
|
+
/** Null for a viewer who is only ever offered the page's refresh. */
|
|
18
|
+
source: UpdateSource | null;
|
|
19
|
+
status: UpdateStatus | null;
|
|
20
|
+
/** Has the status read again, as once an update ends. */
|
|
21
|
+
readAgain: () => void;
|
|
22
|
+
build: BuildWatch;
|
|
23
|
+
/** From {@link useStaleBuild}. */
|
|
24
|
+
stale: string | null;
|
|
25
|
+
app: UpdateNoticeApp;
|
|
26
|
+
first?: ReactOffer | null;
|
|
27
|
+
last?: ReactOffer | null;
|
|
28
|
+
/** Draws the Not now button in place of the package's own. */
|
|
29
|
+
renderNotNow?: (press: () => void) => ReactNode;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Pins one card for whatever is newer, in the order {@link pickOffer} gives.
|
|
33
|
+
* One press of Refresh to update on the server's update updates the server, follows it, and reloads once into the new
|
|
34
|
+
* build. A viewer who may update the server and finds an update already running follows it, then is offered the refresh.
|
|
35
|
+
*/
|
|
36
|
+
export declare function UpdateNotice({ source, status, readAgain, build, stale, app, first, last, renderNotNow, }: UpdateNoticeProps): import("react").JSX.Element;
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { checkForNewBuild } from '../../core/update/build.js';
|
|
4
|
+
import { FOLLOW_FOR_MS, followUpdate } from '../../core/update/follow.js';
|
|
5
|
+
import { isPutOff, putOff } from '../../core/update/notNow.js';
|
|
6
|
+
import { pickOffer } from '../../core/update/offer.js';
|
|
7
|
+
import { reloadWhenServing } from '../../core/update/reload.js';
|
|
8
|
+
import { Offer } from './Offer.js';
|
|
9
|
+
/**
|
|
10
|
+
* Pins one card for whatever is newer, in the order {@link pickOffer} gives.
|
|
11
|
+
* One press of Refresh to update on the server's update updates the server, follows it, and reloads once into the new
|
|
12
|
+
* build. A viewer who may update the server and finds an update already running follows it, then is offered the refresh.
|
|
13
|
+
*/
|
|
14
|
+
export function UpdateNotice({ source, status, readAgain, build, stale, app, first, last, renderNotNow, }) {
|
|
15
|
+
const flow = useServerFlow({ source, status, readAgain, build, app });
|
|
16
|
+
const [putOffNow, setPutOffNow] = useState(null);
|
|
17
|
+
const offer = pickOffer({ first, last, server: flow.taken ?? status, stale });
|
|
18
|
+
const key = offer?.key ?? '';
|
|
19
|
+
const hidden = !offer || putOffNow === key || isPutOff(app.notNowKey, key);
|
|
20
|
+
const reload = app.reload ?? (() => location.reload());
|
|
21
|
+
function notNow() {
|
|
22
|
+
putOff(app.notNowKey, key);
|
|
23
|
+
setPutOffNow(key);
|
|
24
|
+
}
|
|
25
|
+
function content() {
|
|
26
|
+
if (offer?.kind === 'app')
|
|
27
|
+
return offer.offer.node;
|
|
28
|
+
if (offer?.kind === 'refresh')
|
|
29
|
+
return (_jsx(Offer, { text: 'New version ready', whatsNew: app.whatsNew, id: 'update-reload', label: 'Refresh to update', onPress: () => void reloadWhenServing({ ...build, reload }) }));
|
|
30
|
+
if (offer?.kind !== 'server')
|
|
31
|
+
return null;
|
|
32
|
+
if (flow.step)
|
|
33
|
+
return _jsx("span", { children: flow.step });
|
|
34
|
+
const { status: offered } = offer;
|
|
35
|
+
return (_jsx(Offer, { text: flow.stopped ?? 'New version ready', whatsNew: app.whatsNew, id: 'update-reload', label: 'Refresh to update', onPress: () => void flow.press(offered) }));
|
|
36
|
+
}
|
|
37
|
+
return (_jsxs("div", { className: 'vieo-update-notice', id: 'update-notice', role: 'status', hidden: hidden, children: [content(), renderNotNow ? renderNotNow(notNow) : _jsx(NotNow, { onPress: notNow })] }));
|
|
38
|
+
}
|
|
39
|
+
function errorText(error) {
|
|
40
|
+
return error instanceof Error ? error.message : String(error);
|
|
41
|
+
}
|
|
42
|
+
function NotNow({ onPress }) {
|
|
43
|
+
return (_jsx("button", { type: 'button', className: 'vieo-update-not-now', id: 'update-not-now', "aria-label": 'Not now', title: 'Not now', onClick: onPress, children: _jsx("svg", { viewBox: '0 0 24 24', "aria-hidden": 'true', children: _jsx("path", { d: 'M18 6 6 18M6 6l12 12' }) }) }));
|
|
44
|
+
}
|
|
45
|
+
/** Starts the server's update on a press, or follows one found running, and says each step. Only a press reloads at the end. */
|
|
46
|
+
function useServerFlow({ source, status, readAgain, build, app, }) {
|
|
47
|
+
const [taken, setTaken] = useState(null);
|
|
48
|
+
const [step, setStep] = useState(null);
|
|
49
|
+
const [stopped, setStopped] = useState(null);
|
|
50
|
+
// A run that ended is not followed again from the read that showed it running, which stays until the next read
|
|
51
|
+
// lands, nor from a later read of the version it installed, since a server can go on reporting the run that long.
|
|
52
|
+
const [endedOn, setEndedOn] = useState({
|
|
53
|
+
read: null,
|
|
54
|
+
installed: null,
|
|
55
|
+
});
|
|
56
|
+
const current = useRef(status);
|
|
57
|
+
current.current = status;
|
|
58
|
+
const reload = app.reload ?? (() => location.reload());
|
|
59
|
+
async function reloadAfterUpdate() {
|
|
60
|
+
const tookPageElsewhere = await app.afterUpdate?.().catch(() => false);
|
|
61
|
+
if (!tookPageElsewhere)
|
|
62
|
+
await reloadWhenServing({ ...build, reload });
|
|
63
|
+
}
|
|
64
|
+
async function servesNewerBuild() {
|
|
65
|
+
const served = await build.read().catch(() => null);
|
|
66
|
+
return served !== null && served !== build.loaded;
|
|
67
|
+
}
|
|
68
|
+
function settle(end) {
|
|
69
|
+
setEndedOn({ read: current.current, installed: end.installed });
|
|
70
|
+
setStep(null);
|
|
71
|
+
setTaken(null);
|
|
72
|
+
readAgain();
|
|
73
|
+
}
|
|
74
|
+
async function ended(end, pressed) {
|
|
75
|
+
if (!end) {
|
|
76
|
+
setStep(null);
|
|
77
|
+
setStopped(`The server’s update hasn’t finished in ${FOLLOW_FOR_MS / 60_000} minutes.`);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const { progress, status: final } = end;
|
|
81
|
+
if (progress.kind === 'failed') {
|
|
82
|
+
setStep(null);
|
|
83
|
+
setStopped(`The server’s update stopped: ${progress.reason}`);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const reloads = pressed && (progress.kind === 'updated' || (await servesNewerBuild()));
|
|
87
|
+
if (!reloads) {
|
|
88
|
+
settle(final);
|
|
89
|
+
checkForNewBuild(build.checkEvent, build.channel);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
await reloadAfterUpdate();
|
|
93
|
+
}
|
|
94
|
+
async function follow(before, pressed) {
|
|
95
|
+
if (!source)
|
|
96
|
+
return;
|
|
97
|
+
setTaken(before);
|
|
98
|
+
setStopped(null);
|
|
99
|
+
setStep('Updating the server…');
|
|
100
|
+
const end = await followUpdate(source, before, { away: () => setStep('Restarting…') });
|
|
101
|
+
await ended(end, pressed);
|
|
102
|
+
}
|
|
103
|
+
async function press(offered) {
|
|
104
|
+
if (!source || !offered.latest)
|
|
105
|
+
return;
|
|
106
|
+
if (offered.blockers > 0 && app.confirm && !(await app.confirm(offered)))
|
|
107
|
+
return;
|
|
108
|
+
setTaken(offered);
|
|
109
|
+
setStopped(null);
|
|
110
|
+
setStep('Updating the server…');
|
|
111
|
+
let answer;
|
|
112
|
+
try {
|
|
113
|
+
answer = await source.start(offered.latest);
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
answer = { refused: errorText(error) };
|
|
117
|
+
}
|
|
118
|
+
if (typeof answer === 'object') {
|
|
119
|
+
setStep(null);
|
|
120
|
+
setStopped(`The server didn’t start its update: ${answer.refused}`);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (answer === 'current') {
|
|
124
|
+
if (await servesNewerBuild())
|
|
125
|
+
await reloadAfterUpdate();
|
|
126
|
+
else
|
|
127
|
+
settle(offered);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
await follow(offered, true);
|
|
131
|
+
}
|
|
132
|
+
const followedAlready = status === endedOn.read ||
|
|
133
|
+
(endedOn.installed !== null && status?.installed === endedOn.installed);
|
|
134
|
+
const runningHere = status?.running === true && status.mayStart && taken === null && !followedAlready;
|
|
135
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: a run found here is followed once, from the status that showed it.
|
|
136
|
+
useEffect(() => {
|
|
137
|
+
if (runningHere && status)
|
|
138
|
+
void follow(status, false);
|
|
139
|
+
}, [runningHere]);
|
|
140
|
+
return { taken, step, stopped, press };
|
|
141
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type BuildWatch } from '../../core/update/build.js';
|
|
2
|
+
import type { UpdateSource, UpdateStatus } from '../../core/update/types.js';
|
|
3
|
+
/** The key of the build the server serves, while it is not the one this page loaded. */
|
|
4
|
+
export declare function useStaleBuild(build: BuildWatch): string | null;
|
|
5
|
+
/**
|
|
6
|
+
* The server's update, read at mount, then hourly while the page is in view and on `checkEvent`.
|
|
7
|
+
* Null until it first answers, and always for a null source.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useUpdateStatus(source: UpdateSource | null, checkEvent: string): [UpdateStatus | null, () => void];
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { hourlyInView, watchForNewBuild } from '../../core/update/build.js';
|
|
3
|
+
/** The key of the build the server serves, while it is not the one this page loaded. */
|
|
4
|
+
export function useStaleBuild(build) {
|
|
5
|
+
const [stale, setStale] = useState(null);
|
|
6
|
+
const { loaded, read, checkEvent, channel } = build;
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
if (!loaded)
|
|
9
|
+
return;
|
|
10
|
+
return watchForNewBuild({
|
|
11
|
+
loaded,
|
|
12
|
+
onStale: setStale,
|
|
13
|
+
read,
|
|
14
|
+
checkEvent,
|
|
15
|
+
channel: channel && typeof BroadcastChannel === 'function'
|
|
16
|
+
? new BroadcastChannel(channel)
|
|
17
|
+
: undefined,
|
|
18
|
+
});
|
|
19
|
+
}, [loaded, read, checkEvent, channel]);
|
|
20
|
+
return stale;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The server's update, read at mount, then hourly while the page is in view and on `checkEvent`.
|
|
24
|
+
* Null until it first answers, and always for a null source.
|
|
25
|
+
*/
|
|
26
|
+
export function useUpdateStatus(source, checkEvent) {
|
|
27
|
+
const [status, setStatus] = useState(null);
|
|
28
|
+
const readNow = useRef(() => { });
|
|
29
|
+
const readAgain = useCallback(() => readNow.current(), []);
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
if (!source) {
|
|
32
|
+
setStatus(null);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
let current = true;
|
|
36
|
+
function read() {
|
|
37
|
+
source?.read().then((next) => {
|
|
38
|
+
if (current)
|
|
39
|
+
setStatus(next);
|
|
40
|
+
}, () => undefined);
|
|
41
|
+
}
|
|
42
|
+
readNow.current = read;
|
|
43
|
+
read();
|
|
44
|
+
const schedule = hourlyInView(read, checkEvent);
|
|
45
|
+
return () => {
|
|
46
|
+
current = false;
|
|
47
|
+
schedule.stop();
|
|
48
|
+
};
|
|
49
|
+
}, [source, checkEvent]);
|
|
50
|
+
return [status, readAgain];
|
|
51
|
+
}
|
package/dist/search.css
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
.vds-settings-search {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
gap: var(--space-2);
|
|
5
|
+
min-width: 0;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.vds-settings-search__box {
|
|
9
|
+
box-sizing: border-box;
|
|
10
|
+
width: 100%;
|
|
11
|
+
height: var(--control-height);
|
|
12
|
+
padding: 0 var(--space-3);
|
|
13
|
+
border: 1px solid var(--border-strong);
|
|
14
|
+
border-radius: var(--radius-sm);
|
|
15
|
+
background: var(--surface);
|
|
16
|
+
color: var(--text);
|
|
17
|
+
font: inherit;
|
|
18
|
+
font-size: var(--font-ui);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.vds-settings-search__box::placeholder {
|
|
22
|
+
color: var(--muted);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.vds-settings-search__box:focus-visible {
|
|
26
|
+
border-color: var(--accent);
|
|
27
|
+
outline: none;
|
|
28
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.vds-settings-search__results {
|
|
32
|
+
display: flex;
|
|
33
|
+
flex-direction: column;
|
|
34
|
+
gap: var(--row-gap);
|
|
35
|
+
margin: 0;
|
|
36
|
+
padding: 0;
|
|
37
|
+
list-style: none;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.vds-settings-search__result {
|
|
41
|
+
display: flex;
|
|
42
|
+
flex-direction: column;
|
|
43
|
+
justify-content: center;
|
|
44
|
+
min-height: var(--row-height);
|
|
45
|
+
padding: var(--space-1) var(--space-2);
|
|
46
|
+
border-radius: var(--radius-sm);
|
|
47
|
+
cursor: pointer;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.vds-settings-search__result:hover {
|
|
51
|
+
background: var(--bg-hover);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.vds-settings-search__result[aria-selected="true"] {
|
|
55
|
+
background: var(--accent-soft);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.vds-settings-search__title {
|
|
59
|
+
font-size: var(--font-ui);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.vds-settings-search__section,
|
|
63
|
+
.vds-settings-search__empty {
|
|
64
|
+
color: var(--muted);
|
|
65
|
+
font-size: var(--font-sm);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/* --muted falls below 4.5:1 on the hover and --accent-soft fills. */
|
|
69
|
+
.vds-settings-search__result:hover .vds-settings-search__section,
|
|
70
|
+
.vds-settings-search__result[aria-selected="true"] .vds-settings-search__section {
|
|
71
|
+
color: var(--text);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.vds-settings-search__empty {
|
|
75
|
+
margin: 0;
|
|
76
|
+
padding: var(--space-2);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@media (pointer: coarse) {
|
|
80
|
+
.vds-settings-search__box {
|
|
81
|
+
height: 44px;
|
|
82
|
+
}
|
|
83
|
+
}
|
package/dist/setting.css
CHANGED
|
@@ -40,3 +40,29 @@
|
|
|
40
40
|
.vds-setting--stacked .vds-setting__control {
|
|
41
41
|
flex: auto;
|
|
42
42
|
}
|
|
43
|
+
|
|
44
|
+
/* A row a settings search opened. The pulse stands in for the focus ring. */
|
|
45
|
+
.vds-setting-pulse {
|
|
46
|
+
border-radius: var(--radius-sm);
|
|
47
|
+
outline: 2px solid transparent;
|
|
48
|
+
outline-offset: 4px;
|
|
49
|
+
animation: vds-setting-pulse 650ms ease-in-out 2;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@keyframes vds-setting-pulse {
|
|
53
|
+
50% {
|
|
54
|
+
outline-color: color-mix(in srgb, var(--accent) 70%, transparent);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* A revealed row keeps the focus after its pulse, without the browser's focus ring. */
|
|
59
|
+
[id^="setting-"][tabindex="-1"]:focus:not(.vds-setting-pulse) {
|
|
60
|
+
outline: none;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@media (prefers-reduced-motion: reduce) {
|
|
64
|
+
.vds-setting-pulse {
|
|
65
|
+
animation: none;
|
|
66
|
+
outline-color: var(--accent);
|
|
67
|
+
}
|
|
68
|
+
}
|
package/dist/shell.css
CHANGED
|
@@ -40,6 +40,37 @@
|
|
|
40
40
|
grid-column: 1 / -1;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
@media not (prefers-contrast: more) {
|
|
44
|
+
@media (forced-colors: none) {
|
|
45
|
+
.vds-app-shell--gradient {
|
|
46
|
+
--muted: var(--muted-on-wash);
|
|
47
|
+
|
|
48
|
+
isolation: isolate;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.vds-app-shell--gradient::before {
|
|
52
|
+
position: fixed;
|
|
53
|
+
inset: 0;
|
|
54
|
+
z-index: -1;
|
|
55
|
+
background: var(--wash), var(--ground);
|
|
56
|
+
content: "";
|
|
57
|
+
pointer-events: none;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.vds-app-shell--gradient .vds-app-shell__main,
|
|
61
|
+
.vds-app-shell--gradient .vds-sidebar,
|
|
62
|
+
.vds-app-shell--gradient .vds-toolbar {
|
|
63
|
+
background: transparent;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/* The drawer is a sidebar too, so this follows the transparent rule above to keep it opaque. */
|
|
67
|
+
.vds-app-shell--gradient .vds-drawer {
|
|
68
|
+
background: var(--wash), var(--raised);
|
|
69
|
+
background-attachment: fixed;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
43
74
|
.vds-sidebar-frame {
|
|
44
75
|
position: relative;
|
|
45
76
|
display: flex;
|
|
@@ -2,6 +2,13 @@ import { type JSX } from '@solidjs/web';
|
|
|
2
2
|
export type AppShellProps = {
|
|
3
3
|
/** The page: a toolbar, then whatever scrolls. */
|
|
4
4
|
children: JSX.Element;
|
|
5
|
+
/**
|
|
6
|
+
* Draws the palette's `--wash` on one fixed backdrop behind the sidebar, the toolbar, and the page.
|
|
7
|
+
* Those go transparent over it, dialogs and toasts keep their colour, and the drawer draws the wash over `--raised`.
|
|
8
|
+
* Inside the shell, `--muted` becomes `--muted-on-wash`.
|
|
9
|
+
* Off when the person asks for more contrast or uses forced colours.
|
|
10
|
+
*/
|
|
11
|
+
gradient?: boolean;
|
|
5
12
|
/** Gets the `main` element, which can take focus, such as after a navigation from the drawer. */
|
|
6
13
|
mainRef?: (element: HTMLElement) => void;
|
|
7
14
|
sidebar?: JSX.Element;
|
|
@@ -4,7 +4,7 @@ import { Show } from '@solidjs/web';
|
|
|
4
4
|
* from the window by `--shell-inset` with `--shell-radius` corners in a design that insets it.
|
|
5
5
|
*/
|
|
6
6
|
export function AppShell(props) {
|
|
7
|
-
return (<div class='vds-app-shell'>
|
|
7
|
+
return (<div class={['vds-app-shell', { 'vds-app-shell--gradient': props.gradient }]}>
|
|
8
8
|
{props.sidebar}
|
|
9
9
|
<main ref={props.mainRef} class='vds-app-shell__main' tabindex='-1'>
|
|
10
10
|
{props.children}
|
|
@@ -37,6 +37,6 @@ type Group = {
|
|
|
37
37
|
export declare function CommandPalette(props: CommandPaletteProps): import("@solidjs/web").JSX.Element;
|
|
38
38
|
/** The commands in group order, each group in the order its commands were given. */
|
|
39
39
|
export declare function grouped(commands: Command[]): Group[];
|
|
40
|
-
/** The commands whose label or keywords contain every word of the query, ignoring case. */
|
|
40
|
+
/** The commands whose label or keywords contain every word of the query, ignoring case and accents. */
|
|
41
41
|
export declare function matching(commands: Command[], query: string): Command[];
|
|
42
42
|
export {};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { For, Show } from '@solidjs/web';
|
|
2
2
|
import { createEffect, createMemo, createSignal, createUniqueId } from 'solid-js';
|
|
3
|
-
import { aria } from '
|
|
3
|
+
import { aria } from '../core/aria';
|
|
4
|
+
import { first, moveFor, rows } from '../core/roving';
|
|
5
|
+
import { matchWords } from '../core/search';
|
|
4
6
|
import { Icon } from './Icon';
|
|
5
|
-
import { first, moveFor, rows } from './roving';
|
|
6
7
|
/**
|
|
7
8
|
* A search field over a list of commands, in the combobox pattern: focus stays in the field, arrow
|
|
8
9
|
* keys move the highlighted command, and Enter runs it. Every word typed must appear in a command's
|
|
@@ -95,13 +96,7 @@ export function grouped(commands) {
|
|
|
95
96
|
row.index = index++;
|
|
96
97
|
return [...groups.values()];
|
|
97
98
|
}
|
|
98
|
-
/** The commands whose label or keywords contain every word of the query, ignoring case. */
|
|
99
|
+
/** The commands whose label or keywords contain every word of the query, ignoring case and accents. */
|
|
99
100
|
export function matching(commands, query) {
|
|
100
|
-
|
|
101
|
-
if (!words.length)
|
|
102
|
-
return commands;
|
|
103
|
-
return commands.filter((command) => {
|
|
104
|
-
const text = [command.label, ...(command.keywords ?? [])].join(' ').toLowerCase();
|
|
105
|
-
return words.every((word) => text.includes(word));
|
|
106
|
-
});
|
|
101
|
+
return commands.filter((command) => matchWords(query, [command.label, ...(command.keywords ?? [])]));
|
|
107
102
|
}
|