@dexhq/canvas 0.13.0 → 0.15.0
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/CHANGELOG.md +53 -0
- package/README.md +21 -18
- package/app/canvas/activity.tsx +8 -15
- package/app/canvas/anchoring.ts +3 -5
- package/app/canvas/canvas-input.ts +151 -14
- package/app/canvas/canvas-keys.ts +9 -0
- package/app/canvas/canvas-model.ts +5 -42
- package/app/canvas/canvas-panels.ts +1 -17
- package/app/canvas/canvas-scene.ts +7 -3
- package/app/canvas/canvas-ui.ts +2 -1
- package/app/canvas/canvas.css +61 -26
- package/app/canvas/change-notice.tsx +10 -1
- package/app/canvas/comment-layer.tsx +2 -1
- package/app/canvas/comments.tsx +204 -82
- package/app/canvas/element-picker.ts +200 -27
- package/app/canvas/engine/canvas-gestures.ts +72 -17
- package/app/canvas/engine/canvas-store.ts +17 -1
- package/app/canvas/engine/engine.css +6 -3
- package/app/canvas/find-bar.tsx +817 -0
- package/app/canvas/find-model.ts +135 -0
- package/app/canvas/flow-canvas.tsx +18 -2
- package/app/canvas/follow-pin.ts +26 -6
- package/app/canvas/frame-node.tsx +43 -26
- package/app/canvas/imported-reviews.tsx +12 -22
- package/app/canvas/layout.ts +27 -0
- package/app/canvas/live-page.ts +142 -19
- package/app/canvas/page-find.ts +220 -0
- package/app/canvas/page-style.ts +23 -0
- package/app/canvas/section-node.tsx +2 -0
- package/app/canvas/spec-threads.ts +24 -23
- package/app/canvas/thread-focus.tsx +14 -12
- package/app/canvas/tool-cursors.ts +16 -16
- package/app/canvas/use-activity.ts +0 -8
- package/app/canvas/use-agent-changes.tsx +34 -40
- package/app/canvas/use-canvas-clipboard.tsx +11 -14
- package/app/canvas/xray.ts +3 -12
- package/app/frame.tsx +5 -0
- package/app/i18n/locales/en/messages.po +114 -12
- package/app/i18n/locales/en/messages.ts +1 -1
- package/app/i18n/locales/pseudo/messages.po +114 -12
- package/app/i18n/locales/pseudo/messages.ts +1 -1
- package/app/icons/{sets/lucide.tsx → glyphs.tsx} +7 -5
- package/app/icons/index.tsx +3 -3
- package/app/icons/types.ts +3 -10
- package/app/index.html +3 -3
- package/app/main.tsx +3 -0
- package/app/pages/canvas-settings.tsx +35 -0
- package/app/pages/canvas.tsx +27 -8
- package/app/pages/commands-settings.tsx +16 -2
- package/app/shell/about.tsx +5 -4
- package/app/shell/feedback-details.ts +0 -3
- package/app/shell/feedback-form.tsx +10 -21
- package/app/shell/feedback-link.tsx +2 -1
- package/app/shell/instructions-editor.tsx +1 -1
- package/app/shell/presence-style.ts +59 -0
- package/app/shell/presence.tsx +6 -3
- package/app/shell/scaled-frame.tsx +21 -9
- package/app/shell/settings-sections.ts +12 -0
- package/app/shell/sidebar.tsx +1 -1
- package/app/studio-ui.d.ts +0 -9
- package/app/types.ts +21 -205
- package/app/ui/file-drop.ts +128 -0
- package/app/ui/prompt-editor.tsx +1 -1
- package/app/ui/shadcn/input-group.tsx +2 -2
- package/dist/cli/banner.d.mts +4 -2
- package/dist/cli/banner.mjs +34 -11
- package/dist/cli/commands/app.mjs +19 -11
- package/dist/cli/commands/create.d.mts +26 -14
- package/dist/cli/commands/create.mjs +13 -7
- package/dist/cli/commands/dev.mjs +2 -3
- package/dist/cli/commands/hook.mjs +2 -1
- package/dist/cli/commands/init.d.mts +11 -6
- package/dist/cli/help.d.mts +1 -1
- package/dist/cli/help.mjs +3 -3
- package/dist/cli/main.d.mts +22 -12
- package/dist/config/index.d.mts +6 -5
- package/dist/config/project-files.d.mts +6 -3
- package/dist/config/project-files.mjs +14 -5
- package/dist/config/renamed.d.mts +0 -2
- package/dist/config/renamed.mjs +1 -3
- package/dist/config/schema.d.mts +0 -5
- package/dist/config/schema.mjs +0 -5
- package/dist/content/capture.d.mts +2 -2
- package/dist/content/capture.mjs +2 -2
- package/dist/content/content.d.mts +3 -141
- package/dist/content/content.mjs +7 -65
- package/dist/content/flow-specs.mjs +1 -1
- package/dist/content/prototype-summary.d.mts +3 -39
- package/dist/content/prototype-summary.mjs +2 -3
- package/dist/content/prototypes.mjs +1 -1
- package/dist/content/snapshot-client.mjs +1 -1
- package/dist/content/text-replace.d.mts +30 -0
- package/dist/content/text-replace.mjs +309 -0
- package/dist/content/thread-module.mjs +1 -1
- package/dist/content/threads.mjs +1 -1
- package/dist/paths.d.mts +0 -2
- package/dist/paths.mjs +1 -3
- package/dist/server/agent-env.d.mts +5 -1
- package/dist/server/agent-env.mjs +7 -2
- package/dist/server/agent-session.d.mts +14 -1
- package/dist/server/agent-session.mjs +84 -19
- package/dist/server/brief.mjs +3 -3
- package/dist/server/build-pictures.mjs +1 -1
- package/dist/server/channel.d.mts +19 -24
- package/dist/server/channel.mjs +70 -37
- package/dist/server/claimed-presence.d.mts +18 -0
- package/dist/server/claimed-presence.mjs +58 -0
- package/dist/server/close-check.mjs +2 -2
- package/dist/server/comments/actions.d.mts +153 -0
- package/dist/server/comments/actions.mjs +154 -0
- package/dist/server/comments/routes.d.mts +25 -0
- package/dist/server/comments/routes.mjs +88 -0
- package/dist/server/comments/tools.d.mts +6 -0
- package/dist/server/comments/tools.mjs +154 -0
- package/dist/server/dev-server.mjs +36 -13
- package/dist/server/file-errors.d.mts +7 -2
- package/dist/server/file-errors.mjs +31 -8
- package/dist/server/file-lock.d.mts +2 -2
- package/dist/server/file-lock.mjs +130 -36
- package/dist/server/mcp.d.mts +0 -2
- package/dist/server/mcp.mjs +7 -8
- package/dist/server/me.d.mts +1 -1
- package/dist/server/open-page.d.mts +22 -0
- package/dist/server/open-page.mjs +20 -2
- package/dist/server/outcome.d.mts +22 -0
- package/dist/server/outcome.mjs +8 -0
- package/dist/server/own-copies.mjs +2 -2
- package/dist/server/people.d.mts +1 -1
- package/dist/server/port.d.mts +12 -0
- package/dist/server/port.mjs +66 -14
- package/dist/server/presence.d.mts +4 -1
- package/dist/server/presence.mjs +2 -2
- package/dist/server/requests.d.mts +5 -1
- package/dist/server/requests.mjs +32 -47
- package/dist/server/studio-for.d.mts +5 -0
- package/dist/server/studio-for.mjs +18 -4
- package/dist/server/sync-install.d.mts +8 -12
- package/dist/server/sync-install.mjs +12 -30
- package/dist/server/thread-source.mjs +2 -2
- package/dist/server/tools/describe.d.mts +1 -1
- package/dist/server/tools/describe.mjs +1 -1
- package/dist/server/tools/feedback.d.mts +1 -1
- package/dist/server/tools/reading.mjs +13 -4
- package/dist/server/tools/show.d.mts +1 -1
- package/dist/server/tools/snapshot.d.mts +1 -1
- package/dist/server/tools/thread-list.mjs +1 -1
- package/dist/server/tools/watch.mjs +5 -3
- package/dist/server/vite.mjs +28 -31
- package/dist/server/web-app.mjs +7 -10
- package/dist/server/work-groups.mjs +1 -1
- package/dist/setup/apply.mjs +8 -14
- package/dist/setup/create.d.mts +4 -2
- package/dist/setup/create.mjs +118 -36
- package/dist/setup/design-system-checks.mjs +3 -12
- package/dist/setup/desktop-app-script.mjs +4 -3
- package/dist/setup/desktop-app-start.d.mts +8 -2
- package/dist/setup/desktop-app-start.mjs +64 -29
- package/dist/setup/desktop-app.d.mts +8 -0
- package/dist/setup/desktop-app.mjs +20 -4
- package/dist/setup/detect.d.mts +14 -7
- package/dist/setup/detect.mjs +56 -10
- package/dist/setup/doctor.mjs +2 -4
- package/dist/setup/existing-setup.d.mts +1 -3
- package/dist/setup/existing-setup.mjs +10 -11
- package/dist/setup/migrate/row-titles.mjs +1 -1
- package/dist/setup/own-app.d.mts +1 -2
- package/dist/setup/own-app.mjs +4 -5
- package/dist/setup/plan.d.mts +8 -6
- package/dist/setup/plan.mjs +64 -48
- package/dist/setup/project.d.mts +6 -17
- package/dist/setup/project.mjs +17 -61
- package/dist/setup/prompts.d.mts +5 -5
- package/dist/setup/prompts.mjs +28 -61
- package/dist/setup/questions.d.mts +12 -4
- package/dist/setup/questions.mjs +10 -25
- package/dist/setup/starters.d.mts +2 -0
- package/dist/setup/starters.mjs +26 -9
- package/dist/setup/workspace-setup.d.mts +1 -2
- package/dist/setup/workspace-setup.mjs +4 -6
- package/dist/setup/write.d.mts +15 -5
- package/dist/setup/write.mjs +35 -9
- package/dist/shared/annotations-core.mjs +1 -1
- package/dist/shared/canvas-core.mjs +1 -1
- package/dist/shared/canvas-file.d.mts +201 -0
- package/dist/shared/canvas-file.mjs +1 -0
- package/dist/shared/comments/routes.d.mts +53 -0
- package/dist/shared/comments/routes.mjs +37 -0
- package/dist/shared/feedback.d.mts +8 -0
- package/dist/shared/feedback.mjs +10 -2
- package/dist/shared/page-review.d.mts +2 -11
- package/dist/shared/page-review.mjs +4 -13
- package/dist/shared/presence-core.d.mts +11 -0
- package/dist/shared/presence-core.mjs +11 -2
- package/dist/shared/review-file.d.mts +5 -0
- package/dist/shared/review-file.mjs +23 -13
- package/dist/shared/server-page.mjs +7 -1
- package/dist/shared/signup.d.mts +2 -5
- package/dist/shared/signup.mjs +2 -35
- package/dist/shared/studio-events.d.mts +0 -6
- package/dist/shared/studio-events.mjs +1 -5
- package/dist/shared/studio-files.d.mts +12 -0
- package/dist/shared/studio-files.mjs +6 -1
- package/dist/shared/studio-routes.d.mts +16 -62
- package/dist/shared/studio-routes.mjs +1 -69
- package/dist/shared/threads-core.d.mts +2 -2
- package/dist/shared/threads-core.mjs +1 -1
- package/extension/dist/feedback.js +148 -138
- package/extension/dist/manifest.json +1 -1
- package/extension/dist/picker.js +146 -136
- package/package.json +3 -20
- package/src/cli/banner.ts +45 -11
- package/src/cli/commands/app.ts +23 -8
- package/src/cli/commands/create.ts +17 -9
- package/src/cli/commands/dev.ts +0 -3
- package/src/cli/commands/hook.ts +4 -1
- package/src/cli/help.ts +3 -3
- package/src/config/index.ts +6 -5
- package/src/config/project-files.ts +21 -11
- package/src/config/renamed.ts +0 -3
- package/src/config/schema.ts +0 -1
- package/src/content/capture.ts +6 -12
- package/src/content/content.ts +7 -244
- package/src/content/flow-specs.ts +2 -1
- package/src/content/prototype-summary.ts +4 -44
- package/src/content/review-pages.ts +2 -1
- package/src/content/snapshot-client.ts +1 -1
- package/src/content/text-replace.ts +449 -0
- package/src/paths.ts +0 -8
- package/src/server/agent-env.ts +12 -2
- package/src/server/agent-session.ts +124 -34
- package/src/server/brief.ts +8 -3
- package/src/server/channel.ts +121 -52
- package/src/server/claimed-presence.ts +93 -0
- package/src/server/comments/actions.ts +352 -0
- package/src/server/comments/routes.ts +176 -0
- package/src/server/comments/tools.ts +317 -0
- package/src/server/dev-server.ts +49 -15
- package/src/server/file-errors.ts +47 -13
- package/src/server/file-lock.ts +205 -54
- package/src/server/mcp.ts +13 -14
- package/src/server/me.ts +2 -5
- package/src/server/open-page.ts +54 -4
- package/src/server/outcome.ts +26 -0
- package/src/server/people.ts +2 -1
- package/src/server/port.ts +94 -20
- package/src/server/presence.ts +11 -3
- package/src/server/requests.ts +60 -70
- package/src/server/studio-for.ts +27 -3
- package/src/server/sync-install.ts +35 -26
- package/src/server/thread-place.ts +2 -4
- package/src/server/tools/reading.ts +16 -3
- package/src/server/tools/watch.ts +7 -7
- package/src/server/vite.ts +37 -40
- package/src/server/web-app.ts +14 -12
- package/src/setup/apply.ts +10 -16
- package/src/setup/create.ts +143 -37
- package/src/setup/design-system-checks.ts +7 -15
- package/src/setup/desktop-app-script.ts +4 -3
- package/src/setup/desktop-app-start.ts +94 -26
- package/src/setup/desktop-app.ts +24 -3
- package/src/setup/detect.ts +56 -14
- package/src/setup/doctor.ts +4 -4
- package/src/setup/existing-setup.ts +10 -12
- package/src/setup/own-app.ts +2 -5
- package/src/setup/plan.ts +93 -84
- package/src/setup/project.ts +25 -118
- package/src/setup/prompts.ts +44 -127
- package/src/setup/questions.ts +27 -29
- package/src/setup/starters.ts +35 -10
- package/src/setup/workspace-setup.ts +8 -18
- package/src/setup/write.ts +52 -9
- package/src/shared/canvas-file.ts +205 -0
- package/src/shared/comments/routes.ts +79 -0
- package/src/shared/feedback.ts +14 -4
- package/src/shared/page-review.ts +11 -16
- package/src/shared/presence-core.ts +16 -2
- package/src/shared/review-file.ts +28 -12
- package/src/shared/server-page.ts +11 -1
- package/src/shared/signup.ts +4 -28
- package/src/shared/studio-events.ts +0 -13
- package/src/shared/studio-files.ts +14 -0
- package/src/shared/studio-routes.ts +21 -64
- package/src/shared/threads-core.ts +2 -2
- package/templates/methods/review.md +2 -2
- package/templates/rules/canvas-frames.md +104 -0
- package/templates/rules/canvas.md +8 -142
- package/templates/rules/prototypes.md +1 -1
- package/templates/rules/snapshots.md +52 -0
- package/templates/starters/standalone/README.md +7 -7
- package/templates/starters/standalone/components.json +1 -1
- package/templates/starters/standalone/package.json +1 -2
- package/templates/starters/turborepo/README.md +6 -6
- package/templates/starters/turborepo/apps/web/components.json +1 -1
- package/templates/starters/turborepo/apps/web/package.json +1 -2
- package/templates/starters/turborepo/apps/web/src/app.tsx +4 -5
- package/templates/starters/turborepo/packages/ui/components.json +1 -1
- package/templates/starters/turborepo/packages/ui/package.json +1 -2
- package/templates/starters/vite/README.md +7 -6
- package/templates/starters/vite/components.json +1 -1
- package/templates/starters/vite/package.json +1 -2
- package/templates/starters/vite/src/app.tsx +3 -4
- package/templates/starters/vite/src/components/ui/accordion.tsx +71 -0
- package/templates/starters/vite/src/components/ui/attachment.tsx +1 -1
- package/templates/starters/vite/src/components/ui/badge.tsx +2 -2
- package/templates/starters/vite/src/components/ui/button.tsx +17 -12
- package/templates/starters/vite/src/components/ui/card.tsx +1 -1
- package/templates/starters/vite/src/components/ui/checkbox.tsx +28 -0
- package/templates/starters/vite/src/components/ui/dialog.tsx +5 -5
- package/templates/starters/vite/src/components/ui/dropdown-menu.tsx +17 -14
- package/templates/starters/vite/src/components/ui/field.tsx +3 -1
- package/templates/starters/vite/src/components/ui/input-group.tsx +5 -3
- package/templates/starters/vite/src/components/ui/input.tsx +1 -1
- package/templates/starters/vite/src/components/ui/label.tsx +2 -0
- package/templates/starters/vite/src/components/ui/native-select.tsx +3 -4
- package/templates/starters/vite/src/components/ui/popover.tsx +1 -1
- package/templates/starters/vite/src/components/ui/separator.tsx +2 -0
- package/templates/starters/vite/src/components/ui/spinner.tsx +3 -7
- package/templates/starters/vite/src/components/ui/switch.tsx +1 -1
- package/templates/starters/vite/src/components/ui/textarea.tsx +1 -1
- package/templates/starters/vite/src/components/ui/toggle.tsx +4 -2
- package/templates/starters/vite/src/index.css +533 -111
- package/app/icons/sets/hugeicons.tsx +0 -259
- package/app/icons/sets/phosphor.tsx +0 -251
- package/dist/server/icon-set.d.mts +0 -15
- package/dist/server/icon-set.mjs +0 -31
- package/dist/server/tools/close-reply.d.mts +0 -6
- package/dist/server/tools/close-reply.mjs +0 -138
- package/dist/server/tools/comment.d.mts +0 -6
- package/dist/server/tools/comment.mjs +0 -49
- package/dist/shared/icon-sets.d.mts +0 -9
- package/dist/shared/icon-sets.mjs +0 -21
- package/src/server/icon-set.ts +0 -56
- package/src/server/tools/close-reply.ts +0 -271
- package/src/server/tools/comment.ts +0 -96
- package/src/shared/icon-sets.ts +0 -23
- /package/app/public/{sudio-192.png → dex-192.png} +0 -0
- /package/app/public/{sudio-512.png → dex-512.png} +0 -0
- /package/app/public/{apple-touch-icon.png → dex-apple-touch-icon.png} +0 -0
- /package/app/public/{favicon-32.png → dex-icon-32.png} +0 -0
- /package/app/public/{favicon.svg → dex-icon.svg} +0 -0
- /package/app/public/{sudio-maskable-512.png → dex-maskable-512.png} +0 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { matcherOf, matchesIn } from "./page-find.ts";
|
|
2
|
+
|
|
3
|
+
// Find on the canvas, apart from any page: the matches of the words on each
|
|
4
|
+
// frame, in the canvas's order, the one that is current, and the words
|
|
5
|
+
// around each for the list. A frame's texts are what its page showed when it
|
|
6
|
+
// was last on the canvas, so a frame scrolled off still counts.
|
|
7
|
+
|
|
8
|
+
/** Most matches counted; past it the count says there are more. */
|
|
9
|
+
export const MOST_HITS = 1000;
|
|
10
|
+
|
|
11
|
+
/** A frame's texts, as its page showed them, in the page's order. */
|
|
12
|
+
export interface FrameTexts {
|
|
13
|
+
key: string;
|
|
14
|
+
texts: readonly string[];
|
|
15
|
+
title: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** One match: on which frame, which of its matches, and the text it is in. */
|
|
19
|
+
export interface Hit {
|
|
20
|
+
frame: string;
|
|
21
|
+
/** Its place among the frame's matches, from 0. */
|
|
22
|
+
index: number;
|
|
23
|
+
/** Where in its text the match starts. */
|
|
24
|
+
start: number;
|
|
25
|
+
text: string;
|
|
26
|
+
title: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface Found {
|
|
30
|
+
hits: Hit[];
|
|
31
|
+
/** More matched than MOST_HITS: only that many are counted. */
|
|
32
|
+
more: boolean;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Each frame's texts as one, made once for each list of them. */
|
|
36
|
+
const wholes = new WeakMap<readonly string[], string>();
|
|
37
|
+
const wholeOf = (texts: readonly string[]) => {
|
|
38
|
+
let whole = wholes.get(texts);
|
|
39
|
+
if (whole === undefined) {
|
|
40
|
+
// A line between texts, so no match runs from one into the next.
|
|
41
|
+
whole = texts.join("\n");
|
|
42
|
+
wholes.set(texts, whole);
|
|
43
|
+
}
|
|
44
|
+
return whole;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/** Every match of `query` on the frames, in the frames' order. */
|
|
48
|
+
export const findOnFrames = (
|
|
49
|
+
frames: readonly FrameTexts[],
|
|
50
|
+
query: string
|
|
51
|
+
): Found => {
|
|
52
|
+
const hits: Hit[] = [];
|
|
53
|
+
if (!query.trim()) {
|
|
54
|
+
return { hits, more: false };
|
|
55
|
+
}
|
|
56
|
+
for (const { key, texts, title } of frames) {
|
|
57
|
+
// Most frames hold none of the words: one look at all of it says so.
|
|
58
|
+
if (!matcherOf(query).test(wholeOf(texts))) {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
let index = 0;
|
|
62
|
+
for (const text of texts) {
|
|
63
|
+
for (const start of matchesIn(text, query)) {
|
|
64
|
+
if (hits.length >= MOST_HITS) {
|
|
65
|
+
return { hits, more: true };
|
|
66
|
+
}
|
|
67
|
+
hits.push({ frame: key, index, start, text, title });
|
|
68
|
+
index += 1;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return { hits, more: false };
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/** The match `by` steps from `current`, round from the last to the first. */
|
|
76
|
+
export const stepHit = (current: number, by: 1 | -1, count: number) =>
|
|
77
|
+
count === 0 ? 0 : (current + by + count) % count;
|
|
78
|
+
|
|
79
|
+
/** The matches grouped by frame, in order, each with its place in `hits`. */
|
|
80
|
+
export const hitsByFrame = (hits: readonly Hit[]) => {
|
|
81
|
+
const groups: {
|
|
82
|
+
frame: string;
|
|
83
|
+
hits: { at: number; hit: Hit }[];
|
|
84
|
+
title: string;
|
|
85
|
+
}[] = [];
|
|
86
|
+
hits.forEach((hit, at) => {
|
|
87
|
+
const last = groups.at(-1);
|
|
88
|
+
if (last?.frame === hit.frame) {
|
|
89
|
+
last.hits.push({ at, hit });
|
|
90
|
+
} else {
|
|
91
|
+
groups.push({ frame: hit.frame, hits: [{ at, hit }], title: hit.title });
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
return groups;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/** Words either side of a match in the list, at most. */
|
|
98
|
+
const AROUND = 28;
|
|
99
|
+
const SPACES_RE = /\s+/g;
|
|
100
|
+
|
|
101
|
+
/** A match with the words around it, cut to fit a row of the list. */
|
|
102
|
+
export const snippet = (hit: Hit, length: number) => {
|
|
103
|
+
const from = Math.max(0, hit.start - AROUND);
|
|
104
|
+
const to = Math.min(hit.text.length, hit.start + length + AROUND);
|
|
105
|
+
const tidy = (text: string) => text.replace(SPACES_RE, " ");
|
|
106
|
+
return {
|
|
107
|
+
after:
|
|
108
|
+
tidy(hit.text.slice(hit.start + length, to)) +
|
|
109
|
+
(to < hit.text.length ? "…" : ""),
|
|
110
|
+
before:
|
|
111
|
+
(from > 0 ? "…" : "") + tidy(hit.text.slice(from, hit.start)).trimStart(),
|
|
112
|
+
match: hit.text.slice(hit.start, hit.start + length),
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* The texts a Replace all sends: each on a frame that holds `query`, once,
|
|
118
|
+
* however many matches there are, so the code only changes where the
|
|
119
|
+
* frames showed the words.
|
|
120
|
+
*/
|
|
121
|
+
export const seenTexts = (
|
|
122
|
+
frames: readonly { key: string }[],
|
|
123
|
+
texts: ReadonlyMap<string, readonly string[]>,
|
|
124
|
+
query: string
|
|
125
|
+
) => {
|
|
126
|
+
const seen = new Set<string>();
|
|
127
|
+
for (const { key } of frames) {
|
|
128
|
+
for (const text of texts.get(key) ?? []) {
|
|
129
|
+
if (matchesIn(text, query).length > 0) {
|
|
130
|
+
seen.add(text);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return [...seen];
|
|
135
|
+
};
|
|
@@ -49,7 +49,7 @@ import { FrameNode, settle } from "./frame-node";
|
|
|
49
49
|
import { setPicturesZoom, useCanvasPictures } from "./frame-pictures";
|
|
50
50
|
import { frameSource } from "./frame-source";
|
|
51
51
|
import { InsertHint } from "./insert-hint";
|
|
52
|
-
import type
|
|
52
|
+
import { type Box, type DropMark, type Gap, sectionNamesZoom } from "./layout";
|
|
53
53
|
import { usePlaceNote } from "./note-placing";
|
|
54
54
|
import { RowNode } from "./row-node";
|
|
55
55
|
import { useCanvasScene } from "./scene-context";
|
|
@@ -61,10 +61,15 @@ import { storedViewport, storeViewport } from "./stored-viewport";
|
|
|
61
61
|
import { surfaceCursor } from "./tool-cursors";
|
|
62
62
|
import { useSpecCopiesApart } from "./use-spec-copies";
|
|
63
63
|
|
|
64
|
-
/**
|
|
64
|
+
/**
|
|
65
|
+
* Below this zoom frame names hide; section names carry the canvas, until
|
|
66
|
+
* they hide too (sectionNamesZoom).
|
|
67
|
+
*/
|
|
65
68
|
const FAR_ZOOM = 0.15;
|
|
66
69
|
/** Below this, row names would reach into the section above, so they go. */
|
|
67
70
|
const SMALL_ZOOM = 0.35;
|
|
71
|
+
/** A root font's size when the page can't say. */
|
|
72
|
+
const DEFAULT_REM_PX = 16;
|
|
68
73
|
/**
|
|
69
74
|
* How far the zoom moves, as a log ratio, before labels follow it mid-move:
|
|
70
75
|
* 2%, less than a label's edge can show.
|
|
@@ -394,6 +399,9 @@ export const FlowCanvas = ({
|
|
|
394
399
|
// every one of them restyles when it changes. A pan leaves it as it was;
|
|
395
400
|
// a pinch moves it in steps too small to see, and exactly once it ends.
|
|
396
401
|
const zoomShown = useRef<number>(undefined);
|
|
402
|
+
// Section names are sized in rem, so the zoom they hide below follows the
|
|
403
|
+
// root font: read once, as the canvas first shows.
|
|
404
|
+
const namesZoom = useRef<number>(undefined);
|
|
397
405
|
const setZoom = useCallback((zoom: number, exact: boolean) => {
|
|
398
406
|
const element = surface.current;
|
|
399
407
|
const shown = zoomShown.current;
|
|
@@ -403,10 +411,18 @@ export const FlowCanvas = ({
|
|
|
403
411
|
return;
|
|
404
412
|
}
|
|
405
413
|
zoomShown.current = zoom;
|
|
414
|
+
namesZoom.current ??= sectionNamesZoom(
|
|
415
|
+
Number.parseFloat(getComputedStyle(document.documentElement).fontSize) ||
|
|
416
|
+
DEFAULT_REM_PX
|
|
417
|
+
);
|
|
406
418
|
element.setAttribute("data-pictures", String(setPicturesZoom(zoom)));
|
|
407
419
|
element.style.setProperty("--zoom", String(zoom));
|
|
408
420
|
element.setAttribute("data-far", String(zoom < FAR_ZOOM));
|
|
409
421
|
element.setAttribute("data-small", String(zoom < SMALL_ZOOM));
|
|
422
|
+
element.setAttribute(
|
|
423
|
+
"data-section-names",
|
|
424
|
+
String(zoom >= namesZoom.current)
|
|
425
|
+
);
|
|
410
426
|
}, []);
|
|
411
427
|
useEffect(() => {
|
|
412
428
|
setZoom(view.getZoom(), true);
|
package/app/canvas/follow-pin.ts
CHANGED
|
@@ -16,34 +16,54 @@ export const anchorElement = (anchor: string): Element | null => {
|
|
|
16
16
|
return page ? page.querySelector(anchor) : (last ?? null);
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
+
type Place = (pin: DOMRect, floating: HTMLElement) => ScreenPoint;
|
|
20
|
+
|
|
19
21
|
/**
|
|
20
22
|
* Keeps something floating hung from its pin, as a selector, wherever `place`
|
|
21
23
|
* puts it from the pin's box. Pans, zooms and a frame laid out again all
|
|
22
24
|
* move the pin, the canvas's camera only some of them and Play's page none,
|
|
23
25
|
* so it asks where its pin is each frame, and moves itself without
|
|
24
|
-
* rendering. No pin, and it stays where it
|
|
26
|
+
* rendering. No pin, and it hangs from `orElse`, if given, or stays where it
|
|
27
|
+
* was put. `onFound` runs when it first finds its pin.
|
|
25
28
|
*/
|
|
26
29
|
export const useFollowPin = (
|
|
27
30
|
ref: RefObject<HTMLElement | null>,
|
|
28
31
|
anchor: string | undefined,
|
|
29
|
-
place:
|
|
32
|
+
place: Place,
|
|
33
|
+
{
|
|
34
|
+
onFound,
|
|
35
|
+
orElse,
|
|
36
|
+
}: { onFound?: () => void; orElse?: { anchor: string; place: Place } } = {}
|
|
30
37
|
) => {
|
|
38
|
+
const elseAnchor = orElse?.anchor;
|
|
39
|
+
const elsePlace = orElse?.place;
|
|
31
40
|
useLayoutEffect(() => {
|
|
32
41
|
if (!anchor) {
|
|
33
42
|
return;
|
|
34
43
|
}
|
|
35
44
|
let frame = 0;
|
|
45
|
+
let found = false;
|
|
46
|
+
const moveTo = (floating: HTMLElement, { left, top }: ScreenPoint) => {
|
|
47
|
+
floating.style.left = `${left}px`;
|
|
48
|
+
floating.style.top = `${top}px`;
|
|
49
|
+
};
|
|
36
50
|
const follow = () => {
|
|
37
51
|
const floating = ref.current;
|
|
38
52
|
const pin = anchorElement(anchor);
|
|
53
|
+
const fallback =
|
|
54
|
+
pin || !elseAnchor ? null : document.querySelector(elseAnchor);
|
|
39
55
|
if (floating && pin) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
56
|
+
moveTo(floating, place(pin.getBoundingClientRect(), floating));
|
|
57
|
+
if (!found) {
|
|
58
|
+
found = true;
|
|
59
|
+
onFound?.();
|
|
60
|
+
}
|
|
61
|
+
} else if (floating && fallback && elsePlace) {
|
|
62
|
+
moveTo(floating, elsePlace(fallback.getBoundingClientRect(), floating));
|
|
43
63
|
}
|
|
44
64
|
frame = window.requestAnimationFrame(follow);
|
|
45
65
|
};
|
|
46
66
|
follow();
|
|
47
67
|
return () => window.cancelAnimationFrame(frame);
|
|
48
|
-
}, [anchor, place, ref]);
|
|
68
|
+
}, [anchor, elseAnchor, elsePlace, onFound, place, ref]);
|
|
49
69
|
};
|
|
@@ -57,7 +57,7 @@ import {
|
|
|
57
57
|
threadsOn,
|
|
58
58
|
} from "./anchoring";
|
|
59
59
|
import { type CanvasContextValue, useCanvas } from "./canvas-context";
|
|
60
|
-
import { keepPageWheel } from "./canvas-input";
|
|
60
|
+
import { keepPageWheel, takeKeyboardFrom } from "./canvas-input";
|
|
61
61
|
import { AddBeside } from "./canvas-menus";
|
|
62
62
|
import {
|
|
63
63
|
type FrameAddress,
|
|
@@ -75,7 +75,7 @@ import {
|
|
|
75
75
|
} from "./canvas-ui";
|
|
76
76
|
import { AgentPin } from "./change-notice";
|
|
77
77
|
import { CommentLayer } from "./comment-layer";
|
|
78
|
-
import { DraftPin, Pin, usePinFilter } from "./comments";
|
|
78
|
+
import { cardPoint, DraftPin, Pin, usePinFilter } from "./comments";
|
|
79
79
|
import { DevicePicker } from "./device-picker";
|
|
80
80
|
import { EditableText } from "./editable-text";
|
|
81
81
|
import { frameControls } from "./frame-context-menu";
|
|
@@ -121,7 +121,6 @@ import { useSpecMarks } from "./spec-threads";
|
|
|
121
121
|
import { useStateOf } from "./state-store";
|
|
122
122
|
import { StylesLayer } from "./styles-layer";
|
|
123
123
|
import { TextLayer } from "./text-layer";
|
|
124
|
-
import { cardPoint } from "./thread-focus";
|
|
125
124
|
import { Tip, TipGroup } from "./tip";
|
|
126
125
|
import { UnknownFrame } from "./unknown-frame";
|
|
127
126
|
import { useAgentChangesOf } from "./use-agent-changes";
|
|
@@ -404,13 +403,14 @@ const FramePins = ({
|
|
|
404
403
|
const { editor, openThread, showResolved, threads } = useCanvas();
|
|
405
404
|
const activeThread = useCanvasUi(activeThreadOf);
|
|
406
405
|
const draft = useCanvasUi((state) => draftOn(state, key));
|
|
407
|
-
const
|
|
408
|
-
|
|
409
|
-
);
|
|
406
|
+
const shown = usePinFilter(showResolved, activeThread);
|
|
407
|
+
const pins = threadsOn(threads.threads, editor.canvas, key).filter(shown);
|
|
410
408
|
// Where agents' changes landed on this frame: unseen, or just gone to.
|
|
409
|
+
// Each shows where its comment's pin would.
|
|
411
410
|
const changes = useAgentChangesOf();
|
|
412
411
|
const landed = threads.threads.flatMap((thread) => {
|
|
413
|
-
|
|
412
|
+
const ticked = Boolean(changes?.pinned.has(thread.id)) && shown(thread);
|
|
413
|
+
if (!ticked) {
|
|
414
414
|
return [];
|
|
415
415
|
}
|
|
416
416
|
const placed = landedOn(thread, editor.canvas);
|
|
@@ -817,6 +817,9 @@ const FrameReset = ({ onReset }: { onReset: () => void }) => {
|
|
|
817
817
|
);
|
|
818
818
|
};
|
|
819
819
|
|
|
820
|
+
/** Each of Pick's words, laid over the others in the one grid cell. */
|
|
821
|
+
const PICK_WORD = "col-start-1 row-start-1";
|
|
822
|
+
|
|
820
823
|
/**
|
|
821
824
|
* Pick: shown when you reach for the frame, until it is picked; then
|
|
822
825
|
* "Picked" for good, which offers to unpick on hover. Yours alone: nobody
|
|
@@ -844,18 +847,30 @@ const PickToggle = ({
|
|
|
844
847
|
shown={picked}
|
|
845
848
|
>
|
|
846
849
|
<Icon className="size-3" name="Check" />
|
|
847
|
-
{
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
</
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
850
|
+
{/* Its three words share one place, as wide as the widest, so Pick
|
|
851
|
+
never changes width and the actions before it never move. */}
|
|
852
|
+
<span className="grid">
|
|
853
|
+
<span className={cn(PICK_WORD, picked && "invisible")}>
|
|
854
|
+
<Trans>Pick</Trans>
|
|
855
|
+
</span>
|
|
856
|
+
<span
|
|
857
|
+
className={cn(
|
|
858
|
+
PICK_WORD,
|
|
859
|
+
picked ? "group-hover/pick:invisible" : "invisible"
|
|
860
|
+
)}
|
|
861
|
+
>
|
|
862
|
+
<Trans>Picked</Trans>
|
|
863
|
+
</span>
|
|
864
|
+
<span
|
|
865
|
+
className={cn(
|
|
866
|
+
PICK_WORD,
|
|
867
|
+
"invisible",
|
|
868
|
+
picked && "group-hover/pick:visible"
|
|
869
|
+
)}
|
|
870
|
+
>
|
|
871
|
+
<Trans>Unpick</Trans>
|
|
872
|
+
</span>
|
|
873
|
+
</span>
|
|
859
874
|
</LabelAction>
|
|
860
875
|
);
|
|
861
876
|
};
|
|
@@ -910,7 +925,7 @@ const FrameLabel = ({
|
|
|
910
925
|
live: boolean;
|
|
911
926
|
/** Puts back a page that was used live; Reset shows while there is one. */
|
|
912
927
|
onReset?: () => void;
|
|
913
|
-
/** Whether Play shows (
|
|
928
|
+
/** Whether Play shows: for a step of a section, always (playsFrom). */
|
|
914
929
|
playable: boolean;
|
|
915
930
|
/**
|
|
916
931
|
* A slide's: a band, as a spec's, joined to the edge round the slide, so a
|
|
@@ -984,9 +999,11 @@ const FrameLabel = ({
|
|
|
984
999
|
);
|
|
985
1000
|
};
|
|
986
1001
|
|
|
987
|
-
/**
|
|
988
|
-
|
|
989
|
-
|
|
1002
|
+
/**
|
|
1003
|
+
* A step of a section plays from its label, whether or not it is used live or
|
|
1004
|
+
* resized: Play never comes and goes, so the label's actions keep their places.
|
|
1005
|
+
*/
|
|
1006
|
+
const playsFrom = (frame: Frame) => stepFrame(frame) !== undefined;
|
|
990
1007
|
|
|
991
1008
|
/** A frame's size shows under it while selected, live or resized. */
|
|
992
1009
|
const showsSize = (selected: boolean, draft: Size | undefined, live: boolean) =>
|
|
@@ -1334,8 +1351,8 @@ export const FrameNode = memo(
|
|
|
1334
1351
|
const changesOutlined = Boolean(useAgentChangesOf()?.outlined.has(key));
|
|
1335
1352
|
// A frame left behind takes the keyboard with it back to the canvas.
|
|
1336
1353
|
useEffect(() => {
|
|
1337
|
-
if (!live && iframe
|
|
1338
|
-
iframe
|
|
1354
|
+
if (!live && iframe) {
|
|
1355
|
+
takeKeyboardFrom(iframe);
|
|
1339
1356
|
}
|
|
1340
1357
|
}, [iframe, live]);
|
|
1341
1358
|
const view = viewOf(frame);
|
|
@@ -1429,7 +1446,7 @@ export const FrameNode = memo(
|
|
|
1429
1446
|
by={by}
|
|
1430
1447
|
live={live}
|
|
1431
1448
|
onReset={onReset}
|
|
1432
|
-
playable={
|
|
1449
|
+
playable={playsFrom(frame)}
|
|
1433
1450
|
selected={Boolean(selected)}
|
|
1434
1451
|
slide={slide}
|
|
1435
1452
|
source={source}
|
|
@@ -11,6 +11,7 @@ import type { I18n } from "@lingui/core";
|
|
|
11
11
|
import { msg } from "@lingui/core/macro";
|
|
12
12
|
import { Plural, Trans, useLingui } from "@lingui/react/macro";
|
|
13
13
|
import { Icon } from "@studio/icons";
|
|
14
|
+
import { useFileDrop } from "@studio/ui/file-drop";
|
|
14
15
|
import { Segmented } from "@studio/ui/segmented";
|
|
15
16
|
import { Button } from "@studio/ui/shadcn/button";
|
|
16
17
|
import {
|
|
@@ -32,13 +33,7 @@ import {
|
|
|
32
33
|
InputGroupInput,
|
|
33
34
|
} from "@studio/ui/shadcn/input-group";
|
|
34
35
|
import { cn } from "cn";
|
|
35
|
-
import {
|
|
36
|
-
type DragEvent,
|
|
37
|
-
type ReactNode,
|
|
38
|
-
useEffect,
|
|
39
|
-
useRef,
|
|
40
|
-
useState,
|
|
41
|
-
} from "react";
|
|
36
|
+
import { type ReactNode, useEffect, useRef, useState } from "react";
|
|
42
37
|
import {
|
|
43
38
|
isPageReview,
|
|
44
39
|
isZip,
|
|
@@ -654,13 +649,10 @@ const ImportReviewsDialog = ({
|
|
|
654
649
|
const [picked, setPicked] = useState<Picked[]>([]);
|
|
655
650
|
const [sending, setSending] = useState(false);
|
|
656
651
|
const [problem, setProblem] = useState<string>();
|
|
657
|
-
const add = async (files:
|
|
658
|
-
if (!files) {
|
|
659
|
-
return;
|
|
660
|
-
}
|
|
652
|
+
const add = async (files: File[]) => {
|
|
661
653
|
const prototype = canvas?.prototype.slug ?? "";
|
|
662
654
|
const read = await Promise.all(
|
|
663
|
-
|
|
655
|
+
files.map((file) => readPicked(file, i18n, prototype))
|
|
664
656
|
);
|
|
665
657
|
// A review picked twice is one row.
|
|
666
658
|
setPicked((current) => {
|
|
@@ -687,10 +679,8 @@ const ImportReviewsDialog = ({
|
|
|
687
679
|
(each) => each.review && !isReviewIn(threads, each.review)
|
|
688
680
|
);
|
|
689
681
|
const count = fresh.length;
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
add(event.dataTransfer.files);
|
|
693
|
-
};
|
|
682
|
+
// Files dropped anywhere on the dialog are picked, as on its drop box.
|
|
683
|
+
const { over, zone } = useFileDrop(add);
|
|
694
684
|
const send = async () => {
|
|
695
685
|
if (!canvas || fresh.length === 0) {
|
|
696
686
|
return;
|
|
@@ -722,18 +712,18 @@ const ImportReviewsDialog = ({
|
|
|
722
712
|
};
|
|
723
713
|
return (
|
|
724
714
|
<Dialog onOpenChange={close} open={open}>
|
|
725
|
-
<DialogContent className="sm:max-w-md">
|
|
715
|
+
<DialogContent className="sm:max-w-md" {...zone}>
|
|
726
716
|
<DialogHeader>
|
|
727
717
|
<DialogTitle>
|
|
728
718
|
<Trans>Import reviews</Trans>
|
|
729
719
|
</DialogTitle>
|
|
730
720
|
</DialogHeader>
|
|
731
|
-
{/* biome-ignore lint/a11y/noNoninteractiveElementInteractions: dropping files is the mouse's way in; Choose files is the keyboard's */}
|
|
732
721
|
<section
|
|
733
722
|
aria-label={t`Review files`}
|
|
734
|
-
className=
|
|
735
|
-
|
|
736
|
-
|
|
723
|
+
className={cn(
|
|
724
|
+
"flex items-center justify-between gap-3 rounded-lg border border-dashed px-3 py-2.5 text-muted-foreground transition-colors",
|
|
725
|
+
over && "border-ring bg-muted/50"
|
|
726
|
+
)}
|
|
737
727
|
>
|
|
738
728
|
<Trans>Drop reviews’ .json or .zip files here</Trans>
|
|
739
729
|
<Button
|
|
@@ -749,7 +739,7 @@ const ImportReviewsDialog = ({
|
|
|
749
739
|
className="sr-only"
|
|
750
740
|
multiple
|
|
751
741
|
onChange={(event) => {
|
|
752
|
-
add(event.target.files);
|
|
742
|
+
add([...(event.target.files ?? [])]);
|
|
753
743
|
event.target.value = "";
|
|
754
744
|
}}
|
|
755
745
|
ref={input}
|
package/app/canvas/layout.ts
CHANGED
|
@@ -44,6 +44,33 @@ export const ROW_GAP = 200;
|
|
|
44
44
|
export const STACK_GAP = COLUMN_GAP;
|
|
45
45
|
export const SECTION_GAP = 360;
|
|
46
46
|
export const SECTION_PADDING = 96;
|
|
47
|
+
/**
|
|
48
|
+
* How tall a section's name is on screen at any zoom, in rem: a line of
|
|
49
|
+
* small text and the space under it (section-node's handle).
|
|
50
|
+
*/
|
|
51
|
+
export const SECTION_NAME_REMS = 1.625;
|
|
52
|
+
/**
|
|
53
|
+
* How far past a frame or a section its resize handles reach on screen, at
|
|
54
|
+
* any zoom: the corner's, the furthest (canvas.css,
|
|
55
|
+
* .studio-resize[data-edge="corner"]).
|
|
56
|
+
*/
|
|
57
|
+
export const RESIZE_REACH = 6;
|
|
58
|
+
/**
|
|
59
|
+
* The least zoom section names show at, with a root font this many pixels
|
|
60
|
+
* tall. A name sits above its section, as tall on screen at any zoom, so in
|
|
61
|
+
* the canvas it reaches its height over the zoom up into the gap. Any further
|
|
62
|
+
* out it would reach into the section above, or, with a small root font,
|
|
63
|
+
* meet the resize handles reaching down from its frames, which would take a
|
|
64
|
+
* press on it. The section above's own handles reach under the name a little
|
|
65
|
+
* sooner, but the name is drawn over them: the section below comes later.
|
|
66
|
+
*/
|
|
67
|
+
export const sectionNamesZoom = (remPx: number) => {
|
|
68
|
+
const name = SECTION_NAME_REMS * remPx;
|
|
69
|
+
return Math.max(
|
|
70
|
+
name / SECTION_GAP,
|
|
71
|
+
(name + RESIZE_REACH) / (SECTION_GAP + SECTION_PADDING)
|
|
72
|
+
);
|
|
73
|
+
};
|
|
47
74
|
|
|
48
75
|
/**
|
|
49
76
|
* The area a section of this size shows: a column's gap narrower, as a
|