@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
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
// client/v2/settings/this-project-model.js — 2.1.1 T6: Settings › General › This project (canvas 17 · 08 · 09).
|
|
2
|
+
//
|
|
3
|
+
// PURE (no DOM, no React, no fetch). The card says three things about THIS project — where it lives, which
|
|
4
|
+
// account it uses, whether it connects — and carries the one fix in its header when a sign-in broke:
|
|
5
|
+
//
|
|
6
|
+
// This project Brand site
|
|
7
|
+
// Your folder · ~/git/brand-site · also on Maude Cloud
|
|
8
|
+
// ● Connected · synced 2 min ago
|
|
9
|
+
// Lives in [Your folder ~/git/brand-site] Change…
|
|
10
|
+
// Account alice@example.com Switch…
|
|
11
|
+
// Connection ● Connected · synced 2 min ago
|
|
12
|
+
// › Sync details Project files · trash · first link
|
|
13
|
+
//
|
|
14
|
+
// The connection is the shell's one model (shell/connection-state.js, 2.1.1 T2): the same seven states and
|
|
15
|
+
// words the avatar, the save word and the toast say. Where it lives is `/_api/cloud/status` `place`
|
|
16
|
+
// (`{ kept: true }` for a copy Maude keeps, else `{ kept: false, folder }` with home as `~`).
|
|
17
|
+
|
|
18
|
+
import { syncPresentation } from '../../../sync/presentation.ts';
|
|
19
|
+
import { connectionState, connectionWords } from '../shell/connection-state.js';
|
|
20
|
+
|
|
21
|
+
/** The status dot per state (canvas 17 `StatusWord`: ok · busy · off · error · warn). */
|
|
22
|
+
const DOT = Object.freeze({
|
|
23
|
+
connected: 'ok',
|
|
24
|
+
syncing: 'busy',
|
|
25
|
+
offline: 'off',
|
|
26
|
+
'signin-missing': 'error',
|
|
27
|
+
'signin-rejected': 'error',
|
|
28
|
+
unreachable: 'warn',
|
|
29
|
+
unconfirmed: 'off',
|
|
30
|
+
local: 'off',
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const str = (v) => (typeof v === 'string' && v.trim() ? v.trim() : null);
|
|
34
|
+
|
|
35
|
+
/** "synced just now" · "synced 2 min ago" · "synced at 14:05" · null. */
|
|
36
|
+
export function syncedWords(ms, now = Date.now()) {
|
|
37
|
+
if (!Number.isFinite(ms) || ms <= 0) return null;
|
|
38
|
+
const age = Math.max(0, now - ms);
|
|
39
|
+
if (age < 60_000) return 'synced just now';
|
|
40
|
+
if (age < 60 * 60_000) return `synced ${Math.floor(age / 60_000)} min ago`;
|
|
41
|
+
const d = new Date(ms);
|
|
42
|
+
return `synced at ${d.getHours()}:${String(d.getMinutes()).padStart(2, '0')}`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** The card's status line for a connection (the header line and the Connection row say the same). */
|
|
46
|
+
export function statusLine(conn, { syncStatus = null, pending = 0, now = Date.now() } = {}) {
|
|
47
|
+
const w = connectionWords(conn, { pending });
|
|
48
|
+
switch (conn.state) {
|
|
49
|
+
case 'connected': {
|
|
50
|
+
const synced = syncedWords(syncStatus?.lastSyncAt, now);
|
|
51
|
+
return synced ? `Connected · ${synced}` : 'Connected';
|
|
52
|
+
}
|
|
53
|
+
case 'syncing':
|
|
54
|
+
return w.line;
|
|
55
|
+
default:
|
|
56
|
+
return w.word;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The whole card.
|
|
62
|
+
* @param in.status `/_api/cloud/status` json (`connected`, `email`, `url`, `project`, `linkedHub`, `place`)
|
|
63
|
+
* @param in.syncStatus the shell's sync payload
|
|
64
|
+
* @param in.hubAccount the team-server sign-in's recorded account (`/_api/connections/hub` `account`)
|
|
65
|
+
* @param in.native the desktop app (Show in Finder is the Mac app's door)
|
|
66
|
+
*/
|
|
67
|
+
export function thisProjectModel({
|
|
68
|
+
status = null,
|
|
69
|
+
syncStatus = null,
|
|
70
|
+
hubAccount = null,
|
|
71
|
+
online = true,
|
|
72
|
+
native = false,
|
|
73
|
+
now = Date.now(),
|
|
74
|
+
} = {}) {
|
|
75
|
+
const linkedHub = status?.linkedHub?.url ? status.linkedHub : null;
|
|
76
|
+
const pending = Number(syncStatus?.queuedOps) || Number(syncStatus?.docs?.pending) || 0;
|
|
77
|
+
const conn = connectionState({
|
|
78
|
+
linkedHub,
|
|
79
|
+
cloudUrl: status?.url ?? '',
|
|
80
|
+
syncStatus,
|
|
81
|
+
phase: syncPresentation(syncStatus ?? null)?.phase ?? null,
|
|
82
|
+
pending,
|
|
83
|
+
online,
|
|
84
|
+
});
|
|
85
|
+
const words = connectionWords(conn, { pending });
|
|
86
|
+
const host = conn.host ?? '';
|
|
87
|
+
const linkKind = conn.kind === 'local' ? null : conn.kind;
|
|
88
|
+
const kept = status?.place?.kept === true;
|
|
89
|
+
const folder = !kept ? (str(status?.place?.folder) ?? '') : '';
|
|
90
|
+
|
|
91
|
+
// Lives in: the person's folder, or a copy Maude keeps — of a server project it reads "On <host>".
|
|
92
|
+
let place;
|
|
93
|
+
if (kept && linkKind === 'server') place = { kind: 'server', label: `On ${host}`, path: '' };
|
|
94
|
+
else if (kept) place = { kind: 'kept', label: 'Kept by Maude', path: '' };
|
|
95
|
+
else place = { kind: 'folder', label: 'Your folder', path: folder };
|
|
96
|
+
|
|
97
|
+
const where = place.kind === 'folder' && folder ? `Your folder · ${folder}` : place.label;
|
|
98
|
+
let desc;
|
|
99
|
+
if (place.kind === 'server') desc = `${where} · copy kept by Maude`;
|
|
100
|
+
else if (linkKind === 'cloud') desc = `${where} · also on Maude Cloud`;
|
|
101
|
+
else if (linkKind === 'server') desc = `${where} · also on ${host}`;
|
|
102
|
+
else desc = `${where} · only on this Mac`;
|
|
103
|
+
|
|
104
|
+
// Account: who this project talks as — never a token, only the name the page already holds.
|
|
105
|
+
let account;
|
|
106
|
+
if (linkKind === 'cloud')
|
|
107
|
+
account = { kind: 'cloud', label: str(status?.email) ?? 'Maude Cloud', host };
|
|
108
|
+
else if (linkKind === 'server')
|
|
109
|
+
account = { kind: 'server', label: str(hubAccount) ?? host, host };
|
|
110
|
+
else account = { kind: 'local', label: 'No account', host: '' };
|
|
111
|
+
|
|
112
|
+
const bad = conn.state === 'signin-missing' || conn.state === 'signin-rejected';
|
|
113
|
+
const where2 = linkKind === 'cloud' ? 'Maude Cloud' : host || 'the server';
|
|
114
|
+
const callout =
|
|
115
|
+
conn.state === 'signin-rejected'
|
|
116
|
+
? {
|
|
117
|
+
title: `Your sign-in to ${where2} stopped working.`,
|
|
118
|
+
line: 'Changes wait on this Mac and go out after you sign in.',
|
|
119
|
+
}
|
|
120
|
+
: conn.state === 'signin-missing'
|
|
121
|
+
? {
|
|
122
|
+
title: `This project is on ${where2} — sign in to sync.`,
|
|
123
|
+
line: 'Changes wait on this Mac and go out after you sign in.',
|
|
124
|
+
}
|
|
125
|
+
: null;
|
|
126
|
+
|
|
127
|
+
// Change…: only what this Mac can do today. Moving a project between the person's folder and a copy
|
|
128
|
+
// Maude keeps has no backend yet, so those rows are listed as unavailable and never drawn.
|
|
129
|
+
const changeOptions = [
|
|
130
|
+
{
|
|
131
|
+
id: 'folder',
|
|
132
|
+
label: 'Your folder',
|
|
133
|
+
detail: place.kind === 'folder' ? folder : '',
|
|
134
|
+
current: place.kind === 'folder',
|
|
135
|
+
available: place.kind === 'folder',
|
|
136
|
+
},
|
|
137
|
+
{ id: 'another-folder', label: 'Use another folder…', current: false, available: false },
|
|
138
|
+
{
|
|
139
|
+
id: 'kept',
|
|
140
|
+
label: 'Let Maude keep it',
|
|
141
|
+
detail: 'no path',
|
|
142
|
+
current: place.kind !== 'folder',
|
|
143
|
+
available: place.kind !== 'folder',
|
|
144
|
+
},
|
|
145
|
+
{ id: 'finder', label: 'Show in Finder', current: false, available: !!native },
|
|
146
|
+
];
|
|
147
|
+
|
|
148
|
+
return {
|
|
149
|
+
name: str(status?.project) ?? 'this project',
|
|
150
|
+
conn,
|
|
151
|
+
statusWord: statusLine(conn, { syncStatus, pending, now }),
|
|
152
|
+
sw: DOT[conn.state] ?? 'off',
|
|
153
|
+
bad,
|
|
154
|
+
fixLabel: bad ? (words.fix?.label ?? 'Sign in') : null,
|
|
155
|
+
callout,
|
|
156
|
+
place,
|
|
157
|
+
desc,
|
|
158
|
+
account,
|
|
159
|
+
linkKind,
|
|
160
|
+
// an address this Mac never confirmed is never handed to a sign-in (2.1.1 T8): Review… instead
|
|
161
|
+
unconfirmed:
|
|
162
|
+
conn.state === 'unconfirmed'
|
|
163
|
+
? { line: words.line, label: words.fix?.label ?? 'Review…' }
|
|
164
|
+
: null,
|
|
165
|
+
hubUrl: conn.state === 'unconfirmed' ? null : (linkedHub?.url ?? null),
|
|
166
|
+
host,
|
|
167
|
+
local: conn.state === 'local',
|
|
168
|
+
changeOptions,
|
|
169
|
+
// the menu is drawn only when it has something to do beyond saying where the project is
|
|
170
|
+
canChange: changeOptions.some((o) => o.available && !o.current),
|
|
171
|
+
};
|
|
172
|
+
}
|
|
@@ -50,7 +50,8 @@ export function useCloudConnection({ onLinkedHub, onLocalProject, syncStatus } =
|
|
|
50
50
|
const [email, setEmail] = useState(null);
|
|
51
51
|
// The address this Mac signs in against (`status.url`) — never a hard-coded vendor URL.
|
|
52
52
|
const [cloudUrl, setCloudUrl] = useState('');
|
|
53
|
-
|
|
53
|
+
// `place` (2.1.1 T2): `{ kept: true }` or `{ kept: false, folder }` — where this project lives
|
|
54
|
+
const [local, setLocal] = useState({ project: '', linkedHub: null, place: null });
|
|
54
55
|
const [projects, setProjects] = useState(null);
|
|
55
56
|
const [busy, setBusy] = useState('');
|
|
56
57
|
const [error, setError] = useState('');
|
|
@@ -76,7 +77,7 @@ export function useCloudConnection({ onLinkedHub, onLocalProject, syncStatus } =
|
|
|
76
77
|
const r = await api('/_api/cloud/status');
|
|
77
78
|
if (r.json?.url) setCloudUrl(r.json.url);
|
|
78
79
|
const linkedHub = r.json?.linkedHub ?? null;
|
|
79
|
-
setLocal({ project: r.json?.project ?? '', linkedHub });
|
|
80
|
+
setLocal({ project: r.json?.project ?? '', linkedHub, place: r.json?.place ?? null });
|
|
80
81
|
liftRef.current.onLinkedHub?.(linkedHub);
|
|
81
82
|
liftRef.current.onLocalProject?.(r.json?.project ?? null);
|
|
82
83
|
if (r.ok && r.json?.connected) {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// client/v2/settings/use-open-card.js — 2.1.1 T6: which card of a Settings tab is open (one at a time),
|
|
2
|
+
// remembered per tab for this session (settings-cards.js). `focus` is ⌘K's ask — `{ card, n }`, a new `n`
|
|
3
|
+
// each time — and opens the card that holds the hit even when the person had closed it.
|
|
4
|
+
|
|
5
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
6
|
+
|
|
7
|
+
import { openCardOf, readOpenCards, toggleCard, writeOpenCard } from './settings-cards.js';
|
|
8
|
+
|
|
9
|
+
export function useOpenCard(tab, focus = null) {
|
|
10
|
+
const [open, setOpen] = useState(() => focus?.card ?? openCardOf(tab, readOpenCards()));
|
|
11
|
+
const focusCard = focus?.card ?? null;
|
|
12
|
+
const focusN = focus?.n ?? 0;
|
|
13
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: a new ask (`n`) re-opens the same card
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (!focusCard) return;
|
|
16
|
+
setOpen(focusCard);
|
|
17
|
+
writeOpenCard(tab, focusCard);
|
|
18
|
+
}, [tab, focusCard, focusN]);
|
|
19
|
+
const toggle = useCallback(
|
|
20
|
+
(id) =>
|
|
21
|
+
setOpen((cur) => {
|
|
22
|
+
const next = toggleCard(cur, id);
|
|
23
|
+
writeOpenCard(tab, next);
|
|
24
|
+
return next;
|
|
25
|
+
}),
|
|
26
|
+
[tab]
|
|
27
|
+
);
|
|
28
|
+
/** Open `id` (a header action that needs its card's body, e.g. Manage…). */
|
|
29
|
+
const show = useCallback(
|
|
30
|
+
(id) => {
|
|
31
|
+
setOpen(id);
|
|
32
|
+
writeOpenCard(tab, id);
|
|
33
|
+
},
|
|
34
|
+
[tab]
|
|
35
|
+
);
|
|
36
|
+
return { open, toggle, show };
|
|
37
|
+
}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
// client/v2/shell/connection-state.js — 2.1.1 T2: is THIS project's connection working, and whose move
|
|
2
|
+
// is it? (canvas 17 · ac-states). PURE: one place derives the state the account chip's badge, the save
|
|
3
|
+
// word, the avatar menu's project block and the once-per-session toast all say.
|
|
4
|
+
//
|
|
5
|
+
// Eight states, from what the page already holds:
|
|
6
|
+
// local no `linkedHub` in this folder: nothing leaves this Mac (a plain laptop, never a badge)
|
|
7
|
+
// unconfirmed the folder NAMES a server this Mac never linked or confirmed (`/_api/cloud/status`
|
|
8
|
+
// `linkedHub.confirmed === false`, from this Mac's link record — gate-b-sec4 parked it).
|
|
9
|
+
// A committed address is a peer's text: no toast, no badge, no prefilled sign-in — only
|
|
10
|
+
// a neutral line and Review…, which opens the Share sheet's Connect (the consent step).
|
|
11
|
+
// signin-missing a server this Mac linked (`confirmed`) and holds no sign-in for
|
|
12
|
+
// (`linkedHub.credentialed === false`)
|
|
13
|
+
// signin-rejected the server refuses the sign-in this Mac holds: the accepted lane's
|
|
14
|
+
// `accepted.credentialRefused` (sync/status.ts), or every document refused with
|
|
15
|
+
// `invalid-token` (DDR-102's own classification, sync/index.ts `AuthFailureClass`)
|
|
16
|
+
// offline this Mac has no network (`navigator.onLine === false`) — the face greys, nothing to do
|
|
17
|
+
// unreachable the network is up but the server does not answer (the hub monitor's offline /
|
|
18
|
+
// offline-long, or syncPresentation's offline / stalled)
|
|
19
|
+
// syncing a pass is running or changes are going out
|
|
20
|
+
// connected everything else on a linked folder
|
|
21
|
+
//
|
|
22
|
+
// The badge says whose move it is (canvas 17 note 2): `broken` only for a sign-in the person can repair
|
|
23
|
+
// in one click, `warn` for the server's side, `grey` for the network, a turning `ring` while syncing.
|
|
24
|
+
|
|
25
|
+
import { isCloudHub } from '../settings/connections-model.js';
|
|
26
|
+
|
|
27
|
+
export const CONNECTION_STATES = Object.freeze([
|
|
28
|
+
'connected',
|
|
29
|
+
'syncing',
|
|
30
|
+
'offline',
|
|
31
|
+
'signin-missing',
|
|
32
|
+
'signin-rejected',
|
|
33
|
+
'unreachable',
|
|
34
|
+
'unconfirmed',
|
|
35
|
+
'local',
|
|
36
|
+
]);
|
|
37
|
+
|
|
38
|
+
const UNREACHABLE_PHASES = new Set(['offline', 'stalled']);
|
|
39
|
+
const SYNCING_PHASES = new Set(['connecting', 'syncing']);
|
|
40
|
+
|
|
41
|
+
/** host, plus the port when it is not the scheme's default — how every surface names a server */
|
|
42
|
+
export function hostOf(url) {
|
|
43
|
+
try {
|
|
44
|
+
return new URL(String(url)).host.toLowerCase();
|
|
45
|
+
} catch {
|
|
46
|
+
return '';
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const str = (v) => (typeof v === 'string' && v.trim() ? v.trim() : null);
|
|
51
|
+
const count = (n) => (Number.isFinite(n) && n > 0 ? n : 0);
|
|
52
|
+
|
|
53
|
+
/** The sign-in this Mac holds is refused (only a literal `true`, never a guess). */
|
|
54
|
+
export function signInRefused(syncStatus) {
|
|
55
|
+
const s = syncStatus && typeof syncStatus === 'object' ? syncStatus : null;
|
|
56
|
+
if (!s) return false;
|
|
57
|
+
if (s.accepted && typeof s.accepted === 'object' && s.accepted.credentialRefused === true)
|
|
58
|
+
return true;
|
|
59
|
+
// Every document refused, and refused for an invalid token: the sign-in itself stopped working.
|
|
60
|
+
const docs = s.docs && typeof s.docs === 'object' ? s.docs : null;
|
|
61
|
+
const items = Array.isArray(s.items) ? s.items : [];
|
|
62
|
+
if (!docs || count(docs.rejected) === 0 || count(docs.synced) > 0) return false;
|
|
63
|
+
return items.some((i) => i?.state === 'auth-rejected' && i?.reason === 'invalid-token');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @param in.linkedHub `/_api/cloud/status` `linkedHub` — `{ url, credentialed, confirmed }` or null
|
|
68
|
+
* @param in.cloudUrl the Maude Cloud address this Mac signs in against (tells cloud from your server)
|
|
69
|
+
* @param in.syncStatus the shell's raw sync status (the hub monitor + the accepted lane)
|
|
70
|
+
* @param in.phase syncPresentation(syncStatus).phase, or null
|
|
71
|
+
* @param in.pending changes still going out (queued ops + the outbox)
|
|
72
|
+
* @param in.online false only when the browser says there is no network
|
|
73
|
+
* @returns {{ state, kind: 'cloud'|'server'|'local', host: string|null, url: string|null,
|
|
74
|
+
* (an unconfirmed claim is kind 'local' — nothing leaves this Mac — with the named host)
|
|
75
|
+
* badge: 'broken'|'warn'|'grey'|'ring'|null }}
|
|
76
|
+
*/
|
|
77
|
+
export function connectionState(input = {}) {
|
|
78
|
+
const {
|
|
79
|
+
linkedHub = null,
|
|
80
|
+
cloudUrl = '',
|
|
81
|
+
syncStatus = null,
|
|
82
|
+
phase = null,
|
|
83
|
+
pending = 0,
|
|
84
|
+
online = true,
|
|
85
|
+
} = input ?? {};
|
|
86
|
+
const url = str(linkedHub?.url);
|
|
87
|
+
if (!url) return { state: 'local', kind: 'local', host: null, url: null, badge: null };
|
|
88
|
+
// An address this Mac never confirmed: what the repo says, worded as such — never as a repair.
|
|
89
|
+
if (linkedHub?.confirmed === false)
|
|
90
|
+
return { state: 'unconfirmed', kind: 'local', host: hostOf(url) || null, url, badge: null };
|
|
91
|
+
const kind = isCloudHub(url, cloudUrl) ? 'cloud' : 'server';
|
|
92
|
+
const host = hostOf(url) || url;
|
|
93
|
+
const out = (state, badge) => ({ state, kind, host, url, badge });
|
|
94
|
+
if (linkedHub?.credentialed !== true) return out('signin-missing', 'broken');
|
|
95
|
+
if (signInRefused(syncStatus)) return out('signin-rejected', 'broken');
|
|
96
|
+
if (online === false) return out('offline', 'grey');
|
|
97
|
+
const hub = syncStatus?.state;
|
|
98
|
+
if (hub === 'offline' || hub === 'offline-long' || UNREACHABLE_PHASES.has(phase))
|
|
99
|
+
return out('unreachable', 'warn');
|
|
100
|
+
if (SYNCING_PHASES.has(phase) || count(pending) > 0) return out('syncing', 'ring');
|
|
101
|
+
return out('connected', null);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Where the sign-in lives, in the menu's words: "Maude Cloud" or the server's host. */
|
|
105
|
+
const placeName = (c) => (c.kind === 'cloud' ? 'Maude Cloud' : c.host || 'the server');
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The words each state says (canvas 17 · ac-states, CONTRACT voice): the save word beside the chip, the
|
|
109
|
+
* status line of the avatar menu, and the one-click fix.
|
|
110
|
+
* @param c connectionState()
|
|
111
|
+
* @param in.pending changes going out ("Syncing · 3 changes going out")
|
|
112
|
+
* @returns {{ word, icon, tone, line, fix: null | { id: 'sign-in'|'retry'|'move-to-cloud', label } }}
|
|
113
|
+
*/
|
|
114
|
+
export function connectionWords(c, { pending = 0 } = {}) {
|
|
115
|
+
const where = placeName(c ?? {});
|
|
116
|
+
const n = count(pending);
|
|
117
|
+
switch (c?.state) {
|
|
118
|
+
case 'signin-missing':
|
|
119
|
+
return {
|
|
120
|
+
word: 'Sign in to sync',
|
|
121
|
+
icon: 'lock',
|
|
122
|
+
tone: 'error',
|
|
123
|
+
line: `This project is on ${where} — sign in to sync.`,
|
|
124
|
+
fix: { id: 'sign-in', label: 'Sign in' },
|
|
125
|
+
};
|
|
126
|
+
case 'signin-rejected':
|
|
127
|
+
return {
|
|
128
|
+
word: 'Sign-in stopped working',
|
|
129
|
+
icon: 'lock',
|
|
130
|
+
tone: 'error',
|
|
131
|
+
line: `Your sign-in to ${where} stopped working. Changes wait on this Mac.`,
|
|
132
|
+
fix: { id: 'sign-in', label: 'Sign in again' },
|
|
133
|
+
};
|
|
134
|
+
case 'unreachable':
|
|
135
|
+
return {
|
|
136
|
+
word: `Can’t reach ${where}`,
|
|
137
|
+
icon: 'problem',
|
|
138
|
+
tone: 'warn',
|
|
139
|
+
line: `${where} doesn’t answer. Changes wait on this Mac.`,
|
|
140
|
+
fix: { id: 'retry', label: `Retry ${where}` },
|
|
141
|
+
};
|
|
142
|
+
case 'offline':
|
|
143
|
+
return {
|
|
144
|
+
word: 'Offline — changes wait on this Mac',
|
|
145
|
+
icon: 'offline',
|
|
146
|
+
tone: 'warn',
|
|
147
|
+
line: 'Offline — changes wait on this Mac. They go out when it’s back online.',
|
|
148
|
+
fix: null,
|
|
149
|
+
};
|
|
150
|
+
case 'syncing':
|
|
151
|
+
return {
|
|
152
|
+
word: 'Syncing…',
|
|
153
|
+
icon: 'sync',
|
|
154
|
+
tone: '',
|
|
155
|
+
line: n > 0 ? `Syncing · ${n} change${n === 1 ? '' : 's'} going out` : 'Syncing',
|
|
156
|
+
fix: null,
|
|
157
|
+
};
|
|
158
|
+
case 'connected':
|
|
159
|
+
return { word: 'Saved', icon: 'cloud', tone: '', line: 'Connected', fix: null };
|
|
160
|
+
case 'unconfirmed':
|
|
161
|
+
return {
|
|
162
|
+
word: 'Not linked on this Mac',
|
|
163
|
+
icon: 'laptop',
|
|
164
|
+
tone: '',
|
|
165
|
+
line: `This project names ${c.host || 'a server'}. Not linked on this Mac.`,
|
|
166
|
+
fix: { id: 'review-link', label: 'Review…' },
|
|
167
|
+
};
|
|
168
|
+
default:
|
|
169
|
+
return {
|
|
170
|
+
word: 'Only on this Mac',
|
|
171
|
+
icon: 'laptop',
|
|
172
|
+
tone: '',
|
|
173
|
+
line: 'Nothing leaves this Mac.',
|
|
174
|
+
fix: { id: 'move-to-cloud', label: 'Put on Maude Cloud…' },
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** True for the two states the person repairs with one sign-in (the broken-link badge, the toast). */
|
|
180
|
+
export const isBrokenSignIn = (c) =>
|
|
181
|
+
c?.state === 'signin-missing' || c?.state === 'signin-rejected';
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* The once-per-session toast for a broken sign-in (canvas 17 · ac-toast), or null. Keyed by project and
|
|
185
|
+
* state, so a missing sign-in fixed and later rejected is told again — but never twice for the same.
|
|
186
|
+
*/
|
|
187
|
+
export function signInToast(c, { project = '' } = {}) {
|
|
188
|
+
if (!isBrokenSignIn(c)) return null;
|
|
189
|
+
const w = connectionWords(c);
|
|
190
|
+
return {
|
|
191
|
+
key: `${project || '-'}|${c.url || ''}|${c.state}`,
|
|
192
|
+
id: `signin-${c.state}`,
|
|
193
|
+
title: w.line,
|
|
194
|
+
kind: 'warning',
|
|
195
|
+
actionLabel: w.fix.label,
|
|
196
|
+
};
|
|
197
|
+
}
|
|
@@ -27,6 +27,7 @@ import { createAccessHandlers } from '../access/access-client.js';
|
|
|
27
27
|
import { createDiagnosticsHandlers } from '../diagnostics/diagnostics-handlers.js';
|
|
28
28
|
import { runFillAsk } from '../empty/fill-ask.js';
|
|
29
29
|
import { runAssetsAction } from '../assets/assets-bus.js';
|
|
30
|
+
import { runLinkServer } from './project-account-bus.js';
|
|
30
31
|
import { runTakeStepNow } from '../assets/use-takes-lane.js';
|
|
31
32
|
import { runCopyPng } from '../export/copy-png.js';
|
|
32
33
|
import { foldStore } from '../fold/use-fold.js';
|
|
@@ -280,6 +281,9 @@ export function createMenuHandlers(d) {
|
|
|
280
281
|
'handoff.open': () => d.setExportDialog({ mode: 'handoff' }),
|
|
281
282
|
'canvas.close': () => d.onCloseCanvas(),
|
|
282
283
|
'account.switch': () => d.onSwitchAccount(),
|
|
284
|
+
// 2.1.1 T4 — the Switch account list's foot (account-menu.js)
|
|
285
|
+
'account.add-cloud': () => d.onAddCloudAccount?.(),
|
|
286
|
+
'account.link-server': (params) => runLinkServer(params, d),
|
|
283
287
|
// 2.0.5 W4 — the GitHub device flow is the mounted host's (github-signin-host.jsx: its code sheet
|
|
284
288
|
// and state); it hears this the way IdentityBar hears project.new. A browser tab has no keychain.
|
|
285
289
|
'account.github-signin': () => {
|
|
@@ -591,9 +595,10 @@ export function createMenuHandlers(d) {
|
|
|
591
595
|
requestShareFocus('link');
|
|
592
596
|
d.onShare();
|
|
593
597
|
},
|
|
594
|
-
|
|
598
|
+
// 2.1.1 T7 — about the project, not a canvas: the project's sheet when no canvas is open
|
|
599
|
+
'share.move-to-cloud': () => d.onShare({ project: true }),
|
|
595
600
|
// gate-b-sec4 — Connect lives in the Share sheet
|
|
596
|
-
'sync.connect-link': () => d.onShare(),
|
|
601
|
+
'sync.connect-link': () => d.onShare({ project: true }),
|
|
597
602
|
// S9.21 — Ask to edit (the Viewing button, ⌘K) and the owner's answer (the request block's buttons)
|
|
598
603
|
...createAccessHandlers(d),
|
|
599
604
|
// `{ tab }` lands on that section ("Connect a Google key?" → connections); the sheet resolves a name it lacks
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// Pure and DOM-free on purpose (the hook in use-occluded-insets.js owns the observers): `measure`,
|
|
12
12
|
// `send` and `schedule` are injected, so the pump is exercised headlessly.
|
|
13
13
|
|
|
14
|
-
import { insetsFromIslands, ZERO_INSETS } from '../../../bridge/occlusion.ts';
|
|
14
|
+
import { insetsFromIslands, topBandFromIslands, ZERO_INSETS } from '../../../bridge/occlusion.ts';
|
|
15
15
|
|
|
16
16
|
const EDGES = new Set(['top', 'right', 'bottom', 'left']);
|
|
17
17
|
|
|
@@ -44,9 +44,23 @@ const boxOf = (el) => {
|
|
|
44
44
|
* @param opts.presenting Present mode hides all chrome and the canvas uses 0 there — send zeros
|
|
45
45
|
*/
|
|
46
46
|
export function measureShellInsets(frameEl, root, { presenting = false } = {}) {
|
|
47
|
-
|
|
47
|
+
const m = frameAndIslands(frameEl, root, presenting);
|
|
48
|
+
return m ? insetsFromIslands(m.frame, m.islands) : { ...ZERO_INSETS };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* #217 — the free top band between the top islands (project pill on the left, the Share cluster on the right),
|
|
53
|
+
* in frame px; the canvas centres its top-centre pill there. Null in Present, with no frame, or with no room.
|
|
54
|
+
*/
|
|
55
|
+
export function measureShellTopBand(frameEl, root, { presenting = false } = {}) {
|
|
56
|
+
const m = frameAndIslands(frameEl, root, presenting);
|
|
57
|
+
return m ? topBandFromIslands(m.frame, m.islands) : null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function frameAndIslands(frameEl, root, presenting) {
|
|
61
|
+
if (presenting || !frameEl || !root) return null;
|
|
48
62
|
const frame = boxOf(frameEl);
|
|
49
|
-
if (!frame || !(frame.right > frame.left && frame.bottom > frame.top)) return
|
|
63
|
+
if (!frame || !(frame.right > frame.left && frame.bottom > frame.top)) return null;
|
|
50
64
|
const islands = [];
|
|
51
65
|
for (const el of root.querySelectorAll('[data-occludes]')) {
|
|
52
66
|
const edge = el.getAttribute('data-occludes');
|
|
@@ -54,7 +68,7 @@ export function measureShellInsets(frameEl, root, { presenting = false } = {}) {
|
|
|
54
68
|
const rect = boxOf(el);
|
|
55
69
|
if (rect) islands.push({ rect, edge });
|
|
56
70
|
}
|
|
57
|
-
return
|
|
71
|
+
return { frame, islands };
|
|
58
72
|
}
|
|
59
73
|
|
|
60
74
|
/**
|
|
@@ -92,26 +106,38 @@ export function seedOnLadder(pump, to, { alive = () => true, setTimer, clearTime
|
|
|
92
106
|
|
|
93
107
|
const same = (a, b) =>
|
|
94
108
|
a.top === b.top && a.right === b.right && a.bottom === b.bottom && a.left === b.left;
|
|
109
|
+
const sameBand = (a, b) => (a && b ? a.left === b.left && a.right === b.right : a === b);
|
|
95
110
|
|
|
96
111
|
/**
|
|
97
112
|
* @param measure () => Insets the current insets
|
|
98
|
-
* @param
|
|
113
|
+
* @param measureBand () => TopBand | null #217 — the free top band (optional; absent ⇒ never sent)
|
|
114
|
+
* @param send (seq, insets, to?, topBand?) => void `to` is undefined for "every canvas", a target for a
|
|
115
|
+
* seed; `topBand` is the band, or null when there is none to send
|
|
99
116
|
* @param schedule (fn) => handle requestAnimationFrame in the browser
|
|
100
117
|
* @param cancel (handle) => void
|
|
101
118
|
*/
|
|
102
|
-
export function createInsetsPump({
|
|
119
|
+
export function createInsetsPump({
|
|
120
|
+
measure,
|
|
121
|
+
measureBand = () => null,
|
|
122
|
+
send,
|
|
123
|
+
schedule,
|
|
124
|
+
cancel = () => {},
|
|
125
|
+
}) {
|
|
103
126
|
let seq = 0;
|
|
104
127
|
let last = { ...ZERO_INSETS }; // what the canvases hold: the canvas default is all zero (seq -1)
|
|
128
|
+
let lastBand = null; // …and no band
|
|
105
129
|
let handle = null;
|
|
106
130
|
let disposed = false;
|
|
107
131
|
const flush = () => {
|
|
108
132
|
handle = null;
|
|
109
133
|
if (disposed) return;
|
|
110
134
|
const next = measure();
|
|
111
|
-
|
|
135
|
+
const band = measureBand();
|
|
136
|
+
if (same(next, last) && sameBand(band, lastBand)) return;
|
|
112
137
|
last = next;
|
|
138
|
+
lastBand = band;
|
|
113
139
|
seq += 1;
|
|
114
|
-
send(seq, next);
|
|
140
|
+
send(seq, next, undefined, band);
|
|
115
141
|
};
|
|
116
142
|
return {
|
|
117
143
|
/** Ask for a re-measure; any number of calls in one frame make one send. */
|
|
@@ -132,9 +158,11 @@ export function createInsetsPump({ measure, send, schedule, cancel = () => {} })
|
|
|
132
158
|
seed(to) {
|
|
133
159
|
if (disposed) return;
|
|
134
160
|
const next = measure();
|
|
161
|
+
const band = measureBand();
|
|
135
162
|
last = next;
|
|
163
|
+
lastBand = band;
|
|
136
164
|
seq += 1;
|
|
137
|
-
send(seq, next, to);
|
|
165
|
+
send(seq, next, to, band);
|
|
138
166
|
},
|
|
139
167
|
dispose() {
|
|
140
168
|
disposed = true;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// client/v2/shell/project-account-bus.js — 2.1.1 T2/T4: how the registry reaches the avatar menu and the
|
|
2
|
+
// team-server dialog without a new key handler.
|
|
3
|
+
//
|
|
4
|
+
// ACCOUNT_MENU_EVENT `account.switch` (⌘K, the tab menu) opens the avatar menu on its Switch account
|
|
5
|
+
// list; the Share cluster host hears it (share-cluster-host.jsx).
|
|
6
|
+
// LINK_SERVER_EVENT `account.link-server` — "Link your server…" / "Sign in with custom server…". The one
|
|
7
|
+
// team-server dialog (2.1.1 T5) hears it and calls `preventDefault()`. Nobody did → the
|
|
8
|
+
// row opens Settings › General › This project, where today's team-server dialog lives — a row never
|
|
9
|
+
// does nothing.
|
|
10
|
+
|
|
11
|
+
export const ACCOUNT_MENU_EVENT = 'maude:account-menu';
|
|
12
|
+
export const LINK_SERVER_EVENT = 'maude:link-server';
|
|
13
|
+
|
|
14
|
+
/** Open the avatar menu (`view`: 'menu' | 'switch'). */
|
|
15
|
+
export function openAccountMenu(view = 'switch') {
|
|
16
|
+
window.dispatchEvent(new CustomEvent(ACCOUNT_MENU_EVENT, { detail: { view } }));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* `account.link-server`.
|
|
21
|
+
* @param params `{ intent?: 'link' | 'sign-in', url?: string }` — sign-in = "Sign in with custom server…"
|
|
22
|
+
* @param d the menu runner's deps (`setSettingsOpen`)
|
|
23
|
+
* @returns 'dialog' when the dialog took it, 'settings' when it fell back
|
|
24
|
+
*/
|
|
25
|
+
export function runLinkServer(params, d) {
|
|
26
|
+
const detail = {
|
|
27
|
+
intent: params?.intent === 'sign-in' ? 'sign-in' : 'link',
|
|
28
|
+
...(typeof params?.url === 'string' && params.url ? { url: params.url } : {}),
|
|
29
|
+
};
|
|
30
|
+
const ev = new CustomEvent(LINK_SERVER_EVENT, { detail, cancelable: true });
|
|
31
|
+
window.dispatchEvent(ev);
|
|
32
|
+
if (ev.defaultPrevented) return 'dialog';
|
|
33
|
+
// 2.1.1 T6: the project's link lives in General › This project (canvas 17 · 10)
|
|
34
|
+
d?.setSettingsOpen?.('general#this-project');
|
|
35
|
+
return 'settings';
|
|
36
|
+
}
|