@1agh/maude 2.1.0 → 2.1.2
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/apps/studio/access/request.ts +1 -0
- package/apps/studio/actions/agents.ts +45 -42
- package/apps/studio/actions/defs/app.ts +28 -1
- package/apps/studio/actions/defs/sync.ts +4 -0
- package/apps/studio/actions/verbs.ts +49 -0
- package/apps/studio/actions.manifest.json +162 -20
- package/apps/studio/actions.parity.json +13 -1
- package/apps/studio/ai/create-claim.ts +1 -1
- package/apps/studio/bin/_asset-file.mjs +117 -0
- package/apps/studio/bin/_canvas-file.mjs +146 -0
- package/apps/studio/bin/_curl-local.mjs +7 -4
- package/apps/studio/bin/_footage.mjs +123 -0
- package/apps/studio/bin/_pdf-playwright.mjs +14 -0
- package/apps/studio/bin/_png-playwright.mjs +15 -1
- package/apps/studio/bin/_pw-launch.mjs +98 -0
- package/apps/studio/bin/_retry-save.mjs +49 -0
- package/apps/studio/bin/_sync.mjs +145 -2
- package/apps/studio/bin/asset-rename.sh +12 -0
- package/apps/studio/bin/asset-trash.sh +12 -0
- package/apps/studio/bin/canvas-move.sh +12 -0
- package/apps/studio/bin/canvas-new.sh +12 -0
- package/apps/studio/bin/footage.sh +12 -0
- package/apps/studio/bin/generate.sh +7 -0
- package/apps/studio/bin/retry-save.sh +13 -0
- package/apps/studio/bridge/canvas-mode-store.ts +11 -2
- package/apps/studio/bridge/dgn-protocol.ts +8 -3
- package/apps/studio/bridge/occlusion.ts +45 -0
- package/apps/studio/canvas-theme-pill.tsx +169 -26
- package/apps/studio/client/app.jsx +16 -4
- package/apps/studio/client/export-center.jsx +32 -3
- package/apps/studio/client/home/HomeAccountBanner.jsx +61 -0
- package/apps/studio/client/home/HomeAccountsChip.jsx +404 -0
- package/apps/studio/client/home/HomeConnection.jsx +112 -0
- package/apps/studio/client/home/ProjectRows.jsx +514 -0
- package/apps/studio/client/home/home-accounts-model.js +234 -76
- package/apps/studio/client/home/home-api.js +10 -2
- package/apps/studio/client/home/home-app.jsx +151 -394
- package/apps/studio/client/home/home-icons.jsx +8 -0
- package/apps/studio/client/home/home-model.js +149 -1
- package/apps/studio/client/home/home-where-model.js +105 -0
- package/apps/studio/client/home/home.css +621 -53
- package/apps/studio/client/home/use-account-fix.js +123 -0
- package/apps/studio/client/hooks/use-palette-and-panels.jsx +3 -1
- package/apps/studio/client/hooks/use-tabs.jsx +11 -4
- package/apps/studio/client/panels/TeamProjects.jsx +137 -134
- package/apps/studio/client/share-link.js +12 -0
- package/apps/studio/client/styles/_index.css +4 -0
- package/apps/studio/client/v2/assets/generate-ask.jsx +3 -1
- package/apps/studio/client/v2/diagnostics/diagnostics-host.jsx +1 -0
- package/apps/studio/client/v2/diagnostics/diagnostics-model.js +32 -2
- package/apps/studio/client/v2/diagnostics/diagnostics-sheet.jsx +35 -8
- package/apps/studio/client/v2/diagnostics/diagnostics.css +34 -0
- package/apps/studio/client/v2/diagnostics/sync-details/sync-details-model.js +94 -3
- package/apps/studio/client/v2/diagnostics/sync-details/sync-details.jsx +187 -4
- package/apps/studio/client/v2/export/done-toast.jsx +2 -5
- package/apps/studio/client/v2/export/export-sheet.jsx +9 -2
- package/apps/studio/client/v2/export/export.css +9 -0
- package/apps/studio/client/v2/export/exports-model.js +16 -3
- package/apps/studio/client/v2/export/file-rows.jsx +81 -5
- package/apps/studio/client/v2/export/native-save.js +33 -0
- package/apps/studio/client/v2/export/sections/print-copy.js +3 -0
- package/apps/studio/client/v2/export/sections/print.jsx +37 -20
- package/apps/studio/client/v2/link-server/LinkServerDialog.jsx +492 -0
- package/apps/studio/client/v2/link-server/LinkServerHost.jsx +42 -0
- package/apps/studio/client/v2/link-server/link-server-api.js +142 -0
- package/apps/studio/client/v2/link-server/link-server-model.js +438 -0
- package/apps/studio/client/v2/link-server/link-server.css +109 -0
- package/apps/studio/client/v2/onboarding/AdvancedSheets.jsx +31 -86
- package/apps/studio/client/v2/onboarding/onboarding-model.js +1 -18
- package/apps/studio/client/v2/search/search-keywords.js +3 -2
- package/apps/studio/client/v2/settings/account.jsx +4 -2
- package/apps/studio/client/v2/settings/advanced-section.jsx +245 -148
- package/apps/studio/client/v2/settings/connection-row.jsx +3 -59
- package/apps/studio/client/v2/settings/connections-section.jsx +118 -425
- package/apps/studio/client/v2/settings/general-section.jsx +138 -43
- package/apps/studio/client/v2/settings/project-sync-settings.jsx +4 -3
- package/apps/studio/client/v2/settings/reset-section.jsx +14 -3
- package/apps/studio/client/v2/settings/settings-card.jsx +142 -0
- package/apps/studio/client/v2/settings/settings-cards.js +220 -0
- package/apps/studio/client/v2/settings/settings-handlers.js +7 -6
- package/apps/studio/client/v2/settings/settings-model.js +91 -31
- package/apps/studio/client/v2/settings/settings-sheet.jsx +25 -6
- package/apps/studio/client/v2/settings/settings.css +374 -64
- package/apps/studio/client/v2/settings/this-project-card.jsx +730 -0
- package/apps/studio/client/v2/settings/this-project-model.js +172 -0
- package/apps/studio/client/v2/settings/use-connections.js +3 -2
- package/apps/studio/client/v2/settings/use-open-card.js +37 -0
- package/apps/studio/client/v2/shell/connection-state.js +197 -0
- package/apps/studio/client/v2/shell/menu-runner.js +7 -2
- package/apps/studio/client/v2/shell/occlusion-insets.js +37 -9
- package/apps/studio/client/v2/shell/project-account-bus.js +36 -0
- package/apps/studio/client/v2/shell/project-account-card.jsx +357 -148
- package/apps/studio/client/v2/shell/project-account-model.js +272 -149
- package/apps/studio/client/v2/shell/project-account-toast.js +66 -0
- package/apps/studio/client/v2/shell/project-account.css +237 -0
- package/apps/studio/client/v2/shell/share-cluster-host.jsx +166 -83
- package/apps/studio/client/v2/shell/shell-parity.js +3 -2
- package/apps/studio/client/v2/shell/shell-parity.json +40 -26
- package/apps/studio/client/v2/shell/use-account.js +2 -0
- package/apps/studio/client/v2/shell/use-occluded-insets.js +13 -3
- package/apps/studio/client/v2/signin/use-signin.js +1 -1
- package/apps/studio/cloud/endpoints.ts +29 -4
- package/apps/studio/collab/room.ts +21 -7
- package/apps/studio/dist/client.bundle.js +886 -886
- package/apps/studio/dist/comment-mount.js +2 -2
- package/apps/studio/dist/styles.css +1 -1
- package/apps/studio/exporters/ghostscript.ts +78 -1
- package/apps/studio/exporters/pdf-fonts.ts +31 -4
- package/apps/studio/generation/jobs.ts +6 -0
- package/apps/studio/home/accounts.ts +30 -11
- package/apps/studio/home/cloud.ts +6 -1
- package/apps/studio/home/hub-health.ts +76 -0
- package/apps/studio/home/routes.ts +9 -3
- package/apps/studio/http.ts +14 -2
- package/apps/studio/migrate/hub.ts +8 -1
- package/apps/studio/routes/agent.ts +6 -2
- package/apps/studio/routes/hub-link-folder.ts +334 -0
- package/apps/studio/routes/hub-signin.ts +78 -1
- package/apps/studio/routes/index.ts +4 -0
- package/apps/studio/routes/project-undo.ts +10 -0
- package/apps/studio/routes/sync.ts +22 -4
- package/apps/studio/server.ts +25 -0
- package/apps/studio/shell/api-key.ts +11 -0
- package/apps/studio/shell/cli-yield.ts +48 -11
- package/apps/studio/sync/accepted-cold-start.ts +144 -8
- package/apps/studio/sync/action-stage.ts +18 -1
- package/apps/studio/sync/ctl-heal.ts +58 -0
- package/apps/studio/sync/file-ledger.ts +38 -4
- package/apps/studio/sync/file-plane.ts +226 -19
- package/apps/studio/sync/held-deletes.ts +86 -5
- package/apps/studio/sync/hub-link.ts +8 -0
- package/apps/studio/sync/index.ts +68 -4
- package/apps/studio/sync/link-consent.ts +22 -75
- package/apps/studio/sync/link-survey.ts +252 -0
- package/apps/studio/sync/local-kernel.ts +16 -1
- package/apps/studio/sync/seed-progress.ts +12 -0
- package/apps/studio/sync/source-recovery.ts +18 -2
- package/apps/studio/sync/status.ts +11 -1
- package/apps/studio/sync/writer-registry.ts +5 -0
- package/apps/studio/whats-new.json +36 -0
- package/cli/commands/design.mjs +74 -16
- package/cli/lib/bash-guard.mjs +23 -4
- package/cli/lib/confine-read.mjs +2 -0
- package/cli/lib/design-help.gen.mjs +15 -2
- package/cli/lib/design-hook.mjs +1 -1
- package/cli/lib/desktop-locate.mjs +36 -8
- package/cli/lib/studio-locate.mjs +8 -2
- package/cli/lib/sub-verbs.mjs +13 -1
- package/package.json +9 -8
- package/apps/studio/client/home/HomeAccounts.jsx +0 -262
- package/apps/studio/client/v2/onboarding/HubSheet.jsx +0 -212
- package/apps/studio/client/v2/shell/account-card-model.js +0 -114
- package/apps/studio/client/v2/shell/account-card.jsx +0 -189
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
// client/home/HomeAccounts.jsx — 2.0.5 W4b: Home's avatar and the card it opens.
|
|
2
|
-
//
|
|
3
|
-
// Every profile on this Mac by its label, with the accounts it is signed in with (Maude Cloud,
|
|
4
|
-
// team servers, GitHub): Sign out per account where Home has a path (asks first), Sign in with
|
|
5
|
-
// GitHub for a profile without it, and add / switch at the foot. What each row means and why a
|
|
6
|
-
// row has no button: home-accounts-model.js. The card fetches the team-server sign-ins when it
|
|
7
|
-
// opens (`GET /_home/accounts`) and after every sign-out.
|
|
8
|
-
|
|
9
|
-
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
10
|
-
|
|
11
|
-
import { cloudSignOut, getAccounts, hubSignOut, shellInvoke, shellListen } from './home-api.js';
|
|
12
|
-
import { homeAccounts } from './home-accounts-model.js';
|
|
13
|
-
import { githubSignIn } from '../v2/onboarding/github-home.js';
|
|
14
|
-
|
|
15
|
-
const KIND_TITLE = { cloud: 'Maude Cloud', team: 'Team server', github: 'GitHub' };
|
|
16
|
-
|
|
17
|
-
/** The team-server sign-ins of `ids`, re-read when `open` turns on or `gen` moves. */
|
|
18
|
-
function useHubProfiles(ids, open, gen) {
|
|
19
|
-
const [hubProfiles, setHubProfiles] = useState([]);
|
|
20
|
-
const key = ids.join(',');
|
|
21
|
-
// biome-ignore lint/correctness/useExhaustiveDependencies: `key` stands for `ids`; `gen` re-reads
|
|
22
|
-
useEffect(() => {
|
|
23
|
-
if (!open || !key) return undefined;
|
|
24
|
-
let live = true;
|
|
25
|
-
getAccounts(key.split(',')).then((r) => {
|
|
26
|
-
if (live && r.ok && Array.isArray(r.json?.profiles)) setHubProfiles(r.json.profiles);
|
|
27
|
-
});
|
|
28
|
-
return () => {
|
|
29
|
-
live = false;
|
|
30
|
-
};
|
|
31
|
-
}, [open, key, gen]);
|
|
32
|
-
return hubProfiles;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* @param shell / clouds / native — Home's data
|
|
37
|
-
* @param onAddCloud () => void Home's Maude Cloud sign-in (a fresh profile when one is signed in)
|
|
38
|
-
* @param onAddTeam () => void the Advanced › team server sheet
|
|
39
|
-
* @param onChanged () => Promise reload Home's data after a sign-out / sign-in
|
|
40
|
-
*/
|
|
41
|
-
export function HomeAccounts({ shell, clouds, native, onAddCloud, onAddTeam, onChanged }) {
|
|
42
|
-
const [open, setOpen] = useState(false);
|
|
43
|
-
const [gen, setGen] = useState(0);
|
|
44
|
-
const [asking, setAsking] = useState(null);
|
|
45
|
-
const [busy, setBusy] = useState(false);
|
|
46
|
-
const [error, setError] = useState(null);
|
|
47
|
-
const [ghCode, setGhCode] = useState(null);
|
|
48
|
-
const wrap = useRef(null);
|
|
49
|
-
const ids = (shell?.profiles ?? []).map((p) => p?.id).filter((id) => typeof id === 'string');
|
|
50
|
-
const hubProfiles = useHubProfiles(ids, open, gen);
|
|
51
|
-
const model = homeAccounts({ native, shell, clouds, hubProfiles });
|
|
52
|
-
|
|
53
|
-
const close = useCallback(() => {
|
|
54
|
-
setOpen(false);
|
|
55
|
-
setAsking(null);
|
|
56
|
-
setError(null);
|
|
57
|
-
}, []);
|
|
58
|
-
useEffect(() => {
|
|
59
|
-
if (!open) return undefined;
|
|
60
|
-
const onKey = (e) => e.key === 'Escape' && close();
|
|
61
|
-
const onDown = (e) => wrap.current && !wrap.current.contains(e.target) && close();
|
|
62
|
-
window.addEventListener('keydown', onKey);
|
|
63
|
-
window.addEventListener('pointerdown', onDown);
|
|
64
|
-
return () => {
|
|
65
|
-
window.removeEventListener('keydown', onKey);
|
|
66
|
-
window.removeEventListener('pointerdown', onDown);
|
|
67
|
-
};
|
|
68
|
-
}, [open, close]);
|
|
69
|
-
// the GitHub device code arrives as a shell message while a sign-in from this card runs
|
|
70
|
-
useEffect(() => {
|
|
71
|
-
if (!open || !native) return undefined;
|
|
72
|
-
let off = () => {};
|
|
73
|
-
shellListen('github://device-code', (p) => setGhCode(p?.user_code ?? null)).then((u) => {
|
|
74
|
-
off = u;
|
|
75
|
-
});
|
|
76
|
-
return () => off();
|
|
77
|
-
}, [open, native]);
|
|
78
|
-
|
|
79
|
-
if (!model.face) return null;
|
|
80
|
-
|
|
81
|
-
const signOut = async () => {
|
|
82
|
-
const spec = asking;
|
|
83
|
-
setBusy(true);
|
|
84
|
-
setError(null);
|
|
85
|
-
const r =
|
|
86
|
-
spec.path === 'cloud-signout'
|
|
87
|
-
? await cloudSignOut(spec.profile)
|
|
88
|
-
: await hubSignOut(spec.profile, spec.url);
|
|
89
|
-
setBusy(false);
|
|
90
|
-
setAsking(null);
|
|
91
|
-
if (!r.ok || !r.json?.ok) {
|
|
92
|
-
setError(r.json?.error || 'Couldn’t sign out. Nothing changed — try again.');
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
setGen((g) => g + 1);
|
|
96
|
-
await onChanged?.();
|
|
97
|
-
};
|
|
98
|
-
const ghSignIn = async (profile) => {
|
|
99
|
-
setError(null);
|
|
100
|
-
setBusy(true);
|
|
101
|
-
try {
|
|
102
|
-
await githubSignIn(profile, shellInvoke);
|
|
103
|
-
await onChanged?.();
|
|
104
|
-
} catch (e) {
|
|
105
|
-
setError(typeof e === 'string' ? e : 'GitHub sign-in didn’t finish. Try again.');
|
|
106
|
-
} finally {
|
|
107
|
-
setGhCode(null);
|
|
108
|
-
setBusy(false);
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
return (
|
|
113
|
-
<span className="home-top-acct" ref={wrap}>
|
|
114
|
-
<button
|
|
115
|
-
type="button"
|
|
116
|
-
className="home-top-acct-btn"
|
|
117
|
-
data-testid="home-top-face"
|
|
118
|
-
aria-label={model.face.title}
|
|
119
|
-
title={model.face.title}
|
|
120
|
-
aria-haspopup="dialog"
|
|
121
|
-
aria-expanded={open}
|
|
122
|
-
onClick={() => (open ? close() : setOpen(true))}
|
|
123
|
-
>
|
|
124
|
-
<span
|
|
125
|
-
className={`home-face home-face--md home-face--${model.face.tone}`}
|
|
126
|
-
aria-hidden="true"
|
|
127
|
-
>
|
|
128
|
-
{model.face.initial}
|
|
129
|
-
</span>
|
|
130
|
-
</button>
|
|
131
|
-
{open ? (
|
|
132
|
-
<div
|
|
133
|
-
className="home-accts"
|
|
134
|
-
role="dialog"
|
|
135
|
-
aria-label="Accounts on this Mac"
|
|
136
|
-
data-testid="home-accounts"
|
|
137
|
-
>
|
|
138
|
-
<p className="home-accts-h">Accounts on this Mac</p>
|
|
139
|
-
{model.profiles.map((p) => (
|
|
140
|
-
<section
|
|
141
|
-
key={p.id}
|
|
142
|
-
className="home-accts-p"
|
|
143
|
-
data-testid={`home-accounts-profile-${p.id}`}
|
|
144
|
-
>
|
|
145
|
-
<h3 className="home-accts-ph">
|
|
146
|
-
<span className={`home-acctf home-acctf--${p.face.tone}`} aria-hidden="true">
|
|
147
|
-
{p.face.initial}
|
|
148
|
-
</span>
|
|
149
|
-
{p.label}
|
|
150
|
-
</h3>
|
|
151
|
-
{p.accounts.length ? (
|
|
152
|
-
<ul className="home-accts-list">
|
|
153
|
-
{p.accounts.map((a) => (
|
|
154
|
-
<li
|
|
155
|
-
key={a.key}
|
|
156
|
-
className="home-accts-row"
|
|
157
|
-
data-testid={`home-account-${p.id}-${a.kind}`}
|
|
158
|
-
>
|
|
159
|
-
<span className="home-accts-t">
|
|
160
|
-
<strong>
|
|
161
|
-
{a.kind === 'team'
|
|
162
|
-
? `${KIND_TITLE.team} · ${a.host}`
|
|
163
|
-
: KIND_TITLE[a.kind]}
|
|
164
|
-
</strong>
|
|
165
|
-
{a.who ? <span>{a.who}</span> : null}
|
|
166
|
-
</span>
|
|
167
|
-
{a.signOut ? (
|
|
168
|
-
<button
|
|
169
|
-
type="button"
|
|
170
|
-
className="btn btn--ghost btn--sm"
|
|
171
|
-
data-testid={`home-account-signout-${p.id}-${a.kind}`}
|
|
172
|
-
onClick={() => setAsking(a.signOut)}
|
|
173
|
-
disabled={busy}
|
|
174
|
-
>
|
|
175
|
-
Sign out…
|
|
176
|
-
</button>
|
|
177
|
-
) : null}
|
|
178
|
-
</li>
|
|
179
|
-
))}
|
|
180
|
-
</ul>
|
|
181
|
-
) : (
|
|
182
|
-
<p className="home-accts-none">Not signed in to anything yet.</p>
|
|
183
|
-
)}
|
|
184
|
-
{p.githubSignIn ? (
|
|
185
|
-
<button
|
|
186
|
-
type="button"
|
|
187
|
-
className="home-accts-act"
|
|
188
|
-
data-testid={`home-account-github-signin-${p.id}`}
|
|
189
|
-
onClick={() => ghSignIn(p.id)}
|
|
190
|
-
disabled={busy}
|
|
191
|
-
>
|
|
192
|
-
Sign in with GitHub…
|
|
193
|
-
</button>
|
|
194
|
-
) : null}
|
|
195
|
-
</section>
|
|
196
|
-
))}
|
|
197
|
-
{ghCode ? (
|
|
198
|
-
<p className="home-accts-note" data-testid="home-accounts-github-code">
|
|
199
|
-
Enter <strong>{ghCode}</strong> on the GitHub page that opened.
|
|
200
|
-
</p>
|
|
201
|
-
) : null}
|
|
202
|
-
{error ? (
|
|
203
|
-
<p className="home-accts-note" role="alert" data-testid="home-accounts-error">
|
|
204
|
-
{error}
|
|
205
|
-
</p>
|
|
206
|
-
) : null}
|
|
207
|
-
{asking ? (
|
|
208
|
-
<div className="home-accts-ask" role="alertdialog" data-testid="home-accounts-confirm">
|
|
209
|
-
<strong>{asking.confirm.title}</strong>
|
|
210
|
-
<span>{asking.confirm.body}</span>
|
|
211
|
-
<span className="home-accts-btns">
|
|
212
|
-
<button
|
|
213
|
-
type="button"
|
|
214
|
-
className="btn btn--sm"
|
|
215
|
-
data-testid="home-accounts-signout-cancel"
|
|
216
|
-
onClick={() => setAsking(null)}
|
|
217
|
-
>
|
|
218
|
-
{asking.confirm.cancel}
|
|
219
|
-
</button>
|
|
220
|
-
<button
|
|
221
|
-
type="button"
|
|
222
|
-
className="btn btn--sm btn--danger"
|
|
223
|
-
data-testid="home-accounts-signout-confirm"
|
|
224
|
-
disabled={busy}
|
|
225
|
-
onClick={signOut}
|
|
226
|
-
>
|
|
227
|
-
{asking.confirm.primary}
|
|
228
|
-
</button>
|
|
229
|
-
</span>
|
|
230
|
-
</div>
|
|
231
|
-
) : null}
|
|
232
|
-
{model.add ? (
|
|
233
|
-
<div className="home-accts-foot">
|
|
234
|
-
<button
|
|
235
|
-
type="button"
|
|
236
|
-
className="home-accts-act"
|
|
237
|
-
data-testid="home-accounts-add-cloud"
|
|
238
|
-
onClick={() => {
|
|
239
|
-
close();
|
|
240
|
-
onAddCloud?.();
|
|
241
|
-
}}
|
|
242
|
-
>
|
|
243
|
-
{model.add.cloud}
|
|
244
|
-
</button>
|
|
245
|
-
<button
|
|
246
|
-
type="button"
|
|
247
|
-
className="home-accts-act"
|
|
248
|
-
data-testid="home-accounts-add-team"
|
|
249
|
-
onClick={() => {
|
|
250
|
-
close();
|
|
251
|
-
onAddTeam?.();
|
|
252
|
-
}}
|
|
253
|
-
>
|
|
254
|
-
{model.add.team}
|
|
255
|
-
</button>
|
|
256
|
-
</div>
|
|
257
|
-
) : null}
|
|
258
|
-
</div>
|
|
259
|
-
) : null}
|
|
260
|
-
</span>
|
|
261
|
-
);
|
|
262
|
-
}
|
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
// client/v2/onboarding/HubSheet.jsx — "Connect to your own hub" (02 ob-adv-sheets, S6.9). The sheet S11.14's
|
|
2
|
-
// Settings › Connections mounts as "Add a team server…" (G0-D/D12), so it is a view: it owns its fields and
|
|
3
|
-
// calls back; what Test connection and Sign in DO is the caller's (Home: `/_home/hub/{test,signin/*,prepare}`).
|
|
4
|
-
//
|
|
5
|
-
// <HubSheet onTest={(url) => {ok, version?, error?}}
|
|
6
|
-
// onSignIn={({url, invite, onWaiting}) => {ok, error?, cancelled?}}
|
|
7
|
-
// onAbortSignIn={() => void} onCancel />
|
|
8
|
-
//
|
|
9
|
-
// Issue #204 (decision maude/v2-michal-team-server-signin-via-hub-page): the app owns NO login method for a
|
|
10
|
-
// team server. There is no email or password field here: Sign in opens the hub's OWN sign-in page in the
|
|
11
|
-
// browser (with an invite, the hub's own invite page), the sheet waits (`onWaiting` → "Finish signing in in
|
|
12
|
-
// your browser.", Cancel = `onAbortSignIn`) and the caller opens the project once the browser came back.
|
|
13
|
-
// The invite key is a bearer secret: a masked field, read once on Sign in and emptied at once; an error
|
|
14
|
-
// line is the server's own words, never an echo.
|
|
15
|
-
|
|
16
|
-
import { useEffect, useRef, useState } from 'react';
|
|
17
|
-
|
|
18
|
-
import { AdvModal, AdvSheet, Sw } from './AdvSheet.jsx';
|
|
19
|
-
import { HUB_WORDS as W } from './onboarding-model.js';
|
|
20
|
-
|
|
21
|
-
/** `https://hub.example/join/inv_…` → `https://hub.example` (the hub's own invite link); else null. */
|
|
22
|
-
export function hubOfInviteLink(raw) {
|
|
23
|
-
try {
|
|
24
|
-
const u = new URL(String(raw ?? '').trim());
|
|
25
|
-
if (u.protocol !== 'https:' && u.protocol !== 'http:') return null;
|
|
26
|
-
const m = /^(.*)\/join\/[^/]+$/.exec(u.pathname);
|
|
27
|
-
return m ? `${u.origin}${m[1]}` : null;
|
|
28
|
-
} catch {
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* @param {{ onTest: (url: string) => Promise<{ok: boolean, version?: string|null, error?: string}>,
|
|
35
|
-
* onSignIn: (v: {url: string, invite: string, onWaiting: () => void}) =>
|
|
36
|
-
* Promise<{ok: boolean, error?: string, cancelled?: boolean}>,
|
|
37
|
-
* onAbortSignIn?: () => void,
|
|
38
|
-
* onCancel: () => void, initialUrl?: string }} props
|
|
39
|
-
*/
|
|
40
|
-
export function HubSheet({ onTest, onSignIn, onAbortSignIn, onCancel, initialUrl = '' }) {
|
|
41
|
-
const [url, setUrl] = useState(initialUrl);
|
|
42
|
-
const [invite, setInvite] = useState('');
|
|
43
|
-
const [test, setTest] = useState({ phase: 'idle', version: null, error: null });
|
|
44
|
-
const [busy, setBusy] = useState(false);
|
|
45
|
-
const [waiting, setWaiting] = useState(false);
|
|
46
|
-
const [error, setError] = useState(null);
|
|
47
|
-
const alive = useRef(true);
|
|
48
|
-
const seq = useRef(0); // an answer for an address that has since changed is dropped
|
|
49
|
-
useEffect(() => {
|
|
50
|
-
alive.current = true;
|
|
51
|
-
return () => {
|
|
52
|
-
alive.current = false;
|
|
53
|
-
};
|
|
54
|
-
}, []);
|
|
55
|
-
|
|
56
|
-
const runTest = async () => {
|
|
57
|
-
const id = ++seq.current;
|
|
58
|
-
setTest({ phase: 'busy', version: null, error: null });
|
|
59
|
-
let r;
|
|
60
|
-
try {
|
|
61
|
-
r = await onTest(url.trim());
|
|
62
|
-
} catch {
|
|
63
|
-
r = { ok: false, error: W.unreachable };
|
|
64
|
-
}
|
|
65
|
-
if (!alive.current || id !== seq.current) return;
|
|
66
|
-
setTest(
|
|
67
|
-
r?.ok
|
|
68
|
-
? { phase: 'ok', version: r.version ?? null, error: null }
|
|
69
|
-
: { phase: 'bad', version: null, error: r?.error || W.unreachable }
|
|
70
|
-
);
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
const signIn = async () => {
|
|
74
|
-
// read once, empty the field now — an invite key never outlives this call in the page
|
|
75
|
-
const key = invite.trim();
|
|
76
|
-
setInvite('');
|
|
77
|
-
setError(null);
|
|
78
|
-
setBusy(true);
|
|
79
|
-
let r;
|
|
80
|
-
try {
|
|
81
|
-
r = await onSignIn({
|
|
82
|
-
url: url.trim(),
|
|
83
|
-
invite: key,
|
|
84
|
-
onWaiting: () => {
|
|
85
|
-
if (alive.current) setWaiting(true);
|
|
86
|
-
},
|
|
87
|
-
});
|
|
88
|
-
} catch {
|
|
89
|
-
r = { ok: false, error: W.unreachable };
|
|
90
|
-
}
|
|
91
|
-
if (!alive.current) return;
|
|
92
|
-
setBusy(false);
|
|
93
|
-
setWaiting(false);
|
|
94
|
-
if (!r?.ok && !r?.cancelled) setError(r?.error || W.unreachable);
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
const abort = () => {
|
|
98
|
-
setWaiting(false);
|
|
99
|
-
onAbortSignIn?.();
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
return (
|
|
103
|
-
<AdvModal onCancel={waiting ? abort : onCancel}>
|
|
104
|
-
<AdvSheet
|
|
105
|
-
id="hub"
|
|
106
|
-
title={W.title}
|
|
107
|
-
verb={W.verb}
|
|
108
|
-
busyVerb={W.busy}
|
|
109
|
-
busy={busy}
|
|
110
|
-
canSubmit={!!url.trim() && !busy}
|
|
111
|
-
onSubmit={signIn}
|
|
112
|
-
onCancel={waiting ? abort : onCancel}
|
|
113
|
-
>
|
|
114
|
-
<span className="ob-field">
|
|
115
|
-
<label className="ob-field-label" htmlFor="onb-hub-url">
|
|
116
|
-
{W.addressLabel}
|
|
117
|
-
</label>
|
|
118
|
-
<span className="ob-row2">
|
|
119
|
-
<input
|
|
120
|
-
id="onb-hub-url"
|
|
121
|
-
className="ob-input ob-mono"
|
|
122
|
-
data-testid="onb-hub-url"
|
|
123
|
-
type="text"
|
|
124
|
-
inputMode="url"
|
|
125
|
-
autoComplete="off"
|
|
126
|
-
spellCheck={false}
|
|
127
|
-
placeholder="https://"
|
|
128
|
-
// biome-ignore lint/a11y/noAutofocus: the sheet opens for this one field
|
|
129
|
-
autoFocus
|
|
130
|
-
disabled={busy}
|
|
131
|
-
value={url}
|
|
132
|
-
onChange={(e) => {
|
|
133
|
-
seq.current += 1;
|
|
134
|
-
setUrl(e.target.value);
|
|
135
|
-
setTest({ phase: 'idle', version: null, error: null });
|
|
136
|
-
}}
|
|
137
|
-
/>
|
|
138
|
-
<button
|
|
139
|
-
type="button"
|
|
140
|
-
className="btn btn--sm"
|
|
141
|
-
data-testid="onb-hub-test"
|
|
142
|
-
disabled={!url.trim() || test.phase === 'busy' || busy}
|
|
143
|
-
onClick={runTest}
|
|
144
|
-
>
|
|
145
|
-
{W.test}
|
|
146
|
-
</button>
|
|
147
|
-
</span>
|
|
148
|
-
{test.phase === 'busy' ? (
|
|
149
|
-
<span className="ob-ok" role="status">
|
|
150
|
-
<Sw state="busy" testid="onb-hub-testing">
|
|
151
|
-
{W.testing}
|
|
152
|
-
</Sw>
|
|
153
|
-
</span>
|
|
154
|
-
) : null}
|
|
155
|
-
{test.phase === 'ok' ? (
|
|
156
|
-
<span className="ob-ok" role="status">
|
|
157
|
-
<Sw state="ok" testid="onb-hub-reachable">
|
|
158
|
-
{W.reachable(test.version)}
|
|
159
|
-
</Sw>
|
|
160
|
-
</span>
|
|
161
|
-
) : null}
|
|
162
|
-
{test.phase === 'bad' ? (
|
|
163
|
-
<span className="ob-err" role="alert" data-testid="onb-hub-test-error">
|
|
164
|
-
{test.error}
|
|
165
|
-
</span>
|
|
166
|
-
) : null}
|
|
167
|
-
</span>
|
|
168
|
-
|
|
169
|
-
<span className="ob-field">
|
|
170
|
-
<label className="ob-field-label" htmlFor="onb-hub-invite">
|
|
171
|
-
{W.inviteLabel}
|
|
172
|
-
</label>
|
|
173
|
-
<input
|
|
174
|
-
id="onb-hub-invite"
|
|
175
|
-
className="ob-input"
|
|
176
|
-
data-testid="onb-hub-invite"
|
|
177
|
-
// a bearer secret: masked, never drawn back
|
|
178
|
-
type="password"
|
|
179
|
-
autoComplete="off"
|
|
180
|
-
spellCheck={false}
|
|
181
|
-
placeholder={W.invitePlaceholder}
|
|
182
|
-
disabled={busy}
|
|
183
|
-
value={invite}
|
|
184
|
-
onChange={(e) => {
|
|
185
|
-
const v = e.target.value;
|
|
186
|
-
setInvite(v);
|
|
187
|
-
// a pasted hub link names its hub: fill an empty address (the address is not secret)
|
|
188
|
-
const at = url.trim() ? null : hubOfInviteLink(v);
|
|
189
|
-
if (at) {
|
|
190
|
-
seq.current += 1;
|
|
191
|
-
setUrl(at);
|
|
192
|
-
setTest({ phase: 'idle', version: null, error: null });
|
|
193
|
-
}
|
|
194
|
-
}}
|
|
195
|
-
/>
|
|
196
|
-
</span>
|
|
197
|
-
|
|
198
|
-
{waiting ? (
|
|
199
|
-
<p className="ob-ok" role="status" data-testid="onb-hub-waiting">
|
|
200
|
-
<Sw state="busy">{W.waiting}</Sw>
|
|
201
|
-
</p>
|
|
202
|
-
) : null}
|
|
203
|
-
{error ? (
|
|
204
|
-
<p className="ai-conn-err" role="alert" data-testid="onb-hub-error">
|
|
205
|
-
{error}
|
|
206
|
-
</p>
|
|
207
|
-
) : null}
|
|
208
|
-
<p className="ob-fine">{W.fine}</p>
|
|
209
|
-
</AdvSheet>
|
|
210
|
-
</AdvModal>
|
|
211
|
-
);
|
|
212
|
-
}
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
// client/v2/shell/account-card-model.js — S1.22a: the account chip beside the faces and its card
|
|
2
|
-
// (canvas 11 · pn-accounts, CONTRACT §6 "Accounts": each project tab is bound to one account).
|
|
3
|
-
//
|
|
4
|
-
// PURE: what the chip and the card SAY. The binding itself is the shell's (V2-3.1 / V2-3.8: a project
|
|
5
|
-
// carries a profile, `/_config.profile` is `{ id, label? }`); this module only words it.
|
|
6
|
-
//
|
|
7
|
-
// Two inputs the page has and one it may have:
|
|
8
|
-
// profile `/_config.profile` — which account THIS tab runs as (always known on the desktop)
|
|
9
|
-
// email `/_api/cloud/status` — the signed-in address of that profile (absent when signed out)
|
|
10
|
-
// accounts OPTIONAL — every account on this Mac, `[{ id, label, email, projects }]`: `projects` is
|
|
11
|
-
// the project names for the caller's own account and a count (a number) for every other
|
|
12
|
-
// one (S1.22b `accounts_list`, option B). A project page cannot read the shell's profile registry (the page
|
|
13
|
-
// capability deliberately omits it), so this arrives only from a shell command that returns
|
|
14
|
-
// it for the caller (patch request S1.22a-1). Without it the card still says everything that
|
|
15
|
-
// is known and leaves out the lines that would need it — never an invented list.
|
|
16
|
-
//
|
|
17
|
-
// The canvas draws the chip "only when this Mac has two or more accounts". A tab on a profile other than
|
|
18
|
-
// `default` proves a second account exists (the default profile always does); a tab on `default` needs the
|
|
19
|
-
// list to say so.
|
|
20
|
-
|
|
21
|
-
import { ACTIONS_BY_ID } from '../../../actions/index.ts';
|
|
22
|
-
import { accountTone } from '../../shell/account-tone.js';
|
|
23
|
-
|
|
24
|
-
const DEFAULT_ID = 'default';
|
|
25
|
-
|
|
26
|
-
const labelOf = (p) => String(p?.label || p?.id || '').trim();
|
|
27
|
-
const initialOf = (label) => (label ? Array.from(label)[0].toUpperCase() : '·');
|
|
28
|
-
const plural = (n, one, many) => `${n} ${n === 1 ? one : many}`;
|
|
29
|
-
|
|
30
|
-
/** "A" · "A and B" · "A, B and C" · "A, B and 4 more" — the canvas's project lists. */
|
|
31
|
-
export function projectsPhrase(names) {
|
|
32
|
-
const list = (names ?? []).filter((n) => typeof n === 'string' && n.trim());
|
|
33
|
-
if (list.length === 0) return '';
|
|
34
|
-
if (list.length === 1) return list[0];
|
|
35
|
-
if (list.length <= 3) return `${list.slice(0, -1).join(', ')} and ${list[list.length - 1]}`;
|
|
36
|
-
return `${list[0]}, ${list[1]} and ${list.length - 2} more`;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/** The account's tone: the one function every surface asks (shell/account-tone.js) — Work sky,
|
|
40
|
-
* Personal yellow, anything else a stable object-palette tone. */
|
|
41
|
-
const toneOf = (id, label) => accountTone(id, label);
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* The chip in the Share cluster, or null when there is nothing to show.
|
|
45
|
-
* @param native the desktop app (a browser tab / cloud tab has no Mac accounts)
|
|
46
|
-
* @param connected this profile holds a cloud sign-in (an account is what a sign-in IS)
|
|
47
|
-
* @param cloud a cloud tab (its account is the hub's, not the Mac's)
|
|
48
|
-
*/
|
|
49
|
-
export function accountChip({ native, connected, cloud = false, profile, email, accounts = null }) {
|
|
50
|
-
if (!native || cloud || !connected) return null;
|
|
51
|
-
const id = profile?.id || DEFAULT_ID;
|
|
52
|
-
const twoOrMore = Array.isArray(accounts) ? accounts.length >= 2 : id !== DEFAULT_ID;
|
|
53
|
-
if (!twoOrMore) return null;
|
|
54
|
-
const label = labelOf(profile) || id;
|
|
55
|
-
return {
|
|
56
|
-
id,
|
|
57
|
-
label,
|
|
58
|
-
initial: initialOf(label),
|
|
59
|
-
tone: toneOf(id, label),
|
|
60
|
-
title: email ? `${label} · ${email}` : label,
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/** Everything the open card says. */
|
|
65
|
-
export function accountCard({ project, profile, email, accounts = null }) {
|
|
66
|
-
const id = profile?.id || DEFAULT_ID;
|
|
67
|
-
const label = labelOf(profile) || id;
|
|
68
|
-
const list = Array.isArray(accounts) ? accounts : null;
|
|
69
|
-
const mine = list?.find((a) => a?.id === id) ?? null;
|
|
70
|
-
const here = (Array.isArray(mine?.projects) ? mine.projects : []).filter(
|
|
71
|
-
(n) => typeof n === 'string'
|
|
72
|
-
);
|
|
73
|
-
const who = email || label;
|
|
74
|
-
const effect = 'Signs out every project on it';
|
|
75
|
-
const named = projectsPhrase(here);
|
|
76
|
-
return {
|
|
77
|
-
current: {
|
|
78
|
-
initial: initialOf(label),
|
|
79
|
-
tone: toneOf(id, label),
|
|
80
|
-
title: email ? `${label} · ${email}` : label,
|
|
81
|
-
sub: project ? `${project} uses this account` : 'This project uses this account',
|
|
82
|
-
},
|
|
83
|
-
others: (list ?? [])
|
|
84
|
-
.filter((a) => a && a.id !== id)
|
|
85
|
-
.map((a) => {
|
|
86
|
-
const l = labelOf(a) || a.id;
|
|
87
|
-
return {
|
|
88
|
-
id: a.id,
|
|
89
|
-
initial: initialOf(l),
|
|
90
|
-
tone: toneOf(a.id, l),
|
|
91
|
-
title: a.email ? `${l} · ${a.email}` : l,
|
|
92
|
-
// S1.22b `accounts_list` (option B): another account carries a COUNT, not names.
|
|
93
|
-
sub: Array.isArray(a.projects)
|
|
94
|
-
? projectsPhrase(a.projects) || plural(a.projects.length, 'project', 'projects')
|
|
95
|
-
: plural(Number(a.projects) || 0, 'project', 'projects'),
|
|
96
|
-
};
|
|
97
|
-
}),
|
|
98
|
-
// The registry's own label — one label on every surface (CONTRACT §3).
|
|
99
|
-
switchLabel: ACTIONS_BY_ID.get('account.switch')?.label ?? 'Sign in as another account…',
|
|
100
|
-
signOut: {
|
|
101
|
-
label: `Sign out of ${who}…`,
|
|
102
|
-
sub: named ? `${effect}: ${named}.` : `${effect}.`,
|
|
103
|
-
confirm: {
|
|
104
|
-
title: `Sign out of ${who}?`,
|
|
105
|
-
body: 'Every project on it is signed out. Your work stays on this Mac.',
|
|
106
|
-
primary: 'Sign out',
|
|
107
|
-
cancel: 'Cancel',
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
foot: project
|
|
111
|
-
? `Kept on this Mac — ${project} opens as ${label} next time.`
|
|
112
|
-
: `Kept on this Mac — this project opens as ${label} next time.`,
|
|
113
|
-
};
|
|
114
|
-
}
|