@1agh/maude 2.0.4 → 2.0.8
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/hub/src/project-transactions/kernel.mjs +10 -1
- package/apps/studio/access/closure.ts +156 -16
- package/apps/studio/access/filters.ts +39 -5
- package/apps/studio/access/known-canvases.ts +24 -1
- package/apps/studio/access/refused-inputs.ts +89 -0
- package/apps/studio/actions/agents.ts +59 -0
- package/apps/studio/actions/ctx.ts +3 -0
- package/apps/studio/actions/defs/app.ts +12 -0
- package/apps/studio/actions/defs/sync.ts +13 -0
- package/apps/studio/actions/defs/view.ts +59 -3
- package/apps/studio/actions/keymap.gen.ts +35 -0
- package/apps/studio/actions/menu.ts +2 -0
- package/apps/studio/actions/types.ts +3 -1
- package/apps/studio/actions.manifest.json +148 -1
- package/apps/studio/actions.parity.json +31 -1
- package/apps/studio/annotations/ui/ai-seen.tsx +4 -3
- package/apps/studio/annotations/ui/element-node.tsx +139 -54
- package/apps/studio/annotations/ui/lod.tsx +1 -1
- package/apps/studio/annotations/ui/ride.ts +2 -1
- package/apps/studio/annotations/ui/text-style.ts +1 -1
- package/apps/studio/annotations-context-toolbar.tsx +5 -4
- package/apps/studio/annotations-layer.tsx +4 -15
- package/apps/studio/api.ts +425 -128
- package/apps/studio/artboard-activity-overlay.tsx +4 -4
- package/apps/studio/artboard-ai-copies.tsx +4 -4
- package/apps/studio/artboard-freeze.ts +108 -0
- package/apps/studio/artboard-live-gate.tsx +636 -0
- package/apps/studio/artboard-live.ts +831 -0
- package/apps/studio/artboard-placeholder.ts +197 -0
- package/apps/studio/artboard-still-raster.ts +485 -0
- package/apps/studio/artboard-still-warmup.ts +221 -0
- package/apps/studio/artboard-still.ts +1188 -0
- package/apps/studio/artboard-webgl.ts +669 -0
- package/apps/studio/asset-placeholder.tsx +237 -132
- package/apps/studio/asset-upload-bars.tsx +4 -4
- package/apps/studio/bin/_agent-browser-bin.mjs +8 -0
- package/apps/studio/bin/_agent-browser-safe.mjs +2 -1
- package/apps/studio/bin/_canvas-reasons.mjs +34 -0
- package/apps/studio/bin/_ds-check-live.mjs +37 -0
- package/apps/studio/bin/_ds-check.mjs +4 -1
- package/apps/studio/bin/_ds-prove-judge.mjs +167 -0
- package/apps/studio/bin/_ds-prove-playwright.mjs +183 -105
- package/apps/studio/bin/_import-asset.mjs +2 -1
- package/apps/studio/bin/_perf-probe-open.mjs +364 -0
- package/apps/studio/bin/_perf-probe.mjs +2 -1
- package/apps/studio/bin/_perf-shared.mjs +12 -7
- package/apps/studio/bin/_pw-launch.mjs +26 -1
- package/apps/studio/bin/_studio-verb.mjs +24 -3
- package/apps/studio/bin/_thumb-blank.mjs +70 -0
- package/apps/studio/bin/_thumb-cover.mjs +35 -0
- package/apps/studio/bin/_thumbs-playwright.mjs +89 -12
- package/apps/studio/bin/ds-check.sh +5 -1
- package/apps/studio/bin/perf.sh +30 -1
- package/apps/studio/bin/server-up.sh +7 -2
- package/apps/studio/bin/smoke.sh +19 -0
- package/apps/studio/bridge/dgn-protocol.ts +35 -0
- package/apps/studio/canvas-build-sandbox.ts +69 -13
- package/apps/studio/canvas-camera.ts +90 -0
- package/apps/studio/canvas-comment-mount.tsx +9 -9
- package/apps/studio/canvas-lib.tsx +289 -44
- package/apps/studio/canvas-pages-view.tsx +465 -0
- package/apps/studio/canvas-pages.ts +305 -0
- package/apps/studio/canvas-rows.ts +62 -0
- package/apps/studio/canvas-shell.tsx +62 -16
- package/apps/studio/canvas-theme-icons.tsx +41 -0
- package/apps/studio/canvas-theme-pill.tsx +15 -6
- package/apps/studio/canvas-theme.ts +12 -11
- package/apps/studio/client/app.jsx +7 -0
- package/apps/studio/client/canvas-url.js +36 -1
- package/apps/studio/client/home/HomeAccounts.jsx +262 -0
- package/apps/studio/client/home/Shelves.jsx +4 -3
- package/apps/studio/client/home/home-accounts-model.js +121 -0
- package/apps/studio/client/home/home-api.js +6 -0
- package/apps/studio/client/home/home-app.jsx +141 -40
- package/apps/studio/client/home/home-model.js +172 -6
- package/apps/studio/client/home/home.css +169 -5
- package/apps/studio/client/home/shell-mode.js +8 -1
- package/apps/studio/client/hooks/canvas-origin-probe.js +34 -0
- package/apps/studio/client/hooks/use-action-keys.jsx +3 -1
- package/apps/studio/client/hooks/use-canvas-bridge.jsx +1 -1
- package/apps/studio/client/hooks/use-palette-and-panels.jsx +23 -6
- package/apps/studio/client/hooks/use-photo-and-timeline.jsx +16 -8
- package/apps/studio/client/hooks/use-project-data.jsx +13 -2
- package/apps/studio/client/hooks/use-shell-core.jsx +19 -9
- package/apps/studio/client/index-loader.ts +41 -21
- package/apps/studio/client/inspector/inspector-panel.jsx +35 -14
- package/apps/studio/client/panels/ChatPanel.jsx +27 -20
- package/apps/studio/client/panels/CreateProject.jsx +19 -5
- package/apps/studio/client/panels/caps-cache.js +46 -0
- package/apps/studio/client/shell/viewport.jsx +66 -22
- package/apps/studio/client/tree/tree.jsx +17 -0
- package/apps/studio/client/v2/access/access-client.js +2 -0
- package/apps/studio/client/v2/access/access-host.jsx +12 -1
- package/apps/studio/client/v2/access/trashed-banner.jsx +6 -3
- package/apps/studio/client/v2/ai/Advanced.jsx +12 -0
- package/apps/studio/client/v2/ai/Composer.jsx +27 -10
- package/apps/studio/client/v2/canvases/canvases-panel.jsx +24 -0
- package/apps/studio/client/v2/canvases/use-canvas-index.js +24 -1
- package/apps/studio/client/v2/code/canvas-error-card.jsx +14 -2
- package/apps/studio/client/v2/code/canvas-imports-card.jsx +19 -14
- package/apps/studio/client/v2/code/canvas-imports-words.js +60 -0
- package/apps/studio/client/v2/code/canvas-waiting-card.jsx +59 -5
- package/apps/studio/client/v2/code/canvas-waiting.js +18 -1
- package/apps/studio/client/v2/code/code-bus.js +5 -0
- package/apps/studio/client/v2/code/code-consent-sheet.jsx +87 -0
- package/apps/studio/client/v2/code/code-consent.js +67 -0
- package/apps/studio/client/v2/diagnostics/sync-details/sync-details-model.js +62 -10
- package/apps/studio/client/v2/diagnostics/sync-details/sync-details.jsx +314 -5
- package/apps/studio/client/v2/ds/advanced-host.jsx +11 -26
- package/apps/studio/client/v2/ds/ds-refresh.js +161 -0
- package/apps/studio/client/v2/ds/library-host.jsx +45 -45
- package/apps/studio/client/v2/ds/make-host.jsx +13 -15
- package/apps/studio/client/v2/ds/off-system-host.jsx +18 -19
- package/apps/studio/client/v2/ds/review-host.jsx +7 -1
- package/apps/studio/client/v2/ds/truth-host.jsx +15 -17
- package/apps/studio/client/v2/ds/upgrade-host.jsx +26 -10
- package/apps/studio/client/v2/history/branch-actions.js +13 -9
- package/apps/studio/client/v2/history/git-advanced.jsx +8 -1
- package/apps/studio/client/v2/history/git-model.js +3 -1
- package/apps/studio/client/v2/history/git-parts.jsx +16 -1
- package/apps/studio/client/v2/layers/artboard-layers.jsx +24 -5
- package/apps/studio/client/v2/layers/layers-request.js +49 -0
- package/apps/studio/client/v2/left-panel/canvases-pinned.jsx +93 -3
- package/apps/studio/client/v2/left-panel/ds-boards.js +39 -0
- package/apps/studio/client/v2/left-panel/left-panel-model.js +13 -0
- package/apps/studio/client/v2/left-panel/left-panel.css +24 -0
- package/apps/studio/client/v2/presence/faces.jsx +42 -14
- package/apps/studio/client/v2/shell/account-card.jsx +10 -4
- package/apps/studio/client/v2/shell/canvas-crash-guard.js +172 -0
- package/apps/studio/client/v2/shell/canvas-mode.js +17 -1
- package/apps/studio/client/v2/shell/floating-panels.css +37 -1
- package/apps/studio/client/v2/shell/github-signin-host.jsx +42 -0
- package/apps/studio/client/v2/shell/menu-runner.js +11 -0
- package/apps/studio/client/v2/shell/mode-switch.jsx +14 -3
- package/apps/studio/client/v2/shell/opening-skeleton.js +118 -0
- package/apps/studio/client/v2/shell/opening-skeleton.jsx +103 -0
- package/apps/studio/client/v2/shell/pages-pick.js +49 -0
- package/apps/studio/client/v2/shell/project-account-card.jsx +203 -0
- package/apps/studio/client/v2/shell/project-account-model.js +182 -0
- package/apps/studio/client/v2/shell/project-menu-model.js +3 -0
- package/apps/studio/client/v2/shell/share-cluster-host.jsx +140 -11
- package/apps/studio/client/v2/shell/share-cluster.css +58 -0
- package/apps/studio/client/v2/shell/share-cluster.jsx +26 -7
- package/apps/studio/client/v2/shell/shell-parity.json +8 -0
- package/apps/studio/client/v2/shell/team-switch.js +94 -0
- package/apps/studio/client/v2/shell/too-heavy-card.jsx +38 -0
- package/apps/studio/client/v2/shell/use-account.js +8 -1
- package/apps/studio/client/v2/shell/use-canvas-mode-lane.js +30 -0
- package/apps/studio/collab/persistence.ts +9 -1
- package/apps/studio/collab/registry.ts +32 -0
- package/apps/studio/collab/room.ts +8 -0
- package/apps/studio/comments-overlay.tsx +12 -11
- package/apps/studio/config-reload-wire.ts +56 -0
- package/apps/studio/config.schema.json +6 -0
- package/apps/studio/context.ts +37 -1
- package/apps/studio/dist/client.bundle.js +1198 -1198
- package/apps/studio/dist/comment-mount.js +2 -2
- package/apps/studio/dist/styles.css +1 -1
- package/apps/studio/ds/board/board.css +6 -0
- package/apps/studio/ds/board/ds-bar.tsx +21 -3
- package/apps/studio/ds/board/specimen.tsx +16 -2
- package/apps/studio/ds/board/template.ts +39 -19
- package/apps/studio/ds/canvas-cli.ts +58 -2
- package/apps/studio/ds/check.ts +26 -1
- package/apps/studio/ds/cli.ts +14 -4
- package/apps/studio/ds/component-list.ts +2 -1
- package/apps/studio/ds/convert.ts +34 -6
- package/apps/studio/ds/default.ts +6 -1
- package/apps/studio/ds/ds-resolver.ts +58 -8
- package/apps/studio/ds/ds-verb.ts +13 -0
- package/apps/studio/ds/engine.ts +3 -1
- package/apps/studio/ds/folder-systems.ts +199 -0
- package/apps/studio/ds/pairing-css.ts +2 -1
- package/apps/studio/ds/post-build.ts +38 -0
- package/apps/studio/ds/rename.ts +10 -3
- package/apps/studio/ds/shell-fallbacks.ts +2 -1
- package/apps/studio/ds/upgrade-apply.ts +27 -5
- package/apps/studio/ds/upgrade-cli.ts +22 -2
- package/apps/studio/ds/upgrade-prove.ts +198 -15
- package/apps/studio/ds/upgrade-stage.ts +10 -3
- package/apps/studio/editing/ai-point-ring.tsx +4 -4
- package/apps/studio/editing/ai-scope-outline.tsx +4 -4
- package/apps/studio/editing/align-bar.tsx +4 -4
- package/apps/studio/editing/anchor-report.ts +3 -2
- package/apps/studio/editing/artboard-handles.tsx +4 -4
- package/apps/studio/editing/corner-dots.tsx +4 -4
- package/apps/studio/editing/crop-mode.tsx +4 -4
- package/apps/studio/editing/drop-chip.tsx +4 -4
- package/apps/studio/editing/empty-report.ts +3 -2
- package/apps/studio/editing/focus-model.tsx +4 -4
- package/apps/studio/editing/gap-bands.tsx +3 -3
- package/apps/studio/editing/hold-rings.tsx +4 -4
- package/apps/studio/editing/lock-badge.tsx +3 -3
- package/apps/studio/editing/long-page.ts +23 -1
- package/apps/studio/editing/nudge.tsx +2 -2
- package/apps/studio/editing/page-activity.ts +4 -3
- package/apps/studio/editing/paste-bar.tsx +4 -4
- package/apps/studio/editing/pen/overlay.tsx +4 -3
- package/apps/studio/editing/place-freely.tsx +3 -3
- package/apps/studio/editing/reorder-slot.tsx +3 -3
- package/apps/studio/editing/selection.tsx +4 -4
- package/apps/studio/editing/size-ghost.tsx +4 -4
- package/apps/studio/editing/tab-order.tsx +4 -4
- package/apps/studio/editing/text-in-place.tsx +4 -4
- package/apps/studio/editing/undo-preview.tsx +3 -3
- package/apps/studio/equal-spacing-handles.tsx +3 -3
- package/apps/studio/frame-clock.ts +89 -0
- package/apps/studio/history/trash.ts +6 -0
- package/apps/studio/home/accounts.ts +87 -0
- package/apps/studio/home/index-reader.ts +24 -2
- package/apps/studio/home/routes.ts +19 -0
- package/apps/studio/http.ts +80 -34
- package/apps/studio/index/ds-usage.ts +4 -1
- package/apps/studio/index-cache.ts +272 -0
- package/apps/studio/inspect-overlay.tsx +4 -3
- package/apps/studio/inspect.ts +7 -2
- package/apps/studio/link-chip-overlay.tsx +4 -3
- package/apps/studio/measure-overlay.tsx +4 -3
- package/apps/studio/present/pointer-dot.tsx +3 -2
- package/apps/studio/present/present-media.ts +6 -2
- package/apps/studio/present/present-stage.tsx +3 -2
- package/apps/studio/preview/preview-camera.tsx +3 -2
- package/apps/studio/routes/ds-convert.ts +18 -0
- package/apps/studio/routes/sync.ts +176 -0
- package/apps/studio/routes/trash.ts +16 -1
- package/apps/studio/safe-zones-overlay.tsx +3 -2
- package/apps/studio/server.ts +8 -10
- package/apps/studio/skip-dirs.ts +103 -47
- package/apps/studio/studio-page-host.ts +70 -0
- package/apps/studio/sync/accepted-cold-start.ts +28 -13
- package/apps/studio/sync/asset-push.ts +146 -23
- package/apps/studio/sync/asset-state.ts +3 -2
- package/apps/studio/sync/code-module-consent.ts +86 -0
- package/apps/studio/sync/file-ledger.ts +24 -0
- package/apps/studio/sync/file-membership.ts +28 -3
- package/apps/studio/sync/file-plane.ts +497 -61
- package/apps/studio/sync/file-pull.ts +304 -33
- package/apps/studio/sync/held-deletes.ts +230 -0
- package/apps/studio/sync/hub-link.ts +1 -2
- package/apps/studio/sync/hubs-config.ts +59 -2
- package/apps/studio/sync/index.ts +405 -163
- package/apps/studio/sync/journal-client.ts +94 -5
- package/apps/studio/sync/pending-deletes.ts +100 -0
- package/apps/studio/sync/projection.ts +77 -12
- package/apps/studio/sync/seed-progress.ts +104 -3
- package/apps/studio/sync/settings.ts +36 -1
- package/apps/studio/sync/status.ts +17 -1
- package/apps/studio/sync/writer-registry.ts +5 -0
- package/apps/studio/text-caret.ts +5 -3
- package/apps/studio/thumbs/service.ts +12 -2
- package/apps/studio/thumbs/validate.ts +7 -0
- package/apps/studio/toolbars/toolbar-rect.ts +3 -2
- package/apps/studio/ui-prefs-migrate.ts +4 -0
- package/apps/studio/use-annotation-resize.tsx +4 -3
- package/apps/studio/use-artboard-drag.tsx +3 -2
- package/apps/studio/use-element-resize.tsx +7 -6
- package/apps/studio/use-grid-track-handles.tsx +5 -4
- package/apps/studio/use-selection-set.tsx +64 -4
- package/apps/studio/use-spacing-handles.tsx +7 -6
- package/apps/studio/video-comp.tsx +75 -39
- package/apps/studio/video-play-overlay.tsx +4 -3
- package/apps/studio/whats-new.json +99 -0
- package/cli/commands/design.mjs +5 -2
- package/cli/commands/hub.mjs +10 -1
- package/cli/lib/bash-guard.mjs +27 -1
- package/cli/lib/design-help.gen.mjs +1 -1
- package/cli/lib/design-hook.mjs +20 -0
- package/cli/lib/design-link.mjs +42 -17
- package/cli/lib/hub-purge.mjs +183 -0
- package/cli/lib/studio-locate.mjs +35 -10
- package/package.json +8 -8
- package/plugins/design/templates/_shell.html +164 -1
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
// that stops refreshing — or lies about time — holds nothing.
|
|
16
16
|
|
|
17
17
|
import { type CSSProperties, useEffect, useMemo, useRef, useState } from 'react';
|
|
18
|
-
|
|
19
18
|
import { acceptFromShell } from '../bridge/dgn-protocol.ts';
|
|
19
|
+
import { frameCaf, frameRaf } from '../frame-clock.ts';
|
|
20
20
|
import { isReadOnlyCanvas } from '../read-only-mode.ts';
|
|
21
21
|
import {
|
|
22
22
|
createHoldPublisher,
|
|
@@ -401,11 +401,11 @@ export function HoldRings() {
|
|
|
401
401
|
div.dataset.hold === 'person' ? RING_OFFSET : 2
|
|
402
402
|
);
|
|
403
403
|
}
|
|
404
|
-
raf =
|
|
404
|
+
raf = frameRaf(tick);
|
|
405
405
|
};
|
|
406
|
-
raf =
|
|
406
|
+
raf = frameRaf(tick);
|
|
407
407
|
return () => {
|
|
408
|
-
if (raf != null)
|
|
408
|
+
if (raf != null) frameCaf(raf);
|
|
409
409
|
};
|
|
410
410
|
}, [drawn]);
|
|
411
411
|
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
// Read-only on purpose: the badge never writes and never captures the pointer.
|
|
9
9
|
|
|
10
10
|
import { useEffect, useRef, useState } from 'react';
|
|
11
|
-
|
|
12
11
|
import { canvasModeStore } from '../bridge/canvas-mode-store.ts';
|
|
12
|
+
import { frameCaf, frameRaf } from '../frame-clock.ts';
|
|
13
13
|
import { type CrumbNode, crumbLabel } from './crumbs.ts';
|
|
14
14
|
|
|
15
15
|
const LOCKED = '[data-cd-locked]';
|
|
@@ -103,7 +103,7 @@ export function LockBadge({ readOnly = false }: { readOnly?: boolean }) {
|
|
|
103
103
|
const onMove = (e: PointerEvent) => {
|
|
104
104
|
if (raf.current != null) return;
|
|
105
105
|
const { clientX, clientY, target } = e;
|
|
106
|
-
raf.current =
|
|
106
|
+
raf.current = frameRaf(() => {
|
|
107
107
|
raf.current = null;
|
|
108
108
|
const el = editing() && target instanceof Element ? lockedUnder(target) : null;
|
|
109
109
|
if (!el) {
|
|
@@ -127,7 +127,7 @@ export function LockBadge({ readOnly = false }: { readOnly?: boolean }) {
|
|
|
127
127
|
document.removeEventListener('pointermove', onMove, true);
|
|
128
128
|
document.removeEventListener('pointerleave', onLeave, true);
|
|
129
129
|
window.removeEventListener('blur', onLeave);
|
|
130
|
-
if (raf.current != null)
|
|
130
|
+
if (raf.current != null) frameCaf(raf.current);
|
|
131
131
|
};
|
|
132
132
|
}, [readOnly]);
|
|
133
133
|
|
|
@@ -34,12 +34,34 @@ export function sectionName(el: Element): string {
|
|
|
34
34
|
return el.getAttribute('data-cd-id') || el.id || el.tagName.toLowerCase();
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
// 2.0.7 — the sticky name and the minimap poll this 10× and 5× a second. Reading every artboard's
|
|
38
|
+
// `offsetHeight` each time forced a synchronous layout of the whole world whenever anything was dirty (an
|
|
39
|
+
// artboard mounting, a picture arriving): on an 88-artboard canvas that was the pan's main cost. A body's height
|
|
40
|
+
// now comes from one ResizeObserver (delivered when layout is clean anyway); only a page that IS long is read
|
|
41
|
+
// for its rectangle.
|
|
42
|
+
const heights = new WeakMap<Element, number>();
|
|
43
|
+
let heightObserver: ResizeObserver | null = null;
|
|
44
|
+
|
|
45
|
+
function bodyHeight(body: HTMLElement): number {
|
|
46
|
+
const known = heights.get(body);
|
|
47
|
+
if (known !== undefined) return known;
|
|
48
|
+
const h = body.offsetHeight;
|
|
49
|
+
if (typeof ResizeObserver === 'function') {
|
|
50
|
+
heightObserver ??= new ResizeObserver((entries) => {
|
|
51
|
+
for (const en of entries) heights.set(en.target, (en.target as HTMLElement).offsetHeight);
|
|
52
|
+
});
|
|
53
|
+
heights.set(body, h);
|
|
54
|
+
heightObserver.observe(body);
|
|
55
|
+
}
|
|
56
|
+
return h;
|
|
57
|
+
}
|
|
58
|
+
|
|
37
59
|
/** Every artboard in `doc` whose design surface is a long page, with where it is on screen. */
|
|
38
60
|
export function measureLongPages(doc: Document, win: Window = window): LongPage[] {
|
|
39
61
|
const out: LongPage[] = [];
|
|
40
62
|
for (const article of Array.from(doc.querySelectorAll<HTMLElement>('[data-dc-screen]'))) {
|
|
41
63
|
const body = article.querySelector<HTMLElement>(':scope > .dc-artboard-body');
|
|
42
|
-
if (!body || !isLongPage(body
|
|
64
|
+
if (!body || !isLongPage(bodyHeight(body)) || !body.offsetWidth) continue;
|
|
43
65
|
const br = body.getBoundingClientRect();
|
|
44
66
|
const zoom = br.width / body.offsetWidth || 1;
|
|
45
67
|
const labelEl = article.querySelector<HTMLElement>(':scope > .dc-artboard-label');
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
// of a drag). It never writes and never takes a key.
|
|
9
9
|
|
|
10
10
|
import { useEffect, useRef, useState } from 'react';
|
|
11
|
-
|
|
12
11
|
import { resolveSelectionEl } from '../dom-selection.ts';
|
|
12
|
+
import { frameRaf } from '../frame-clock.ts';
|
|
13
13
|
import { type Selection, useSelectionSet } from '../use-selection-set.tsx';
|
|
14
14
|
import { stampedParent } from './selection.tsx';
|
|
15
15
|
|
|
@@ -134,7 +134,7 @@ export function NudgeReadout({ readOnly = false }: { readOnly?: boolean }) {
|
|
|
134
134
|
if (e.key === 'Alt') return showGaps();
|
|
135
135
|
if (!ARROWS.has(e.key)) return;
|
|
136
136
|
// after v1's handler has run (it previews inline in the same task)
|
|
137
|
-
|
|
137
|
+
frameRaf(() => {
|
|
138
138
|
const one = oneElement(selRef.current);
|
|
139
139
|
if (!one || !(one.el instanceof HTMLElement)) return;
|
|
140
140
|
const t = nudgeTag(e.key, one.el.offsetLeft, one.el.offsetTop);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { frameCaf, frameRaf } from '../frame-clock.ts';
|
|
1
2
|
// editing/page-activity.ts — Maude 2.0.4 (task O): one "is anyone using this canvas right now" clock for the
|
|
2
3
|
// canvas runtime's per-frame and polling loops.
|
|
3
4
|
//
|
|
@@ -186,17 +187,17 @@ export function activeFrameLoop(
|
|
|
186
187
|
let running = false;
|
|
187
188
|
const frame = () => {
|
|
188
189
|
if (!running) return;
|
|
189
|
-
raf =
|
|
190
|
+
raf = frameRaf(frame);
|
|
190
191
|
tick();
|
|
191
192
|
};
|
|
192
193
|
const start = () => {
|
|
193
194
|
if (running) return;
|
|
194
195
|
running = true;
|
|
195
|
-
raf =
|
|
196
|
+
raf = frameRaf(frame);
|
|
196
197
|
};
|
|
197
198
|
const stop = () => {
|
|
198
199
|
running = false;
|
|
199
|
-
|
|
200
|
+
frameCaf(raf);
|
|
200
201
|
};
|
|
201
202
|
if (activity.active()) start();
|
|
202
203
|
else tick();
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
// closes the bar.
|
|
14
14
|
|
|
15
15
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
16
|
-
|
|
17
16
|
import { uploadAsset } from '../asset-upload.ts';
|
|
18
17
|
import { showCanvasToast } from '../canvas-notifications.tsx';
|
|
19
18
|
import type { ElementRef } from '../edit-ops/types.ts';
|
|
19
|
+
import { frameCaf, frameRaf } from '../frame-clock.ts';
|
|
20
20
|
import { isEditableTarget } from '../input-router.tsx';
|
|
21
21
|
import { isEmbedCanvas, isReadOnlyCanvas } from '../read-only-mode.ts';
|
|
22
22
|
import { type Selection, useSelectionSet } from '../use-selection-set.tsx';
|
|
@@ -341,10 +341,10 @@ export function PasteBar({ readOnly }: { readOnly?: boolean }) {
|
|
|
341
341
|
: { left: r.left, top: r.bottom + 14 }
|
|
342
342
|
);
|
|
343
343
|
}
|
|
344
|
-
raf =
|
|
344
|
+
raf = frameRaf(tick);
|
|
345
345
|
};
|
|
346
|
-
raf =
|
|
347
|
-
return () =>
|
|
346
|
+
raf = frameRaf(tick);
|
|
347
|
+
return () => frameCaf(raf);
|
|
348
348
|
}, [placedRef]);
|
|
349
349
|
|
|
350
350
|
if (!bar) return null;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// tokens; motion is none (a live drag draws as fast as the pointer moves).
|
|
4
4
|
|
|
5
5
|
import { useEffect, useState } from 'react';
|
|
6
|
+
import { frameCaf, frameRaf } from '../../frame-clock.ts';
|
|
6
7
|
|
|
7
8
|
export const PEN_CSS = `
|
|
8
9
|
/* the input layer pen/draw.tsx renders: its rule used to live only in the shape tool's style (G3) */
|
|
@@ -139,9 +140,9 @@ export function useFrameTick(read: () => string, on: boolean): void {
|
|
|
139
140
|
last = now;
|
|
140
141
|
force((n) => n + 1);
|
|
141
142
|
}
|
|
142
|
-
raf =
|
|
143
|
+
raf = frameRaf(tick);
|
|
143
144
|
};
|
|
144
|
-
raf =
|
|
145
|
-
return () =>
|
|
145
|
+
raf = frameRaf(tick);
|
|
146
|
+
return () => frameCaf(raf);
|
|
146
147
|
}, [on, read]);
|
|
147
148
|
}
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
// Pure where it can be (the maths takes rects and numbers, so it runs without layout).
|
|
15
15
|
|
|
16
16
|
import { useEffect, useRef, useState } from 'react';
|
|
17
|
-
|
|
18
17
|
import { resolveSelectionEl } from '../dom-selection.ts';
|
|
19
18
|
import { isElementDragActive } from '../drag-state.ts';
|
|
20
19
|
import type { EditOpResult, ElementRef } from '../edit-ops/types.ts';
|
|
21
20
|
import type { PinH, PinV } from '../edit-ops/words-css.ts';
|
|
21
|
+
import { frameCaf, frameRaf } from '../frame-clock.ts';
|
|
22
22
|
import type { CommandRecord } from '../undo-stack.ts';
|
|
23
23
|
import { useSelectionSet } from '../use-selection-set.tsx';
|
|
24
24
|
import { type RectLike, worldScaleOf } from './arrange.ts';
|
|
@@ -332,7 +332,7 @@ export function PinGuides({ readOnly }: { readOnly?: boolean }) {
|
|
|
332
332
|
}
|
|
333
333
|
let last = '';
|
|
334
334
|
const tick = () => {
|
|
335
|
-
raf.current =
|
|
335
|
+
raf.current = frameRaf(tick);
|
|
336
336
|
if (isElementDragActive()) return;
|
|
337
337
|
const el = resolveSelectionEl(document, one) as HTMLElement | null;
|
|
338
338
|
const next = el ? guidesFor(el) : [];
|
|
@@ -352,7 +352,7 @@ export function PinGuides({ readOnly }: { readOnly?: boolean }) {
|
|
|
352
352
|
};
|
|
353
353
|
tick();
|
|
354
354
|
return () => {
|
|
355
|
-
if (raf.current != null)
|
|
355
|
+
if (raf.current != null) frameCaf(raf.current);
|
|
356
356
|
setGuides([]);
|
|
357
357
|
};
|
|
358
358
|
}, [one, readOnly]);
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
// Pure where it can be (the line, the numbering, the slot rect take numbers and rects).
|
|
20
20
|
|
|
21
21
|
import { useEffect, useRef, useState, useSyncExternalStore } from 'react';
|
|
22
|
-
|
|
23
22
|
import { showCanvasToast } from '../canvas-notifications.tsx';
|
|
24
23
|
import type { EditOpResult, ElementRef } from '../edit-ops/types.ts';
|
|
24
|
+
import { frameCaf, frameRaf } from '../frame-clock.ts';
|
|
25
25
|
import type { CommandRecord } from '../undo-stack.ts';
|
|
26
26
|
import type { RectLike } from './arrange.ts';
|
|
27
27
|
import { crumbLabel } from './crumbs.ts';
|
|
@@ -502,7 +502,7 @@ export function ReorderSlot() {
|
|
|
502
502
|
}
|
|
503
503
|
let last = '';
|
|
504
504
|
const tick = () => {
|
|
505
|
-
raf.current =
|
|
505
|
+
raf.current = frameRaf(tick);
|
|
506
506
|
const next = paintOf(s);
|
|
507
507
|
// Layers draws the same slot: tell the shell when the place changes (not on every frame)
|
|
508
508
|
const msg = next ? slotMessage(s) : null;
|
|
@@ -520,7 +520,7 @@ export function ReorderSlot() {
|
|
|
520
520
|
};
|
|
521
521
|
tick();
|
|
522
522
|
return () => {
|
|
523
|
-
if (raf.current != null)
|
|
523
|
+
if (raf.current != null) frameCaf(raf.current);
|
|
524
524
|
setPaint(null);
|
|
525
525
|
};
|
|
526
526
|
}, [s]);
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
// (S2-edit-ops.md §7) through use-selection-set's describer seam.
|
|
13
13
|
|
|
14
14
|
import { useEffect, useRef } from 'react';
|
|
15
|
-
|
|
16
15
|
import type { SelectionCrumb } from '../bridge/dgn-protocol.ts';
|
|
17
16
|
import { hoverTargetToSelection, resolveSelectionEl } from '../dom-selection.ts';
|
|
18
17
|
import type { ElementRef } from '../edit-ops/types.ts';
|
|
18
|
+
import { frameCaf, frameRaf } from '../frame-clock.ts';
|
|
19
19
|
import { type Selection, setSelectionDescriber, useSelectionSet } from '../use-selection-set.tsx';
|
|
20
20
|
import {
|
|
21
21
|
buildCrumbs,
|
|
@@ -255,11 +255,11 @@ export function EditingSelection({ readOnly = false }: { readOnly?: boolean }) {
|
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
|
-
raf =
|
|
258
|
+
raf = frameRaf(tick);
|
|
259
259
|
};
|
|
260
|
-
raf =
|
|
260
|
+
raf = frameRaf(tick);
|
|
261
261
|
return () => {
|
|
262
|
-
if (raf != null)
|
|
262
|
+
if (raf != null) frameCaf(raf);
|
|
263
263
|
};
|
|
264
264
|
}, [one]);
|
|
265
265
|
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
// Read-only canvases do nothing here (the server refuses anyway).
|
|
16
16
|
|
|
17
17
|
import { useEffect, useRef, useState } from 'react';
|
|
18
|
-
|
|
19
18
|
import { acceptFromShell } from '../bridge/dgn-protocol.ts';
|
|
20
19
|
import { DsIcon } from '../canvas-ds-icons.tsx';
|
|
21
20
|
import { getLiveViewport } from '../canvas-lib.tsx';
|
|
22
21
|
import { showCanvasToast } from '../canvas-notifications.tsx';
|
|
22
|
+
import { frameCaf, frameRaf } from '../frame-clock.ts';
|
|
23
23
|
import type { Tool } from '../input-router.tsx';
|
|
24
24
|
import { customSpec, presetById } from '../kinds/presets.ts';
|
|
25
25
|
import { isReadOnlyCanvas } from '../read-only-mode.ts';
|
|
@@ -269,10 +269,10 @@ export function SizeGhost({ readOnly = false }: { readOnly?: boolean }) {
|
|
|
269
269
|
key = k;
|
|
270
270
|
tick((n) => n + 1);
|
|
271
271
|
}
|
|
272
|
-
raf =
|
|
272
|
+
raf = frameRaf(loop);
|
|
273
273
|
};
|
|
274
|
-
raf =
|
|
275
|
-
return () =>
|
|
274
|
+
raf = frameRaf(loop);
|
|
275
|
+
return () => frameCaf(raf);
|
|
276
276
|
}, [ghost]);
|
|
277
277
|
|
|
278
278
|
if (!ghost || typeof document === 'undefined') return null;
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
// without a layout engine; the DOM fills the measurements in.
|
|
15
15
|
|
|
16
16
|
import { useEffect, useRef } from 'react';
|
|
17
|
-
|
|
18
17
|
import { resolveSelectionEl } from '../dom-selection.ts';
|
|
18
|
+
import { frameCaf, frameRaf } from '../frame-clock.ts';
|
|
19
19
|
import { pageRootOf } from '../input-router.tsx';
|
|
20
20
|
import { type Selection, useSelectionSet } from '../use-selection-set.tsx';
|
|
21
21
|
import { selectionForElement, stampedParent } from './selection.tsx';
|
|
@@ -279,11 +279,11 @@ export function OrderBadges({ active }: { active: boolean }) {
|
|
|
279
279
|
n.style.left = `${Math.round(edge ? edge.left : r.left) + 5}px`;
|
|
280
280
|
n.style.top = `${Math.round(r.top) + (edge ? 2 : 5)}px`;
|
|
281
281
|
}
|
|
282
|
-
raf =
|
|
282
|
+
raf = frameRaf(tick);
|
|
283
283
|
};
|
|
284
|
-
raf =
|
|
284
|
+
raf = frameRaf(tick);
|
|
285
285
|
return () => {
|
|
286
|
-
if (raf != null)
|
|
286
|
+
if (raf != null) frameCaf(raf);
|
|
287
287
|
root.textContent = '';
|
|
288
288
|
};
|
|
289
289
|
}, [active, one]);
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
// Tokens only: the accent is the canvas's own `--maude-hud-accent`; the arc and ring take no other colour.
|
|
12
12
|
|
|
13
13
|
import { useEffect, useState } from 'react';
|
|
14
|
-
|
|
15
14
|
import { isCzech, tiePositions } from '../edit-ops/czech-ties.ts';
|
|
15
|
+
import { frameCaf, frameRaf } from '../frame-clock.ts';
|
|
16
16
|
import { langIn } from './type-role.ts';
|
|
17
17
|
|
|
18
18
|
export const TEXT_RING_STYLE_ID = 'maude-text-in-place-css';
|
|
@@ -153,17 +153,17 @@ export function TextInPlace({ readOnly }: { readOnly?: boolean }) {
|
|
|
153
153
|
// pan / zoom fire no DOM event: follow them with rAF for as long as a text is being edited (the
|
|
154
154
|
// discrete events below keep the arcs right where rAF is paused, e.g. an occluded WKWebView)
|
|
155
155
|
const loop = () => {
|
|
156
|
-
raf = measure() ?
|
|
156
|
+
raf = measure() ? frameRaf(loop) : 0;
|
|
157
157
|
};
|
|
158
158
|
const kick = () => {
|
|
159
159
|
measure(true);
|
|
160
|
-
if (!raf && document.querySelector(EDITING)) raf =
|
|
160
|
+
if (!raf && document.querySelector(EDITING)) raf = frameRaf(loop);
|
|
161
161
|
};
|
|
162
162
|
const events = ['input', 'keyup', 'focusin', 'focusout', 'selectionchange'] as const;
|
|
163
163
|
for (const e of events) document.addEventListener(e, kick, true);
|
|
164
164
|
return () => {
|
|
165
165
|
for (const e of events) document.removeEventListener(e, kick, true);
|
|
166
|
-
if (raf)
|
|
166
|
+
if (raf) frameCaf(raf);
|
|
167
167
|
};
|
|
168
168
|
}, [readOnly]);
|
|
169
169
|
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
// artboards (`[data-dc-screen="<id>"]`), follows them while the camera moves, and never writes.
|
|
8
8
|
|
|
9
9
|
import { useEffect, useRef, useState } from 'react';
|
|
10
|
-
|
|
11
10
|
import { acceptFromShell } from '../bridge/dgn-protocol.ts';
|
|
11
|
+
import { frameCaf, frameRaf } from '../frame-clock.ts';
|
|
12
12
|
|
|
13
13
|
type Lit = { id: string; left: number; top: number; width: number; height: number };
|
|
14
14
|
|
|
@@ -82,11 +82,11 @@ export function UndoPreview() {
|
|
|
82
82
|
last = key;
|
|
83
83
|
setLit(next); // only when a box moved — a still camera re-renders nothing
|
|
84
84
|
}
|
|
85
|
-
raf.current =
|
|
85
|
+
raf.current = frameRaf(tick);
|
|
86
86
|
};
|
|
87
87
|
tick();
|
|
88
88
|
return () => {
|
|
89
|
-
if (raf.current != null)
|
|
89
|
+
if (raf.current != null) frameCaf(raf.current);
|
|
90
90
|
raf.current = null;
|
|
91
91
|
};
|
|
92
92
|
}, [want]);
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import { useEffect, useRef, useState } from 'react';
|
|
16
|
-
|
|
17
16
|
import { resolveSelectionEl } from './dom-selection.ts';
|
|
18
17
|
import { detectEqualSpacing, type EqualSpacingResult } from './equal-spacing-detector.ts';
|
|
18
|
+
import { frameCaf, frameRaf } from './frame-clock.ts';
|
|
19
19
|
import { useSelectionSet } from './use-selection-set.tsx';
|
|
20
20
|
|
|
21
21
|
const HOVER_PADDING_PX = 40;
|
|
@@ -198,7 +198,7 @@ export function EqualSpacingHandles() {
|
|
|
198
198
|
|
|
199
199
|
const onFrame = () => {
|
|
200
200
|
if (rafRef.current != null) return;
|
|
201
|
-
rafRef.current =
|
|
201
|
+
rafRef.current = frameRaf(tick);
|
|
202
202
|
};
|
|
203
203
|
|
|
204
204
|
// Initial paint + continuous follow on pan/zoom/scroll.
|
|
@@ -211,7 +211,7 @@ export function EqualSpacingHandles() {
|
|
|
211
211
|
|
|
212
212
|
return () => {
|
|
213
213
|
alive = false;
|
|
214
|
-
if (rafRef.current != null)
|
|
214
|
+
if (rafRef.current != null) frameCaf(rafRef.current);
|
|
215
215
|
window.removeEventListener('scroll', recheck, { capture: true } as EventListenerOptions);
|
|
216
216
|
window.removeEventListener('resize', recheck);
|
|
217
217
|
observer.disconnect();
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file frame-clock.ts — 2.0.7: Maude's own frame callbacks, exempt from the gesture freeze
|
|
3
|
+
* @scope apps/studio/frame-clock.ts (canvas frame only; React-free)
|
|
4
|
+
* @purpose While the camera moves, an artboard's own frame callbacks wait (Michal: "while you pan or zoom,
|
|
5
|
+
* artboards must not redraw"). The canvas frame's document (`plugins/design/templates/_shell.html`,
|
|
6
|
+
* script `maude-frame-freeze`) gates `window.requestAnimationFrame` before any module loads, so the
|
|
7
|
+
* canvas runtime (motion captures it when it loads), Remotion's Player, pixi, three.js and a canvas's
|
|
8
|
+
* own loops all wait while frozen and run on the first frame after the thaw, in the order they asked.
|
|
9
|
+
*
|
|
10
|
+
* Maude's own frame code must never wait — the camera's animation, the gesture's own end
|
|
11
|
+
* (`afterQuietFrame`), the mount ring's queue, the stills' slices and the chrome that follows the camera
|
|
12
|
+
* (halos, comment pins, toolbars). It calls `frameRaf` / `frameCaf` instead of the globals:
|
|
13
|
+
* `test/v2-207-gesture-freeze.test.tsx` fails on a bare `requestAnimationFrame(` anywhere in the frame's
|
|
14
|
+
* import graph.
|
|
15
|
+
*
|
|
16
|
+
* Without the shell's script (tests, a document that is not the canvas shell) these are the plain
|
|
17
|
+
* globals and `setFrameFreeze` does nothing.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/** The API the shell's `maude-frame-freeze` script installs on the canvas frame's window. */
|
|
21
|
+
export interface FrameFreezeApi {
|
|
22
|
+
v: number;
|
|
23
|
+
/** The platform's requestAnimationFrame — never deferred. */
|
|
24
|
+
raf(cb: FrameRequestCallback): number;
|
|
25
|
+
/** Cancels a frame callback of either kind (a deferred one too). */
|
|
26
|
+
caf(id: number): void;
|
|
27
|
+
/** Freeze (renews the watchdog) or thaw. */
|
|
28
|
+
set(on: boolean): void;
|
|
29
|
+
frozen(): boolean;
|
|
30
|
+
/** Called on every freeze / thaw transition (a watchdog thaw too). */
|
|
31
|
+
on(fn: (frozen: boolean) => void): () => void;
|
|
32
|
+
stats(): {
|
|
33
|
+
frozen: boolean;
|
|
34
|
+
freezes: number;
|
|
35
|
+
held: number;
|
|
36
|
+
deferred: number;
|
|
37
|
+
flushed: number;
|
|
38
|
+
watchdog: number;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const FRAME_FREEZE_KEY = '__maudeFrameFreeze';
|
|
43
|
+
|
|
44
|
+
export function frameFreezeApi(): FrameFreezeApi | null {
|
|
45
|
+
if (typeof window === 'undefined') return null;
|
|
46
|
+
const a = (window as unknown as Record<string, unknown>)[FRAME_FREEZE_KEY] as
|
|
47
|
+
| FrameFreezeApi
|
|
48
|
+
| undefined;
|
|
49
|
+
return a && typeof a.raf === 'function' ? a : null;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** requestAnimationFrame for Maude's own code: runs on the next frame even while the gesture freeze holds. */
|
|
53
|
+
export function frameRaf(cb: FrameRequestCallback): number {
|
|
54
|
+
const a = frameFreezeApi();
|
|
55
|
+
return a ? a.raf(cb) : requestAnimationFrame(cb);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** cancelAnimationFrame for a handle from `frameRaf` (or any other). */
|
|
59
|
+
export function frameCaf(id: number): void {
|
|
60
|
+
const a = frameFreezeApi();
|
|
61
|
+
if (a) a.caf(id);
|
|
62
|
+
else cancelAnimationFrame(id);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** `win.requestAnimationFrame` for a window Maude's code was handed: the exempt one when it is this frame's. */
|
|
66
|
+
export function frameRafOn(win: Window, cb: FrameRequestCallback): number {
|
|
67
|
+
return typeof window !== 'undefined' && win === window
|
|
68
|
+
? frameRaf(cb)
|
|
69
|
+
: win.requestAnimationFrame(cb);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function frameCafOn(win: Window, id: number): void {
|
|
73
|
+
if (typeof window !== 'undefined' && win === window) frameCaf(id);
|
|
74
|
+
else win.cancelAnimationFrame(id);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** The camera is moving (renew on every input) / it stopped. */
|
|
78
|
+
export function setFrameFreeze(on: boolean): void {
|
|
79
|
+
frameFreezeApi()?.set(on);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function frameFrozen(): boolean {
|
|
83
|
+
return frameFreezeApi()?.frozen() ?? false;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Freeze / thaw transitions; a no-op subscription without the shell's script. */
|
|
87
|
+
export function onFrameFreeze(fn: (frozen: boolean) => void): () => void {
|
|
88
|
+
return frameFreezeApi()?.on(fn) ?? (() => {});
|
|
89
|
+
}
|
|
@@ -93,6 +93,12 @@ export interface CanvasItem extends StoreCanvasItem, ItemWho {
|
|
|
93
93
|
id: `canvas:${string}`;
|
|
94
94
|
kind: 'canvas';
|
|
95
95
|
group: 'today' | 'earlier';
|
|
96
|
+
/**
|
|
97
|
+
* A live canvas holds this item's path right now (one made again at the old place): this is an OLDER
|
|
98
|
+
* copy, not the canvas a tab has open. The "moved to the trash" bar never shows for it. Set by
|
|
99
|
+
* GET /_api/trash (routes/trash.ts); absent when the home cannot list live documents.
|
|
100
|
+
*/
|
|
101
|
+
liveAtPath?: boolean;
|
|
96
102
|
}
|
|
97
103
|
|
|
98
104
|
export interface ArtboardItem extends StoreArtboardItem, ItemWho {
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// home/accounts.ts — 2.0.5 W4b: the accounts each profile on this Mac is signed in with, for Home's
|
|
2
|
+
// avatar, and the per-account sign-outs it offers.
|
|
3
|
+
//
|
|
4
|
+
// GET /_home/accounts?profiles=a,b → { ok, profiles: [{ id, hubs: [{ url, account }] }] }
|
|
5
|
+
// POST /_home/hub/signout { profile, url } → forget that profile's sign-in for that server
|
|
6
|
+
// POST /_home/cloud/signout { profile } → forget that profile's Maude Cloud sign-in
|
|
7
|
+
//
|
|
8
|
+
// Public handles only: a server address and the account the server vouched for at sign-in
|
|
9
|
+
// (`hubs.json` `account`, display data) — never a token. A profile id is `[a-z0-9-]{1,32}`
|
|
10
|
+
// (`profileHubsPath` refuses anything else); a profile's files are named from its id the same way
|
|
11
|
+
// `profiles.rs` `paths_in` names them. A sign-out removes ONE credential from that profile's own
|
|
12
|
+
// file (atomic, 0600) — the project servers watch `hubs.json` and drop the link's sync themselves.
|
|
13
|
+
// Home serves every profile, so it never reads its own process-global path for a non-default one.
|
|
14
|
+
|
|
15
|
+
import { existsSync, unlinkSync } from 'node:fs';
|
|
16
|
+
|
|
17
|
+
import { deleteHubCredential } from '../sync/hub-link.ts';
|
|
18
|
+
import { loadHubsConfig, normalizeUrl, safeAccount } from '../sync/hubs-config.ts';
|
|
19
|
+
import { profileCloudPath, profileHubsPath } from './cloud.ts';
|
|
20
|
+
import type { HomeAnswer } from './signin.ts';
|
|
21
|
+
|
|
22
|
+
const MAX_PROFILES = 16;
|
|
23
|
+
const MAX_HUBS = 50;
|
|
24
|
+
|
|
25
|
+
export interface ProfileHubs {
|
|
26
|
+
id: string;
|
|
27
|
+
hubs: Array<{ url: string; account: string | null }>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Each named profile's team-server sign-ins (no tokens). Unknown / invalid ids are skipped. */
|
|
31
|
+
export function profileAccounts(ids: string[]): ProfileHubs[] {
|
|
32
|
+
const out: ProfileHubs[] = [];
|
|
33
|
+
for (const id of [...new Set(ids)].slice(0, MAX_PROFILES)) {
|
|
34
|
+
const file = profileHubsPath(id);
|
|
35
|
+
if (!file) continue;
|
|
36
|
+
let hubs: ProfileHubs['hubs'] = [];
|
|
37
|
+
try {
|
|
38
|
+
const cfg = loadHubsConfig(file);
|
|
39
|
+
hubs = Object.entries(cfg.hubs ?? {})
|
|
40
|
+
.filter(([, rec]) => rec && typeof rec.token === 'string' && rec.token)
|
|
41
|
+
.slice(0, MAX_HUBS)
|
|
42
|
+
.map(([url, rec]) => ({ url, account: safeAccount(rec.account) }));
|
|
43
|
+
} catch {
|
|
44
|
+
hubs = [];
|
|
45
|
+
}
|
|
46
|
+
out.push({ id, hubs });
|
|
47
|
+
}
|
|
48
|
+
return out;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const bad = (error: string): HomeAnswer => ({ status: 400, body: { ok: false, error } });
|
|
52
|
+
|
|
53
|
+
export function createHomeAccounts(deps: { forgetCloud?: (profile: string) => void } = {}) {
|
|
54
|
+
return {
|
|
55
|
+
list(param: string | null): HomeAnswer {
|
|
56
|
+
const ids = (param ?? '').split(',').filter(Boolean);
|
|
57
|
+
return { status: 200, body: { ok: true, profiles: profileAccounts(ids) } };
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
hubSignOut(b: Record<string, unknown>): HomeAnswer {
|
|
61
|
+
const profile = typeof b.profile === 'string' ? b.profile : '';
|
|
62
|
+
const file = profileHubsPath(profile);
|
|
63
|
+
if (!file) return bad('That account isn’t on this Mac.');
|
|
64
|
+
let url: string;
|
|
65
|
+
try {
|
|
66
|
+
url = normalizeUrl(String(b.url ?? ''));
|
|
67
|
+
} catch {
|
|
68
|
+
return bad('That server address isn’t valid.');
|
|
69
|
+
}
|
|
70
|
+
deleteHubCredential(url, file);
|
|
71
|
+
return { status: 200, body: { ok: true } };
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
cloudSignOut(b: Record<string, unknown>): HomeAnswer {
|
|
75
|
+
const profile = typeof b.profile === 'string' ? b.profile : '';
|
|
76
|
+
const file = profileCloudPath(profile);
|
|
77
|
+
if (!file) return bad('That account isn’t on this Mac.');
|
|
78
|
+
try {
|
|
79
|
+
if (existsSync(file)) unlinkSync(file);
|
|
80
|
+
} catch {
|
|
81
|
+
return { status: 500, body: { ok: false, error: 'Couldn’t sign out. Try again.' } };
|
|
82
|
+
}
|
|
83
|
+
deps.forgetCloud?.(profile);
|
|
84
|
+
return { status: 200, body: { ok: true } };
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
}
|
|
@@ -67,6 +67,13 @@ export interface HomeProjectIndex {
|
|
|
67
67
|
linkedHub: { url: string } | null;
|
|
68
68
|
managed: boolean;
|
|
69
69
|
};
|
|
70
|
+
/**
|
|
71
|
+
* 2.0.5 W4b — the realpath of the project's design root, so Home shows two folders that share
|
|
72
|
+
* one `.design` (a symlink) as ONE project. Set for `ok`, and for a `mismatch` whose root IS this
|
|
73
|
+
* pid but whose design dir resolves elsewhere through a symlink (nothing is read there — W5 — the
|
|
74
|
+
* path is only compared). Never for a snapshot that names another folder.
|
|
75
|
+
*/
|
|
76
|
+
designReal?: string;
|
|
70
77
|
counts?: ProjectIndexSnapshot['counts'];
|
|
71
78
|
canvases?: HomeCanvasRow[];
|
|
72
79
|
}
|
|
@@ -82,7 +89,12 @@ export function resolveProject(
|
|
|
82
89
|
snap: ProjectIndexSnapshot | null = readSnapshot(pid)
|
|
83
90
|
):
|
|
84
91
|
| { ok: true; snap: ProjectIndexSnapshot; root: string; designRoot: string }
|
|
85
|
-
| {
|
|
92
|
+
| {
|
|
93
|
+
ok: false;
|
|
94
|
+
state: Exclude<HomeProjectState, 'ok'>;
|
|
95
|
+
snap: ProjectIndexSnapshot | null;
|
|
96
|
+
designReal?: string;
|
|
97
|
+
} {
|
|
86
98
|
if (!snap || snap.pid !== pid) return { ok: false, state: 'missing', snap: null };
|
|
87
99
|
const root = snap.project?.root;
|
|
88
100
|
const designRel = snap.project?.designRel;
|
|
@@ -115,7 +127,15 @@ export function resolveProject(
|
|
|
115
127
|
} catch {
|
|
116
128
|
return { ok: false, state: 'gone', snap };
|
|
117
129
|
}
|
|
118
|
-
if (st.isSymbolicLink())
|
|
130
|
+
if (st.isSymbolicLink()) {
|
|
131
|
+
let designReal: string | undefined;
|
|
132
|
+
try {
|
|
133
|
+
designReal = realpathSync(designRoot);
|
|
134
|
+
} catch {
|
|
135
|
+
designReal = undefined;
|
|
136
|
+
}
|
|
137
|
+
return { ok: false, state: 'mismatch', snap, ...(designReal ? { designReal } : {}) };
|
|
138
|
+
}
|
|
119
139
|
}
|
|
120
140
|
if (!existsSync(designRoot)) return { ok: false, state: 'gone', snap };
|
|
121
141
|
return { ok: true, snap, root: real, designRoot };
|
|
@@ -191,6 +211,7 @@ export function readHomeIndex(pids: string[], running: ReadonlySet<string> = new
|
|
|
191
211
|
pid,
|
|
192
212
|
state: r.state,
|
|
193
213
|
stale: false,
|
|
214
|
+
...(r.designReal ? { designReal: r.designReal } : {}),
|
|
194
215
|
...(snap
|
|
195
216
|
? {
|
|
196
217
|
project: {
|
|
@@ -232,6 +253,7 @@ export function readHomeIndex(pids: string[], running: ReadonlySet<string> = new
|
|
|
232
253
|
state: 'ok',
|
|
233
254
|
stale,
|
|
234
255
|
...(rebuilt ? { rebuilt } : {}),
|
|
256
|
+
designReal: r.designRoot,
|
|
235
257
|
project: {
|
|
236
258
|
root: r.root,
|
|
237
259
|
name: snap.project.name,
|