@bridgebrew/shell 0.0.2 → 0.0.6
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/browser/browser.tsx +108 -9
- package/browser/errors.tsx +135 -20
- package/browser/mobile.tsx +79 -12
- package/browser/notifications.ts +75 -6
- package/browser/overlay-hold.ts +162 -0
- package/browser/shell-state.ts +2 -0
- package/browser/shell.d.ts +73 -8
- package/package.json +20 -3
package/browser/browser.tsx
CHANGED
|
@@ -56,6 +56,7 @@ import {
|
|
|
56
56
|
CommandHostProvider,
|
|
57
57
|
ToastStack,
|
|
58
58
|
TooltipProvider,
|
|
59
|
+
Tip,
|
|
59
60
|
DEFAULT_ICON_SET,
|
|
60
61
|
DEFAULT_KIT,
|
|
61
62
|
clampSidebarWidth,
|
|
@@ -141,12 +142,17 @@ import {
|
|
|
141
142
|
import { SidebarToggle, ThemeControls, type ManagerOption } from './theme-controls.tsx';
|
|
142
143
|
import {
|
|
143
144
|
MobileFrame,
|
|
145
|
+
clearMobileHolds,
|
|
146
|
+
isMobile,
|
|
147
|
+
markMore,
|
|
144
148
|
mobileFrame,
|
|
145
149
|
mobileOwner,
|
|
150
|
+
overlayOnPhone,
|
|
146
151
|
setSidebarItems,
|
|
147
152
|
transitions,
|
|
148
153
|
useMobile,
|
|
149
154
|
} from './mobile.tsx';
|
|
155
|
+
import { createOverlayHold, type OverlayHold } from './overlay-hold.ts';
|
|
150
156
|
|
|
151
157
|
export const name = 'shell';
|
|
152
158
|
export const inject = ['slots', 'workspaceEntries', 'hostStatus', 'screenRequests', 'sidebarItems'];
|
|
@@ -196,6 +202,7 @@ type RenderScreen = (
|
|
|
196
202
|
next: Record<string, string> | undefined,
|
|
197
203
|
options?: { push?: boolean },
|
|
198
204
|
) => void;
|
|
205
|
+
setActions?: (list: readonly ScreenAction[]) => void;
|
|
199
206
|
},
|
|
200
207
|
opts: { entryKey: string; fallback: React.ReactNode },
|
|
201
208
|
) => React.ReactNode;
|
|
@@ -213,14 +220,25 @@ type Parts = {
|
|
|
213
220
|
};
|
|
214
221
|
bar: { 'data-slot': 'shell-window-bar' };
|
|
215
222
|
crumbs: React.ReactNode;
|
|
223
|
+
actions?: React.ReactNode;
|
|
216
224
|
body: React.ReactNode;
|
|
217
225
|
};
|
|
226
|
+
/** ./shell.d.ts `ScreenAction`: a button a desktop screen gives its window's bar. */
|
|
227
|
+
type ScreenAction = {
|
|
228
|
+
id: string;
|
|
229
|
+
label: string;
|
|
230
|
+
icon: string;
|
|
231
|
+
onSelect: () => void;
|
|
232
|
+
pressed?: boolean;
|
|
233
|
+
disabled?: boolean;
|
|
234
|
+
};
|
|
218
235
|
type Options = {
|
|
219
236
|
focused: boolean;
|
|
220
237
|
active?: boolean;
|
|
221
238
|
choices?: boolean;
|
|
222
239
|
others?: Others;
|
|
223
240
|
frame?: (parts: Parts) => React.ReactNode;
|
|
241
|
+
drawsActions?: boolean;
|
|
224
242
|
};
|
|
225
243
|
type StageOwner = {
|
|
226
244
|
renderWindow: (id: string, view: View, options: Options) => React.ReactNode;
|
|
@@ -232,7 +250,7 @@ type StageOwner = {
|
|
|
232
250
|
* before windows (main's `shell-top-bar`): a line on its left against the sidebar, a 44px top bar holding the
|
|
233
251
|
* breadcrumb over a line, the screen under it scrolling alone; no corner, no shadow (./window.css adds the line between
|
|
234
252
|
* the rail and the sidebar). */
|
|
235
|
-
export const flatFrame = ({ window, bar, crumbs, body }: Parts) => (
|
|
253
|
+
export const flatFrame = ({ window, bar, crumbs, actions, body }: Parts) => (
|
|
236
254
|
<div
|
|
237
255
|
{...window}
|
|
238
256
|
data-flat=""
|
|
@@ -240,6 +258,7 @@ export const flatFrame = ({ window, bar, crumbs, body }: Parts) => (
|
|
|
240
258
|
>
|
|
241
259
|
<header {...bar} className="flex h-11 shrink-0 items-center gap-4 border-b border-border px-4">
|
|
242
260
|
{crumbs}
|
|
261
|
+
{actions && <div className="-mr-2 ml-auto flex shrink-0">{actions}</div>}
|
|
243
262
|
</header>
|
|
244
263
|
{body}
|
|
245
264
|
</div>
|
|
@@ -466,11 +485,14 @@ export function ShellWindow({
|
|
|
466
485
|
choices,
|
|
467
486
|
others,
|
|
468
487
|
frame,
|
|
488
|
+
drawsActions = false,
|
|
469
489
|
mobile,
|
|
470
490
|
}: {
|
|
471
491
|
shell: Shell;
|
|
472
492
|
renderSlot: RenderScreen;
|
|
473
493
|
mobile?: boolean | undefined;
|
|
494
|
+
/** `frame` draws `Parts.actions`: only then does its screen get `setActions`. */
|
|
495
|
+
drawsActions?: boolean | undefined;
|
|
474
496
|
id: string;
|
|
475
497
|
view: View;
|
|
476
498
|
focused: boolean;
|
|
@@ -498,6 +520,15 @@ export function ShellWindow({
|
|
|
498
520
|
shell.setScreenState(id, next, options),
|
|
499
521
|
[shell, id],
|
|
500
522
|
);
|
|
523
|
+
// The buttons its screen gives the bar (`setActions`), kept with the view that gave them: another screen or node in
|
|
524
|
+
// this window shows none of the previous one's.
|
|
525
|
+
const viewKey = JSON.stringify([node, screen?.plugin, screen?.id]);
|
|
526
|
+
const [given, setGiven] = React.useState<{ key: string; list: readonly ScreenAction[] }>();
|
|
527
|
+
const setActions = React.useCallback(
|
|
528
|
+
(list: readonly ScreenAction[]) => setGiven({ key: viewKey, list }),
|
|
529
|
+
[viewKey],
|
|
530
|
+
);
|
|
531
|
+
const actions = given?.key === viewKey && given.list.length > 0 ? given.list : undefined;
|
|
501
532
|
const stateProps = { ...(screenState && { screenState }), setScreenState };
|
|
502
533
|
// Research-069: the view's scope, one per view generation (a node change remounts the view): its editors register
|
|
503
534
|
// there; the state the shell shows (a notice in its place) is told once rendered.
|
|
@@ -657,6 +688,8 @@ export function ShellWindow({
|
|
|
657
688
|
...at,
|
|
658
689
|
...(others && { others }),
|
|
659
690
|
...stateProps,
|
|
691
|
+
// Only where its frame draws them: a screen without it draws its own (a manager that does not, an older one).
|
|
692
|
+
...(drawsActions && { setActions }),
|
|
660
693
|
};
|
|
661
694
|
// Research-069: shown, the slot has no entry for it (failed, missing, or not loaded yet): the view says so.
|
|
662
695
|
const fallback = (
|
|
@@ -748,6 +781,24 @@ export function ShellWindow({
|
|
|
748
781
|
/>
|
|
749
782
|
</FollowProvider>
|
|
750
783
|
),
|
|
784
|
+
actions: actions && (
|
|
785
|
+
<div data-slot="shell-window-actions" className="flex items-center gap-1">
|
|
786
|
+
{actions.map((each) => (
|
|
787
|
+
<Tip key={each.id} label={each.label}>
|
|
788
|
+
<Button
|
|
789
|
+
variant="ghost"
|
|
790
|
+
size="icon-sm"
|
|
791
|
+
aria-label={each.label}
|
|
792
|
+
{...(each.pressed !== undefined && { 'aria-pressed': each.pressed })}
|
|
793
|
+
disabled={each.disabled}
|
|
794
|
+
onClick={each.onSelect}
|
|
795
|
+
>
|
|
796
|
+
<Icon name={each.icon} size={16} />
|
|
797
|
+
</Button>
|
|
798
|
+
</Tip>
|
|
799
|
+
))}
|
|
800
|
+
</div>
|
|
801
|
+
),
|
|
751
802
|
body: (
|
|
752
803
|
<div data-slot="shell-window-body" className="flex min-h-0 flex-1 flex-col overflow-y-auto">
|
|
753
804
|
{/* One parent whether archived or not: only a node change remounts the view. */}
|
|
@@ -811,7 +862,11 @@ function Main({
|
|
|
811
862
|
});
|
|
812
863
|
}, [failed, toast, chooser]);
|
|
813
864
|
const renderWindow = React.useCallback(
|
|
814
|
-
(
|
|
865
|
+
(
|
|
866
|
+
id: string,
|
|
867
|
+
view: View,
|
|
868
|
+
{ focused, active, choices, others, frame, drawsActions }: Options,
|
|
869
|
+
) => (
|
|
815
870
|
<ShellWindow
|
|
816
871
|
key={id}
|
|
817
872
|
shell={shell}
|
|
@@ -823,6 +878,7 @@ function Main({
|
|
|
823
878
|
choices={choices}
|
|
824
879
|
others={others}
|
|
825
880
|
frame={frame ?? flatFrame}
|
|
881
|
+
drawsActions={frame === undefined || drawsActions === true}
|
|
826
882
|
mobile={mobile}
|
|
827
883
|
/>
|
|
828
884
|
),
|
|
@@ -1044,6 +1100,35 @@ function Notifications({
|
|
|
1044
1100
|
|
|
1045
1101
|
/** The installed window managers for the theme menu (WM5): every `stage` entry's plugin, the default (the slot's head)
|
|
1046
1102
|
* first; any can be chosen (CAP-6). */
|
|
1103
|
+
/** `overlay`'s entries, each drawn apart: over a joined Bridge's page (`over`), hidden (kept mounted), where they would
|
|
1104
|
+
* cover the rail, but the ones holding the home page in front (`holdOverlay({ id })`), whose window shows there. */
|
|
1105
|
+
export function OverlayEntries({
|
|
1106
|
+
slots,
|
|
1107
|
+
overlays,
|
|
1108
|
+
over,
|
|
1109
|
+
renderSlot,
|
|
1110
|
+
}: {
|
|
1111
|
+
slots: Pick<Context['slots'], 'subscribe' | 'entriesOfSlot'>;
|
|
1112
|
+
overlays: Pick<OverlayHold, 'subscribe' | 'entries'>;
|
|
1113
|
+
over: boolean;
|
|
1114
|
+
renderSlot: (key: 'overlay', props: object, options: { only: string }) => React.ReactNode;
|
|
1115
|
+
}) {
|
|
1116
|
+
const joined = React.useSyncExternalStore(
|
|
1117
|
+
React.useCallback((changed: () => void) => slots.subscribe('overlay', changed), [slots]),
|
|
1118
|
+
() => [...new Set(slots.entriesOfSlot('overlay').map((entry) => entry.options.id ?? ''))].join('\n'),
|
|
1119
|
+
);
|
|
1120
|
+
const held = React.useSyncExternalStore(overlays.subscribe, overlays.entries);
|
|
1121
|
+
return (
|
|
1122
|
+
<div data-slot="shell-overlay" className="contents">
|
|
1123
|
+
{(joined ? joined.split('\n') : []).map((id) => (
|
|
1124
|
+
<div key={id} data-overlay-entry={id} className={over && !held.includes(id) ? 'hidden' : 'contents'}>
|
|
1125
|
+
{renderSlot('overlay', {}, { only: id })}
|
|
1126
|
+
</div>
|
|
1127
|
+
))}
|
|
1128
|
+
</div>
|
|
1129
|
+
);
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1047
1132
|
function useManagers(slots: Context['slots']): ManagerOption[] {
|
|
1048
1133
|
const read = React.useCallback(
|
|
1049
1134
|
() => JSON.stringify(liveStages(slots).map((entry) => entry.registrant ?? null)),
|
|
@@ -1228,7 +1313,9 @@ function Frame({
|
|
|
1228
1313
|
renderSlot,
|
|
1229
1314
|
commands,
|
|
1230
1315
|
themeMenu,
|
|
1316
|
+
overlays,
|
|
1231
1317
|
}: {
|
|
1318
|
+
overlays: OverlayHold;
|
|
1232
1319
|
shell: Shell;
|
|
1233
1320
|
slots: Context['slots'];
|
|
1234
1321
|
hostStatus: Context['hostStatus'];
|
|
@@ -1239,8 +1326,9 @@ function Frame({
|
|
|
1239
1326
|
app: boolean;
|
|
1240
1327
|
errors: ErrorsSignal;
|
|
1241
1328
|
renderSlot: (
|
|
1242
|
-
key: 'rail' | 'sidebar' | 'main' | 'overlay' | 'controls',
|
|
1329
|
+
key: 'rail' | 'sidebar' | 'main' | 'overlay' | 'controls' | 'more',
|
|
1243
1330
|
props: object,
|
|
1331
|
+
options?: { only?: string },
|
|
1244
1332
|
) => React.ReactNode;
|
|
1245
1333
|
commands: CommandsService;
|
|
1246
1334
|
}) {
|
|
@@ -1540,11 +1628,8 @@ function Frame({
|
|
|
1540
1628
|
)}
|
|
1541
1629
|
</div>
|
|
1542
1630
|
</div>
|
|
1543
|
-
{/* Over the whole frame: floating tools (`point`'s selections and windows), each positioned by its plugin
|
|
1544
|
-
|
|
1545
|
-
<div data-slot="shell-overlay" className={over ? 'hidden' : 'contents'}>
|
|
1546
|
-
{renderSlot('overlay', {})}
|
|
1547
|
-
</div>
|
|
1631
|
+
{/* Over the whole frame: floating tools (`point`'s selections and windows), each positioned by its plugin. */}
|
|
1632
|
+
<OverlayEntries slots={slots} overlays={overlays} over={over} renderSlot={renderSlot} />
|
|
1548
1633
|
<ShortcutsHelp shell={shell} help={help} app={app} />
|
|
1549
1634
|
<ErrorsModal
|
|
1550
1635
|
hostStatus={hostStatus}
|
|
@@ -1807,7 +1892,19 @@ export function apply(ctx: Context) {
|
|
|
1807
1892
|
() => setCurrent(slug),
|
|
1808
1893
|
);
|
|
1809
1894
|
};
|
|
1810
|
-
|
|
1895
|
+
// One count for every popup and window over a joined Bridge's page, the phone's opted-in overlays, More's marks
|
|
1896
|
+
// (research-128 §7).
|
|
1897
|
+
const overlays = createOverlayHold();
|
|
1898
|
+
ctx.effect(() => () => {
|
|
1899
|
+
overlays.dispose();
|
|
1900
|
+
clearMobileHolds();
|
|
1901
|
+
});
|
|
1902
|
+
ctx.provide(
|
|
1903
|
+
'shell',
|
|
1904
|
+
Object.defineProperties(Object.assign(shell, { holdOverlay: overlays.hold, overlayOnPhone, markMore }), {
|
|
1905
|
+
mobile: { get: isMobile, enumerable: true },
|
|
1906
|
+
}),
|
|
1907
|
+
);
|
|
1811
1908
|
// What this page has changes (a pack, an icon set, a window manager comes or goes): the looks again, the user's look
|
|
1812
1909
|
// everywhere applying where it now can (research-035).
|
|
1813
1910
|
ctx.effect(() => {
|
|
@@ -1979,6 +2076,7 @@ export function apply(ctx: Context) {
|
|
|
1979
2076
|
sidebar: { ...slot, ...open },
|
|
1980
2077
|
main: slot,
|
|
1981
2078
|
overlay: { kind: 'list', scope: 'root' },
|
|
2079
|
+
more: { kind: 'list', scope: 'root' },
|
|
1982
2080
|
controls: { kind: 'list', scope: 'root', ...open },
|
|
1983
2081
|
},
|
|
1984
2082
|
},
|
|
@@ -1999,6 +2097,7 @@ export function apply(ctx: Context) {
|
|
|
1999
2097
|
renderSlot={renderSlot}
|
|
2000
2098
|
commands={commands}
|
|
2001
2099
|
themeMenu={themeMenu}
|
|
2100
|
+
overlays={overlays}
|
|
2002
2101
|
/>
|
|
2003
2102
|
</PackThemesProvider>
|
|
2004
2103
|
),
|
package/browser/errors.tsx
CHANGED
|
@@ -55,10 +55,11 @@ export const fixLabels: Record<Fix['action'], string> = {
|
|
|
55
55
|
'reload-all': 'Reload all',
|
|
56
56
|
setting: 'Open the setting',
|
|
57
57
|
'plugin-action': 'Run',
|
|
58
|
+
contract: 'Fix',
|
|
58
59
|
};
|
|
59
60
|
/** A fix's button label: a plugin's action names its own; a setting with no field opens the plugin's settings page. */
|
|
60
61
|
export const fixLabel = (fix: Fix) =>
|
|
61
|
-
fix.action === 'plugin-action' || fix.action === 'retry'
|
|
62
|
+
fix.action === 'plugin-action' || fix.action === 'retry' || fix.action === 'contract'
|
|
62
63
|
? fix.label
|
|
63
64
|
: fix.action === 'setting' && fix.setting === ''
|
|
64
65
|
? 'Open its settings'
|
|
@@ -66,7 +67,9 @@ export const fixLabel = (fix: Fix) =>
|
|
|
66
67
|
|
|
67
68
|
/** The host route a fix's button runs (the Plugins section's, `bridge restart` / `bridge reload`'s); Reload page then
|
|
68
69
|
* reloads the page. Reload all is not one route: the targets are walked in turn. */
|
|
69
|
-
const fixUrl = (
|
|
70
|
+
const fixUrl = (
|
|
71
|
+
fix: Exclude<Fix, { action: 'reload-all' | 'setting' | 'plugin-action' | 'contract' }>,
|
|
72
|
+
) =>
|
|
70
73
|
fix.action === 'restart-bridge'
|
|
71
74
|
? '/_bridge/restart'
|
|
72
75
|
: `/_bridge/workspaces/${encodeURIComponent(fix.slug)}/${
|
|
@@ -80,10 +83,10 @@ const fixUrl = (fix: Exclude<Fix, { action: 'reload-all' | 'setting' | 'plugin-a
|
|
|
80
83
|
export function runFix(fix: Fix, title: string, toast: (input: ToastInput) => string) {
|
|
81
84
|
// Open the setting is the page's own navigation (`Notifications`), no request.
|
|
82
85
|
if (fix.action === 'setting') return;
|
|
83
|
-
if (fix.action === 'plugin-action') {
|
|
86
|
+
if (fix.action === 'plugin-action' || fix.action === 'contract') {
|
|
84
87
|
// Through `ActionConfirm` when it is mounted (its question first), else at once.
|
|
85
88
|
if (actions.size) for (const listener of actions) listener(fix);
|
|
86
|
-
else void runPluginAction(fix, toast);
|
|
89
|
+
else void (fix.action === 'contract' ? runContractFix(fix, toast) : runPluginAction(fix, toast));
|
|
87
90
|
return;
|
|
88
91
|
}
|
|
89
92
|
const label = fixLabels[fix.action];
|
|
@@ -147,42 +150,141 @@ export function runFix(fix: Fix, title: string, toast: (input: ToastInput) => st
|
|
|
147
150
|
}
|
|
148
151
|
|
|
149
152
|
type PluginActionFix = Extract<Fix, { action: 'plugin-action' }>;
|
|
150
|
-
|
|
151
|
-
|
|
153
|
+
type ContractFix = Extract<Fix, { action: 'contract' }>;
|
|
154
|
+
/** The mounted `ActionConfirm`s, `runFix`'s way to a plugin's action or a contract fix (one, the shell's). */
|
|
155
|
+
const actions = new Set<(fix: PluginActionFix | ContractFix) => void>();
|
|
156
|
+
/** A step of a contract fix in people's words. */
|
|
157
|
+
const stepText = (step: ContractFix['steps'][number]) =>
|
|
158
|
+
step.action === 'install'
|
|
159
|
+
? `Install a plugin providing ${step.contract}`
|
|
160
|
+
: `${step.action[0]!.toUpperCase()}${step.action.slice(1)} ${step.plugin}`;
|
|
161
|
+
/** What a contract fix's request answered: done, refused (its words), or a change that would leave other readers in
|
|
162
|
+
* error, announced (`contract_break`, bridgebrew/bridge#598): made only once `accept` names them. */
|
|
163
|
+
type FixAnswer =
|
|
164
|
+
| { done: true }
|
|
165
|
+
| { done: false; message: string; hint?: string; accept?: string[] };
|
|
166
|
+
/** Runs a contract fix as one change (`plugin/batch` behind the host's `…/plugins/<id>/fix`), with `accept` the readers
|
|
167
|
+
* an announcement named; a refusal toasted unless it is an announcement, which is handed back. */
|
|
168
|
+
async function postContractFix(fix: ContractFix, accept?: string[]): Promise<FixAnswer> {
|
|
169
|
+
const steps = fix.steps
|
|
170
|
+
.map((step) => `${step.action}:${step.action === 'install' ? step.contract : step.plugin}`)
|
|
171
|
+
.join(',');
|
|
172
|
+
try {
|
|
173
|
+
const res = await fetch(
|
|
174
|
+
`/_bridge/workspaces/${encodeURIComponent(fix.slug)}/plugins/${encodeURIComponent(fix.plugin)}/fix?steps=${encodeURIComponent(steps)}${accept ? `&accept=${accept.map(encodeURIComponent).join(',')}` : ''}`,
|
|
175
|
+
{ method: 'POST' },
|
|
176
|
+
);
|
|
177
|
+
if (res.ok) return { done: true };
|
|
178
|
+
const body: unknown = await res.json().catch(() => undefined);
|
|
179
|
+
const { message, hint } = refusalOf(body, res.status);
|
|
180
|
+
const error = isRecord(body) && isRecord(body.error) ? body.error : {};
|
|
181
|
+
const readers = Array.isArray(error.accept)
|
|
182
|
+
? error.accept.filter((each): each is string => typeof each === 'string')
|
|
183
|
+
: undefined;
|
|
184
|
+
return {
|
|
185
|
+
done: false,
|
|
186
|
+
message,
|
|
187
|
+
...(hint !== undefined && { hint }),
|
|
188
|
+
...(error.code === 'contract_break' && readers?.length && { accept: readers }),
|
|
189
|
+
};
|
|
190
|
+
} catch (cause) {
|
|
191
|
+
return { done: false, message: cause instanceof Error ? cause.message : String(cause) };
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
/** A contract fix without its dialog: run at once, an announcement left unconfirmed (its words toasted). */
|
|
195
|
+
async function runContractFix(
|
|
196
|
+
fix: ContractFix,
|
|
197
|
+
toast: (input: ToastInput) => string,
|
|
198
|
+
accept?: string[],
|
|
199
|
+
): Promise<FixAnswer> {
|
|
200
|
+
toast({ variant: 'info', title: `${fix.label}…` });
|
|
201
|
+
const answer = await postContractFix(fix, accept);
|
|
202
|
+
if (!answer.done && answer.accept === undefined) {
|
|
203
|
+
const text = [answer.message, answer.hint].filter(Boolean).join(' ');
|
|
204
|
+
toast(
|
|
205
|
+
toastOf({
|
|
206
|
+
variant: 'error',
|
|
207
|
+
title: `${fix.label} failed`,
|
|
208
|
+
description: text,
|
|
209
|
+
copy: copyOf(`${fix.label} failed`, text),
|
|
210
|
+
}),
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
return answer;
|
|
214
|
+
}
|
|
152
215
|
|
|
153
216
|
/** A plugin's settings action run from a toast, a card or Health (`runFix`): its `confirm` asked first in a dialog
|
|
154
217
|
* (Take over: the other Bridge stops writing), the buttons on the right; one without `confirm` runs at once. */
|
|
155
218
|
export function ActionConfirm() {
|
|
156
219
|
const { toast } = useToast();
|
|
157
|
-
|
|
220
|
+
/** The question shown: a settings action's `confirm`, a contract fix's steps, or what a fix would leave in error. */
|
|
221
|
+
const [pending, setPending] = React.useState<
|
|
222
|
+
| { fix: PluginActionFix }
|
|
223
|
+
| { fix: ContractFix; announced?: { message: string; hint?: string; accept: string[] } }
|
|
224
|
+
| undefined
|
|
225
|
+
>(undefined);
|
|
158
226
|
React.useEffect(() => {
|
|
159
|
-
const listener = (fix: PluginActionFix) => {
|
|
160
|
-
if (fix.confirm === undefined) void runPluginAction(fix, toast);
|
|
161
|
-
else setPending(fix);
|
|
227
|
+
const listener = (fix: PluginActionFix | ContractFix) => {
|
|
228
|
+
if (fix.action === 'plugin-action' && fix.confirm === undefined) void runPluginAction(fix, toast);
|
|
229
|
+
else setPending({ fix } as typeof pending);
|
|
162
230
|
};
|
|
163
231
|
actions.add(listener);
|
|
164
232
|
return () => void actions.delete(listener);
|
|
165
233
|
}, [toast]);
|
|
234
|
+
const confirm = async () => {
|
|
235
|
+
if (!pending) return;
|
|
236
|
+
setPending(undefined);
|
|
237
|
+
if (pending.fix.action === 'plugin-action') return void runPluginAction(pending.fix, toast);
|
|
238
|
+
const announced = 'announced' in pending ? pending.announced : undefined;
|
|
239
|
+
const answer = await runContractFix(pending.fix, toast, announced?.accept);
|
|
240
|
+
// Readers it would leave in error (bridgebrew/bridge#598): said, then made for exactly them once confirmed.
|
|
241
|
+
if (!answer.done && answer.accept !== undefined)
|
|
242
|
+
setPending({
|
|
243
|
+
fix: pending.fix,
|
|
244
|
+
announced: {
|
|
245
|
+
message: answer.message,
|
|
246
|
+
...(answer.hint !== undefined && { hint: answer.hint }),
|
|
247
|
+
accept: answer.accept,
|
|
248
|
+
},
|
|
249
|
+
});
|
|
250
|
+
};
|
|
251
|
+
const fix = pending?.fix;
|
|
252
|
+
const announced = pending && 'announced' in pending ? pending.announced : undefined;
|
|
166
253
|
return (
|
|
167
254
|
<Dialog open={pending !== undefined} onOpenChange={(open) => !open && setPending(undefined)}>
|
|
168
255
|
<DialogContent>
|
|
169
256
|
<DialogHeader>
|
|
170
|
-
<DialogTitle>{
|
|
257
|
+
<DialogTitle>{fix?.label}</DialogTitle>
|
|
171
258
|
</DialogHeader>
|
|
172
259
|
<DialogBody className="pb-4">
|
|
173
|
-
|
|
260
|
+
{fix?.action === 'contract' ? (
|
|
261
|
+
announced ? (
|
|
262
|
+
<>
|
|
263
|
+
<DialogDescription>{announced.message}.</DialogDescription>
|
|
264
|
+
{announced.hint && <p className="m-0 mt-2 text-xs text-secondary">{announced.hint}</p>}
|
|
265
|
+
</>
|
|
266
|
+
) : (
|
|
267
|
+
<>
|
|
268
|
+
<DialogDescription>
|
|
269
|
+
Bridge makes these changes as one, then restarts the workspace:
|
|
270
|
+
</DialogDescription>
|
|
271
|
+
<ol data-fix-steps className="m-0 mt-2 pl-5 text-sm">
|
|
272
|
+
{fix.steps.map((step) => (
|
|
273
|
+
<li key={stepText(step)}>{stepText(step)}</li>
|
|
274
|
+
))}
|
|
275
|
+
</ol>
|
|
276
|
+
</>
|
|
277
|
+
)
|
|
278
|
+
) : (
|
|
279
|
+
<DialogDescription>{fix?.confirm}</DialogDescription>
|
|
280
|
+
)}
|
|
174
281
|
</DialogBody>
|
|
175
282
|
<DialogFooter className="justify-end gap-2">
|
|
176
283
|
<Button variant="outline" onClick={() => setPending(undefined)}>
|
|
177
284
|
Cancel
|
|
178
285
|
</Button>
|
|
179
|
-
<Button
|
|
180
|
-
|
|
181
|
-
if (pending) void runPluginAction(pending, toast);
|
|
182
|
-
setPending(undefined);
|
|
183
|
-
}}
|
|
184
|
-
>
|
|
185
|
-
{pending?.label}
|
|
286
|
+
<Button variant="primary" onClick={() => void confirm()}>
|
|
287
|
+
{announced ? 'Continue' : fix?.label}
|
|
186
288
|
</Button>
|
|
187
289
|
</DialogFooter>
|
|
188
290
|
</DialogContent>
|
|
@@ -409,6 +511,16 @@ function ErrorCard({
|
|
|
409
511
|
{fixLabel(item.fix)}
|
|
410
512
|
</Button>
|
|
411
513
|
)}
|
|
514
|
+
{item.more?.map((fix) => (
|
|
515
|
+
<Button
|
|
516
|
+
key={fixLabel(fix)}
|
|
517
|
+
size="sm"
|
|
518
|
+
variant="outline"
|
|
519
|
+
onClick={(event) => onFix(fix, item.title, event)}
|
|
520
|
+
>
|
|
521
|
+
{fixLabel(fix)}
|
|
522
|
+
</Button>
|
|
523
|
+
))}
|
|
412
524
|
<CopyButton text={copy} />
|
|
413
525
|
</div>
|
|
414
526
|
{hasLogs && (
|
|
@@ -484,7 +596,10 @@ export function ErrorsModal({
|
|
|
484
596
|
React.useEffect(() => {
|
|
485
597
|
if (!open) return;
|
|
486
598
|
load();
|
|
487
|
-
|
|
599
|
+
// Bridge's update (bridge#677) is no error, and comes at each percent of a download.
|
|
600
|
+
return hostStatus.subscribe((event) => {
|
|
601
|
+
if (String(event.event) !== 'update') load();
|
|
602
|
+
});
|
|
488
603
|
}, [open, hostStatus, load]);
|
|
489
604
|
|
|
490
605
|
// Opening with a key: scroll that item into view and outline it briefly.
|
package/browser/mobile.tsx
CHANGED
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
subscribeClientAppearance,
|
|
26
26
|
} from '@bridge/ui';
|
|
27
27
|
import { modeColour, tileColourOf, tileShapeStyles } from '@bridge/kernel/look';
|
|
28
|
+
import { heldIds } from './overlay-hold.ts';
|
|
28
29
|
import { blocksOn, pathTo, viewOf, type Shell, type View } from './shell-state.ts';
|
|
29
30
|
import './mobile.css';
|
|
30
31
|
|
|
@@ -79,6 +80,9 @@ export function drawerState(
|
|
|
79
80
|
let open = false;
|
|
80
81
|
let marker = 0;
|
|
81
82
|
let after: (() => void) | undefined;
|
|
83
|
+
/** Going back off the drawer's entry (`history.back()` answers later, with `popstate`): a second close or stay
|
|
84
|
+
* meanwhile would go back a second time, past the screen; it is dropped, the first one's action kept. */
|
|
85
|
+
let leaving = false;
|
|
82
86
|
// `stay`: the drawer kept open past its entry gone back off, with no entry of its own (`marker` 0) from there: the
|
|
83
87
|
// shell writes the history of the workspace it opens (its last screen, in place or as a new entry), over which an
|
|
84
88
|
// entry of the drawer's would be lost; Back then goes on under it, and the drawer closes by its own controls.
|
|
@@ -95,6 +99,7 @@ export function drawerState(
|
|
|
95
99
|
(history.state as Record<string, unknown> | null)?.[key] === marker
|
|
96
100
|
)
|
|
97
101
|
return;
|
|
102
|
+
leaving = false;
|
|
98
103
|
if (keep) {
|
|
99
104
|
keep = false;
|
|
100
105
|
const then = after;
|
|
@@ -123,8 +128,10 @@ export function drawerState(
|
|
|
123
128
|
close(then?: () => void): void {
|
|
124
129
|
if (above?.get()) return above.close(() => state.close(then));
|
|
125
130
|
if (!open) return then?.();
|
|
131
|
+
if (leaving) return;
|
|
126
132
|
if ((history.state as Record<string, unknown> | null)?.[key] === marker) {
|
|
127
133
|
after = then;
|
|
134
|
+
leaving = true;
|
|
128
135
|
history.back();
|
|
129
136
|
return;
|
|
130
137
|
}
|
|
@@ -137,8 +144,10 @@ export function drawerState(
|
|
|
137
144
|
if (above?.get()) return above.close(() => state.stay(then));
|
|
138
145
|
if (!open || (history.state as Record<string, unknown> | null)?.[key] !== marker)
|
|
139
146
|
return then();
|
|
147
|
+
if (leaving) return;
|
|
140
148
|
keep = true;
|
|
141
149
|
after = then;
|
|
150
|
+
leaving = true;
|
|
142
151
|
history.back();
|
|
143
152
|
},
|
|
144
153
|
subscribe(listener: () => void) {
|
|
@@ -599,15 +608,7 @@ function BottomBar({ shell, primary }: { shell: Shell; primary: MobileAction | u
|
|
|
599
608
|
</button>
|
|
600
609
|
);
|
|
601
610
|
})}
|
|
602
|
-
<
|
|
603
|
-
type="button"
|
|
604
|
-
aria-label="More"
|
|
605
|
-
onClick={() => drawer.open()}
|
|
606
|
-
className="mobile-press mobile-tab flex h-[52px] min-w-0 flex-1 flex-col items-center justify-center gap-0.5 rounded-full"
|
|
607
|
-
>
|
|
608
|
-
<Icon name="ellipsis" size={22} />
|
|
609
|
-
<span className="text-[10px] font-medium">More</span>
|
|
610
|
-
</button>
|
|
611
|
+
<MoreTab />
|
|
611
612
|
</nav>
|
|
612
613
|
{primary && (
|
|
613
614
|
<GlassButton
|
|
@@ -623,6 +624,47 @@ function BottomBar({ shell, primary }: { shell: Shell; primary: MobileAction | u
|
|
|
623
624
|
);
|
|
624
625
|
}
|
|
625
626
|
|
|
627
|
+
/** The plugins asking for attention on More (`ctx.shell.markMore`): its dot shows while any holds a mark. */
|
|
628
|
+
const moreMarks = heldIds();
|
|
629
|
+
/** Marks More for attention (research-128 §7): the dot on its tab while held; returns the release. */
|
|
630
|
+
export const markMore = (id: string) => moreMarks.hold(id);
|
|
631
|
+
/** The `overlay` entries drawn on a phone too (`ctx.shell.overlayOnPhone`), by their id: none by default. */
|
|
632
|
+
const phoneOverlays = heldIds();
|
|
633
|
+
/** Opts entry `id` of `overlay` in on a phone (research-128 §7): drawn there, outside the shell's frame, while held;
|
|
634
|
+
* returns the release. */
|
|
635
|
+
export const overlayOnPhone = (id: string) => phoneOverlays.hold(id);
|
|
636
|
+
/** The shell is disposed: every mark and phone overlay dropped (a plugin outliving it holds nothing). */
|
|
637
|
+
export const clearMobileHolds = () => {
|
|
638
|
+
moreMarks.clear();
|
|
639
|
+
phoneOverlays.clear();
|
|
640
|
+
};
|
|
641
|
+
|
|
642
|
+
/** "More", with a dot while a plugin marks it for attention (`ctx.shell.markMore`: Bridge's update, research-128). */
|
|
643
|
+
function MoreTab() {
|
|
644
|
+
const marks = React.useSyncExternalStore(moreMarks.subscribe, moreMarks.get);
|
|
645
|
+
const dot = marks.length > 0;
|
|
646
|
+
return (
|
|
647
|
+
<button
|
|
648
|
+
type="button"
|
|
649
|
+
aria-label={dot ? 'More, something needs your attention' : 'More'}
|
|
650
|
+
onClick={() => drawer.open()}
|
|
651
|
+
className="mobile-press mobile-tab flex h-[52px] min-w-0 flex-1 flex-col items-center justify-center gap-0.5 rounded-full"
|
|
652
|
+
>
|
|
653
|
+
<span className="relative flex">
|
|
654
|
+
<Icon name="ellipsis" size={22} />
|
|
655
|
+
{dot && (
|
|
656
|
+
// A plugin's mark: the kit's red, as the rail's update dot (the owner's choice, seen at a glance).
|
|
657
|
+
<span
|
|
658
|
+
data-slot="more-dot"
|
|
659
|
+
className="absolute -top-0.5 -right-1.5 size-2 rounded-full bg-destructive ring-2 ring-background"
|
|
660
|
+
/>
|
|
661
|
+
)}
|
|
662
|
+
</span>
|
|
663
|
+
<span className="text-[10px] font-medium">More</span>
|
|
664
|
+
</button>
|
|
665
|
+
);
|
|
666
|
+
}
|
|
667
|
+
|
|
626
668
|
/** A desktop view's title: its screen's (its items' own names, as `plugin:sessions/en/index`, mean nothing here). */
|
|
627
669
|
const desktopTitle = (shell: Shell, view: View) => {
|
|
628
670
|
const { screen } = view;
|
|
@@ -693,6 +735,7 @@ let sidebarItems: Context['sidebarItems'] = {
|
|
|
693
735
|
export const setSidebarItems = (service: Context['sidebarItems']) => {
|
|
694
736
|
sidebarItems = service;
|
|
695
737
|
};
|
|
738
|
+
|
|
696
739
|
function useSidebarItems() {
|
|
697
740
|
React.useSyncExternalStore(sidebarItems.subscribe, sidebarItems.get);
|
|
698
741
|
React.useSyncExternalStore(sidebarItems.navigation.subscribe, sidebarItems.navigation.get);
|
|
@@ -995,9 +1038,11 @@ export function MobileFrame({
|
|
|
995
1038
|
renderSlot,
|
|
996
1039
|
}: {
|
|
997
1040
|
shell: Shell;
|
|
998
|
-
|
|
1041
|
+
/** The frame's slots: `main`, the drawer's `more` rows, and `overlay` (its entries opted in on a phone only). */
|
|
1042
|
+
renderSlot: (key: 'main' | 'more' | 'overlay', props: object, options?: { only?: string }) => React.ReactNode;
|
|
999
1043
|
}) {
|
|
1000
1044
|
const open = React.useSyncExternalStore(drawer.subscribe, drawer.get);
|
|
1045
|
+
const overlays = React.useSyncExternalStore(phoneOverlays.subscribe, phoneOverlays.get);
|
|
1001
1046
|
const style = React.useSyncExternalStore(menuStyle.subscribe, menuStyle.get);
|
|
1002
1047
|
const { current, workspaces } = React.useSyncExternalStore(shell.subscribe, shell.get);
|
|
1003
1048
|
const mode = React.useSyncExternalStore(
|
|
@@ -1043,6 +1088,7 @@ export function MobileFrame({
|
|
|
1043
1088
|
}
|
|
1044
1089
|
}, [slug, workspaces.length]);
|
|
1045
1090
|
return (
|
|
1091
|
+
<>
|
|
1046
1092
|
<div
|
|
1047
1093
|
data-slot="shell"
|
|
1048
1094
|
data-mobile=""
|
|
@@ -1063,13 +1109,23 @@ export function MobileFrame({
|
|
|
1063
1109
|
: 'mobile-drawer top-0 left-0 h-full max-h-none w-full max-w-none translate-x-0 translate-y-0 rounded-none pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)] pr-[env(safe-area-inset-right)] pl-[env(safe-area-inset-left)] transition-transform duration-300 ease-out data-[ending-style]:-translate-x-full data-[starting-style]:-translate-x-full'
|
|
1064
1110
|
}
|
|
1065
1111
|
>
|
|
1066
|
-
<Menu shell={shell} style={style} />
|
|
1112
|
+
<Menu shell={shell} style={style} renderSlot={renderSlot} />
|
|
1067
1113
|
{/* Inside the drawer: dialogs of their own, nested, so a tap in them does not close the drawer. */}
|
|
1068
1114
|
{style === 'tree' && <WorkspaceSheet shell={shell} />}
|
|
1069
1115
|
<PhoneSettings textSize={textSize} mode={mode} style={style} />
|
|
1070
1116
|
</DialogContent>
|
|
1071
1117
|
</Dialog>
|
|
1072
1118
|
</div>
|
|
1119
|
+
{/* The `overlay` entries that opted in on a phone, outside the frame (a window over everything); none by default:
|
|
1120
|
+
the desktop's floating tools (a dock, a palette) stay off a phone. */}
|
|
1121
|
+
{overlays.length > 0 && (
|
|
1122
|
+
<div data-slot="shell-overlay">
|
|
1123
|
+
{overlays.map((id) => (
|
|
1124
|
+
<React.Fragment key={id}>{renderSlot('overlay', {}, { only: id })}</React.Fragment>
|
|
1125
|
+
))}
|
|
1126
|
+
</div>
|
|
1127
|
+
)}
|
|
1128
|
+
</>
|
|
1073
1129
|
);
|
|
1074
1130
|
}
|
|
1075
1131
|
|
|
@@ -1104,7 +1160,15 @@ type Page = { node: string } | { entry: Entry };
|
|
|
1104
1160
|
/** The drawer's content: with `pages`, a page (a node's views, then its child nodes; a view's rows under it), each
|
|
1105
1161
|
* row with rows under it opening its own page in the drawer, Back going up one; with `tree`, the node's views as a
|
|
1106
1162
|
* tree and a row opening the tree's page. The workspaces. It opens on the node shown. */
|
|
1107
|
-
function Menu({
|
|
1163
|
+
function Menu({
|
|
1164
|
+
shell,
|
|
1165
|
+
style,
|
|
1166
|
+
renderSlot,
|
|
1167
|
+
}: {
|
|
1168
|
+
shell: Shell;
|
|
1169
|
+
style: MenuStyle;
|
|
1170
|
+
renderSlot: (key: 'more', props: { style: MenuStyle; close: (then?: () => void) => void }) => React.ReactNode;
|
|
1171
|
+
}) {
|
|
1108
1172
|
const state = React.useSyncExternalStore(shell.subscribe, shell.get);
|
|
1109
1173
|
useSidebarItems();
|
|
1110
1174
|
const { current, nodes } = state;
|
|
@@ -1242,6 +1306,9 @@ function Menu({ shell, style }: { shell: Shell; style: MenuStyle }) {
|
|
|
1242
1306
|
push={(next) => push({ entry: next })}
|
|
1243
1307
|
/>
|
|
1244
1308
|
)}
|
|
1309
|
+
{/* Rows plugins add (`more`, research-128 §7), after More's own: the menu's style, so a row is drawn as its
|
|
1310
|
+
neighbours, and `close`, which closes the drawer and runs `then` after (as a row of the menu does). */}
|
|
1311
|
+
{!back && renderSlot('more', { style, close: (then?: () => void) => drawer.close(then) })}
|
|
1245
1312
|
{style === 'pages' && kids.length > 0 && (
|
|
1246
1313
|
<nav aria-label="Nodes" className="flex flex-col px-2 pb-2">
|
|
1247
1314
|
<h2 className="m-0 px-2 pt-3 pb-1 text-xs font-medium tracking-wide text-secondary uppercase">
|
package/browser/notifications.ts
CHANGED
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
|
|
42
42
|
import type { HostStatusEvent } from './shell.d.ts';
|
|
43
43
|
import type { Attention } from '@bridge/kernel/status';
|
|
44
|
+
import type { FixStep } from '@bridge/kernel/contracts';
|
|
44
45
|
import { pageSlot } from './page-slot.ts';
|
|
45
46
|
|
|
46
47
|
export type { HostStatusEvent };
|
|
@@ -55,6 +56,9 @@ export type Fix =
|
|
|
55
56
|
/** Restarts workspace `slug`, which tries its composition again (an attention's `retry`, research-087 §7.7); `label`,
|
|
56
57
|
* its button. */
|
|
57
58
|
| { action: 'retry'; slug: string; label: string }
|
|
59
|
+
/** A way out of plugin `plugin`'s contracts that do not agree (bridgebrew/bridge#598, `PluginView.fixes`): its `steps`
|
|
60
|
+
* run as one change (`plugin/batch`), shown first; `label`, its button. */
|
|
61
|
+
| { action: 'contract'; slug: string; plugin: string; steps: FixStep[]; label: string }
|
|
58
62
|
/** Opens plugin `plugin`'s settings in workspace `slug`, on field `setting`. */
|
|
59
63
|
| { action: 'setting'; slug: string; plugin: string; setting: string }
|
|
60
64
|
/** Runs plugin `plugin`'s settings action `id` (an `x-bridge-action` entry's) in workspace `slug`; `label`, its button. */
|
|
@@ -87,6 +91,42 @@ export const attentionFix = (
|
|
|
87
91
|
label: fix.label,
|
|
88
92
|
...(fix.confirm !== undefined && { confirm: fix.confirm }),
|
|
89
93
|
};
|
|
94
|
+
const capital = (word: string) => `${word[0]!.toUpperCase()}${word.slice(1)}`;
|
|
95
|
+
/** A plugin's contract fixes (`PluginView.fixes`, bridgebrew/bridge#598) as buttons, named by their steps as the status
|
|
96
|
+
* page names them (`Enable contacts, then Remove organizations`). A fix that installs a plugin is not one click (which
|
|
97
|
+
* plugin is the person's choice): left out. */
|
|
98
|
+
export const contractFixes = (
|
|
99
|
+
{ id, fixes }: Pick<PluginView, 'id' | 'fixes'>,
|
|
100
|
+
slug: string,
|
|
101
|
+
): Extract<Fix, { action: 'contract' }>[] =>
|
|
102
|
+
(fixes ?? []).flatMap((steps) =>
|
|
103
|
+
steps.some((step) => step.action === 'install')
|
|
104
|
+
? []
|
|
105
|
+
: [
|
|
106
|
+
{
|
|
107
|
+
action: 'contract' as const,
|
|
108
|
+
slug,
|
|
109
|
+
plugin: id,
|
|
110
|
+
steps,
|
|
111
|
+
label: steps
|
|
112
|
+
.map((step) => (step.action === 'install' ? '' : `${capital(step.action)} ${step.plugin}`))
|
|
113
|
+
.join(', then '),
|
|
114
|
+
},
|
|
115
|
+
],
|
|
116
|
+
);
|
|
117
|
+
/** A toast's one button among `fixes`: never a removal (one click would take a plugin away); the Errors modal offers
|
|
118
|
+
* them all. */
|
|
119
|
+
const toastFix = (fixes: Extract<Fix, { action: 'contract' }>[]) =>
|
|
120
|
+
fixes.find(({ steps }) => !steps.some((step) => step.action === 'remove'));
|
|
121
|
+
/** What a plugin's contracts say (`PluginView.contracts`), as one text, and a provider to install when that is a way
|
|
122
|
+
* out (which plugin is the person's choice: no button); none when they agree. */
|
|
123
|
+
const contractsText = ({ contracts, fixes }: Pick<PluginView, 'contracts' | 'fixes'>) => {
|
|
124
|
+
if (!contracts?.length) return undefined;
|
|
125
|
+
const install = fixes
|
|
126
|
+
?.flat()
|
|
127
|
+
.flatMap((step) => (step.action === 'install' ? [step.contract] : []));
|
|
128
|
+
return `${contracts.join('; ')}.${install?.length ? ` Install a plugin providing ${install.join(', ')}.` : ''}`;
|
|
129
|
+
};
|
|
90
130
|
export type Notice = {
|
|
91
131
|
variant: 'error' | 'warning' | 'info' | 'success';
|
|
92
132
|
title: string;
|
|
@@ -318,7 +358,19 @@ const shownOf = ({
|
|
|
318
358
|
reloadError,
|
|
319
359
|
blockedBy,
|
|
320
360
|
attention,
|
|
321
|
-
|
|
361
|
+
contracts,
|
|
362
|
+
fixes,
|
|
363
|
+
}: PluginView) => [
|
|
364
|
+
state,
|
|
365
|
+
error,
|
|
366
|
+
unresolved,
|
|
367
|
+
browserError,
|
|
368
|
+
reloadError,
|
|
369
|
+
blockedBy,
|
|
370
|
+
attention,
|
|
371
|
+
contracts,
|
|
372
|
+
fixes,
|
|
373
|
+
];
|
|
322
374
|
/** `a`; `a and b`; `a, b and c`: every name. */
|
|
323
375
|
const listNames = (names: string[]) =>
|
|
324
376
|
names.length <= 1 ? (names[0] ?? '') : `${names.slice(0, -1).join(', ')} and ${names.at(-1)}`;
|
|
@@ -357,22 +409,28 @@ function noticesOf(
|
|
|
357
409
|
});
|
|
358
410
|
} else if (state === 'failed') {
|
|
359
411
|
if ((reloadError === undefined ? undefined : withoutGeneration(reloadError)) !== error) {
|
|
360
|
-
|
|
412
|
+
// A reader whose contracts do not agree (bridgebrew/bridge#598): what they say, and their first fix.
|
|
413
|
+
const contract = toastFix(contractFixes(plugin, slug));
|
|
414
|
+
const description = contractsText(plugin) ?? withHint(plugin, slug, error, true);
|
|
361
415
|
notices.push({
|
|
362
416
|
variant: 'error',
|
|
363
417
|
title: failed,
|
|
364
418
|
description,
|
|
365
|
-
...fixOf(plugin, slug, error),
|
|
419
|
+
...(contract ? { fix: contract } : fixOf(plugin, slug, error)),
|
|
366
420
|
copy: copyOf(failed, description),
|
|
367
421
|
details,
|
|
368
422
|
});
|
|
369
423
|
}
|
|
370
424
|
} else if (state === 'unresolved') {
|
|
371
|
-
|
|
425
|
+
// Waiting for a provider (bridgebrew/bridge#598): what its contracts say, and their first fix.
|
|
426
|
+
const contract = toastFix(contractFixes(plugin, slug));
|
|
427
|
+
const description =
|
|
428
|
+
contractsText(plugin) ?? (unresolved?.length ? `Unresolved: ${unresolved.join(', ')}` : undefined);
|
|
372
429
|
notices.push({
|
|
373
430
|
variant: 'warning',
|
|
374
431
|
title: failed,
|
|
375
432
|
...(description !== undefined && { description }),
|
|
433
|
+
...(contract && { fix: contract }),
|
|
376
434
|
copy: copyOf(failed, description),
|
|
377
435
|
details,
|
|
378
436
|
});
|
|
@@ -1003,6 +1061,8 @@ export function notifier(
|
|
|
1003
1061
|
renderCauses();
|
|
1004
1062
|
return;
|
|
1005
1063
|
}
|
|
1064
|
+
// A Bridge-wide event (Bridge's update, bridge#677) is no plugin's: the update screens show it.
|
|
1065
|
+
if (!('slug' in event.data)) return;
|
|
1006
1066
|
const { slug, id } = event.data;
|
|
1007
1067
|
const key = pluginKey(slug, id);
|
|
1008
1068
|
const workspace = titles.get(slug) ?? slug;
|
|
@@ -1080,6 +1140,8 @@ export function notifier(
|
|
|
1080
1140
|
);
|
|
1081
1141
|
};
|
|
1082
1142
|
return (raw: HostStatusEvent) => {
|
|
1143
|
+
// Bridge's update (bridge#677) comes at each percent of a download: nothing here to render again.
|
|
1144
|
+
if (String(raw.event) === 'update') return;
|
|
1083
1145
|
listen(raw);
|
|
1084
1146
|
noteStarted(namedEvent(raw));
|
|
1085
1147
|
renderAttentions();
|
|
@@ -1106,6 +1168,8 @@ export type ReportItem = {
|
|
|
1106
1168
|
/** Every other status field set, as the modal's definition list. */
|
|
1107
1169
|
details: { label: string; value: string }[];
|
|
1108
1170
|
fix?: Fix;
|
|
1171
|
+
/** Its other ways out, after `fix` (a reader's contract fixes, bridgebrew/bridge#598). */
|
|
1172
|
+
more?: Fix[];
|
|
1109
1173
|
};
|
|
1110
1174
|
|
|
1111
1175
|
/** The status fields of `view` (and a workspace's reason) an item does not already show as its `text`; a field equal to
|
|
@@ -1201,10 +1265,13 @@ export function report(given: SnapshotData['workspaces']): ReportItem[] {
|
|
|
1201
1265
|
const { key, slug, view } = entry;
|
|
1202
1266
|
if (!pluginFails(view) || view.blockedBy?.length || inCause.has(key)) continue;
|
|
1203
1267
|
const reload = view.reloadError;
|
|
1268
|
+
const contract = contractFixes(view, slug);
|
|
1204
1269
|
const text =
|
|
1205
1270
|
reload !== undefined
|
|
1206
1271
|
? reload
|
|
1207
|
-
: view
|
|
1272
|
+
: contractsText(view) !== undefined
|
|
1273
|
+
? contractsText(view)!
|
|
1274
|
+
: view.state === 'unresolved'
|
|
1208
1275
|
? `Unresolved: ${view.unresolved?.join(', ') ?? ''}`
|
|
1209
1276
|
: view.state === 'failed'
|
|
1210
1277
|
? (view.error ?? `${view.id} failed`)
|
|
@@ -1213,7 +1280,8 @@ export function report(given: SnapshotData['workspaces']): ReportItem[] {
|
|
|
1213
1280
|
const title = `${view.id} ${reloading ? 'failed to reload' : 'failed'} in ${titleOf(slug)}`;
|
|
1214
1281
|
const cause = reloading ? reload : view.state === 'failed' ? view.error : view.browserError;
|
|
1215
1282
|
const hint = view.state === 'unresolved' ? undefined : sentenceOf(view, slug, cause, true);
|
|
1216
|
-
const
|
|
1283
|
+
const fix = reloading ? fixOf(view, slug, cause).fix : (contract[0] ?? fixOf(view, slug, cause).fix);
|
|
1284
|
+
const more = !reloading && contract[0] ? contract.slice(1) : [];
|
|
1217
1285
|
items.push({
|
|
1218
1286
|
key,
|
|
1219
1287
|
kind: 'plugin',
|
|
@@ -1226,6 +1294,7 @@ export function report(given: SnapshotData['workspaces']): ReportItem[] {
|
|
|
1226
1294
|
.map((each) => ({ slug: each.slug, id: each.view.id })),
|
|
1227
1295
|
details: detailsOf(view, text),
|
|
1228
1296
|
...(fix !== undefined && { fix }),
|
|
1297
|
+
...(more.length > 0 && { more }),
|
|
1229
1298
|
});
|
|
1230
1299
|
}
|
|
1231
1300
|
for (const workspace of workspaces) {
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
// One count for every popup and window of the home page (research-128 §7), whichever plugin opens it: while any is
|
|
2
|
+
// open over a joined Bridge's page, the desktop app keeps the home page in front (`bridgeDesktop.overlay(true)`), and
|
|
3
|
+
// the last one closing gives the window back (`overlay(false)`). Each plugin used to count its own: a tooltip closing
|
|
4
|
+
// while a window of another was open gave the window back too early. `ctx.shell.holdOverlay` is this.
|
|
5
|
+
import type { BridgeDesktop } from './shell.d.ts';
|
|
6
|
+
|
|
7
|
+
type DesktopState = { shown: unknown; overlay?: boolean };
|
|
8
|
+
/** What the hold reads of the desktop app: its overlay, and whether a joined page shows. */
|
|
9
|
+
type Desktop = {
|
|
10
|
+
overlay: BridgeDesktop['overlay'];
|
|
11
|
+
state(): Promise<DesktopState>;
|
|
12
|
+
onState(listener: (state: DesktopState) => void): () => void;
|
|
13
|
+
};
|
|
14
|
+
/** A hold: call it to release (once; later calls do nothing). `ready` resolves once the home page is in front (at once
|
|
15
|
+
* when no joined page shows, and after `waitMs` at most when the app does not answer), so a popup opens over the
|
|
16
|
+
* remote page, not under it. */
|
|
17
|
+
export type OverlayRelease = (() => void) & { readonly ready: Promise<void> };
|
|
18
|
+
export type OverlayHoldOptions = {
|
|
19
|
+
/** A dialog or window (not a tooltip or a menu): it takes the keyboard, the home page is focused. */
|
|
20
|
+
modal?: boolean;
|
|
21
|
+
/** The `overlay` slot entry the popup draws in: over a joined page, that entry alone shows while held. */
|
|
22
|
+
id?: string;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export function createOverlayHold(
|
|
26
|
+
desktop: () => Desktop | undefined = () => window.bridgeDesktop,
|
|
27
|
+
{ waitMs = 300 }: { waitMs?: number } = {},
|
|
28
|
+
) {
|
|
29
|
+
let count = 0;
|
|
30
|
+
/** A joined Bridge's page shows under the home page (the app's state). */
|
|
31
|
+
let shown = false;
|
|
32
|
+
/** The app was told the home page is in front. */
|
|
33
|
+
let sent = false;
|
|
34
|
+
/** The last overlay request: a hold while it runs waits for it. */
|
|
35
|
+
let request: Promise<void> = Promise.resolve();
|
|
36
|
+
/** The app's state came through `onState`: the first `state()` read, answering later, is stale. */
|
|
37
|
+
let followed = false;
|
|
38
|
+
/** The first `state()` read answered (or failed). */
|
|
39
|
+
let settled = false;
|
|
40
|
+
/** The release that left no hold waits a tick: a hold taken in the same interaction keeps the home page in front. */
|
|
41
|
+
let lowering: ReturnType<typeof setTimeout> | undefined;
|
|
42
|
+
const held = heldIds();
|
|
43
|
+
const app = desktop();
|
|
44
|
+
|
|
45
|
+
const send = (open: boolean, focus = false): Promise<void> => {
|
|
46
|
+
if (!app || (open === sent && !focus)) return request;
|
|
47
|
+
sent = open;
|
|
48
|
+
request = app.overlay(open, ...(focus ? [{ focus: true }] : [])).then(
|
|
49
|
+
() => undefined,
|
|
50
|
+
// Refused (the app is closing, an older app): the popup opens anyway, the next hold asks again.
|
|
51
|
+
() => {
|
|
52
|
+
if (sent === open) sent = !open;
|
|
53
|
+
},
|
|
54
|
+
);
|
|
55
|
+
return request;
|
|
56
|
+
};
|
|
57
|
+
const follow = (state: DesktopState) => {
|
|
58
|
+
shown = state.shown !== null && state.shown !== undefined;
|
|
59
|
+
// The app's overlay, set by someone else: what was sent is no longer true.
|
|
60
|
+
if (typeof state.overlay === 'boolean') sent = state.overlay;
|
|
61
|
+
// A remote page shown while a popup is open: the home page comes in front now; none any more: nothing to cover.
|
|
62
|
+
void send(shown && count > 0);
|
|
63
|
+
};
|
|
64
|
+
const stop = app?.onState((state) => {
|
|
65
|
+
followed = true;
|
|
66
|
+
follow(state);
|
|
67
|
+
});
|
|
68
|
+
/** The app's first state read. */
|
|
69
|
+
const watching: Promise<void> = app
|
|
70
|
+
? app.state().then(
|
|
71
|
+
(state) => {
|
|
72
|
+
settled = true;
|
|
73
|
+
if (!followed) follow(state);
|
|
74
|
+
},
|
|
75
|
+
() => void (settled = true),
|
|
76
|
+
)
|
|
77
|
+
: Promise.resolve();
|
|
78
|
+
const frame = () => new Promise<void>((done) => requestAnimationFrame(() => done()));
|
|
79
|
+
const bounded = (wait: Promise<void>) =>
|
|
80
|
+
new Promise<void>((done) => {
|
|
81
|
+
const timer = setTimeout(done, waitMs);
|
|
82
|
+
void wait.then(() => {
|
|
83
|
+
clearTimeout(timer);
|
|
84
|
+
done();
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
watching,
|
|
90
|
+
count: () => count,
|
|
91
|
+
/** The `overlay` entries held now (a stable array between changes). */
|
|
92
|
+
entries: held.get,
|
|
93
|
+
subscribe: held.subscribe,
|
|
94
|
+
hold({ modal = false, id }: OverlayHoldOptions = {}): OverlayRelease {
|
|
95
|
+
count++;
|
|
96
|
+
clearTimeout(lowering);
|
|
97
|
+
const releaseId = id === undefined ? undefined : held.hold(id);
|
|
98
|
+
// The desktop app focuses the home page over its remote view (`focus`, ignored by an older app); the page too.
|
|
99
|
+
if (modal) window.focus();
|
|
100
|
+
const raise = () => (shown ? send(true, modal).then(frame) : Promise.resolve());
|
|
101
|
+
const ready = !app ? Promise.resolve() : bounded(followed || settled ? raise() : watching.then(raise));
|
|
102
|
+
let released = false;
|
|
103
|
+
const release = () => {
|
|
104
|
+
if (released) return;
|
|
105
|
+
released = true;
|
|
106
|
+
count = Math.max(0, count - 1);
|
|
107
|
+
releaseId?.();
|
|
108
|
+
if (count > 0) return;
|
|
109
|
+
clearTimeout(lowering);
|
|
110
|
+
lowering = setTimeout(() => {
|
|
111
|
+
if (count === 0) void send(false);
|
|
112
|
+
}, 0);
|
|
113
|
+
};
|
|
114
|
+
return Object.assign(release, { ready });
|
|
115
|
+
},
|
|
116
|
+
/** The shell is disposed: stop following the app, drop every hold, give the window back. */
|
|
117
|
+
dispose() {
|
|
118
|
+
stop?.();
|
|
119
|
+
clearTimeout(lowering);
|
|
120
|
+
count = 0;
|
|
121
|
+
held.clear();
|
|
122
|
+
void send(false);
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
export type OverlayHold = ReturnType<typeof createOverlayHold>;
|
|
127
|
+
|
|
128
|
+
/** A set of ids held by plugins, each as many times as held (`hold` returns the release), followed by the frame. */
|
|
129
|
+
export function heldIds() {
|
|
130
|
+
const held = new Map<string, number>();
|
|
131
|
+
const listeners = new Set<() => void>();
|
|
132
|
+
let ids: readonly string[] = [];
|
|
133
|
+
const changed = () => {
|
|
134
|
+
ids = [...held.keys()];
|
|
135
|
+
for (const listener of listeners) listener();
|
|
136
|
+
};
|
|
137
|
+
return {
|
|
138
|
+
hold(id: string) {
|
|
139
|
+
held.set(id, (held.get(id) ?? 0) + 1);
|
|
140
|
+
changed();
|
|
141
|
+
let released = false;
|
|
142
|
+
return () => {
|
|
143
|
+
if (released || !held.has(id)) return;
|
|
144
|
+
released = true;
|
|
145
|
+
const left = (held.get(id) ?? 1) - 1;
|
|
146
|
+
if (left > 0) held.set(id, left);
|
|
147
|
+
else held.delete(id);
|
|
148
|
+
changed();
|
|
149
|
+
};
|
|
150
|
+
},
|
|
151
|
+
get: () => ids,
|
|
152
|
+
subscribe(listener: () => void) {
|
|
153
|
+
listeners.add(listener);
|
|
154
|
+
return () => void listeners.delete(listener);
|
|
155
|
+
},
|
|
156
|
+
/** Every hold dropped (the shell is disposed). */
|
|
157
|
+
clear() {
|
|
158
|
+
held.clear();
|
|
159
|
+
changed();
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
}
|
package/browser/shell-state.ts
CHANGED
|
@@ -482,6 +482,8 @@ export function followStatus(
|
|
|
482
482
|
let replaying = true;
|
|
483
483
|
const unsubscribe = subscribe((event) => {
|
|
484
484
|
if (event.event === 'nodes') shell.nodesChanged(event.data.workspace, event.data.revision);
|
|
485
|
+
// Bridge's update (bridge#677) changes no workspace, and comes at each percent of a download: nothing to refresh.
|
|
486
|
+
else if (String(event.event) === 'update') return;
|
|
485
487
|
else if (!(replaying && event.event === 'snapshot')) shell.refresh();
|
|
486
488
|
});
|
|
487
489
|
replaying = false;
|
package/browser/shell.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// browser type-check (tsconfig.pages.json); no plugin imports it (AD-8).
|
|
6
6
|
import type {} from 'cordis';
|
|
7
7
|
import type {} from '@bridge/ui-slots';
|
|
8
|
-
import type { ReactNode } from 'react';
|
|
8
|
+
import type { ReactElement, ReactNode } from 'react';
|
|
9
9
|
import type { StatusStreamEvent, WorkspaceLook } from '@bridge/kernel/status';
|
|
10
10
|
|
|
11
11
|
/** `look`: its look as it shows for this user (research-018 slice 8, research-028): the workspace's proposal with the
|
|
@@ -206,22 +206,40 @@ export interface WindowParts {
|
|
|
206
206
|
};
|
|
207
207
|
bar: { 'data-slot': 'shell-window-bar' };
|
|
208
208
|
crumbs: ReactNode;
|
|
209
|
+
/** The buttons its screen gave (`screen`'s `setActions`), drawn by the shell (`shell-window-actions`): the manager
|
|
210
|
+
* places them in its bar at the right of `crumbs`, before its own controls, and says so (`WindowOptions.drawsActions`).
|
|
211
|
+
* Absent while the screen gives none. */
|
|
212
|
+
actions?: ReactNode;
|
|
209
213
|
body: ReactNode;
|
|
210
214
|
}
|
|
211
215
|
|
|
216
|
+
/** A button a desktop screen gives its window's bar (`screen`'s `setActions`): an icon button the shell draws, `label`
|
|
217
|
+
* its name and tooltip, `pressed` its `aria-pressed` when it toggles something (a panel shown). */
|
|
218
|
+
export interface ScreenAction {
|
|
219
|
+
id: string;
|
|
220
|
+
label: string;
|
|
221
|
+
icon: string;
|
|
222
|
+
onSelect: () => void;
|
|
223
|
+
pressed?: boolean;
|
|
224
|
+
disabled?: boolean;
|
|
225
|
+
}
|
|
226
|
+
|
|
212
227
|
/** `renderWindow`'s options: `focused` marks the window focused among several (`data-focused`, where the manager draws
|
|
213
228
|
* its ring); `active`: it is the window the user works in (the focused one, ring or not: alone, it has none), its
|
|
214
229
|
* screen gets `focused: true`, the others `false`; absent (a manager that does not say), the screen's `focused` is
|
|
215
230
|
* absent too. `choices`: an empty window (a node alone) offers the node's views as buttons under "Choose a view in the
|
|
216
231
|
* sidebar". `others` (research-018 slice 6c): the other windows of its desk (shown or minimized) showing its screen on
|
|
217
232
|
* its node, each with its item and the kind its screen's `windows` rules give, passed on to its screen as `others`.
|
|
218
|
-
* `frame`: draws the window around its parts (`WindowParts`); absent, the shell's flat frame, as without a manager.
|
|
233
|
+
* `frame`: draws the window around its parts (`WindowParts`); absent, the shell's flat frame, as without a manager.
|
|
234
|
+
* `drawsActions`: `frame` draws `WindowParts.actions`; only then does its screen get `setActions` (the flat frame
|
|
235
|
+
* always draws them), so a screen falls back to its own buttons under a manager that does not. */
|
|
219
236
|
export interface WindowOptions {
|
|
220
237
|
focused: boolean;
|
|
221
238
|
active?: boolean;
|
|
222
239
|
choices?: boolean;
|
|
223
240
|
others?: readonly { item?: string; kind?: string }[];
|
|
224
241
|
frame?: (parts: WindowParts) => ReactNode;
|
|
242
|
+
drawsActions?: boolean;
|
|
225
243
|
}
|
|
226
244
|
|
|
227
245
|
/** A window shortcut (research-018 C5): `keys`, one or several, each modifiers then a `KeyboardEvent.code` (or a single
|
|
@@ -451,8 +469,10 @@ export interface BridgeDesktop {
|
|
|
451
469
|
};
|
|
452
470
|
/** The app's recovery screen (the home Bridge did not start): try it again, in safe mode, or quit. */
|
|
453
471
|
recover(action: 'retry' | 'safe' | 'quit'): Promise<DesktopResult>;
|
|
454
|
-
/** A popup of this page opens (`true`) or closes: over a remote page, the page covers the window meanwhile.
|
|
455
|
-
|
|
472
|
+
/** A popup of this page opens (`true`) or closes: over a remote page, the page covers the window meanwhile.
|
|
473
|
+
* `focus`: a window or dialog, the app also gives the home page the keyboard (bridgebrew/bridge#685; an older app
|
|
474
|
+
* ignores it). */
|
|
475
|
+
overlay(open: boolean, options?: { focus?: boolean }): Promise<unknown>;
|
|
456
476
|
/** Home page (research-034 slice 3): the app took ⌘K in a view; returns the unsubscribe. */
|
|
457
477
|
onPalette(listener: () => void): () => void;
|
|
458
478
|
/** Home page: its palette opened or closed; the home view covers the window meanwhile. */
|
|
@@ -494,6 +514,29 @@ declare module 'cordis' {
|
|
|
494
514
|
* `/_bridge/status`; `key`: the item to scroll to and outline briefly (a cause key, `pluginKey(slug, id)`,
|
|
495
515
|
* or a workspace slug, as a failure toast's `details` gives it), none: the top. */
|
|
496
516
|
showErrors(key?: string): void;
|
|
517
|
+
/** Keeps the home page in front of a joined Bridge's page (the desktop app) while a popup or window of this page
|
|
518
|
+
* is open: one count for every plugin (research-128 §7). Returns the release (call it on close or unmount; once);
|
|
519
|
+
* its `ready` resolves once the home page is in front (at once without a joined page or the app), so the popup
|
|
520
|
+
* opens after it (after a short wait at most when the app does not answer). `modal`: a dialog or window (not a
|
|
521
|
+
* tooltip or a menu): the app gives the home page the keyboard. `id`: the `overlay` entry the popup draws in,
|
|
522
|
+
* which alone shows over the joined page while held (the others stay hidden there). Absent in an older shell:
|
|
523
|
+
* the caller keeps its own `bridgeDesktop.overlay` calls.
|
|
524
|
+
*
|
|
525
|
+
* The shell cannot see who calls it: a plugin ties each hold, mark and phone overlay to its own life (a React
|
|
526
|
+
* effect's cleanup, or `ctx.effect(() => ctx.shell.markMore(id))`); the shell drops them all when it goes. */
|
|
527
|
+
holdOverlay?(options?: {
|
|
528
|
+
modal?: boolean;
|
|
529
|
+
id?: string;
|
|
530
|
+
}): (() => void) & { readonly ready: Promise<void> };
|
|
531
|
+
/** Draws entry `id` of `overlay` on a phone too (none is by default), outside the shell's frame; returns the
|
|
532
|
+
* release. Absent in an older shell. */
|
|
533
|
+
overlayOnPhone?(id: string): () => void;
|
|
534
|
+
/** Marks the phone's More for attention: a dot on its tab while held (any plugin's mark, until the last is
|
|
535
|
+
* released); returns the release. Absent in an older shell. */
|
|
536
|
+
markMore?(id: string): () => void;
|
|
537
|
+
/** The page shows the phone's layout now (a narrow touch screen, or the phone frame); read at render. Absent in an
|
|
538
|
+
* older shell. */
|
|
539
|
+
readonly mobile?: boolean;
|
|
497
540
|
/** Opens the keyboard shortcuts' help (as `?` does): a plugin's button in the `controls` zone asks for it. */
|
|
498
541
|
showShortcuts(): void;
|
|
499
542
|
/** Opens plugin `plugin`'s settings (its id) in workspace `slug` on field `setting`: a fix's Open the setting, the
|
|
@@ -837,14 +880,30 @@ declare module '@bridge/ui-slots' {
|
|
|
837
880
|
/** Declared by `rail` (CAP-4, research-024 C12): a home plugin's icon (an Inbox, an agenda) at the top of
|
|
838
881
|
* the rail, above the workspaces, or at its bottom, above Admin; each entry its own `id`, about 40px square. */
|
|
839
882
|
'rail-top': { kind: 'list'; scope: 'root' };
|
|
840
|
-
|
|
883
|
+
/** Its entries sit at the bottom, after the divider of the controls the shell moves there, above Bridge's status
|
|
884
|
+
* and Admin; `tip`: the rail's tooltip, so an icon there is named as its neighbours (research-128 §7). An older rail
|
|
885
|
+
* passes none: the entry then draws its icon alone. */
|
|
886
|
+
'rail-bottom': {
|
|
887
|
+
kind: 'list';
|
|
888
|
+
scope: 'root';
|
|
889
|
+
owner: { tip?: (props: { label: ReactNode; children: ReactElement }) => ReactNode };
|
|
890
|
+
};
|
|
841
891
|
sidebar: { kind: 'single'; scope: 'root' };
|
|
842
892
|
/** Declared by `windows`' `stage` entry: at the left of its dock, before the desks (a Start button); each entry its
|
|
843
893
|
* own `id`, 28px high. Not drawn while another manager, or none, lays out the windows. */
|
|
844
894
|
'dock-start': { kind: 'list'; scope: 'root' };
|
|
845
895
|
main: { kind: 'single'; scope: 'root' };
|
|
846
|
-
/** Over the whole frame, after it: `_host` plugins add floating layers (each its own `id`), fixed-positioned.
|
|
896
|
+
/** Over the whole frame, after it: `_host` plugins add floating layers (each its own `id`), fixed-positioned. On a
|
|
897
|
+
* phone, only the entries that opted in (`shell.overlayOnPhone(id)`) are drawn, outside the frame. */
|
|
847
898
|
overlay: { kind: 'list'; scope: 'root' };
|
|
899
|
+
/** Declared by `shell` (research-128 §7): rows a plugin adds to the phone's More, after its own, each its own `id`.
|
|
900
|
+
* `style`: the menu's (`tree`: a SidebarTreeItem row, as its views; `pages`: a 48px row with a 20px icon), so a row
|
|
901
|
+
* is drawn as its neighbours; `close(then)`: closes the drawer, then runs `then` (open a page from it). */
|
|
902
|
+
more: {
|
|
903
|
+
kind: 'list';
|
|
904
|
+
scope: 'root';
|
|
905
|
+
owner: { style: 'tree' | 'pages'; close: (then?: () => void) => void };
|
|
906
|
+
};
|
|
848
907
|
/** Declared by `shell`: with its theme controls, wherever they stand (under the sidebar, under the rail while it is
|
|
849
908
|
* hidden, in the narrow column of the desktop app's pages), first; each entry its own `id`, a 28px button (the
|
|
850
909
|
* Start menu's when no dock shows). */
|
|
@@ -859,7 +918,12 @@ declare module '@bridge/ui-slots' {
|
|
|
859
918
|
* node, each with its item and the kind its screen's `windows` rules give it: a list may leave its own card pane
|
|
860
919
|
* while card windows are open, and send a click to them (`reuse`); absent, a manager (or a Bridge) that does not say.
|
|
861
920
|
* `screenState`, `setScreenState` (research-090): its window's own state and its setter, as `workspace.d.ts`'s
|
|
862
|
-
* `screen` says; absent from an older Bridge.
|
|
921
|
+
* `screen` says; absent from an older Bridge. `setActions`: the buttons the screen wants in its window's bar
|
|
922
|
+
* (`ScreenAction`), at the right of the breadcrumb, before the window's own controls (the shell's top bar without a
|
|
923
|
+
* window manager); call it from an effect, and with `[]` when the screen unmounts. Kept per window and per view:
|
|
924
|
+
* another screen or node there shows none of them. Given only where they are drawn: absent, an older shell, a
|
|
925
|
+
* window manager that does not draw them (`WindowOptions.drawsActions`), a phone, or a utility screen; the
|
|
926
|
+
* screen then draws its own. */
|
|
863
927
|
screen: {
|
|
864
928
|
kind: 'keyed';
|
|
865
929
|
scope: 'root';
|
|
@@ -875,6 +939,7 @@ declare module '@bridge/ui-slots' {
|
|
|
875
939
|
next: Record<string, string> | undefined,
|
|
876
940
|
options?: { push?: boolean },
|
|
877
941
|
) => void;
|
|
942
|
+
setActions?: (actions: readonly ScreenAction[]) => void;
|
|
878
943
|
};
|
|
879
944
|
};
|
|
880
945
|
/** Declared by `shell`'s `main` entry (research-020 C): a screen's phone variant, filled under its plugin key as
|
|
@@ -886,7 +951,7 @@ declare module '@bridge/ui-slots' {
|
|
|
886
951
|
/** `setActions` (research-020, iOS 26's layout): the buttons the screen wants the shell to draw, in glass:
|
|
887
952
|
* `top`, the capsule at the top right; `primary`, the round button at the bottom right beside the bar of
|
|
888
953
|
* screens. Call it from an effect, and with `[]` when the screen unmounts. Absent: an older shell. */
|
|
889
|
-
owner: SlotMap['screen']['owner'] & {
|
|
954
|
+
owner: Omit<SlotMap['screen']['owner'], 'setActions'> & {
|
|
890
955
|
setActions?: (
|
|
891
956
|
actions: readonly {
|
|
892
957
|
id: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bridgebrew/shell",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "The page around everything: the rail, the sidebar column, the stage beside it and the theme controls.",
|
|
6
6
|
"keywords": [
|
|
@@ -72,7 +72,24 @@
|
|
|
72
72
|
"placement": "host",
|
|
73
73
|
"implements": [
|
|
74
74
|
"shell"
|
|
75
|
-
]
|
|
75
|
+
],
|
|
76
|
+
"contracts": {
|
|
77
|
+
"provides": {
|
|
78
|
+
"shell": {
|
|
79
|
+
"version": "1.0"
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
"uses": {
|
|
83
|
+
"plugin-manager": {
|
|
84
|
+
"version": "1.0",
|
|
85
|
+
"optional": true
|
|
86
|
+
},
|
|
87
|
+
"bridge-settings": {
|
|
88
|
+
"version": "1.0",
|
|
89
|
+
"optional": true
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
76
93
|
},
|
|
77
94
|
"peerDependencies": {
|
|
78
95
|
"@bridge/kernel": ">=0.0.1",
|
|
@@ -86,6 +103,6 @@
|
|
|
86
103
|
"typecheck": "bridge plugin check ."
|
|
87
104
|
},
|
|
88
105
|
"engines": {
|
|
89
|
-
"bridge": ">=0.0.1-nightly.
|
|
106
|
+
"bridge": ">=0.0.1-nightly.20261124.1"
|
|
90
107
|
}
|
|
91
108
|
}
|