@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,438 @@
|
|
|
1
|
+
// client/v2/link-server/link-server-model.js — 2.1.1 T5: the one "Link your server" dialog (canvas 17,
|
|
2
|
+
// artboards 12–13) as pure functions. It replaced Settings' "Add a team server" (TeamProjects serverOnly)
|
|
3
|
+
// and Home's "Sign in to your own hub" (HubSheet).
|
|
4
|
+
//
|
|
5
|
+
// empty ─type→ checking ─answer→ answers · no-answer · not-maude · bad-address
|
|
6
|
+
// answers ─Sign in in your browser→ starting → waiting (the server's own page) → done
|
|
7
|
+
// └→ confirm (the server already holds work) ─Sync this folder→ done
|
|
8
|
+
//
|
|
9
|
+
// The address is checked as it is typed, by THIS app's own server (a project tab's
|
|
10
|
+
// `/_api/hub-signin/check`, Home's `/_home/hub/test`) — one tokenless GET of the server's /health; the
|
|
11
|
+
// page never fetches the remote. The primary button wakes only once the server answered. An invite
|
|
12
|
+
// link fills an empty address and rides the sign-in once (the server checks it names the same server).
|
|
13
|
+
// Advanced: a sign-in key instead of the browser, and the folder on this Mac — each drawn only when the
|
|
14
|
+
// context's API can do it (`advancedParts`).
|
|
15
|
+
//
|
|
16
|
+
// In a project tab whose folder is the person's own (B5, `api.where` names it), the sign-in links THIS folder
|
|
17
|
+
// to the server (`POST /_api/hub/link-folder`): an empty server is seeded right away; a server that already
|
|
18
|
+
// holds work answers with counts, and the dialog asks before anything is linked (`confirmLines`, `runConfirm`).
|
|
19
|
+
//
|
|
20
|
+
// What a context CAN do is its injected API (link-server-api.js); `runLink` drives it. Nothing here
|
|
21
|
+
// keeps or logs a key or an invite: they are read once by `runLink` and never echoed into a line.
|
|
22
|
+
|
|
23
|
+
/** The words (canvas 17 F · Link your server; CONTRACT §3–§4). */
|
|
24
|
+
export const LINK_WORDS = {
|
|
25
|
+
title: 'Link your server',
|
|
26
|
+
addressLabel: 'Address',
|
|
27
|
+
placeholder: 'design.example.com',
|
|
28
|
+
hint: 'Ask whoever runs it for the address. It’s checked as you type.',
|
|
29
|
+
checking: (host) => `Checking ${host}…`,
|
|
30
|
+
answers: (host, version) => (version ? `${host} answers — Maude ${version}` : `${host} answers`),
|
|
31
|
+
noAnswer: (host) =>
|
|
32
|
+
`${host} didn’t answer. Check the address, or try again when this Mac is online.`,
|
|
33
|
+
notMaude: (host) =>
|
|
34
|
+
`${host} answers, but it isn’t a Maude server. Check the address with whoever runs it.`,
|
|
35
|
+
badAddress: 'That doesn’t look like a server address. Type it like design.example.com.',
|
|
36
|
+
signIn: 'Sign in in your browser',
|
|
37
|
+
signInKey: 'Link with this key',
|
|
38
|
+
inviteToggle: 'Use an invite link',
|
|
39
|
+
inviteLabel: 'Invite link',
|
|
40
|
+
invitePlaceholder: 'https://design.example.com/join/…',
|
|
41
|
+
advanced: 'Advanced',
|
|
42
|
+
keyLabel: 'Sign-in key',
|
|
43
|
+
keyPlaceholder: 'Paste a key the server’s admin gave you',
|
|
44
|
+
keyHint: 'Instead of the browser. It stays on this Mac.',
|
|
45
|
+
folderLabel: 'Folder on this Mac',
|
|
46
|
+
folderKept: 'Keep a copy for me',
|
|
47
|
+
folderKeptNote: '— nothing to manage',
|
|
48
|
+
folderMine: 'Use my folder…',
|
|
49
|
+
folderThis: (path) => `This folder (${path})`,
|
|
50
|
+
choose: 'Choose…',
|
|
51
|
+
waitTitle: 'Finish signing in in your browser',
|
|
52
|
+
waitBody: (host) =>
|
|
53
|
+
`${host} opened in your browser. Sign in there — this closes by itself when you’re done.`,
|
|
54
|
+
reopen: 'Open the page again',
|
|
55
|
+
cancel: 'Cancel',
|
|
56
|
+
refused: 'Maude won’t open that address. Check the server address.',
|
|
57
|
+
noBrowser: 'The browser didn’t open. Try again.',
|
|
58
|
+
failed: 'The sign-in didn’t finish. Nothing was linked. Try again.',
|
|
59
|
+
leadOwnTab: 'Sign in to a Maude server your team runs. Its projects open in their own tab.',
|
|
60
|
+
waitThis: (project) =>
|
|
61
|
+
`${project} starts syncing right after. Nothing is sent before you sign in.`,
|
|
62
|
+
waitOwnTab: 'Nothing is sent before you sign in. The project opens right after.',
|
|
63
|
+
confirmTitle: (host) => `Sync this folder with ${host}?`,
|
|
64
|
+
confirmLead: (host) =>
|
|
65
|
+
`You’re signed in. ${host} already holds a project, so syncing puts its work and this folder’s together:`,
|
|
66
|
+
confirmFine: 'Nothing is linked or sent until you press Sync this folder.',
|
|
67
|
+
// 2.1.1 T8 — the first link to a server that holds nothing yet: what goes up, and where
|
|
68
|
+
firstTitle: (host) => `Send this folder to ${host}?`,
|
|
69
|
+
confirmButton: 'Sync this folder',
|
|
70
|
+
linking: 'Linking…',
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/** "1 canvas" · "3 files" · "1 canvas and 2 files" — a count with a noun that reads for one and many. */
|
|
74
|
+
function countOf(c, f) {
|
|
75
|
+
const parts = [];
|
|
76
|
+
if (c) parts.push(`${c} ${c === 1 ? 'canvas' : 'canvases'}`);
|
|
77
|
+
if (f) parts.push(`${f} ${f === 1 ? 'file' : 'files'}`);
|
|
78
|
+
return parts.join(' and ');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* The confirm step's lines (CONTRACT §4: what happens, in counts), from the server's answer
|
|
83
|
+
* `{ canvases: {onlyHere, onlyThere, differ, same}, files: {…} }`. A zero line is left out.
|
|
84
|
+
*/
|
|
85
|
+
export function confirmLines(counts, host) {
|
|
86
|
+
const c = counts?.canvases ?? {};
|
|
87
|
+
const f = counts?.files ?? {};
|
|
88
|
+
const n = (v) => (Number.isFinite(v) && v > 0 ? v : 0);
|
|
89
|
+
const lines = [];
|
|
90
|
+
const up = countOf(n(c.onlyHere), n(f.onlyHere));
|
|
91
|
+
if (up) lines.push({ id: 'here', text: `${up} only on this Mac — sent up to ${host}` });
|
|
92
|
+
const down = countOf(n(c.onlyThere), n(f.onlyThere));
|
|
93
|
+
if (down) lines.push({ id: 'there', text: `${down} only on ${host} — copied to this folder` });
|
|
94
|
+
// S1 (2.1.1, measured against a real server): a canvas on both sides keeps this Mac's source
|
|
95
|
+
// until the person picks a version (a held conflict), and the comments and sticky notes of both
|
|
96
|
+
// sides are kept; a file on both sides takes the server's bytes and keeps this Mac's beside it.
|
|
97
|
+
const both = countOf(n(c.differ), n(f.differ));
|
|
98
|
+
if (both)
|
|
99
|
+
lines.push({
|
|
100
|
+
id: 'differ',
|
|
101
|
+
text: `${both} on both, but different — ${differOutcome(n(c.differ), n(f.differ), host)}`,
|
|
102
|
+
});
|
|
103
|
+
const same = countOf(n(c.same), n(f.same));
|
|
104
|
+
if (same) lines.push({ id: 'same', text: `${same} already the same on both — nothing changes` });
|
|
105
|
+
const stay = stayLine(counts, host);
|
|
106
|
+
if (stay) lines.push(stay);
|
|
107
|
+
return lines;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* 2.1.1 T14 — pictures and videos only this Mac has that the server has no place for. They are not in the
|
|
112
|
+
* "sent up" count (`counts.stayHere`, sync/link-survey.ts): they stay here, said on a line of their own.
|
|
113
|
+
* `null` when there are none.
|
|
114
|
+
*/
|
|
115
|
+
export function stayLine(counts, host) {
|
|
116
|
+
const k = counts?.stayHere;
|
|
117
|
+
if (!(Number.isFinite(k) && k > 0)) return null;
|
|
118
|
+
return {
|
|
119
|
+
id: 'stay',
|
|
120
|
+
text:
|
|
121
|
+
k === 1
|
|
122
|
+
? `1 picture or video stays on this Mac — ${host} doesn’t store it`
|
|
123
|
+
: `${k} pictures and videos stay on this Mac — ${host} doesn’t store them`,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function differOutcome(canvases, files, host) {
|
|
128
|
+
const canvasWords = 'this Mac keeps its version until you choose which to keep';
|
|
129
|
+
const fileWords = `${host}’s version is used, and this Mac’s is kept beside it as a copy`;
|
|
130
|
+
if (canvases && files) return `for a canvas, ${canvasWords}; for a file, ${fileWords}`;
|
|
131
|
+
return canvases ? canvasWords : fileWords;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* 2.1.1 T8 — the first link to a server that holds nothing: one line saying what goes up and where
|
|
136
|
+
* ("3 canvases and 12 files will go to design.example.com."), from the same counts.
|
|
137
|
+
*/
|
|
138
|
+
export function firstLead(counts, host) {
|
|
139
|
+
const n = (v) => (Number.isFinite(v) && v > 0 ? v : 0);
|
|
140
|
+
const up = countOf(n(counts?.canvases?.onlyHere), n(counts?.files?.onlyHere));
|
|
141
|
+
if (up) return `${up} will go to ${host}.`;
|
|
142
|
+
// pictures and videos the server can't store are not "empty": nothing goes up, and the next line says why
|
|
143
|
+
if (stayLine(counts, host)) return `Nothing from this folder will go to ${host}.`;
|
|
144
|
+
return `This folder is empty. What you add here will go to ${host}.`;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const SCHEME_RE = /^[a-z][a-z0-9+.-]*:\/\//i;
|
|
148
|
+
|
|
149
|
+
/** What the person typed → the address the server is asked about (a bare host is https). */
|
|
150
|
+
export function addressOf(raw) {
|
|
151
|
+
const s = String(raw ?? '').trim();
|
|
152
|
+
if (!s) return null;
|
|
153
|
+
return SCHEME_RE.test(s) ? s : `https://${s}`;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** `https://design.example.com` → `design.example.com` (display only). */
|
|
157
|
+
export function hostOf(url) {
|
|
158
|
+
try {
|
|
159
|
+
return new URL(String(url)).host || String(url ?? '');
|
|
160
|
+
} catch {
|
|
161
|
+
return String(url ?? '');
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** `https://hub.example/join/inv_…` → `https://hub.example` (the server's own invite link); else null. */
|
|
166
|
+
export function hubOfInviteLink(raw) {
|
|
167
|
+
try {
|
|
168
|
+
const u = new URL(String(raw ?? '').trim());
|
|
169
|
+
if (u.protocol !== 'https:' && u.protocol !== 'http:') return null;
|
|
170
|
+
const m = /^(.*)\/join\/[^/]+$/.exec(u.pathname);
|
|
171
|
+
return m ? `${u.origin}${m[1]}` : null;
|
|
172
|
+
} catch {
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** @param {string} [initialUrl] a known server's address (Sign in again) */
|
|
178
|
+
export function initialLink(initialUrl = '') {
|
|
179
|
+
const url = String(initialUrl ?? '');
|
|
180
|
+
return {
|
|
181
|
+
url,
|
|
182
|
+
check: {
|
|
183
|
+
phase: url.trim() ? 'checking' : 'empty',
|
|
184
|
+
seq: url.trim() ? 1 : 0,
|
|
185
|
+
version: null,
|
|
186
|
+
error: null,
|
|
187
|
+
},
|
|
188
|
+
invite: { open: false, value: '' },
|
|
189
|
+
advanced: false,
|
|
190
|
+
key: '',
|
|
191
|
+
folder: { mode: 'kept', path: '' },
|
|
192
|
+
phase: 'form', // form · starting · waiting · confirm · linking · done
|
|
193
|
+
wait: null, // { id, signInUrl, host }
|
|
194
|
+
confirm: null, // { url, host, counts, code } — the server already holds work (B5)
|
|
195
|
+
error: null,
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const typed = (s, url) => {
|
|
200
|
+
const seq = s.check.seq + 1;
|
|
201
|
+
return {
|
|
202
|
+
...s,
|
|
203
|
+
url,
|
|
204
|
+
error: null,
|
|
205
|
+
check: { phase: url.trim() ? 'checking' : 'empty', seq, version: null, error: null },
|
|
206
|
+
};
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
const PHASE_OF_REASON = {
|
|
210
|
+
unreachable: 'no-answer',
|
|
211
|
+
'not-a-maude-workspace': 'not-maude',
|
|
212
|
+
'bad-address': 'bad-address',
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
export function linkReducer(s, a) {
|
|
216
|
+
switch (a?.type) {
|
|
217
|
+
case 'type':
|
|
218
|
+
return typed(s, String(a.url ?? ''));
|
|
219
|
+
case 'check-done': {
|
|
220
|
+
if (a.seq !== s.check.seq || s.check.phase !== 'checking') return s; // an older address's answer
|
|
221
|
+
const r = a.answer || {};
|
|
222
|
+
if (r.ok)
|
|
223
|
+
return {
|
|
224
|
+
...s,
|
|
225
|
+
check: { ...s.check, phase: 'answers', version: r.version ?? null, error: null },
|
|
226
|
+
};
|
|
227
|
+
const phase = PHASE_OF_REASON[r.reason] || 'no-answer';
|
|
228
|
+
return {
|
|
229
|
+
...s,
|
|
230
|
+
check: {
|
|
231
|
+
...s.check,
|
|
232
|
+
phase,
|
|
233
|
+
version: null,
|
|
234
|
+
error: phase === 'bad-address' ? r.error || LINK_WORDS.badAddress : null,
|
|
235
|
+
},
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
case 'invite-open':
|
|
239
|
+
return { ...s, invite: { ...s.invite, open: true } };
|
|
240
|
+
case 'invite': {
|
|
241
|
+
const value = String(a.value ?? '');
|
|
242
|
+
const next = { ...s, invite: { open: true, value } };
|
|
243
|
+
// the server's own link names its server: fill an EMPTY address (the address is not secret)
|
|
244
|
+
const at = s.url.trim() ? null : hubOfInviteLink(value);
|
|
245
|
+
return at ? typed(next, at) : next;
|
|
246
|
+
}
|
|
247
|
+
case 'advanced':
|
|
248
|
+
return { ...s, advanced: !s.advanced };
|
|
249
|
+
case 'key':
|
|
250
|
+
return { ...s, key: String(a.value ?? '') };
|
|
251
|
+
case 'folder':
|
|
252
|
+
if (s.folder.mode === 'this') return s; // this project's own folder is not a choice
|
|
253
|
+
return { ...s, folder: { ...s.folder, mode: a.mode === 'mine' ? 'mine' : 'kept' } };
|
|
254
|
+
case 'here':
|
|
255
|
+
// B5 — the project tab's own folder (`api.where`): linking means THIS folder; null = a copy Maude
|
|
256
|
+
// keeps, or a project already linked — the dialog keeps its other behaviour
|
|
257
|
+
return typeof a.folder === 'string' && a.folder
|
|
258
|
+
? { ...s, folder: { mode: 'this', path: a.folder } }
|
|
259
|
+
: s;
|
|
260
|
+
case 'folder-path':
|
|
261
|
+
if (s.folder.mode === 'this') return s;
|
|
262
|
+
return { ...s, folder: { mode: 'mine', path: String(a.path ?? '') } };
|
|
263
|
+
case 'submit':
|
|
264
|
+
// the invite and the key are read once (by `runLink`, from the state before this) and emptied now —
|
|
265
|
+
// a secret never outlives the press in the page
|
|
266
|
+
return { ...s, phase: 'starting', error: null, key: '', invite: { ...s.invite, value: '' } };
|
|
267
|
+
case 'waiting':
|
|
268
|
+
return {
|
|
269
|
+
...s,
|
|
270
|
+
phase: 'waiting',
|
|
271
|
+
wait: { id: a.id, signInUrl: a.signInUrl, host: a.host },
|
|
272
|
+
};
|
|
273
|
+
case 'needs-confirm': {
|
|
274
|
+
const c = a.confirm || {};
|
|
275
|
+
if (typeof c.code !== 'string' || !c.code)
|
|
276
|
+
return { ...s, phase: 'form', wait: null, error: LINK_WORDS.failed };
|
|
277
|
+
return {
|
|
278
|
+
...s,
|
|
279
|
+
phase: 'confirm',
|
|
280
|
+
wait: null,
|
|
281
|
+
confirm: {
|
|
282
|
+
url: c.url,
|
|
283
|
+
host: c.host,
|
|
284
|
+
counts: c.counts ?? null,
|
|
285
|
+
code: c.code,
|
|
286
|
+
empty: c.empty === true,
|
|
287
|
+
},
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
case 'confirming':
|
|
291
|
+
return s.phase === 'confirm' ? { ...s, phase: 'linking' } : s;
|
|
292
|
+
case 'failed':
|
|
293
|
+
return {
|
|
294
|
+
...s,
|
|
295
|
+
phase: 'form',
|
|
296
|
+
wait: null,
|
|
297
|
+
confirm: null,
|
|
298
|
+
error: a.error || LINK_WORDS.failed,
|
|
299
|
+
};
|
|
300
|
+
case 'cancelled':
|
|
301
|
+
return { ...s, phase: 'form', wait: null, confirm: null, error: null };
|
|
302
|
+
case 'done':
|
|
303
|
+
return { ...s, phase: 'done', wait: null, confirm: null };
|
|
304
|
+
default:
|
|
305
|
+
return s;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/** The line under the address: a hint, the check, or why not. */
|
|
310
|
+
export function checkLine(s) {
|
|
311
|
+
const host = hostOf(addressOf(s.url) ?? '');
|
|
312
|
+
switch (s.check.phase) {
|
|
313
|
+
case 'checking':
|
|
314
|
+
return { tone: 'busy', text: LINK_WORDS.checking(host) };
|
|
315
|
+
case 'answers':
|
|
316
|
+
return { tone: 'ok', text: LINK_WORDS.answers(host, s.check.version) };
|
|
317
|
+
case 'no-answer':
|
|
318
|
+
return { tone: 'bad', text: LINK_WORDS.noAnswer(host) };
|
|
319
|
+
case 'not-maude':
|
|
320
|
+
return { tone: 'bad', text: LINK_WORDS.notMaude(host) };
|
|
321
|
+
case 'bad-address':
|
|
322
|
+
return { tone: 'bad', text: s.check.error || LINK_WORDS.badAddress };
|
|
323
|
+
default:
|
|
324
|
+
return { tone: 'hint', text: LINK_WORDS.hint };
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/** The primary button wakes only once the server answered (and a chosen folder is named). */
|
|
329
|
+
export function canSubmit(s) {
|
|
330
|
+
if (s.phase !== 'form' || s.check.phase !== 'answers') return false;
|
|
331
|
+
return s.folder.mode !== 'mine' || !!s.folder.path.trim();
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/** Why the primary button sleeps, in words (a disabled control says why — p8-lock-reasons). */
|
|
335
|
+
export function whyNotSubmit(s) {
|
|
336
|
+
if (s.phase !== 'form') return 'Finish or cancel this sign-in first.';
|
|
337
|
+
switch (s.check.phase) {
|
|
338
|
+
case 'empty':
|
|
339
|
+
return 'Type the server’s address first.';
|
|
340
|
+
case 'checking':
|
|
341
|
+
return 'Waiting for the server to answer.';
|
|
342
|
+
case 'answers':
|
|
343
|
+
return s.folder.mode === 'mine' && !s.folder.path.trim() ? 'Choose a folder first.' : null;
|
|
344
|
+
default:
|
|
345
|
+
return 'Check the address first.';
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
export function primaryLabel(s) {
|
|
350
|
+
return s.key.trim() ? LINK_WORDS.signInKey : LINK_WORDS.signIn;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/** What Advanced holds in this context (its hint line); none = the fold is not drawn. */
|
|
354
|
+
export function advancedParts(api, s) {
|
|
355
|
+
const out = [];
|
|
356
|
+
if (typeof api?.linkKey === 'function') out.push('Sign-in key');
|
|
357
|
+
if (api?.folders === true || s?.folder?.mode === 'this') out.push('folder');
|
|
358
|
+
return out;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/** A `{ok, status, json}` answer → the shape `runLink` reads (`ok` only when both say so). */
|
|
362
|
+
export const answerOf = (r) =>
|
|
363
|
+
r?.json && typeof r.json === 'object' ? { ...r.json, ok: !!(r.ok && r.json.ok) } : { ok: false };
|
|
364
|
+
|
|
365
|
+
/** The check's answer: ok + version, or the reason the dialog words. */
|
|
366
|
+
export const checkAnswerOf = (r) =>
|
|
367
|
+
r?.ok && r.json?.ok
|
|
368
|
+
? { ok: true, version: typeof r.json.version === 'string' ? r.json.version : null }
|
|
369
|
+
: {
|
|
370
|
+
ok: false,
|
|
371
|
+
reason: typeof r?.json?.reason === 'string' ? r.json.reason : 'unreachable',
|
|
372
|
+
...(typeof r?.json?.error === 'string' ? { error: r.json.error } : {}),
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
export const LINK_POLL_MS = 1500;
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Run the link the dialog's state describes, through the context's API:
|
|
379
|
+
* key → api.linkKey(url, key) → api.finish(url, folder)
|
|
380
|
+
* else → api.signInStart(url, invite?) → api.openSignIn(page) → onWaiting → poll → api.finish(url, folder)
|
|
381
|
+
* Resolves `{ ok: true }` · `{ ok: false, error }` · `{ ok: false, cancelled: true }`.
|
|
382
|
+
*/
|
|
383
|
+
export async function runLink(
|
|
384
|
+
s,
|
|
385
|
+
api,
|
|
386
|
+
{ onWaiting = () => {}, isCancelled = () => false, sleep, pollMs = LINK_POLL_MS } = {}
|
|
387
|
+
) {
|
|
388
|
+
const wait = sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
|
|
389
|
+
const url = addressOf(s.url);
|
|
390
|
+
if (!url) return { ok: false, error: LINK_WORDS.badAddress };
|
|
391
|
+
const folder = { mode: s.folder.mode, path: s.folder.mode === 'mine' ? s.folder.path : '' };
|
|
392
|
+
const key = s.key.trim();
|
|
393
|
+
const finish = async (at) => {
|
|
394
|
+
const f = await api.finish(at, folder);
|
|
395
|
+
if (f?.ok) return { ok: true };
|
|
396
|
+
// B5 — the server already holds work: nothing was linked; the dialog asks first
|
|
397
|
+
if (f?.needsConfirm) return { ok: false, needsConfirm: { url: at, ...f.needsConfirm } };
|
|
398
|
+
return { ok: false, error: f?.error || LINK_WORDS.failed };
|
|
399
|
+
};
|
|
400
|
+
if (key && typeof api.linkKey === 'function') {
|
|
401
|
+
const k = await api.linkKey(url, key);
|
|
402
|
+
if (!k?.ok) return { ok: false, error: k?.error || LINK_WORDS.failed };
|
|
403
|
+
return finish(url);
|
|
404
|
+
}
|
|
405
|
+
const invite = s.invite.value.trim();
|
|
406
|
+
const st = await api.signInStart(url, invite || undefined);
|
|
407
|
+
if (!st?.ok || !st.id || !st.signInUrl)
|
|
408
|
+
return { ok: false, error: st?.error || LINK_WORDS.failed };
|
|
409
|
+
const opened = await api.openSignIn(st.signInUrl);
|
|
410
|
+
if (opened !== 'ok') {
|
|
411
|
+
await api.signInCancel(st.id);
|
|
412
|
+
return { ok: false, error: opened === 'refused' ? LINK_WORDS.refused : LINK_WORDS.noBrowser };
|
|
413
|
+
}
|
|
414
|
+
onWaiting({ id: st.id, signInUrl: st.signInUrl, host: hostOf(url) });
|
|
415
|
+
for (;;) {
|
|
416
|
+
if (isCancelled()) return { ok: false, cancelled: true };
|
|
417
|
+
const p = await api.signInPoll(st.id);
|
|
418
|
+
if (isCancelled()) return { ok: false, cancelled: true };
|
|
419
|
+
if (p?.ok && p.pending) {
|
|
420
|
+
await wait(pollMs);
|
|
421
|
+
continue;
|
|
422
|
+
}
|
|
423
|
+
if (p?.ok && p.url) return finish(p.url);
|
|
424
|
+
return { ok: false, error: p?.error || LINK_WORDS.failed };
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* B5 — the person said yes to syncing this folder with a server that already holds work: the one-time
|
|
430
|
+
* code the server's answer carried goes back once. Resolves `{ ok: true }` · `{ ok: false, error }`.
|
|
431
|
+
*/
|
|
432
|
+
export async function runConfirm(s, api) {
|
|
433
|
+
const c = s.confirm;
|
|
434
|
+
if (!c?.code || typeof api?.confirmLink !== 'function')
|
|
435
|
+
return { ok: false, error: LINK_WORDS.failed };
|
|
436
|
+
const r = await api.confirmLink(c.url, c.code);
|
|
437
|
+
return r?.ok ? { ok: true } : { ok: false, error: r?.error || LINK_WORDS.failed };
|
|
438
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/* client/v2/link-server/link-server.css — 2.1.1 T5: the one "Link your server" dialog (canvas 17,
|
|
2
|
+
* artboards 12–13). The sheet plane is the Advanced sheets' (`ai-conn-*`, `ob-*`); these are its own parts:
|
|
3
|
+
* the full-width buttons, the check line under the address, the Advanced fold and the folder radios. */
|
|
4
|
+
@layer components {
|
|
5
|
+
.ls-sheet {
|
|
6
|
+
width: 360px;
|
|
7
|
+
max-width: 100%;
|
|
8
|
+
}
|
|
9
|
+
.ls-full {
|
|
10
|
+
width: 100%;
|
|
11
|
+
justify-content: center;
|
|
12
|
+
}
|
|
13
|
+
.ls-check {
|
|
14
|
+
font-size: var(--type-xs);
|
|
15
|
+
line-height: var(--lh-xs);
|
|
16
|
+
color: var(--fg-2);
|
|
17
|
+
}
|
|
18
|
+
.ls-check .ob-sw {
|
|
19
|
+
font-size: var(--type-xs);
|
|
20
|
+
white-space: normal;
|
|
21
|
+
}
|
|
22
|
+
.ls-check[data-tone="bad"] .ob-sw {
|
|
23
|
+
color: var(--status-error-text);
|
|
24
|
+
}
|
|
25
|
+
.ls-check[data-tone="bad"] .ob-sw i {
|
|
26
|
+
background: var(--status-error);
|
|
27
|
+
}
|
|
28
|
+
.ob-input[data-bad="true"] {
|
|
29
|
+
box-shadow: inset 0 0 0 1px var(--status-error);
|
|
30
|
+
}
|
|
31
|
+
.ls-wait {
|
|
32
|
+
margin: 0;
|
|
33
|
+
}
|
|
34
|
+
.ls-wait .ob-sw {
|
|
35
|
+
white-space: normal;
|
|
36
|
+
color: var(--fg-1);
|
|
37
|
+
}
|
|
38
|
+
.ls-adv {
|
|
39
|
+
border-top: 0.5px solid var(--border-subtle);
|
|
40
|
+
padding-top: var(--space-2);
|
|
41
|
+
}
|
|
42
|
+
.ls-adv-t {
|
|
43
|
+
display: flex;
|
|
44
|
+
align-items: center;
|
|
45
|
+
gap: var(--space-2);
|
|
46
|
+
width: 100%;
|
|
47
|
+
padding: var(--space-1) 0;
|
|
48
|
+
border: 0;
|
|
49
|
+
background: none;
|
|
50
|
+
color: var(--fg-0);
|
|
51
|
+
font: inherit;
|
|
52
|
+
font-size: var(--type-sm);
|
|
53
|
+
text-align: left;
|
|
54
|
+
cursor: default;
|
|
55
|
+
}
|
|
56
|
+
.ls-chev {
|
|
57
|
+
display: inline-block;
|
|
58
|
+
transition: transform var(--dur-fast, 120ms) ease;
|
|
59
|
+
}
|
|
60
|
+
.ls-adv[data-open="true"] .ls-chev {
|
|
61
|
+
transform: rotate(90deg);
|
|
62
|
+
}
|
|
63
|
+
.ls-adv-l {
|
|
64
|
+
font-weight: var(--w-medium);
|
|
65
|
+
}
|
|
66
|
+
.ls-adv-h {
|
|
67
|
+
margin-left: auto;
|
|
68
|
+
font-size: var(--type-xs);
|
|
69
|
+
color: var(--fg-2);
|
|
70
|
+
}
|
|
71
|
+
.ls-adv-b {
|
|
72
|
+
display: flex;
|
|
73
|
+
flex-direction: column;
|
|
74
|
+
gap: var(--space-3);
|
|
75
|
+
padding-top: var(--space-2);
|
|
76
|
+
}
|
|
77
|
+
.ls-folder {
|
|
78
|
+
display: flex;
|
|
79
|
+
flex-direction: column;
|
|
80
|
+
gap: var(--space-2);
|
|
81
|
+
margin: 0;
|
|
82
|
+
padding: 0;
|
|
83
|
+
border: 0;
|
|
84
|
+
}
|
|
85
|
+
.ls-radio {
|
|
86
|
+
display: flex;
|
|
87
|
+
align-items: center;
|
|
88
|
+
gap: var(--space-2);
|
|
89
|
+
font-size: var(--type-sm);
|
|
90
|
+
color: var(--fg-0);
|
|
91
|
+
}
|
|
92
|
+
.ls-path {
|
|
93
|
+
display: flex;
|
|
94
|
+
align-items: center;
|
|
95
|
+
overflow: hidden;
|
|
96
|
+
text-overflow: ellipsis;
|
|
97
|
+
white-space: nowrap;
|
|
98
|
+
}
|
|
99
|
+
/* B5 — the confirm step's counts (what syncing this folder with the server would do) */
|
|
100
|
+
.ls-counts {
|
|
101
|
+
display: flex;
|
|
102
|
+
flex-direction: column;
|
|
103
|
+
gap: var(--space-1);
|
|
104
|
+
margin: 0;
|
|
105
|
+
padding-left: var(--space-4);
|
|
106
|
+
font-size: var(--type-sm);
|
|
107
|
+
color: var(--fg-0);
|
|
108
|
+
}
|
|
109
|
+
}
|