@sixb/app 0.2.3 → 0.2.5
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/assets/connector-icons/README.md +1 -0
- package/assets/connector-icons/ctm.png +0 -0
- package/dist/agent/activity-label.d.ts.map +1 -1
- package/dist/agent/agent-chat.d.ts +3 -1
- package/dist/agent/agent-chat.d.ts.map +1 -1
- package/dist/agent/agent-panel.d.ts.map +1 -1
- package/dist/agent/artifact-panel.d.ts +3 -1
- package/dist/agent/artifact-panel.d.ts.map +1 -1
- package/dist/agent/background/background-tool-row.d.ts.map +1 -1
- package/dist/agent/background/interpret.d.ts +1 -1
- package/dist/agent/background/interpret.d.ts.map +1 -1
- package/dist/agent/components/composer-settings.d.ts +1 -1
- package/dist/agent/components/composer-settings.d.ts.map +1 -1
- package/dist/agent/components/composer.d.ts +22 -5
- package/dist/agent/components/composer.d.ts.map +1 -1
- package/dist/agent/components/context-meter.d.ts +1 -1
- package/dist/agent/components/context-meter.d.ts.map +1 -1
- package/dist/agent/components/conversation-panel.d.ts +8 -2
- package/dist/agent/components/conversation-panel.d.ts.map +1 -1
- package/dist/agent/components/message-parts.d.ts +2 -1
- package/dist/agent/components/message-parts.d.ts.map +1 -1
- package/dist/agent/components/message-view.d.ts.map +1 -1
- package/dist/agent/components/pending-messages.d.ts +20 -0
- package/dist/agent/components/pending-messages.d.ts.map +1 -0
- package/dist/agent/components/sandbox-recovery.d.ts +11 -2
- package/dist/agent/components/sandbox-recovery.d.ts.map +1 -1
- package/dist/agent/components/threads-button.d.ts +1 -1
- package/dist/agent/components/threads-button.d.ts.map +1 -1
- package/dist/agent/components/transcript.d.ts +5 -0
- package/dist/agent/components/transcript.d.ts.map +1 -1
- package/dist/agent/conversation.d.ts +3 -6
- package/dist/agent/conversation.d.ts.map +1 -1
- package/dist/agent/delegation/agent-exchange.d.ts +16 -0
- package/dist/agent/delegation/agent-exchange.d.ts.map +1 -0
- package/dist/agent/delegation/child-card.d.ts +3 -3
- package/dist/agent/delegation/child-card.d.ts.map +1 -1
- package/dist/agent/delegation/child-parts.d.ts +1 -10
- package/dist/agent/delegation/child-parts.d.ts.map +1 -1
- package/dist/agent/delegation/child-work.d.ts.map +1 -1
- package/dist/agent/delegation/interpret.d.ts +9 -10
- package/dist/agent/delegation/interpret.d.ts.map +1 -1
- package/dist/agent/delegation/use-children.d.ts.map +1 -1
- package/dist/agent/file-edits/file-edit-tool-view.d.ts +10 -0
- package/dist/agent/file-edits/file-edit-tool-view.d.ts.map +1 -0
- package/dist/agent/file-edits/interpret.d.ts +25 -0
- package/dist/agent/file-edits/interpret.d.ts.map +1 -0
- package/dist/agent/hooks/use-agent-conversation.d.ts +16 -4
- package/dist/agent/hooks/use-agent-conversation.d.ts.map +1 -1
- package/dist/agent/hooks/use-thread-lists.d.ts.map +1 -1
- package/dist/agent/hooks/use-thread-stream.d.ts.map +1 -1
- package/dist/agent/i18n/en.d.ts +114 -5
- package/dist/agent/i18n/en.d.ts.map +1 -1
- package/dist/agent/i18n/fr.d.ts.map +1 -1
- package/dist/agent/i18n/index.d.ts +190 -8
- package/dist/agent/i18n/index.d.ts.map +1 -1
- package/dist/agent/inbox-handoff.d.ts +10 -0
- package/dist/agent/inbox-handoff.d.ts.map +1 -0
- package/dist/agent/live-run.d.ts +8 -1
- package/dist/agent/live-run.d.ts.map +1 -1
- package/dist/agent/message-agent/interpret.d.ts +2 -2
- package/dist/agent/message-agent/interpret.d.ts.map +1 -1
- package/dist/agent/publish-artifact/interpret.d.ts +1 -1
- package/dist/agent/publish-artifact/interpret.d.ts.map +1 -1
- package/dist/agent/questions/interpret.d.ts +31 -0
- package/dist/agent/questions/interpret.d.ts.map +1 -0
- package/dist/agent/questions/question-card.d.ts +16 -0
- package/dist/agent/questions/question-card.d.ts.map +1 -0
- package/dist/agent/questions/question-composer.d.ts +15 -0
- package/dist/agent/questions/question-composer.d.ts.map +1 -0
- package/dist/agent/read/interpret.d.ts +8 -1
- package/dist/agent/read/interpret.d.ts.map +1 -1
- package/dist/agent/read/read-tool-view.d.ts.map +1 -1
- package/dist/agent/search/interpret.d.ts +101 -0
- package/dist/agent/search/interpret.d.ts.map +1 -0
- package/dist/agent/search/search-tool-view.d.ts +10 -0
- package/dist/agent/search/search-tool-view.d.ts.map +1 -0
- package/dist/agent/thread-state.d.ts +26 -0
- package/dist/agent/thread-state.d.ts.map +1 -0
- package/dist/agent/tool-views/built-in.d.ts.map +1 -1
- package/dist/agent/tool-views/registry.d.ts +5 -6
- package/dist/agent/tool-views/registry.d.ts.map +1 -1
- package/dist/agent/types.d.ts +5 -1
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/view-file/view-file-tool-view.d.ts +2 -1
- package/dist/agent/view-file/view-file-tool-view.d.ts.map +1 -1
- package/dist/agent/waits.d.ts +14 -0
- package/dist/agent/waits.d.ts.map +1 -0
- package/dist/artifacts/card-preview.d.ts.map +1 -1
- package/dist/artifacts/edit-session.d.ts +11 -1
- package/dist/artifacts/edit-session.d.ts.map +1 -1
- package/dist/artifacts/editor/block-handle.d.ts +20 -0
- package/dist/artifacts/editor/block-handle.d.ts.map +1 -0
- package/dist/artifacts/editor/blocks.d.ts +34 -0
- package/dist/artifacts/editor/blocks.d.ts.map +1 -0
- package/dist/artifacts/editor/callout-view.d.ts +7 -0
- package/dist/artifacts/editor/callout-view.d.ts.map +1 -0
- package/dist/artifacts/editor/document-editor.d.ts +30 -0
- package/dist/artifacts/editor/document-editor.d.ts.map +1 -0
- package/dist/artifacts/editor/figure-view.d.ts +12 -0
- package/dist/artifacts/editor/figure-view.d.ts.map +1 -0
- package/dist/artifacts/editor/find-blocks.d.ts +6 -0
- package/dist/artifacts/editor/find-blocks.d.ts.map +1 -0
- package/dist/artifacts/editor/markdown-document.d.ts +12 -0
- package/dist/artifacts/editor/markdown-document.d.ts.map +1 -0
- package/dist/artifacts/editor/messages.d.ts +4 -0
- package/dist/artifacts/editor/messages.d.ts.map +1 -0
- package/dist/artifacts/editor/schema.d.ts +21 -0
- package/dist/artifacts/editor/schema.d.ts.map +1 -0
- package/dist/artifacts/editor/selection-toolbar.d.ts +35 -0
- package/dist/artifacts/editor/selection-toolbar.d.ts.map +1 -0
- package/dist/artifacts/editor/slash-menu.d.ts +43 -0
- package/dist/artifacts/editor/slash-menu.d.ts.map +1 -0
- package/dist/artifacts/editor/upload.d.ts +12 -0
- package/dist/artifacts/editor/upload.d.ts.map +1 -0
- package/dist/artifacts/file-source.d.ts +5 -0
- package/dist/artifacts/file-source.d.ts.map +1 -1
- package/dist/artifacts/frame-editor/bundle.d.ts +7 -0
- package/dist/artifacts/frame-editor/bundle.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/commands.d.ts +93 -0
- package/dist/artifacts/frame-editor/commands.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/entry.d.ts +2 -0
- package/dist/artifacts/frame-editor/entry.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/frame.d.ts +5 -0
- package/dist/artifacts/frame-editor/frame.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/keys.d.ts +8 -0
- package/dist/artifacts/frame-editor/keys.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/protocol.d.ts +186 -0
- package/dist/artifacts/frame-editor/protocol.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/schema.d.ts +34 -0
- package/dist/artifacts/frame-editor/schema.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/style.d.ts +2 -0
- package/dist/artifacts/frame-editor/style.d.ts.map +1 -0
- package/dist/artifacts/frame.d.ts +2 -2
- package/dist/artifacts/frame.d.ts.map +1 -1
- package/dist/artifacts/live/boards.d.ts +2 -0
- package/dist/artifacts/live/boards.d.ts.map +1 -1
- package/dist/artifacts/live/document.d.ts +32 -0
- package/dist/artifacts/live/document.d.ts.map +1 -0
- package/dist/artifacts/live/header.d.ts +4 -4
- package/dist/artifacts/live/header.d.ts.map +1 -1
- package/dist/artifacts/live/presence.d.ts.map +1 -1
- package/dist/artifacts/live/session.d.ts +2 -0
- package/dist/artifacts/live/session.d.ts.map +1 -1
- package/dist/artifacts/live/view.d.ts +4 -3
- package/dist/artifacts/live/view.d.ts.map +1 -1
- package/dist/artifacts/messages.d.ts +278 -2
- package/dist/artifacts/messages.d.ts.map +1 -1
- package/dist/artifacts/pdf.d.ts +8 -0
- package/dist/artifacts/pdf.d.ts.map +1 -0
- package/dist/artifacts/queries.d.ts +80 -0
- package/dist/artifacts/queries.d.ts.map +1 -1
- package/dist/artifacts/references/references.d.ts +3 -3
- package/dist/artifacts/references/references.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/board-editor.d.ts +11 -4
- package/dist/artifacts/renderers/canvas/board-editor.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/board.d.ts +14 -2
- package/dist/artifacts/renderers/canvas/board.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/canvas.d.ts +4 -3
- package/dist/artifacts/renderers/canvas/canvas.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/comment-pins.d.ts +4 -2
- package/dist/artifacts/renderers/canvas/comment-pins.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/comments-panel.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/comments.d.ts +2 -1
- package/dist/artifacts/renderers/canvas/comments.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/controls.d.ts +15 -4
- package/dist/artifacts/renderers/canvas/controls.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/focus.d.ts +19 -5
- package/dist/artifacts/renderers/canvas/focus.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/gestures.d.ts +46 -0
- package/dist/artifacts/renderers/canvas/gestures.d.ts.map +1 -0
- package/dist/artifacts/renderers/canvas/page-resize.d.ts +21 -0
- package/dist/artifacts/renderers/canvas/page-resize.d.ts.map +1 -0
- package/dist/artifacts/renderers/canvas/page-size-controls.d.ts +21 -0
- package/dist/artifacts/renderers/canvas/page-size-controls.d.ts.map +1 -0
- package/dist/artifacts/renderers/canvas/page-size.d.ts +93 -0
- package/dist/artifacts/renderers/canvas/page-size.d.ts.map +1 -0
- package/dist/artifacts/renderers/canvas/page-zoom.d.ts +64 -0
- package/dist/artifacts/renderers/canvas/page-zoom.d.ts.map +1 -0
- package/dist/artifacts/renderers/canvas/shown-size.d.ts +26 -0
- package/dist/artifacts/renderers/canvas/shown-size.d.ts.map +1 -0
- package/dist/artifacts/renderers/designed-document.d.ts +28 -0
- package/dist/artifacts/renderers/designed-document.d.ts.map +1 -0
- package/dist/artifacts/renderers/document-tree.d.ts +2 -0
- package/dist/artifacts/renderers/document-tree.d.ts.map +1 -1
- package/dist/artifacts/renderers/document.d.ts +9 -1
- package/dist/artifacts/renderers/document.d.ts.map +1 -1
- package/dist/artifacts/renderers/live-frame.d.ts +145 -0
- package/dist/artifacts/renderers/live-frame.d.ts.map +1 -0
- package/dist/artifacts/renderers/page-editor.d.ts +16 -0
- package/dist/artifacts/renderers/page-editor.d.ts.map +1 -0
- package/dist/artifacts/renderers/page.d.ts +10 -1
- package/dist/artifacts/renderers/page.d.ts.map +1 -1
- package/dist/artifacts/viewer.d.ts.map +1 -1
- package/dist/{chunk-001c4gnk.js → chunk-4fex83k2.js} +19965 -13027
- package/dist/chunk-4fex83k2.js.map +239 -0
- package/dist/{chunk-5crvhjp2.js → chunk-4wm09prf.js} +1633 -1999
- package/dist/chunk-4wm09prf.js.map +27 -0
- package/dist/{chunk-fwb9mxwm.js → chunk-5sgac68y.js} +1 -1
- package/dist/{chunk-kes4ygmz.js → chunk-69qgh20f.js} +1 -1
- package/dist/chunk-y51c4tsz.js +11 -0
- package/dist/chunk-y51c4tsz.js.map +10 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -6
- package/dist/index.js.map +5 -5
- package/dist/pages/console/data/messages.d.ts +6 -0
- package/dist/pages/console/data/messages.d.ts.map +1 -1
- package/dist/pages/console/data/shared.d.ts.map +1 -1
- package/dist/pages.js +12 -5
- package/dist/pages.js.map +6 -6
- package/dist/shell/search-command.d.ts.map +1 -1
- package/package.json +22 -5
- package/src/agent/activity-label.ts +9 -1
- package/src/agent/agent-chat.tsx +57 -37
- package/src/agent/agent-execution-trace.tsx +2 -2
- package/src/agent/agent-panel.tsx +6 -4
- package/src/agent/agent.css +254 -0
- package/src/agent/artifact-panel.tsx +77 -22
- package/src/agent/background/background-tool-row.tsx +24 -10
- package/src/agent/background/interpret.ts +60 -51
- package/src/agent/components/composer-settings.tsx +20 -10
- package/src/agent/components/composer.tsx +342 -104
- package/src/agent/components/context-meter.tsx +7 -3
- package/src/agent/components/conversation-panel.tsx +96 -37
- package/src/agent/components/message-parts.tsx +390 -64
- package/src/agent/components/message-view.tsx +12 -2
- package/src/agent/components/pending-messages.tsx +338 -0
- package/src/agent/components/sandbox-recovery.tsx +36 -17
- package/src/agent/components/threads-button.tsx +3 -2
- package/src/agent/components/transcript.tsx +92 -45
- package/src/agent/conversation.ts +203 -54
- package/src/agent/delegation/agent-exchange.tsx +53 -0
- package/src/agent/delegation/child-card.tsx +6 -40
- package/src/agent/delegation/child-parts.tsx +1 -84
- package/src/agent/delegation/child-work.tsx +19 -5
- package/src/agent/delegation/interpret.ts +64 -61
- package/src/agent/delegation/model.ts +1 -1
- package/src/agent/file-edits/file-edit-tool-view.tsx +126 -0
- package/src/agent/file-edits/interpret.ts +120 -0
- package/src/agent/hooks/use-agent-conversation.ts +360 -92
- package/src/agent/hooks/use-thread-stream.ts +10 -0
- package/src/agent/i18n/en.ts +134 -16
- package/src/agent/i18n/fr.ts +122 -16
- package/src/agent/inbox-handoff.ts +47 -0
- package/src/agent/live-run.ts +23 -2
- package/src/agent/message-agent/interpret.ts +4 -3
- package/src/agent/publish-artifact/interpret.ts +14 -5
- package/src/agent/publish-artifact/publish-artifact-tool-view.tsx +2 -2
- package/src/agent/questions/interpret.ts +90 -0
- package/src/agent/questions/question-card.tsx +57 -0
- package/src/agent/questions/question-composer.tsx +257 -0
- package/src/agent/react-router.tsx +2 -2
- package/src/agent/read/interpret.ts +34 -1
- package/src/agent/read/read-tool-view.tsx +20 -4
- package/src/agent/search/interpret.ts +367 -0
- package/src/agent/search/search-tool-view.tsx +235 -0
- package/src/agent/thread-state.ts +114 -0
- package/src/agent/tool-views/built-in.tsx +33 -6
- package/src/agent/tool-views/registry.tsx +28 -2
- package/src/agent/types.ts +7 -0
- package/src/agent/view-file/view-file-tool-view.tsx +33 -19
- package/src/agent/waits.ts +50 -0
- package/src/artifacts/artifacts.css +434 -0
- package/src/artifacts/card-preview.tsx +6 -1
- package/src/artifacts/edit-session.tsx +15 -1
- package/src/artifacts/editor/block-handle.tsx +278 -0
- package/src/artifacts/editor/blocks.ts +216 -0
- package/src/artifacts/editor/callout-view.tsx +31 -0
- package/src/artifacts/editor/document-editor.tsx +484 -0
- package/src/artifacts/editor/figure-view.tsx +66 -0
- package/src/artifacts/editor/find-blocks.ts +19 -0
- package/src/artifacts/editor/markdown-document.tsx +72 -0
- package/src/artifacts/editor/messages.ts +4 -0
- package/src/artifacts/editor/schema.ts +159 -0
- package/src/artifacts/editor/selection-toolbar.tsx +364 -0
- package/src/artifacts/editor/slash-menu.tsx +251 -0
- package/src/artifacts/editor/upload.ts +40 -0
- package/src/artifacts/file-source.ts +11 -0
- package/src/artifacts/frame-editor/bundle.ts +8 -0
- package/src/artifacts/frame-editor/commands.ts +565 -0
- package/src/artifacts/frame-editor/entry.ts +6 -0
- package/src/artifacts/frame-editor/frame.ts +847 -0
- package/src/artifacts/frame-editor/generated/editor.txt +149 -0
- package/src/artifacts/frame-editor/generated.d.ts +5 -0
- package/src/artifacts/frame-editor/keys.ts +323 -0
- package/src/artifacts/frame-editor/protocol.ts +151 -0
- package/src/artifacts/frame-editor/schema.ts +293 -0
- package/src/artifacts/frame-editor/style.ts +58 -0
- package/src/artifacts/frame.tsx +14 -5
- package/src/artifacts/live/boards.ts +46 -3
- package/src/artifacts/live/document.ts +89 -0
- package/src/artifacts/live/header.tsx +9 -14
- package/src/artifacts/live/presence.ts +5 -1
- package/src/artifacts/live/session.ts +4 -2
- package/src/artifacts/live/view.ts +14 -8
- package/src/artifacts/messages.ts +192 -2
- package/src/artifacts/pdf.ts +50 -0
- package/src/artifacts/references/references.tsx +46 -11
- package/src/artifacts/renderers/canvas/board-editor.tsx +44 -155
- package/src/artifacts/renderers/canvas/board.tsx +70 -8
- package/src/artifacts/renderers/canvas/canvas.tsx +66 -15
- package/src/artifacts/renderers/canvas/comment-pins.tsx +5 -0
- package/src/artifacts/renderers/canvas/comments-panel.tsx +58 -1
- package/src/artifacts/renderers/canvas/comments.ts +8 -4
- package/src/artifacts/renderers/canvas/controls.tsx +64 -30
- package/src/artifacts/renderers/canvas/focus.tsx +200 -56
- package/src/artifacts/renderers/canvas/gestures.ts +265 -0
- package/src/artifacts/renderers/canvas/page-resize.tsx +542 -0
- package/src/artifacts/renderers/canvas/page-size-controls.tsx +193 -0
- package/src/artifacts/renderers/canvas/page-size.ts +218 -0
- package/src/artifacts/renderers/canvas/page-zoom.ts +280 -0
- package/src/artifacts/renderers/canvas/shown-size.ts +105 -0
- package/src/artifacts/renderers/designed-document.tsx +277 -0
- package/src/artifacts/renderers/document-tree.ts +9 -0
- package/src/artifacts/renderers/document.tsx +13 -102
- package/src/artifacts/renderers/live-frame.ts +163 -0
- package/src/artifacts/renderers/page-editor.tsx +613 -0
- package/src/artifacts/renderers/page.tsx +21 -4
- package/src/artifacts/viewer.tsx +101 -41
- package/src/index.ts +8 -0
- package/src/pages/console/data/messages.ts +6 -0
- package/src/pages/console/data/projections.tsx +4 -0
- package/src/pages/console/data/shared.tsx +1 -0
- package/src/pages/console/ontology/lineage/trail.tsx +3 -0
- package/src/shell/search-command.tsx +2 -0
- package/dist/chunk-001c4gnk.js.map +0 -204
- package/dist/chunk-5crvhjp2.js.map +0 -28
- /package/dist/{chunk-fwb9mxwm.js.map → chunk-5sgac68y.js.map} +0 -0
- /package/dist/{chunk-kes4ygmz.js.map → chunk-69qgh20f.js.map} +0 -0
|
@@ -4,11 +4,10 @@ import {
|
|
|
4
4
|
type CanvasBoard,
|
|
5
5
|
type FrameEditTarget,
|
|
6
6
|
type FrameEvent,
|
|
7
|
-
|
|
7
|
+
type FrameZoom,
|
|
8
8
|
} from "@sixb/core/artifacts"
|
|
9
9
|
import {
|
|
10
10
|
boardFilePath,
|
|
11
|
-
boardFramePatches,
|
|
12
11
|
mergeBoardText,
|
|
13
12
|
setBoardImage,
|
|
14
13
|
setBoardStyle,
|
|
@@ -30,19 +29,15 @@ import {
|
|
|
30
29
|
useState,
|
|
31
30
|
} from "react"
|
|
32
31
|
import { formatFileSize } from "../../file-size"
|
|
33
|
-
import { ArtifactFrame
|
|
34
|
-
import {
|
|
32
|
+
import { ArtifactFrame } from "../../frame"
|
|
33
|
+
import { useLiveStoredFiles } from "../../live/boards"
|
|
35
34
|
import type { LiveCanvas } from "../../live/canvas"
|
|
36
35
|
import type { LiveArtifact } from "../../live/session"
|
|
37
36
|
import { useArtifactMessages } from "../../messages"
|
|
38
|
-
import { type ArtifactVersion,
|
|
37
|
+
import { type ArtifactVersion, versionFileSource } from "../../queries"
|
|
38
|
+
import { useFrameEditing, useLiveFrame } from "../live-frame"
|
|
39
39
|
import { type CanvasImage, ImagePanel, type StyleChange, StylePanel } from "./board-properties"
|
|
40
|
-
import {
|
|
41
|
-
boardAttribute,
|
|
42
|
-
boardInlineStyle,
|
|
43
|
-
boardReferencePath,
|
|
44
|
-
showablePatches,
|
|
45
|
-
} from "./board-source"
|
|
40
|
+
import { boardAttribute, boardInlineStyle, boardReferencePath } from "./board-source"
|
|
46
41
|
import {
|
|
47
42
|
CommentPin,
|
|
48
43
|
cardPlace,
|
|
@@ -51,18 +46,15 @@ import {
|
|
|
51
46
|
type PinPlace,
|
|
52
47
|
pinPoint,
|
|
53
48
|
} from "./comment-pins"
|
|
49
|
+
import type { PageSize } from "./page-size"
|
|
54
50
|
|
|
55
51
|
// A board opened over the canvas, as its page runs in its frame, and what the reader does on it:
|
|
56
|
-
// read it, edit what it shows, or pick what to comment on.
|
|
57
|
-
//
|
|
58
|
-
// The frame serves the board as a stored version holds it, marked for editing; the live document
|
|
59
|
-
// holds it as everyone is changing it now. The frame is kept at the version it loaded and told,
|
|
60
|
-
// element by element, what changed since (`edit.patch`), so typing goes on under the caret while
|
|
61
|
-
// others change other elements. It loads a newer version only when the elements themselves
|
|
62
|
-
// changed, or a picture it does not hold yet is shown, and then once the stored version holds it.
|
|
52
|
+
// read it, edit what it shows, or pick what to comment on. The frame follows the live document as
|
|
53
|
+
// ../live-frame.ts describes.
|
|
63
54
|
//
|
|
64
55
|
// frame ── edit.select ──▶ the element picked, its toolbar (the reader's own click)
|
|
65
56
|
// ── edit.text ───▶ mergeBoardText → the board's Y.Text (only for the element picked)
|
|
57
|
+
// ── zoom ────────▶ the opened board zoomed, not the browser (the reader's own gesture)
|
|
66
58
|
// ◀─ edit.patch ── what the document changed since the frame's version
|
|
67
59
|
|
|
68
60
|
/** What edits a board's elements: the live canvas, under the reader's own undo. */
|
|
@@ -78,101 +70,13 @@ export type CommentPick = Omit<DraftPlace, "board">
|
|
|
78
70
|
const IMAGE_EXTENSIONS = /\.(png|jpe?g|gif|webp|avif|svg)$/i
|
|
79
71
|
|
|
80
72
|
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*/
|
|
84
|
-
function useBoardFrame({
|
|
85
|
-
version,
|
|
86
|
-
board,
|
|
87
|
-
live,
|
|
88
|
-
}: {
|
|
89
|
-
readonly version: ArtifactVersion
|
|
90
|
-
readonly board: CanvasBoard
|
|
91
|
-
readonly live: LiveArtifact | null
|
|
92
|
-
}) {
|
|
93
|
-
const source = useLiveBoardSource(live, board.file)
|
|
94
|
-
const patching = source !== null
|
|
95
|
-
const [pinned, setPinned] = useState(version)
|
|
96
|
-
const shows = patching ? pinned : version
|
|
97
|
-
const stored = useFileText(patching ? versionFileSource(pinned, board.file) : null).text
|
|
98
|
-
|
|
99
|
-
const handle = useRef<ArtifactFrameHandle | null>(null)
|
|
100
|
-
/** Each load the frame said it is ready, for what follows to start over. */
|
|
101
|
-
const [loads, setLoads] = useState(0)
|
|
102
|
-
/** What the frame shows now, once patched past its version's page. */
|
|
103
|
-
const shown = useRef<string | null>(null)
|
|
104
|
-
/** Pictures the reader just uploaded, shown from their bytes until a version holds them. */
|
|
105
|
-
const previews = useRef(new Map<string, string>())
|
|
106
|
-
/** The frame must load a newer version: the elements changed, or a picture is missing. */
|
|
107
|
-
const [stale, setStale] = useState(false)
|
|
108
|
-
/**
|
|
109
|
-
* The elements themselves changed: the frame's addresses name other elements than the
|
|
110
|
-
* document's, so nothing is edited through it until it loads a version that has them.
|
|
111
|
-
*/
|
|
112
|
-
const [moved, setMoved] = useState(false)
|
|
113
|
-
const [holding, setHolding] = useState(false)
|
|
114
|
-
|
|
115
|
-
const ready = useCallback(() => {
|
|
116
|
-
shown.current = null
|
|
117
|
-
setLoads((count) => count + 1)
|
|
118
|
-
}, [])
|
|
119
|
-
|
|
120
|
-
// What the document holds now, as patches to what the frame shows.
|
|
121
|
-
useEffect(() => {
|
|
122
|
-
if (loads === 0 || stored === undefined || source === null) return
|
|
123
|
-
|
|
124
|
-
const patches = boardFramePatches(shown.current ?? stored, source)
|
|
125
|
-
if (patches === null) {
|
|
126
|
-
setStale(true)
|
|
127
|
-
setMoved(true)
|
|
128
|
-
return
|
|
129
|
-
}
|
|
130
|
-
setMoved(false)
|
|
131
|
-
|
|
132
|
-
const holds = (path: string) => shows.files.some((file) => file.path === path)
|
|
133
|
-
const showable = showablePatches(patches, board.file, holds, previews.current)
|
|
134
|
-
if (showable.waiting) setStale(true)
|
|
135
|
-
shown.current = source
|
|
136
|
-
if (showable.patches.length === 0) return
|
|
137
|
-
|
|
138
|
-
handle.current?.send("edit.patch", { patches: showable.patches }).catch(() => {})
|
|
139
|
-
}, [loads, stored, source, shows, board.file])
|
|
140
|
-
|
|
141
|
-
// A stale frame loads the version the viewer has now once it is past the one it shows, and
|
|
142
|
-
// while the reader is not typing in it, unless what they type in is no longer where it was.
|
|
143
|
-
useEffect(() => {
|
|
144
|
-
if (!stale || (holding && !moved) || version.revision <= pinned.revision) return
|
|
145
|
-
setStale(false)
|
|
146
|
-
setPinned(version)
|
|
147
|
-
}, [stale, holding, moved, version, pinned.revision])
|
|
148
|
-
|
|
149
|
-
/** Loads the frame's page again, as what it shows can no longer be patched. */
|
|
150
|
-
const resync = useCallback(() => {
|
|
151
|
-
shown.current = null
|
|
152
|
-
handle.current?.send("reload", {}).catch(() => {})
|
|
153
|
-
}, [])
|
|
154
|
-
|
|
155
|
-
return {
|
|
156
|
-
shows,
|
|
157
|
-
source,
|
|
158
|
-
handle,
|
|
159
|
-
loads,
|
|
160
|
-
ready,
|
|
161
|
-
resync,
|
|
162
|
-
stale,
|
|
163
|
-
moved,
|
|
164
|
-
previews: previews.current,
|
|
165
|
-
hold: setHolding,
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* An opened board at its size on screen: its page in its frame, the picture under it until it is
|
|
171
|
-
* ready, comments' pins over it, and, editing, the picked element's tools.
|
|
73
|
+
* An opened board at its size on screen: its page in its frame, laid out at `size`, the picture
|
|
74
|
+
* under it until it is ready, comments' pins over it, and, editing, the picked element's tools.
|
|
172
75
|
*/
|
|
173
76
|
export function BoardStage({
|
|
174
77
|
version,
|
|
175
78
|
board,
|
|
79
|
+
size,
|
|
176
80
|
title,
|
|
177
81
|
scale,
|
|
178
82
|
live,
|
|
@@ -188,9 +92,13 @@ export function BoardStage({
|
|
|
188
92
|
onOpenPin,
|
|
189
93
|
onSubmitDraft,
|
|
190
94
|
onCancelDraft,
|
|
95
|
+
onContentHeight,
|
|
96
|
+
onZoom,
|
|
191
97
|
}: {
|
|
192
98
|
readonly version: ArtifactVersion
|
|
193
99
|
readonly board: CanvasBoard
|
|
100
|
+
/** The size the page is laid out at: the board's, or the one the reader chose to see it at. */
|
|
101
|
+
readonly size: PageSize
|
|
194
102
|
readonly title: string
|
|
195
103
|
readonly scale: number
|
|
196
104
|
/** The canvas held live, whose document the board is patched from. */
|
|
@@ -208,9 +116,13 @@ export function BoardStage({
|
|
|
208
116
|
readonly onOpenPin: (id: string) => void
|
|
209
117
|
readonly onSubmitDraft: (body: string) => Promise<void>
|
|
210
118
|
readonly onCancelDraft: () => void
|
|
119
|
+
/** The page's height as laid out at its width, as the frame reports it. */
|
|
120
|
+
readonly onContentHeight?: (height: number) => void
|
|
121
|
+
/** The reader zoomed over the page: the frame passes it on instead of the browser zooming. */
|
|
122
|
+
readonly onZoom?: (zoom: FrameZoom) => void
|
|
211
123
|
}) {
|
|
212
124
|
const messages = useArtifactMessages().canvas
|
|
213
|
-
const frame =
|
|
125
|
+
const frame = useLiveFrame({ version, file: board.file, live })
|
|
214
126
|
const editing = mode === "edit" && canvas !== null
|
|
215
127
|
const [selected, setSelected] = useState<FrameEditTarget | null>(null)
|
|
216
128
|
/** What the pointer is over while the reader picks what to comment on. */
|
|
@@ -247,48 +159,16 @@ export function BoardStage({
|
|
|
247
159
|
if (!draft) setHovered(null)
|
|
248
160
|
}, [draft])
|
|
249
161
|
|
|
250
|
-
// Each load of the frame, a port of its own, handed over with its first `edit` request: what
|
|
251
|
-
// editing reports comes through it alone, never through the window, where the board's scripts
|
|
252
|
-
// post too.
|
|
253
|
-
const port = useRef<{ readonly mine: MessagePort; handed: MessagePort | null } | null>(null)
|
|
254
|
-
const onEditRef = useRef<(event: FrameEvent) => void>(() => {})
|
|
255
|
-
useEffect(() => {
|
|
256
|
-
if (frame.loads === 0) return
|
|
257
|
-
const channel = new MessageChannel()
|
|
258
|
-
channel.port1.onmessage = (message: MessageEvent) => {
|
|
259
|
-
const event = parseFrameEvent(message.data)
|
|
260
|
-
if (event?.event.startsWith("edit.")) onEditRef.current(event)
|
|
261
|
-
}
|
|
262
|
-
port.current = { mine: channel.port1, handed: channel.port2 }
|
|
263
|
-
return () => channel.port1.close()
|
|
264
|
-
}, [frame.loads])
|
|
265
|
-
|
|
266
|
-
// The frame picks and types as the mode says, each time it loads; while its elements are not
|
|
267
|
-
// the document's, it does neither.
|
|
268
|
-
const send = frame.handle
|
|
269
|
-
useEffect(() => {
|
|
270
|
-
if (frame.loads === 0) return
|
|
271
|
-
const handed = port.current?.handed
|
|
272
|
-
if (port.current) port.current.handed = null
|
|
273
|
-
send.current
|
|
274
|
-
?.send(
|
|
275
|
-
"edit",
|
|
276
|
-
{ on: mode !== "read" && !frame.moved, typing: editing },
|
|
277
|
-
handed ? [handed] : []
|
|
278
|
-
)
|
|
279
|
-
.catch(() => {})
|
|
280
|
-
}, [frame.loads, frame.moved, mode, editing, send])
|
|
281
|
-
|
|
282
162
|
const point = useCallback(
|
|
283
163
|
(at: { readonly x: number; readonly y: number } | undefined, rect: FrameEditTarget["rect"]) => {
|
|
284
164
|
const x = at?.x ?? rect.x + rect.width
|
|
285
165
|
const y = at?.y ?? rect.y
|
|
286
166
|
return {
|
|
287
|
-
x: Math.min(1, Math.max(0, x /
|
|
288
|
-
y: Math.min(1, Math.max(0, y /
|
|
167
|
+
x: Math.min(1, Math.max(0, x / size.w)),
|
|
168
|
+
y: Math.min(1, Math.max(0, y / size.h)),
|
|
289
169
|
}
|
|
290
170
|
},
|
|
291
|
-
[
|
|
171
|
+
[size.w, size.h]
|
|
292
172
|
)
|
|
293
173
|
|
|
294
174
|
const onEvent = useCallback(
|
|
@@ -301,12 +181,14 @@ export function BoardStage({
|
|
|
301
181
|
frame.ready()
|
|
302
182
|
} else if (event.event === "press") {
|
|
303
183
|
onPress(event.params.text)
|
|
184
|
+
} else if (event.event === "size") {
|
|
185
|
+
onContentHeight?.(event.params.height)
|
|
304
186
|
}
|
|
305
187
|
},
|
|
306
|
-
[frame, onPress]
|
|
188
|
+
[frame, onPress, onContentHeight]
|
|
307
189
|
)
|
|
308
190
|
|
|
309
|
-
|
|
191
|
+
const onEdit = (event: FrameEvent) => {
|
|
310
192
|
if (moved.current) return
|
|
311
193
|
|
|
312
194
|
switch (event.event) {
|
|
@@ -326,7 +208,7 @@ export function BoardStage({
|
|
|
326
208
|
// The page's body is the whole board, named by its title.
|
|
327
209
|
...(target.address === "body" ? { anchor: title } : {}),
|
|
328
210
|
point: point(at, target.rect),
|
|
329
|
-
under: Math.min(1, (target.rect.y + target.rect.height) /
|
|
211
|
+
under: Math.min(1, (target.rect.y + target.rect.height) / size.h),
|
|
330
212
|
})
|
|
331
213
|
return
|
|
332
214
|
}
|
|
@@ -355,13 +237,15 @@ export function BoardStage({
|
|
|
355
237
|
return
|
|
356
238
|
}
|
|
357
239
|
}
|
|
240
|
+
// The frame picks and types as the mode says, each time it loads.
|
|
241
|
+
useFrameEditing({ frame, on: mode !== "read", typing: editing, onEdit, onZoom })
|
|
358
242
|
|
|
359
243
|
return (
|
|
360
244
|
<div className="relative size-full">
|
|
361
245
|
<div className="absolute inset-0 overflow-hidden rounded-[inherit]">
|
|
362
246
|
<div
|
|
363
247
|
className="absolute top-0 left-0 origin-top-left"
|
|
364
|
-
style={{ width:
|
|
248
|
+
style={{ width: size.w, height: size.h, transform: `scale(${scale})` }}
|
|
365
249
|
>
|
|
366
250
|
<ArtifactFrame
|
|
367
251
|
key={board.id}
|
|
@@ -378,14 +262,15 @@ export function BoardStage({
|
|
|
378
262
|
</div>
|
|
379
263
|
</div>
|
|
380
264
|
|
|
381
|
-
|
|
265
|
+
{/* Over the page's resize handles: a pin at the page's edge stays pressable. */}
|
|
266
|
+
<div className="pointer-events-none absolute inset-0 z-10" data-board-overlay="">
|
|
382
267
|
{pins.map((pin, index) => {
|
|
383
268
|
const at = pinPoint(pin, pin.point ? 0 : index)
|
|
384
269
|
return (
|
|
385
270
|
<div
|
|
386
271
|
key={pin.id}
|
|
387
272
|
className="absolute"
|
|
388
|
-
style={{ left: at.x *
|
|
273
|
+
style={{ left: at.x * size.w * scale, top: at.y * size.h * scale }}
|
|
389
274
|
>
|
|
390
275
|
<CommentPin
|
|
391
276
|
number={pin.number}
|
|
@@ -403,13 +288,13 @@ export function BoardStage({
|
|
|
403
288
|
{draft ? (
|
|
404
289
|
<div
|
|
405
290
|
className="absolute"
|
|
406
|
-
style={{ left: draft.point.x *
|
|
291
|
+
style={{ left: draft.point.x * size.w * scale, top: draft.point.y * size.h * scale }}
|
|
407
292
|
>
|
|
408
293
|
<CommentPin label={messages.comments.newPin} active resolved={false} draft />
|
|
409
294
|
<div
|
|
410
295
|
className={cn("absolute", draftAbove(draft) ? "bottom-9" : null)}
|
|
411
296
|
style={{
|
|
412
|
-
...cardPlace(draft.point.x *
|
|
297
|
+
...cardPlace(draft.point.x * size.w * scale, size.w * scale),
|
|
413
298
|
// Under what it is about, so the words it points at stay in view.
|
|
414
299
|
...(draftAbove(draft)
|
|
415
300
|
? {}
|
|
@@ -417,7 +302,7 @@ export function BoardStage({
|
|
|
417
302
|
top:
|
|
418
303
|
Math.max(
|
|
419
304
|
0,
|
|
420
|
-
((draft.under ?? draft.point.y) - draft.point.y) *
|
|
305
|
+
((draft.under ?? draft.point.y) - draft.point.y) * size.h * scale
|
|
421
306
|
) + 10,
|
|
422
307
|
}),
|
|
423
308
|
}}
|
|
@@ -436,6 +321,7 @@ export function BoardStage({
|
|
|
436
321
|
key={selected.address ?? "scripted"}
|
|
437
322
|
target={selected}
|
|
438
323
|
scale={scale}
|
|
324
|
+
width={size.w}
|
|
439
325
|
board={board}
|
|
440
326
|
version={version}
|
|
441
327
|
live={live}
|
|
@@ -514,6 +400,7 @@ function HoverTag({ target, scale }: { readonly target: FrameEditTarget; readonl
|
|
|
514
400
|
function ElementTools({
|
|
515
401
|
target,
|
|
516
402
|
scale,
|
|
403
|
+
width: pageWidth,
|
|
517
404
|
board,
|
|
518
405
|
version,
|
|
519
406
|
live,
|
|
@@ -524,6 +411,8 @@ function ElementTools({
|
|
|
524
411
|
}: {
|
|
525
412
|
readonly target: FrameEditTarget
|
|
526
413
|
readonly scale: number
|
|
414
|
+
/** The page's width as laid out. */
|
|
415
|
+
readonly width: number
|
|
527
416
|
readonly board: CanvasBoard
|
|
528
417
|
readonly version: ArtifactVersion
|
|
529
418
|
readonly live: LiveArtifact | null
|
|
@@ -542,7 +431,7 @@ function ElementTools({
|
|
|
542
431
|
useLayoutEffect(() => {
|
|
543
432
|
setWidth(toolbar.current?.offsetWidth ?? 0)
|
|
544
433
|
})
|
|
545
|
-
const left = Math.max(4, Math.min(rect.x * scale,
|
|
434
|
+
const left = Math.max(4, Math.min(rect.x * scale, pageWidth * scale - width - 4))
|
|
546
435
|
const above = rect.y * scale >= 44
|
|
547
436
|
const top = above ? rect.y * scale - 40 : (rect.y + rect.height) * scale + 8
|
|
548
437
|
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import { CANVAS_FILE } from "@sixb/core/artifacts"
|
|
1
|
+
import { CANVAS_FILE, parseFrameEvent } from "@sixb/core/artifacts"
|
|
2
2
|
import { cn } from "@sixb/ui/lib/utils"
|
|
3
3
|
import { useStoreApi } from "@xyflow/react"
|
|
4
4
|
import type { LucideIcon } from "lucide-react"
|
|
5
5
|
import {
|
|
6
6
|
createContext,
|
|
7
7
|
type ReactNode,
|
|
8
|
+
type RefObject,
|
|
8
9
|
useContext,
|
|
9
10
|
useEffect,
|
|
10
11
|
useRef,
|
|
11
12
|
useState,
|
|
12
13
|
useSyncExternalStore,
|
|
13
14
|
} from "react"
|
|
14
|
-
import { ArtifactFrame } from "../../frame"
|
|
15
|
+
import { ArtifactFrame, type ArtifactFrameHandle } from "../../frame"
|
|
15
16
|
import type { ArtifactVersion } from "../../queries"
|
|
17
|
+
import type { BoardGestures } from "./gestures"
|
|
16
18
|
import type { BoardPreviews } from "./previews"
|
|
17
19
|
|
|
18
20
|
/** The most boards and embeds live at once: each board is a page running in its own frame. */
|
|
@@ -157,6 +159,13 @@ interface LiveBoards {
|
|
|
157
159
|
readonly mode: "light" | "dark"
|
|
158
160
|
/** Opens a board over the canvas. */
|
|
159
161
|
readonly open?: (id: string) => void
|
|
162
|
+
/**
|
|
163
|
+
* Whether the reader uses the running boards' pages in place: while they read the canvas, not
|
|
164
|
+
* while they edit it or place a comment.
|
|
165
|
+
*/
|
|
166
|
+
readonly interactive?: boolean
|
|
167
|
+
/** What the canvas does with what a running board's page hands it. */
|
|
168
|
+
readonly gestures?: BoardGestures | null
|
|
160
169
|
}
|
|
161
170
|
|
|
162
171
|
const LiveBoardsContext = createContext<LiveBoards>({
|
|
@@ -340,8 +349,12 @@ function usePagesVersion(version: ArtifactVersion | null): ArtifactVersion | nul
|
|
|
340
349
|
* A board's page, running, when the view shows it large enough, over its tile: the tile stays
|
|
341
350
|
* under the frame while it fades in, once its page is ready, so a board never flashes blank as it
|
|
342
351
|
* starts or stops; then the tile goes, so nothing of it shows through a page drawn on the board's
|
|
343
|
-
* own surface.
|
|
344
|
-
*
|
|
352
|
+
* own surface.
|
|
353
|
+
*
|
|
354
|
+
* While the reader reads the canvas, a running page is theirs to use in place: its clicks, keys,
|
|
355
|
+
* text and cursor are its own, and its frame hands the canvas what moves it, as `gestures.ts`
|
|
356
|
+
* says. Editing the canvas or placing a comment, or until it runs, it takes no clicks: a drag
|
|
357
|
+
* across it pans, as across its picture.
|
|
345
358
|
*/
|
|
346
359
|
export function LiveBoard({
|
|
347
360
|
id,
|
|
@@ -354,15 +367,28 @@ export function LiveBoard({
|
|
|
354
367
|
readonly title: string
|
|
355
368
|
readonly tile: ReactNode
|
|
356
369
|
}) {
|
|
357
|
-
const { version } = useContext(LiveBoardsContext)
|
|
370
|
+
const { version, interactive = false, gestures = null } = useContext(LiveBoardsContext)
|
|
358
371
|
const live = useLive(id)
|
|
359
372
|
const pages = usePagesVersion(version)
|
|
360
373
|
// The pages whose frame said it is ready: a frame that runs other pages, or stops, shows the
|
|
361
374
|
// tile again until it is.
|
|
362
375
|
const [ready, setReady] = useState<ArtifactVersion | null>(null)
|
|
363
376
|
const running = live && pages !== null && ready === pages
|
|
377
|
+
const usable = running && interactive
|
|
378
|
+
|
|
379
|
+
const page = useRef<HTMLDivElement | null>(null)
|
|
380
|
+
const handle = useRef<ArtifactFrameHandle | null>(null)
|
|
381
|
+
/** Each load the frame said it is ready, for its port to be handed over again. */
|
|
382
|
+
const [loads, setLoads] = useState(0)
|
|
383
|
+
useCanvasPort(id, gestures, handle, loads, page)
|
|
384
|
+
|
|
364
385
|
return (
|
|
365
|
-
<div
|
|
386
|
+
<div
|
|
387
|
+
ref={page}
|
|
388
|
+
className="group/board relative size-full"
|
|
389
|
+
data-running={running ? "" : undefined}
|
|
390
|
+
data-interactive={usable ? "" : undefined}
|
|
391
|
+
>
|
|
366
392
|
{/* Gone once the frame has faded in over it: as long as the fade, then not drawn at all. */}
|
|
367
393
|
<div className="size-full transition-[visibility] delay-300 group-data-[running]/board:invisible">
|
|
368
394
|
{tile}
|
|
@@ -372,13 +398,49 @@ export function LiveBoard({
|
|
|
372
398
|
version={pages}
|
|
373
399
|
entry={file}
|
|
374
400
|
title={title}
|
|
375
|
-
decorative
|
|
401
|
+
decorative={!usable}
|
|
402
|
+
handle={handle}
|
|
376
403
|
className="absolute inset-0 overflow-hidden rounded-[10px]"
|
|
377
404
|
onEvent={(event) => {
|
|
378
|
-
if (event.event
|
|
405
|
+
if (event.event !== "ready") return
|
|
406
|
+
setReady(pages)
|
|
407
|
+
setLoads((count) => count + 1)
|
|
379
408
|
}}
|
|
380
409
|
/>
|
|
381
410
|
) : null}
|
|
382
411
|
</div>
|
|
383
412
|
)
|
|
384
413
|
}
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Each load of a running board's frame, a port of its own, handed over with its first `canvas`
|
|
417
|
+
* request: what moves the canvas comes through it alone, never through the window, where the
|
|
418
|
+
* page's scripts post too. The frame hears from then on whether the canvas pans by the wheel.
|
|
419
|
+
*/
|
|
420
|
+
function useCanvasPort(
|
|
421
|
+
id: string,
|
|
422
|
+
gestures: BoardGestures | null,
|
|
423
|
+
handle: RefObject<ArtifactFrameHandle | null>,
|
|
424
|
+
loads: number,
|
|
425
|
+
page: RefObject<HTMLElement | null>
|
|
426
|
+
): void {
|
|
427
|
+
useEffect(() => {
|
|
428
|
+
if (loads === 0 || !gestures) return
|
|
429
|
+
|
|
430
|
+
const channel = new MessageChannel()
|
|
431
|
+
channel.port1.onmessage = (message: MessageEvent) => {
|
|
432
|
+
const event = parseFrameEvent(message.data)
|
|
433
|
+
if (event) gestures.receive(id, event, page.current)
|
|
434
|
+
}
|
|
435
|
+
const tell = (moving: boolean, transfer: Transferable[] = []) => {
|
|
436
|
+
handle.current?.send("canvas", { moving }, transfer).catch(() => {})
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
tell(gestures.moving(), [channel.port2])
|
|
440
|
+
const stop = gestures.onMoving((moving) => tell(moving))
|
|
441
|
+
return () => {
|
|
442
|
+
stop()
|
|
443
|
+
channel.port1.close()
|
|
444
|
+
}
|
|
445
|
+
}, [id, gestures, handle, loads, page])
|
|
446
|
+
}
|
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
useRef,
|
|
27
27
|
useState,
|
|
28
28
|
} from "react"
|
|
29
|
+
import { useStartEditing } from "../../edit-session"
|
|
29
30
|
import type { LiveArtifact } from "../../live/session"
|
|
30
31
|
import { useArtifactMessages } from "../../messages"
|
|
31
32
|
import type { ArtifactVersion } from "../../queries"
|
|
@@ -38,18 +39,21 @@ import { CanvasCommentPins } from "./comment-pins"
|
|
|
38
39
|
import { CommentModeHint, CommentTools, useCanvasCommenting } from "./commenting"
|
|
39
40
|
import { CommentsPanel } from "./comments-panel"
|
|
40
41
|
import { CanvasControls } from "./controls"
|
|
42
|
+
import type { Box } from "./draft"
|
|
41
43
|
import { type CanvasEditor, useBoardEditing } from "./edit-mode"
|
|
42
|
-
import { CanvasEditingProvider } from "./editing"
|
|
43
|
-
import { BoardFocus } from "./focus"
|
|
44
|
+
import { CanvasEditingProvider, type CanvasItemEditing } from "./editing"
|
|
45
|
+
import { BoardFocus, followedArrow } from "./focus"
|
|
46
|
+
import { useBoardGestures } from "./gestures"
|
|
44
47
|
import { CANVAS_NODE_TYPES, NAME_SCALE, zoomMarks } from "./items"
|
|
45
48
|
import { PresenceLayer } from "./presence"
|
|
46
49
|
import { boardPreviewUrl, useBoardPreviews } from "./previews"
|
|
47
50
|
|
|
48
51
|
/**
|
|
49
52
|
* A canvas on an endless board: drag or scroll to pan, pinch or ⌘-scroll to zoom, the zoom
|
|
50
|
-
* controls in a corner. Boards and embeds run live once the view shows them large enough
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
+
* controls in a corner. Boards and embeds run live once the view shows them large enough, and a
|
|
54
|
+
* running board's page is the reader's to use in place while they read; double-click a board,
|
|
55
|
+
* press Enter on it, or press its Open to open it over the canvas. It opens on the item an
|
|
56
|
+
* address named, else fitted to everything. Given an editor, its items are
|
|
53
57
|
* selected, moved, resized, connected, and typed into, with a toolbar to add more.
|
|
54
58
|
*/
|
|
55
59
|
export default memo(function CanvasBoard({
|
|
@@ -157,16 +161,6 @@ function Board({
|
|
|
157
161
|
|
|
158
162
|
void fitView({ nodes: [{ id }], padding: CANVAS_FIT_PADDING, maxZoom: 1, duration: 220 })
|
|
159
163
|
}, [opened, fitView])
|
|
160
|
-
const live = useMemo(
|
|
161
|
-
() => ({
|
|
162
|
-
version: version ?? null,
|
|
163
|
-
live: running,
|
|
164
|
-
previews,
|
|
165
|
-
mode,
|
|
166
|
-
...(version ? { open: setOpened } : {}),
|
|
167
|
-
}),
|
|
168
|
-
[version, running, previews, mode]
|
|
169
|
-
)
|
|
170
164
|
// An opened board's picture, at its own size, under its page until the page is ready.
|
|
171
165
|
const pictureOf = useCallback(
|
|
172
166
|
(id: string) =>
|
|
@@ -175,6 +169,7 @@ function Board({
|
|
|
175
169
|
)
|
|
176
170
|
|
|
177
171
|
const board = useBoardEditing(canvas, edit, version ? setOpened : undefined)
|
|
172
|
+
const resizeBoard = useResizeBoard(board.editing ? board.items : null)
|
|
178
173
|
// What edits a board's elements in place: the live canvas, while the reader edits it.
|
|
179
174
|
const editBoard = edit?.live?.editBoard
|
|
180
175
|
const stopCapturing = edit?.live?.stopCapturing
|
|
@@ -275,6 +270,36 @@ function Board({
|
|
|
275
270
|
[commenting, boards, opened, fitView]
|
|
276
271
|
)
|
|
277
272
|
|
|
273
|
+
// Read, the running boards' pages are the reader's to use in place, and a button or a link in one
|
|
274
|
+
// that reads as the label of an arrow leaving it glides the canvas to the board it points to.
|
|
275
|
+
const reads = !board.editing && !commenting.commenting && opened === null
|
|
276
|
+
const follow = useRef<(from: string, text: string) => void>(() => {})
|
|
277
|
+
const gestures = useBoardGestures({
|
|
278
|
+
root: board.root,
|
|
279
|
+
pointed,
|
|
280
|
+
reading: reads,
|
|
281
|
+
opened: opened !== null,
|
|
282
|
+
padding: CANVAS_FIT_PADDING,
|
|
283
|
+
onPress: (from, text) => follow.current(from, text),
|
|
284
|
+
})
|
|
285
|
+
follow.current = (from, text) => {
|
|
286
|
+
const to = followedArrow(arrows, boards, from, text)
|
|
287
|
+
const target = boards.find((each) => each.id === to)
|
|
288
|
+
if (target) gestures.glide(target)
|
|
289
|
+
}
|
|
290
|
+
const live = useMemo(
|
|
291
|
+
() => ({
|
|
292
|
+
version: version ?? null,
|
|
293
|
+
live: running,
|
|
294
|
+
previews,
|
|
295
|
+
mode,
|
|
296
|
+
interactive: reads && version !== undefined,
|
|
297
|
+
gestures,
|
|
298
|
+
...(version ? { open: setOpened } : {}),
|
|
299
|
+
}),
|
|
300
|
+
[version, running, previews, mode, reads, gestures]
|
|
301
|
+
)
|
|
302
|
+
|
|
278
303
|
// Read, the board's handlers stay the same from one draw to the next, so React Flow doesn't
|
|
279
304
|
// draw every item again when the board does.
|
|
280
305
|
const open = live.open
|
|
@@ -416,6 +441,8 @@ function Board({
|
|
|
416
441
|
live={liveArtifact ?? null}
|
|
417
442
|
canvas={boardEditor}
|
|
418
443
|
mode={commenting.commenting ? "comment" : boardEditor ? "edit" : "read"}
|
|
444
|
+
// Keep this size resizes the board as its handles on the canvas do.
|
|
445
|
+
{...(resizeBoard ? { onResizeBoard: resizeBoard } : {})}
|
|
419
446
|
{...(commenting.enabled
|
|
420
447
|
? {
|
|
421
448
|
pins: commenting.pins,
|
|
@@ -468,6 +495,30 @@ function Board({
|
|
|
468
495
|
)
|
|
469
496
|
}
|
|
470
497
|
|
|
498
|
+
/**
|
|
499
|
+
* Keep this size: a board resized as its handles on the canvas resize it, while the canvas is
|
|
500
|
+
* edited. Outside editing, for whoever may change the canvas, it starts editing and resizes the
|
|
501
|
+
* board once editing is on, as if they had resized it there: the header's Undo takes it back.
|
|
502
|
+
* Null for whoever may not change the canvas.
|
|
503
|
+
*/
|
|
504
|
+
function useResizeBoard(items: CanvasItemEditing | null): ((id: string, box: Box) => void) | null {
|
|
505
|
+
const start = useStartEditing()
|
|
506
|
+
const [waiting, setWaiting] = useState<{ readonly id: string; readonly box: Box } | null>(null)
|
|
507
|
+
|
|
508
|
+
useEffect(() => {
|
|
509
|
+
if (!waiting || !items) return
|
|
510
|
+
items.resize(waiting.id, waiting.box)
|
|
511
|
+
setWaiting(null)
|
|
512
|
+
}, [waiting, items])
|
|
513
|
+
|
|
514
|
+
if (items) return items.resize
|
|
515
|
+
if (!start) return null
|
|
516
|
+
return (id, box) => {
|
|
517
|
+
setWaiting({ id, box })
|
|
518
|
+
start()
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
|
|
471
522
|
/** What belongs to the comments: their panel, their pins, and a board's element tools. */
|
|
472
523
|
const COMMENTS = "[data-comments-panel], [data-comment-pin], [data-board-tools]"
|
|
473
524
|
|
|
@@ -119,6 +119,7 @@ export function CommentComposer({
|
|
|
119
119
|
onCancel,
|
|
120
120
|
autoFocus = true,
|
|
121
121
|
compact = false,
|
|
122
|
+
notice,
|
|
122
123
|
className,
|
|
123
124
|
}: {
|
|
124
125
|
readonly placeholder: string
|
|
@@ -127,6 +128,8 @@ export function CommentComposer({
|
|
|
127
128
|
readonly autoFocus?: boolean
|
|
128
129
|
/** A reply's: one line until it grows. */
|
|
129
130
|
readonly compact?: boolean
|
|
131
|
+
/** Under the words, before they are posted: who else will read them. */
|
|
132
|
+
readonly notice?: ReactNode
|
|
130
133
|
readonly className?: string
|
|
131
134
|
}) {
|
|
132
135
|
const messages = useArtifactMessages().canvas.comments
|
|
@@ -218,6 +221,8 @@ export function CommentComposer({
|
|
|
218
221
|
<p role="alert" className="m-0 px-1 text-xs text-destructive">
|
|
219
222
|
{messages.failures[failure]}
|
|
220
223
|
</p>
|
|
224
|
+
) : notice ? (
|
|
225
|
+
<div className="px-1">{notice}</div>
|
|
221
226
|
) : null}
|
|
222
227
|
</div>
|
|
223
228
|
)
|