@vite-hub/ui 0.1.0 → 0.3.1
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/README.md +244 -18
- package/dist/attachments-BzTwqRTU.js +90 -0
- package/dist/choices-input-ByXJvDn1.d.ts +94 -0
- package/dist/{code-view-J4OsgEdh.js → code-view-D0bqhogi.js} +20 -4
- package/dist/colors-BghReA9C-CjF9gnmy.js +28 -0
- package/dist/comment-composer-Cc8Jvu6u.d.ts +243 -0
- package/dist/comment-composer-jYv2ULNP.js +591 -0
- package/dist/comment-layer-ClH4MLj4.d.ts +165 -0
- package/dist/comment-list-B8hphLfS.d.ts +62 -0
- package/dist/comment-marks.css +234 -0
- package/dist/comment-panel-fcKSKwLC.d.ts +197 -0
- package/dist/comment-person-CLPlW_SS.js +40 -0
- package/dist/comment-pin-CvwgRSDR.d.ts +68 -0
- package/dist/comment-row-Bbm9WwuF.js +39 -0
- package/dist/comment-thread-CoTLrdal.d.ts +368 -0
- package/dist/comment-visibility-DsVuVndP.d.ts +40 -0
- package/dist/{comments-ChNJkV1d.d.ts → comments-Bx2WRsYy.d.ts} +69 -7
- package/dist/{comments-C08J3z4e.js → comments-CkWc2Khc.js} +155 -60
- package/dist/comments-context-C2lOZyQ5.js +38 -0
- package/dist/config-DgxBW013.d.ts +80 -0
- package/dist/config-Dk67emQt.js +63 -0
- package/dist/copy-button-CRN3kmSD.js +253 -0
- package/dist/draw-DzSmD7uo-Dwz8zoH2.js +72976 -0
- package/dist/editor-C_wt4RRV.js +582 -0
- package/dist/error-diagnostics-SXtnk6bz.js +38 -0
- package/dist/{file-tree-C1pv4_AI.js → file-tree-C4OYgbV-.js} +292 -145
- package/dist/{file-tree-Ctb8hZ_g.d.ts → file-tree-DlT9RGhu.d.ts} +51 -15
- package/dist/format-Du58PlsG.js +18 -0
- package/dist/handlers-DMl-Na3x.js +182 -0
- package/dist/headless.d.ts +5 -176
- package/dist/headless.js +5 -3
- package/dist/icon-swap.css +69 -0
- package/dist/{image-preview-VfknBEFu.js → image-preview-C9tdkmEj.js} +8 -5
- package/dist/{index-DcH0QSI5.d.ts → index-BD1e8vx5.d.ts} +8 -0
- package/dist/{code-view-vDM-hph-.d.ts → index-CNY1uNTh.d.ts} +14 -228
- package/dist/index.d.ts +53 -56
- package/dist/index.js +677 -25
- package/dist/markdown-editor-CMbNZOdN.js +2394 -0
- package/dist/markdown-editor-DqdZfIEn.d.ts +195 -0
- package/dist/markdown-editor.d.ts +108 -0
- package/dist/markdown-editor.js +3 -0
- package/dist/message-scroller-Bm1YWTeY.d.ts +175 -0
- package/dist/nuxt-ui-DSQFzq3s.js +38 -0
- package/dist/nuxt.d.ts +84 -2
- package/dist/nuxt.js +237 -35
- package/dist/parts/components/agent-session.d.ts +254 -0
- package/dist/parts/components/agent-session.js +640 -0
- package/dist/{attachment-BBndG9_P.d.ts → parts/components/attachment.d.ts} +13 -14
- package/dist/{attachment-B3dXC7jM.js → parts/components/attachment.js} +6 -4
- package/dist/{avatar-stack.d.ts → parts/components/avatar-stack.d.ts} +1 -1
- package/dist/{avatar-stack-DM6HRnc0.js → parts/components/avatar-stack.js} +2 -5
- package/dist/{bubble-BJH2rfii.d.ts → parts/components/bubble.d.ts} +8 -9
- package/dist/{bubble-BPyFQlW7.js → parts/components/bubble.js} +2 -2
- package/dist/{chat-message-mpDmZbIC.d.ts → parts/components/chat-message.d.ts} +2 -3
- package/dist/{chat-message-BNK9G7xF.js → parts/components/chat-message.js} +4 -4
- package/dist/{chat-session-D6C7VJBR.d.ts → parts/components/chat-session.d.ts} +3 -4
- package/dist/{chat-session-DYEHB1HC.js → parts/components/chat-session.js} +2 -2
- package/dist/{chat-B9HlZWA2.d.ts → parts/components/chat.d.ts} +8 -4
- package/dist/{chat-BoFHlu9V.js → parts/components/chat.js} +42 -9
- package/dist/{highlighted-code-Dzf6o54i.d.ts → parts/components/code-block.d.ts} +16 -24
- package/dist/{code-block-Br-02hn-.js → parts/components/code-block.js} +9 -38
- package/dist/parts/components/code-view.d.ts +270 -0
- package/dist/parts/components/code-view.js +2 -0
- package/dist/parts/components/comment-composer.d.ts +2 -0
- package/dist/parts/components/comment-composer.js +2 -0
- package/dist/parts/components/comment-layer.d.ts +2 -0
- package/dist/parts/components/comment-layer.js +618 -0
- package/dist/parts/components/comment-list.d.ts +2 -0
- package/dist/parts/components/comment-list.js +167 -0
- package/dist/parts/components/comment-panel.d.ts +2 -0
- package/dist/parts/components/comment-panel.js +299 -0
- package/dist/parts/components/comment-pin.d.ts +2 -0
- package/dist/parts/components/comment-pin.js +75 -0
- package/dist/parts/components/comment-thread.d.ts +2 -0
- package/dist/parts/components/comment-thread.js +571 -0
- package/dist/parts/components/comments.d.ts +7 -0
- package/dist/parts/components/comments.js +8 -0
- package/dist/{connection-status-DjGBw6xX.d.ts → parts/components/connection-status.d.ts} +6 -7
- package/dist/{connection-status-CzuWBENf.js → parts/components/connection-status.js} +1 -1
- package/dist/parts/components/copy-button.d.ts +118 -0
- package/dist/parts/components/copy-button.js +2 -0
- package/dist/parts/components/device-frame.d.ts +130 -0
- package/dist/parts/components/device-frame.js +471 -0
- package/dist/parts/components/file-tree.d.ts +2 -0
- package/dist/parts/components/file-tree.js +2 -0
- package/dist/parts/components/filter-search.d.ts +47 -0
- package/dist/parts/components/filter-search.js +58 -0
- package/dist/parts/components/markdown-editor.d.ts +2 -0
- package/dist/parts/components/markdown-editor.js +2 -0
- package/dist/parts/components/markdown-renderer.d.ts +52 -0
- package/dist/parts/components/markdown-renderer.js +23077 -0
- package/dist/{markdown-Dse5ldJe.d.ts → parts/components/markdown.d.ts} +7 -7
- package/dist/parts/components/markdown.js +47 -0
- package/dist/{marker-ea-tvx-J.d.ts → parts/components/marker.d.ts} +5 -6
- package/dist/{marker-Di2ZG_k1.js → parts/components/marker.js} +2 -2
- package/dist/{message-parts-BBFUkluC.d.ts → parts/components/message-parts.d.ts} +2 -3
- package/dist/{message-parts-DQnfioAH.js → parts/components/message-parts.js} +6 -6
- package/dist/{message-CW_paC1k.d.ts → parts/components/message.d.ts} +8 -9
- package/dist/{message-DiyBthIq.js → parts/components/message.js} +2 -2
- package/dist/parts/components/patch-parsers.d.ts +2 -0
- package/dist/parts/components/patch-parsers.js +2 -0
- package/dist/{prompt-input-Cy_Ue6B5.d.ts → parts/components/prompt-input.d.ts} +54 -11
- package/dist/{prompt-input-BbnCb80O.js → parts/components/prompt-input.js} +66 -111
- package/dist/parts/components/relative-time.d.ts +73 -0
- package/dist/parts/components/relative-time.js +2 -0
- package/dist/parts/components/status.d.ts +60 -0
- package/dist/parts/components/status.js +48 -0
- package/dist/{sync-status-refELOZn.d.ts → parts/components/sync-status.d.ts} +5 -6
- package/dist/{sync-status-BpxYdZIJ.js → parts/components/sync-status.js} +1 -1
- package/dist/{tool-list-E7CA52rz.d.ts → parts/components/tool-list.d.ts} +3 -4
- package/dist/{tool-list-BdSr5CT4.js → parts/components/tool-list.js} +7 -38
- package/dist/{trace-run-COeXn46Z.d.ts → parts/components/trace-run.d.ts} +3 -4
- package/dist/{trace-run-BIQ17CED.js → parts/components/trace-run.js} +15 -23
- package/dist/{trace-V7rM3Pyd.d.ts → parts/components/trace.d.ts} +10 -11
- package/dist/{trace-llBCDiSW.js → parts/components/trace.js} +20 -13
- package/dist/parts/composables/attachments.d.ts +32 -0
- package/dist/parts/composables/attachments.js +2 -0
- package/dist/parts/composables/highlighted-code.d.ts +9 -0
- package/dist/{highlighted-code-Ck4zexJX.js → parts/composables/highlighted-code.js} +5 -2
- package/dist/parts/headless/choices-input.d.ts +2 -0
- package/dist/parts/headless/choices-input.js +162 -0
- package/dist/parts/headless/comment-visibility.d.ts +2 -0
- package/dist/parts/headless/comment-visibility.js +128 -0
- package/dist/parts/headless/comments.d.ts +2 -0
- package/dist/parts/headless/comments.js +2 -0
- package/dist/parts/headless/message-scroller.d.ts +2 -0
- package/dist/{message-scroller-CX6NJTdm.js → parts/headless/message-scroller.js} +2 -2
- package/dist/parts/playground/highlight.d.ts +5 -0
- package/dist/parts/playground/highlight.js +23 -0
- package/dist/parts/playground/paths.d.ts +4 -0
- package/dist/parts/playground/paths.js +7 -0
- package/dist/parts/playground/playground-render.d.ts +126 -0
- package/dist/parts/playground/playground-render.js +356 -0
- package/dist/parts/playground/share.d.ts +2 -0
- package/dist/parts/playground/share.js +92 -0
- package/dist/parts/playground/zip.d.ts +6 -0
- package/dist/parts/playground/zip.js +76 -0
- package/dist/parts/workspace/browser-support-notice.d.ts +76 -0
- package/dist/parts/workspace/browser-support-notice.js +105 -0
- package/dist/parts/workspace/codemirror.d.ts +16 -0
- package/dist/parts/workspace/codemirror.js +243 -0
- package/dist/parts/workspace/connect-panel.d.ts +129 -0
- package/dist/parts/workspace/connect-panel.js +285 -0
- package/dist/parts/workspace/connect-store.d.ts +26 -0
- package/dist/parts/workspace/connect-store.js +59 -0
- package/dist/parts/workspace/icons.d.ts +34 -0
- package/dist/parts/workspace/icons.js +46 -0
- package/dist/parts/workspace/playground-container.d.ts +192 -0
- package/dist/parts/workspace/playground-container.js +603 -0
- package/dist/parts/workspace/workspace-boot-status.d.ts +75 -0
- package/dist/parts/workspace/workspace-boot-status.js +207 -0
- package/dist/parts/workspace/workspace-editor.d.ts +43 -0
- package/dist/parts/workspace/workspace-editor.js +54 -0
- package/dist/parts/workspace/workspace-file-tree.d.ts +53 -0
- package/dist/parts/workspace/workspace-file-tree.js +68 -0
- package/dist/parts/workspace/workspace-preview.d.ts +72 -0
- package/dist/parts/workspace/workspace-preview.js +307 -0
- package/dist/parts/workspace/workspace-shell.d.ts +88 -0
- package/dist/parts/workspace/workspace-shell.js +291 -0
- package/dist/parts/workspace/workspace-terminal.d.ts +39 -0
- package/dist/parts/workspace/workspace-terminal.js +130 -0
- package/dist/payload-text-sjkYAwvw.js +32 -0
- package/dist/{pierre-code-view-T7V67hwT.js → pierre-code-view-xgBL6DO7.js} +209 -86
- package/dist/{pierre-dark-DDWDl8g6.js → pierre-dark-CzUmjETS.js} +3 -1
- package/dist/{pierre-light-CWhW4NrH.js → pierre-light-Dn6E0sWv.js} +3 -1
- package/dist/playground.d.ts +4 -0
- package/dist/playground.js +4 -0
- package/dist/relative-time-BVmjOsYG.js +309 -0
- package/dist/rolldown-runtime-C9mWXvCC.js +29 -0
- package/dist/runtime/nuxt-plugin.js +23 -4
- package/dist/sankey-CAYwt82B-D4uDQoMR.js +2887 -0
- package/dist/share-DM4eNy4q.d.ts +37 -0
- package/dist/{slot-part-C7Ocxn3b.js → slot-part-Doic71uh.js} +7 -1
- package/dist/styles.css +2465 -594
- package/dist/temml-BilSAAws.js +12362 -0
- package/dist/theme-focus-ring.css +42 -0
- package/dist/theme.css +376 -0
- package/dist/theme.d.ts +355 -0
- package/dist/theme.js +265 -0
- package/dist/{types-CqDwuJAm.d.ts → types-Dyr6CfBW.d.ts} +1 -1
- package/dist/vue-BDmSCtay.js +30779 -0
- package/dist/vue-DGstVdGn.js +2492 -0
- package/dist/workspace.d.ts +15 -0
- package/dist/workspace.js +12 -0
- package/package.json +136 -150
- package/dist/andromeeda-BASpqCeJ.js +0 -4
- package/dist/attachment.d.ts +0 -2
- package/dist/attachment.js +0 -2
- package/dist/aurora-x-DugsLcii.js +0 -4
- package/dist/avatar-stack.js +0 -2
- package/dist/ayu-dark-BT3qdi3o.js +0 -4
- package/dist/ayu-light-BVZyHoh9.js +0 -4
- package/dist/ayu-mirage-XFwUVZQZ.js +0 -4
- package/dist/bubble.d.ts +0 -2
- package/dist/bubble.js +0 -2
- package/dist/catppuccin-frappe-D20KODDN.js +0 -4
- package/dist/catppuccin-latte-eGLVHIUJ.js +0 -4
- package/dist/catppuccin-macchiato-bQGch4PY.js +0 -4
- package/dist/catppuccin-mocha-Bes8-0Mr.js +0 -4
- package/dist/chat-message.d.ts +0 -2
- package/dist/chat-message.js +0 -2
- package/dist/chat-session.d.ts +0 -2
- package/dist/chat-session.js +0 -2
- package/dist/chat.d.ts +0 -2
- package/dist/chat.js +0 -2
- package/dist/code-block.d.ts +0 -2
- package/dist/code-block.js +0 -3
- package/dist/code-view.d.ts +0 -2
- package/dist/code-view.js +0 -2
- package/dist/comment-layer-CBlxJ8eK.js +0 -1113
- package/dist/comments-Cq5eewsu.d.ts +0 -537
- package/dist/comments.d.ts +0 -2
- package/dist/comments.js +0 -2
- package/dist/config-Bux_AJzm.d.ts +0 -29
- package/dist/config-bHqE4JOs.js +0 -38
- package/dist/connection-status.d.ts +0 -2
- package/dist/connection-status.js +0 -2
- package/dist/dark-plus-BGuiqa1B.js +0 -4
- package/dist/dracula-0CVA2XY5.js +0 -4
- package/dist/dracula-soft-Dk9bpbVU.js +0 -4
- package/dist/error-diagnostics-B4hMpJRL.js +0 -13
- package/dist/everforest-dark-CRjTbhh5.js +0 -4
- package/dist/everforest-light-CEeYFLn8.js +0 -4
- package/dist/file-diff.d.ts +0 -2
- package/dist/file-diff.js +0 -2
- package/dist/file-tree.d.ts +0 -2
- package/dist/file-tree.js +0 -2
- package/dist/file-view.d.ts +0 -2
- package/dist/file-view.js +0 -2
- package/dist/github-dark-BXgKmOw_.js +0 -4
- package/dist/github-dark-default-DzJQXksd.js +0 -4
- package/dist/github-dark-dimmed-B1pEmGtS.js +0 -4
- package/dist/github-dark-high-contrast-BkHIa6jc.js +0 -4
- package/dist/github-light-BKRlUbaB.js +0 -4
- package/dist/github-light-default-BU3eYkzs.js +0 -4
- package/dist/github-light-high-contrast-B3MumDcI.js +0 -4
- package/dist/gruvbox-dark-hard-B0ecF443.js +0 -4
- package/dist/gruvbox-dark-medium-BQnpC39k.js +0 -4
- package/dist/gruvbox-dark-soft-DFZUgESr.js +0 -4
- package/dist/gruvbox-light-hard-CuB_LOJr.js +0 -4
- package/dist/gruvbox-light-medium-idDHgxjs.js +0 -4
- package/dist/gruvbox-light-soft-CfWH49MY.js +0 -4
- package/dist/horizon-bright-Ba6M8QSV.js +0 -4
- package/dist/horizon-h92C5OlZ.js +0 -4
- package/dist/houston-EQnPegWq.js +0 -4
- package/dist/kanagawa-dragon-DgDvwi3B.js +0 -4
- package/dist/kanagawa-lotus-BgoQro20.js +0 -4
- package/dist/kanagawa-wave-DgXEowHs.js +0 -4
- package/dist/laserwave-IxBH_3yW.js +0 -4
- package/dist/light-plus-S8JBx6is.js +0 -4
- package/dist/markdown-BoLBN0qH.js +0 -197
- package/dist/markdown.d.ts +0 -2
- package/dist/markdown.js +0 -2
- package/dist/marker.d.ts +0 -2
- package/dist/marker.js +0 -2
- package/dist/material-theme-D1f3HBq-.js +0 -4
- package/dist/material-theme-darker-ExzYhT0j.js +0 -4
- package/dist/material-theme-lighter-D6gH9nnA.js +0 -4
- package/dist/material-theme-ocean-D1w5BPAa.js +0 -4
- package/dist/material-theme-palenight-CkqWmVpF.js +0 -4
- package/dist/message-parts.d.ts +0 -2
- package/dist/message-parts.js +0 -2
- package/dist/message.d.ts +0 -2
- package/dist/message.js +0 -2
- package/dist/min-dark-npsJH98j.js +0 -4
- package/dist/min-light-DUk1XsVt.js +0 -4
- package/dist/monokai-CfFRWUNl.js +0 -4
- package/dist/multi-file-diff.d.ts +0 -2
- package/dist/multi-file-diff.js +0 -2
- package/dist/night-owl-BS7V-av_.js +0 -4
- package/dist/night-owl-light-CZtRawYE.js +0 -4
- package/dist/nord-BFh54Nqz.js +0 -4
- package/dist/one-dark-pro-zDovGosB.js +0 -4
- package/dist/one-light-gmHK3iK6.js +0 -4
- package/dist/patch-diff.d.ts +0 -2
- package/dist/patch-diff.js +0 -2
- package/dist/plastic-DtdaCjub.js +0 -4
- package/dist/poimandres-Hdda6aHK.js +0 -4
- package/dist/primitive-rail.d.ts +0 -222
- package/dist/primitive-rail.js +0 -348
- package/dist/prompt-input.d.ts +0 -2
- package/dist/prompt-input.js +0 -2
- package/dist/red-VqZFRByZ.js +0 -4
- package/dist/rose-pine-DiTkEueR.js +0 -4
- package/dist/rose-pine-dawn-tfo5y2X0.js +0 -4
- package/dist/rose-pine-moon-C0gON9XN.js +0 -4
- package/dist/runtime-type-DlCscMfw.js +0 -59
- package/dist/slack-dark-v8P_eXr6.js +0 -4
- package/dist/slack-ochin-D8SyEdKz.js +0 -4
- package/dist/snazzy-light-BtkQkvXb.js +0 -4
- package/dist/solarized-dark-B8nAdMfM.js +0 -4
- package/dist/solarized-light-B-3F1INj.js +0 -4
- package/dist/sync-status.d.ts +0 -2
- package/dist/sync-status.js +0 -2
- package/dist/synthwave-84-DcsXCF_c.js +0 -4
- package/dist/tokyo-night-Bvpqduda.js +0 -4
- package/dist/tool-list.d.ts +0 -2
- package/dist/tool-list.js +0 -2
- package/dist/trace-run.d.ts +0 -2
- package/dist/trace-run.js +0 -2
- package/dist/trace.d.ts +0 -2
- package/dist/trace.js +0 -2
- package/dist/unresolved-file.d.ts +0 -2
- package/dist/unresolved-file.js +0 -2
- package/dist/vesper-CfxmMOy3.js +0 -4
- package/dist/vitesse-black-D9-_1mjV.js +0 -4
- package/dist/vitesse-dark-DlSMLlr9.js +0 -4
- package/dist/vitesse-light-KRWWWztf.js +0 -4
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import { t as CommentVisibility } from "./comment-visibility-DsVuVndP.js";
|
|
1
2
|
import { ComputedRef, MaybeRefOrGetter, Ref, ShallowRef } from "vue";
|
|
2
|
-
import { AnchorPoint, AnchorPosition, AnchorTarget, CommentAnchor, CommentSubject, CommentThread, CommentUser, CommentsClient, CommentsClientStatus, CreateAnchorOptions } from "@vite-hub/comments/client";
|
|
3
|
+
import { AnchorPoint, AnchorPosition, AnchorTarget, CommentAnchor, CommentMessage, CommentSubject, CommentThread, CommentUser, CommentsClient, CommentsClientStatus, CreateAnchorOptions } from "@vite-hub/comments/client";
|
|
3
4
|
//#region src/headless/comments.d.ts
|
|
4
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Each switch shows one kind of thread. Resolved threads stay hidden until `resolved` is on. A resolved thread with a
|
|
7
|
+
* reply since it was resolved also counts as open, so the reply is seen.
|
|
8
|
+
*/
|
|
5
9
|
interface CommentFilterState {
|
|
6
10
|
open: boolean;
|
|
7
11
|
resolved: boolean;
|
|
@@ -17,15 +21,33 @@ interface CommentDraft {
|
|
|
17
21
|
point: AnchorPoint;
|
|
18
22
|
body: string;
|
|
19
23
|
mentions: string[];
|
|
24
|
+
/** Attachment keys, such as Blob keys, that the comment sends. */
|
|
25
|
+
attachments: string[];
|
|
26
|
+
/** Files that the composer starts with, such as a screenshot. They upload with the comment, as picked files do. */
|
|
27
|
+
files?: File[];
|
|
20
28
|
busy: boolean;
|
|
21
29
|
error: string | undefined;
|
|
22
30
|
}
|
|
31
|
+
/** What the signed-in user may do to a thread. `edit` and `delete` name a message; deleting the first one deletes the thread. */
|
|
32
|
+
type CommentThreadAction = "reply" | "resolve" | "edit" | "delete";
|
|
33
|
+
/** Whether the signed-in user may do `action`. The parts show only the controls that it allows. The server still decides. */
|
|
34
|
+
type CommentCan = (action: CommentThreadAction, target: {
|
|
35
|
+
thread: CommentThread;
|
|
36
|
+
message?: CommentMessage;
|
|
37
|
+
}) => boolean;
|
|
38
|
+
/**
|
|
39
|
+
* The permissions that the parts assume without a `can` option: a signed-in user may reply to and resolve any thread,
|
|
40
|
+
* and edit and delete their own messages. Nobody may do anything without a user.
|
|
41
|
+
*/
|
|
42
|
+
declare function defaultCommentCan(user: CommentUser | undefined): CommentCan;
|
|
23
43
|
interface UseCommentsOptions {
|
|
24
44
|
client: CommentsClient;
|
|
25
45
|
/** What the threads of this page are about. For a page, `{ kind: "page", id: location.pathname }`. */
|
|
26
46
|
subject: MaybeRefOrGetter<CommentSubject>;
|
|
27
47
|
/** The signed-in user. Defaults to `client.user`. */
|
|
28
48
|
user?: MaybeRefOrGetter<CommentUser | undefined>;
|
|
49
|
+
/** People that the app already knows, such as the ones that a server answer named. Their mentions show as chips. */
|
|
50
|
+
people?: MaybeRefOrGetter<readonly CommentUser[]>;
|
|
29
51
|
/** Where anchors are looked up. Defaults to the document. */
|
|
30
52
|
root?: MaybeRefOrGetter<ParentNode | undefined>;
|
|
31
53
|
/** The query parameter that deep-links a thread. Default `"comment"`. */
|
|
@@ -42,11 +64,24 @@ interface UseCommentsOptions {
|
|
|
42
64
|
location?: () => Pick<Location, "href" | "origin" | "search">;
|
|
43
65
|
/** Load the threads and listen for keys when the component mounts. Default `true`. Call `start()` yourself when `false`. */
|
|
44
66
|
autoStart?: boolean;
|
|
67
|
+
/** What the signed-in user may do, such as your app's sharing rules. Defaults to `defaultCommentCan()`. */
|
|
68
|
+
can?: CommentCan;
|
|
69
|
+
/**
|
|
70
|
+
* Which comments show on the page. Default `"all"`. Pass a ref to keep the reader's choice, such as one saved in
|
|
71
|
+
* `localStorage`: the state reads and writes it.
|
|
72
|
+
*/
|
|
73
|
+
visibility?: CommentVisibility | Ref<CommentVisibility>;
|
|
74
|
+
/** How long a comment or reply that was just sent shows while comments are hidden. Default `2500`. */
|
|
75
|
+
flashMs?: number;
|
|
45
76
|
}
|
|
46
77
|
interface CommentsState {
|
|
47
78
|
readonly client: CommentsClient;
|
|
48
79
|
readonly subject: ComputedRef<CommentSubject>;
|
|
49
80
|
readonly user: ComputedRef<CommentUser | undefined>;
|
|
81
|
+
/** Whether the signed-in user may reply, resolve, edit, or delete. Always false without a user. */
|
|
82
|
+
readonly can: CommentCan;
|
|
83
|
+
/** Every person the state knows: the user, the authors of threads, the people that `users()` found, and `people`. Mentions get their names here. */
|
|
84
|
+
readonly people: ComputedRef<CommentUser[]>;
|
|
50
85
|
/** Comment mode: a click drops a pin. */
|
|
51
86
|
readonly active: Ref<boolean>;
|
|
52
87
|
readonly scope: Ref<CommentScope>;
|
|
@@ -71,11 +106,30 @@ interface CommentsState {
|
|
|
71
106
|
readonly listOpen: Ref<boolean>;
|
|
72
107
|
/** Goes up when a composer with text stopped a click or a key. The composer shakes by itself. */
|
|
73
108
|
readonly blocked: Ref<number>;
|
|
109
|
+
/** Which comments show. Writing or opening a comment never changes it. */
|
|
110
|
+
readonly visibility: Ref<CommentVisibility>;
|
|
111
|
+
/**
|
|
112
|
+
* The ids of the threads of this page that get a pin or a mark: all of them, or while comments are hidden, the open
|
|
113
|
+
* thread and each one that was just sent or replied to. The draft always shows.
|
|
114
|
+
*/
|
|
115
|
+
readonly shown: ComputedRef<ReadonlySet<string>>;
|
|
116
|
+
/** The ids of threads that stopped showing while comments are hidden, for 180 ms. Their marks play the pop-out. */
|
|
117
|
+
readonly leaving: ComputedRef<ReadonlySet<string>>;
|
|
118
|
+
/** Keeps page marks visible without opening a popover. Call the returned release function when the panel closes. */
|
|
119
|
+
retainMark: (id: string) => () => void;
|
|
120
|
+
isShown: (id: string) => boolean;
|
|
121
|
+
/** Shows the thread for `flashMs` while comments are hidden. `send()`, `create()`, and `reply()` call it. */
|
|
122
|
+
flash: (id: string) => void;
|
|
74
123
|
enter: () => void;
|
|
75
124
|
exit: () => void;
|
|
76
125
|
toggle: () => void;
|
|
77
|
-
/**
|
|
78
|
-
|
|
126
|
+
/**
|
|
127
|
+
* Starts a draft on a point, an element, a selection, or `"page"`. Ends an empty draft first, and keeps one with text.
|
|
128
|
+
* A pin has no number until the server assigns one. `files` start in its composer, such as a screenshot of the area.
|
|
129
|
+
*/
|
|
130
|
+
startDraft: (target: AnchorTarget, options?: CreateAnchorOptions & {
|
|
131
|
+
files?: File[];
|
|
132
|
+
}) => void;
|
|
79
133
|
cancelDraft: () => void;
|
|
80
134
|
/** Sends the draft. Resolves with the new thread, or `undefined` when there is nothing to send or the send failed. */
|
|
81
135
|
send: () => Promise<CommentThread | undefined>;
|
|
@@ -84,12 +138,20 @@ interface CommentsState {
|
|
|
84
138
|
}) => void;
|
|
85
139
|
/** Closes the thread, returning false when unsent text prevents closing or navigation. */
|
|
86
140
|
close: () => boolean;
|
|
87
|
-
|
|
141
|
+
/** Starts a thread on the subject. The anchor defaults to the whole page. */
|
|
142
|
+
create: (input: {
|
|
143
|
+
body: string;
|
|
144
|
+
mentions?: string[];
|
|
145
|
+
attachments?: string[];
|
|
146
|
+
anchor?: CommentAnchor;
|
|
147
|
+
}) => Promise<CommentThread>;
|
|
148
|
+
reply: (threadId: string, body: string, mentions?: string[], attachments?: string[]) => Promise<CommentThread>;
|
|
88
149
|
edit: (threadId: string, messageId: string, body: string, mentions?: string[]) => Promise<CommentThread>;
|
|
89
150
|
remove: (threadId: string, messageId?: string) => Promise<CommentThread | null>;
|
|
90
151
|
resolve: (threadId: string) => Promise<CommentThread>;
|
|
91
152
|
reopen: (threadId: string) => Promise<CommentThread>;
|
|
92
|
-
|
|
153
|
+
/** Finds people for a reply or edit in `threadId`, or for a new thread on the current subject. */
|
|
154
|
+
users: (query: string, threadId?: string) => Promise<CommentUser[]>;
|
|
93
155
|
/** The URL that opens the thread: its page with `?comment=<n>`. */
|
|
94
156
|
link: (thread: CommentThread) => string;
|
|
95
157
|
/** Measures every pin again. The state does it on scroll, resize, and DOM changes. */
|
|
@@ -105,4 +167,4 @@ declare function provideComments(state: CommentsState): void;
|
|
|
105
167
|
/** The state that a comment part uses: the one you pass, else the one of the nearest `CommentLayer` or `provideComments()`. Call it in `setup()`. */
|
|
106
168
|
declare function useCommentsContext(state?: CommentsState): CommentsState;
|
|
107
169
|
//#endregion
|
|
108
|
-
export {
|
|
170
|
+
export { CommentThreadAction as a, defaultCommentCan as c, useComments as d, useCommentsContext as f, CommentScope as i, draftPositionKey as l, CommentDraft as n, CommentsState as o, CommentFilterState as r, UseCommentsOptions as s, CommentCan as t, provideComments as u };
|
|
@@ -1,39 +1,33 @@
|
|
|
1
|
-
import { t as uiErrorDiagnostics } from "./error-diagnostics-
|
|
2
|
-
import {
|
|
1
|
+
import { t as uiErrorDiagnostics } from "./error-diagnostics-SXtnk6bz.js";
|
|
2
|
+
import { i as hasDirtyComposer, n as injectComments, o as shakeDirtyComposers, t as commentsKey } from "./comments-context-C2lOZyQ5.js";
|
|
3
|
+
import { createCommentVisibility } from "./parts/headless/comment-visibility.js";
|
|
4
|
+
import { computed, getCurrentInstance, isRef, onBeforeUnmount, onMounted, provide, reactive, ref, shallowRef, toRaw, toValue, watch } from "vue";
|
|
3
5
|
import { createAnchor, resolveAnchor } from "@vite-hub/comments/client";
|
|
4
|
-
//#region src/internal/comment-
|
|
5
|
-
|
|
6
|
-
function
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
cleanup();
|
|
11
|
-
};
|
|
12
|
-
const cleanup = () => {
|
|
13
|
-
document.removeEventListener("click", stop, true);
|
|
14
|
-
document.removeEventListener("pointerdown", cleanup, true);
|
|
15
|
-
};
|
|
16
|
-
document.addEventListener("click", stop, true);
|
|
17
|
-
document.addEventListener("pointerdown", cleanup, true);
|
|
18
|
-
}
|
|
19
|
-
function useDocumentPointerDown(handler) {
|
|
20
|
-
onMounted(() => document.addEventListener("pointerdown", handler, true));
|
|
21
|
-
onBeforeUnmount(() => document.removeEventListener("pointerdown", handler, true));
|
|
22
|
-
}
|
|
23
|
-
const shakeEventName = "comments:shake";
|
|
24
|
-
const dirtySelector = "[data-slot='comment-composer'][data-dirty='true']";
|
|
25
|
-
function hasDirtyComposer(root = document) {
|
|
26
|
-
return root.querySelector(dirtySelector) !== null;
|
|
6
|
+
//#region src/internal/comment-status.ts
|
|
7
|
+
/** The messages written after the thread was resolved. Empty for an open thread. */
|
|
8
|
+
function messagesSinceResolved(thread) {
|
|
9
|
+
const { resolvedAt } = thread;
|
|
10
|
+
if (thread.status !== "resolved" || resolvedAt === void 0) return [];
|
|
11
|
+
return thread.messages.filter((message) => message.createdAt > resolvedAt);
|
|
27
12
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const pathOf = (event) => event.composedPath().filter((node) => node instanceof Element);
|
|
13
|
+
/**
|
|
14
|
+
* Whether someone replied after the thread was resolved, such as an agent that says what it changed. The thread stays
|
|
15
|
+
* resolved, and lists show it with the open threads until someone resolves it again.
|
|
16
|
+
*/
|
|
17
|
+
const repliedSinceResolved = (thread) => messagesSinceResolved(thread).length > 0;
|
|
34
18
|
//#endregion
|
|
35
19
|
//#region src/headless/comments.ts
|
|
36
|
-
|
|
20
|
+
/**
|
|
21
|
+
* The permissions that the parts assume without a `can` option: a signed-in user may reply to and resolve any thread,
|
|
22
|
+
* and edit and delete their own messages. Nobody may do anything without a user.
|
|
23
|
+
*/
|
|
24
|
+
function defaultCommentCan(user) {
|
|
25
|
+
return (action, { message }) => {
|
|
26
|
+
if (!user) return false;
|
|
27
|
+
if (action === "edit" || action === "delete") return message?.author.id === user.id;
|
|
28
|
+
return true;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
37
31
|
const draftPositionKey = "draft";
|
|
38
32
|
const uiSelector = "[data-comments-ui]";
|
|
39
33
|
function defaultIgnore(element) {
|
|
@@ -86,11 +80,23 @@ function useComments(options) {
|
|
|
86
80
|
const positions = shallowRef(/* @__PURE__ */ new Map());
|
|
87
81
|
const draft = ref(null);
|
|
88
82
|
const openId = ref(null);
|
|
83
|
+
const retained = shallowRef(/* @__PURE__ */ new Map());
|
|
84
|
+
const retainedIds = computed(() => new Set(retained.value.values()));
|
|
85
|
+
const retainMark = (id) => {
|
|
86
|
+
const key = Symbol();
|
|
87
|
+
retained.value = new Map(retained.value).set(key, id);
|
|
88
|
+
return () => {
|
|
89
|
+
const next = new Map(retained.value);
|
|
90
|
+
next.delete(key);
|
|
91
|
+
retained.value = next;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
89
94
|
const hoverId = ref(null);
|
|
90
95
|
const listOpen = ref(false);
|
|
91
96
|
const blocked = ref(0);
|
|
97
|
+
const isOpen = (thread) => thread.status === "open" || repliedSinceResolved(thread);
|
|
92
98
|
const passes = (thread) => {
|
|
93
|
-
if (
|
|
99
|
+
if (!(filters.open && isOpen(thread) || filters.resolved && thread.status === "resolved")) return false;
|
|
94
100
|
return !filters.mine || thread.author.id === user.value?.id;
|
|
95
101
|
};
|
|
96
102
|
const onPage = (thread) => sameSubject(thread.subject, subject.value);
|
|
@@ -99,26 +105,53 @@ function useComments(options) {
|
|
|
99
105
|
const counts = computed(() => {
|
|
100
106
|
const scoped = threads.value.filter((thread) => scope.value === "site" || onPage(thread));
|
|
101
107
|
return {
|
|
102
|
-
open: scoped.filter(
|
|
108
|
+
open: scoped.filter(isOpen).length,
|
|
103
109
|
resolved: scoped.filter((thread) => thread.status === "resolved").length
|
|
104
110
|
};
|
|
105
111
|
});
|
|
106
112
|
const opened = computed(() => threads.value.find((thread) => thread.id === openId.value));
|
|
113
|
+
const visibility = isRef(options.visibility) ? options.visibility : ref(options.visibility ?? "all");
|
|
114
|
+
const seen = createCommentVisibility({
|
|
115
|
+
visibility: visibility.value,
|
|
116
|
+
flashMs: options.flashMs
|
|
117
|
+
});
|
|
118
|
+
const seenChanges = ref(0);
|
|
119
|
+
seen.subscribe(() => seenChanges.value++);
|
|
120
|
+
watch(visibility, (value) => seen.set(value), { flush: "sync" });
|
|
121
|
+
watch(openId, (id) => seen.open(id), { flush: "sync" });
|
|
122
|
+
watch(hoverId, (id) => seen.hover(id), { flush: "sync" });
|
|
123
|
+
const marked = computed(() => {
|
|
124
|
+
seenChanges.value;
|
|
125
|
+
const ids = new Set(pageThreads.value.map((thread) => thread.id));
|
|
126
|
+
if (opened.value && onPage(opened.value)) ids.add(opened.value.id);
|
|
127
|
+
for (const thread of threads.value) {
|
|
128
|
+
const temporary = visibility.value === "hidden" && (seen.isShown(thread.id) || seen.leaving.includes(thread.id));
|
|
129
|
+
if (onPage(thread) && (retainedIds.value.has(thread.id) || temporary)) ids.add(thread.id);
|
|
130
|
+
}
|
|
131
|
+
return ids;
|
|
132
|
+
});
|
|
133
|
+
const shown = computed(() => {
|
|
134
|
+
seenChanges.value;
|
|
135
|
+
return new Set([...marked.value].filter((id) => seen.isShown(id) || retainedIds.value.has(id)));
|
|
136
|
+
});
|
|
137
|
+
const leaving = computed(() => {
|
|
138
|
+
seenChanges.value;
|
|
139
|
+
return new Set(seen.leaving.filter((id) => marked.value.has(id) && !retainedIds.value.has(id)));
|
|
140
|
+
});
|
|
141
|
+
const flash = (id) => seen.flash(id);
|
|
107
142
|
const root = () => toValue(options.root) ?? document;
|
|
108
143
|
const uiRoot = () => toValue(options.uiRoot) ?? document;
|
|
109
144
|
function measure() {
|
|
110
145
|
const next = /* @__PURE__ */ new Map();
|
|
111
|
-
for (const thread of
|
|
112
|
-
const current = opened.value;
|
|
113
|
-
if (current && onPage(current) && !next.has(current.id)) next.set(current.id, resolveAnchor(current.anchor, root()));
|
|
146
|
+
for (const thread of threads.value.filter((thread) => marked.value.has(thread.id))) next.set(thread.id, resolveAnchor(thread.anchor, root()));
|
|
114
147
|
if (draft.value) next.set(draftPositionKey, resolveAnchor(draft.value.anchor, root()));
|
|
115
148
|
const previous = positions.value;
|
|
116
149
|
if (!(next.size === previous.size && [...next].every(([key, position]) => samePosition(position, previous.get(key))))) positions.value = next;
|
|
117
150
|
}
|
|
118
151
|
const hasText = () => (draft.value?.body.trim().length ?? 0) > 0 || hasDirtyComposer(uiRoot());
|
|
119
|
-
const block = () => {
|
|
152
|
+
const block = (escape = false) => {
|
|
120
153
|
blocked.value++;
|
|
121
|
-
shakeDirtyComposers(uiRoot());
|
|
154
|
+
shakeDirtyComposers(uiRoot(), escape);
|
|
122
155
|
};
|
|
123
156
|
function enter() {
|
|
124
157
|
active.value = true;
|
|
@@ -126,13 +159,15 @@ function useComments(options) {
|
|
|
126
159
|
if (selection && !selection.isCollapsed && selection.rangeCount > 0) {
|
|
127
160
|
const container = selection.getRangeAt(0).commonAncestorContainer;
|
|
128
161
|
const element = container instanceof Element ? container : container.parentElement;
|
|
129
|
-
if (element && !ignore(element)) {
|
|
162
|
+
if (element?.isConnected && !ignore(element)) {
|
|
130
163
|
const rect = selection.getRangeAt(0).getBoundingClientRect();
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
164
|
+
try {
|
|
165
|
+
startDraft(selection, { point: {
|
|
166
|
+
x: rect.left,
|
|
167
|
+
y: rect.top
|
|
168
|
+
} });
|
|
169
|
+
selection.removeAllRanges();
|
|
170
|
+
} catch {}
|
|
136
171
|
}
|
|
137
172
|
}
|
|
138
173
|
}
|
|
@@ -148,8 +183,8 @@ function useComments(options) {
|
|
|
148
183
|
hoverId.value = null;
|
|
149
184
|
return true;
|
|
150
185
|
}
|
|
151
|
-
function exit() {
|
|
152
|
-
if (hasText()) return block();
|
|
186
|
+
function exit(escape = false) {
|
|
187
|
+
if (hasText()) return block(escape);
|
|
153
188
|
cancelDraft();
|
|
154
189
|
close();
|
|
155
190
|
active.value = false;
|
|
@@ -158,7 +193,7 @@ function useComments(options) {
|
|
|
158
193
|
if (active.value) exit();
|
|
159
194
|
else enter();
|
|
160
195
|
}
|
|
161
|
-
function startDraft(target, anchorOptions = {}) {
|
|
196
|
+
function startDraft(target, { files, ...anchorOptions } = {}) {
|
|
162
197
|
if (hasText()) return block();
|
|
163
198
|
close();
|
|
164
199
|
const anchor = createAnchor(target, {
|
|
@@ -186,6 +221,8 @@ function useComments(options) {
|
|
|
186
221
|
point,
|
|
187
222
|
body: "",
|
|
188
223
|
mentions: [],
|
|
224
|
+
attachments: [],
|
|
225
|
+
...files?.length ? { files } : {},
|
|
189
226
|
busy: false,
|
|
190
227
|
error: void 0
|
|
191
228
|
};
|
|
@@ -194,9 +231,10 @@ function useComments(options) {
|
|
|
194
231
|
async function send() {
|
|
195
232
|
const current = draft.value;
|
|
196
233
|
const body = current?.body.trim() ?? "";
|
|
197
|
-
if (!current || current.busy || !body) return void 0;
|
|
234
|
+
if (!current || current.busy || !body && current.attachments.length === 0) return void 0;
|
|
198
235
|
const submittedBody = current.body;
|
|
199
236
|
const mentions = [...current.mentions];
|
|
237
|
+
const attachments = [...current.attachments];
|
|
200
238
|
current.busy = true;
|
|
201
239
|
current.error = void 0;
|
|
202
240
|
try {
|
|
@@ -204,9 +242,11 @@ function useComments(options) {
|
|
|
204
242
|
subject: subject.value,
|
|
205
243
|
anchor: toRaw(current.anchor),
|
|
206
244
|
body,
|
|
207
|
-
mentions
|
|
245
|
+
mentions,
|
|
246
|
+
...attachments.length > 0 ? { attachments } : {}
|
|
208
247
|
});
|
|
209
248
|
current.busy = false;
|
|
249
|
+
flash(thread.id);
|
|
210
250
|
if (draft.value === current && current.body === submittedBody && current.mentions.length === mentions.length && current.mentions.every((id, index) => id === mentions[index])) draft.value = null;
|
|
211
251
|
return thread;
|
|
212
252
|
} catch (error) {
|
|
@@ -267,7 +307,7 @@ function useComments(options) {
|
|
|
267
307
|
const origin = path[0];
|
|
268
308
|
if (event.key === "Escape") {
|
|
269
309
|
if (path.some((element) => element.matches("[data-slot='comment-composer']"))) return;
|
|
270
|
-
if (active.value || draft.value || openId.value) exit();
|
|
310
|
+
if (active.value || draft.value || openId.value) exit(true);
|
|
271
311
|
return;
|
|
272
312
|
}
|
|
273
313
|
if (event.ctrlKey || event.metaKey || event.altKey || event.shiftKey || isEditable(path)) return;
|
|
@@ -314,6 +354,7 @@ function useComments(options) {
|
|
|
314
354
|
applyDeepLink();
|
|
315
355
|
};
|
|
316
356
|
window.addEventListener("popstate", onPopstate);
|
|
357
|
+
stops.push(watch(() => options.location?.().search, onPopstate));
|
|
317
358
|
const observer = new MutationObserver((records) => {
|
|
318
359
|
if (records.every((record) => record.target instanceof Element && defaultIgnore(record.target))) return;
|
|
319
360
|
schedule();
|
|
@@ -357,10 +398,11 @@ function useComments(options) {
|
|
|
357
398
|
resizes?.disconnect();
|
|
358
399
|
clearTimeout(revealTimer);
|
|
359
400
|
if (frame) cancelAnimationFrame(frame);
|
|
401
|
+
seen.stop();
|
|
360
402
|
});
|
|
361
403
|
stops.push(watch(positions, follow, { flush: "post" }));
|
|
362
404
|
stops.push(watch([
|
|
363
|
-
|
|
405
|
+
marked,
|
|
364
406
|
() => draft.value?.anchor,
|
|
365
407
|
openId
|
|
366
408
|
], () => measure(), { flush: "post" }));
|
|
@@ -377,10 +419,41 @@ function useComments(options) {
|
|
|
377
419
|
for (const stop of stops.splice(0)) stop();
|
|
378
420
|
};
|
|
379
421
|
}
|
|
422
|
+
const found = shallowRef(/* @__PURE__ */ new Map());
|
|
423
|
+
const people = computed(() => {
|
|
424
|
+
const known = /* @__PURE__ */ new Map();
|
|
425
|
+
const add = (person) => {
|
|
426
|
+
if (person && (!known.has(person.id) || person.name)) known.set(person.id, person);
|
|
427
|
+
};
|
|
428
|
+
for (const person of found.value.values()) add(person);
|
|
429
|
+
for (const person of toValue(options.people) ?? []) add(person);
|
|
430
|
+
for (const thread of threads.value) {
|
|
431
|
+
add(thread.author);
|
|
432
|
+
add(thread.resolvedBy);
|
|
433
|
+
for (const message of thread.messages) add(message.author);
|
|
434
|
+
}
|
|
435
|
+
add(user.value);
|
|
436
|
+
return [...known.values()];
|
|
437
|
+
});
|
|
438
|
+
async function users(query, threadId) {
|
|
439
|
+
const result = await client.users({
|
|
440
|
+
query,
|
|
441
|
+
...threadId ? { threadId } : { subject: subject.value }
|
|
442
|
+
});
|
|
443
|
+
if (result.some((person) => found.value.get(person.id) !== person)) {
|
|
444
|
+
const next = new Map(found.value);
|
|
445
|
+
for (const person of result) next.set(person.id, person);
|
|
446
|
+
found.value = next;
|
|
447
|
+
}
|
|
448
|
+
return result;
|
|
449
|
+
}
|
|
450
|
+
const can = (action, target) => user.value !== void 0 && (options.can ?? defaultCommentCan(user.value))(action, target);
|
|
380
451
|
const state = {
|
|
381
452
|
client,
|
|
382
453
|
subject,
|
|
383
454
|
user,
|
|
455
|
+
can,
|
|
456
|
+
people,
|
|
384
457
|
active,
|
|
385
458
|
scope,
|
|
386
459
|
filters,
|
|
@@ -396,6 +469,12 @@ function useComments(options) {
|
|
|
396
469
|
opened,
|
|
397
470
|
listOpen,
|
|
398
471
|
blocked,
|
|
472
|
+
visibility,
|
|
473
|
+
shown,
|
|
474
|
+
leaving,
|
|
475
|
+
retainMark,
|
|
476
|
+
isShown: (id) => shown.value.has(id),
|
|
477
|
+
flash,
|
|
399
478
|
enter,
|
|
400
479
|
exit,
|
|
401
480
|
toggle,
|
|
@@ -404,11 +483,27 @@ function useComments(options) {
|
|
|
404
483
|
send,
|
|
405
484
|
open,
|
|
406
485
|
close,
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
486
|
+
create: async ({ anchor = { kind: "page" }, attachments, body, mentions }) => {
|
|
487
|
+
const thread = await client.create({
|
|
488
|
+
subject: subject.value,
|
|
489
|
+
anchor,
|
|
490
|
+
body,
|
|
491
|
+
mentions,
|
|
492
|
+
...attachments?.length ? { attachments } : {}
|
|
493
|
+
});
|
|
494
|
+
flash(thread.id);
|
|
495
|
+
return thread;
|
|
496
|
+
},
|
|
497
|
+
reply: async (threadId, body, mentions, attachments) => {
|
|
498
|
+
const thread = await client.reply({
|
|
499
|
+
threadId,
|
|
500
|
+
body,
|
|
501
|
+
mentions,
|
|
502
|
+
...attachments?.length ? { attachments } : {}
|
|
503
|
+
});
|
|
504
|
+
flash(threadId);
|
|
505
|
+
return thread;
|
|
506
|
+
},
|
|
412
507
|
edit: (threadId, messageId, body, mentions) => client.edit({
|
|
413
508
|
threadId,
|
|
414
509
|
messageId,
|
|
@@ -428,7 +523,7 @@ function useComments(options) {
|
|
|
428
523
|
},
|
|
429
524
|
resolve: (threadId) => client.resolve({ threadId }),
|
|
430
525
|
reopen: (threadId) => client.reopen({ threadId }),
|
|
431
|
-
users
|
|
526
|
+
users,
|
|
432
527
|
link,
|
|
433
528
|
measure,
|
|
434
529
|
start
|
|
@@ -448,9 +543,9 @@ function provideComments(state) {
|
|
|
448
543
|
}
|
|
449
544
|
/** The state that a comment part uses: the one you pass, else the one of the nearest `CommentLayer` or `provideComments()`. Call it in `setup()`. */
|
|
450
545
|
function useCommentsContext(state) {
|
|
451
|
-
const found = state ??
|
|
546
|
+
const found = state ?? injectComments();
|
|
452
547
|
if (!found) throw uiErrorDiagnostics.UI_R0002({ message: "Comment parts need a comments state. Put them inside CommentLayer, or pass the result of useComments() as the `comments` prop." });
|
|
453
548
|
return found;
|
|
454
549
|
}
|
|
455
550
|
//#endregion
|
|
456
|
-
export {
|
|
551
|
+
export { useCommentsContext as a, useComments as i, draftPositionKey as n, messagesSinceResolved as o, provideComments as r, repliedSinceResolved as s, defaultCommentCan as t };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { inject, onBeforeUnmount, onMounted } from "vue";
|
|
2
|
+
//#region src/internal/comment-outside.ts
|
|
3
|
+
const consumedPointerEvents = /* @__PURE__ */ new WeakSet();
|
|
4
|
+
function swallowNextClick() {
|
|
5
|
+
const stop = (event) => {
|
|
6
|
+
event.stopPropagation();
|
|
7
|
+
event.preventDefault();
|
|
8
|
+
cleanup();
|
|
9
|
+
};
|
|
10
|
+
const cleanup = () => {
|
|
11
|
+
document.removeEventListener("click", stop, true);
|
|
12
|
+
document.removeEventListener("pointerdown", cleanup, true);
|
|
13
|
+
};
|
|
14
|
+
document.addEventListener("click", stop, true);
|
|
15
|
+
document.addEventListener("pointerdown", cleanup, true);
|
|
16
|
+
}
|
|
17
|
+
function useDocumentPointerDown(handler) {
|
|
18
|
+
onMounted(() => document.addEventListener("pointerdown", handler, true));
|
|
19
|
+
onBeforeUnmount(() => document.removeEventListener("pointerdown", handler, true));
|
|
20
|
+
}
|
|
21
|
+
const shakeEventName = "comments:shake";
|
|
22
|
+
const dirtySelector = "[data-slot='comment-composer'][data-dirty='true']";
|
|
23
|
+
function hasDirtyComposer(root = document) {
|
|
24
|
+
return root.querySelector(dirtySelector) !== null;
|
|
25
|
+
}
|
|
26
|
+
function shakeDirtyComposers(root = document, escape = false) {
|
|
27
|
+
const dirty = [...root.querySelectorAll(dirtySelector)];
|
|
28
|
+
for (const composer of dirty) composer.dispatchEvent(new CustomEvent(shakeEventName, { detail: { escape } }));
|
|
29
|
+
return dirty.length > 0;
|
|
30
|
+
}
|
|
31
|
+
const pathOf = (event) => event.composedPath().filter((node) => node instanceof Element);
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/internal/comments-context.ts
|
|
34
|
+
const commentsKey = Symbol("ViteHubComments");
|
|
35
|
+
/** The state of the nearest `CommentLayer`, `CommentPanel`, or `provideComments()`, if there is one. Call it in `setup()`. */
|
|
36
|
+
const injectComments = () => inject(commentsKey, null) ?? void 0;
|
|
37
|
+
//#endregion
|
|
38
|
+
export { pathOf as a, swallowNextClick as c, hasDirtyComposer as i, useDocumentPointerDown as l, injectComments as n, shakeDirtyComposers as o, consumedPointerEvents as r, shakeEventName as s, commentsKey as t };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Component, ComputedRef, InjectionKey, MaybeRefOrGetter, Plugin } from "vue";
|
|
2
|
+
//#region src/internal/nuxt-ui.d.ts
|
|
3
|
+
/** The Nuxt UI components that the styled parts render. */
|
|
4
|
+
type ViteHubUIComponentName = "UBadge" | "UButton" | "UChatReasoning" | "UChatTool" | "UCollapsible" | "UDropdownMenu" | "UEditorDragHandle" | "UEditorSuggestionMenu" | "UEditorToolbar" | "UIcon" | "UInput" | "UModal" | "UTabs" | "UTooltip";
|
|
5
|
+
/** Components that replace the Nuxt UI ones in the parts, by name. Give them to `createViteHubUI({ components })`. */
|
|
6
|
+
type ViteHubUIComponents = Partial<Record<ViteHubUIComponentName, Component>>;
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/config.d.ts
|
|
9
|
+
interface ViteHubUIDefaults {
|
|
10
|
+
markdown?: {
|
|
11
|
+
class?: string;
|
|
12
|
+
};
|
|
13
|
+
messageScroller?: {
|
|
14
|
+
edgeThreshold?: number;
|
|
15
|
+
previousItemPeek?: number;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The icons that the parts render, by name. The names from `arrowLeft` to `stop` are Nuxt UI's `appConfig.ui.icons`
|
|
20
|
+
* names. The others are ViteHub names, for actions that Nuxt UI has no icon for. In Nuxt, the module reads both from
|
|
21
|
+
* the app config for you. Each one falls back to Lucide.
|
|
22
|
+
*/
|
|
23
|
+
interface ViteHubUIIconOptions {
|
|
24
|
+
/** The back button of a comment thread. */
|
|
25
|
+
arrowLeft?: string;
|
|
26
|
+
/** The send button of a prompt. */
|
|
27
|
+
arrowUp?: string;
|
|
28
|
+
/** Resolve on a comment thread. */
|
|
29
|
+
check?: string;
|
|
30
|
+
/** Close a comment thread, an image preview, or remove an attachment. */
|
|
31
|
+
close?: string;
|
|
32
|
+
copy?: string;
|
|
33
|
+
copyCheck?: string;
|
|
34
|
+
/** Open the original of an image preview. */
|
|
35
|
+
external?: string;
|
|
36
|
+
/** An attachment that is not an image. */
|
|
37
|
+
file?: string;
|
|
38
|
+
/** The attach button of a prompt. */
|
|
39
|
+
plus?: string;
|
|
40
|
+
/** The retry button of a prompt after an error. */
|
|
41
|
+
reload?: string;
|
|
42
|
+
/** The stop button of a prompt while it streams. */
|
|
43
|
+
stop?: string;
|
|
44
|
+
/** The comment mode button of `CommentToolbar`. */
|
|
45
|
+
comment?: string;
|
|
46
|
+
/** The thread list button of `CommentToolbar`. */
|
|
47
|
+
commentList?: string;
|
|
48
|
+
/** The page comment button of `CommentToolbar`. */
|
|
49
|
+
commentPage?: string;
|
|
50
|
+
/** Delete a comment. */
|
|
51
|
+
delete?: string;
|
|
52
|
+
/** Edit a comment. */
|
|
53
|
+
edit?: string;
|
|
54
|
+
/** Reopen a resolved comment thread. */
|
|
55
|
+
reopen?: string;
|
|
56
|
+
}
|
|
57
|
+
interface ViteHubUIOptions {
|
|
58
|
+
defaults?: ViteHubUIDefaults;
|
|
59
|
+
/** Components that the parts render instead of Nuxt UI's, by name, such as `{ UIcon: MyIcon }`. */
|
|
60
|
+
components?: ViteHubUIComponents;
|
|
61
|
+
/** Icons by name, such as `vitehubTheme.icons` from `@vite-hub/ui/theme`. A ref or a getter keeps them reactive. */
|
|
62
|
+
icons?: MaybeRefOrGetter<ViteHubUIIconOptions | undefined>;
|
|
63
|
+
}
|
|
64
|
+
interface ResolvedViteHubUIDefaults {
|
|
65
|
+
markdown: {
|
|
66
|
+
class: string;
|
|
67
|
+
};
|
|
68
|
+
messageScroller: {
|
|
69
|
+
edgeThreshold: number;
|
|
70
|
+
previousItemPeek: number;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
declare const ViteHubUIInjectionKey: InjectionKey<ResolvedViteHubUIDefaults>;
|
|
74
|
+
declare function resolveViteHubUIDefaults(options?: ViteHubUIOptions): ResolvedViteHubUIDefaults;
|
|
75
|
+
declare function useViteHubUI(): ResolvedViteHubUIDefaults;
|
|
76
|
+
/** The icons that the parts render. It reads them on each render, so a reactive app config updates them. */
|
|
77
|
+
declare function useViteHubUIIcons(): ComputedRef<Required<ViteHubUIIconOptions>>;
|
|
78
|
+
declare function createViteHubUI(options?: ViteHubUIOptions): Plugin;
|
|
79
|
+
//#endregion
|
|
80
|
+
export { ViteHubUIOptions as a, useViteHubUI as c, ViteHubUIComponents as d, ViteHubUIInjectionKey as i, useViteHubUIIcons as l, ViteHubUIDefaults as n, createViteHubUI as o, ViteHubUIIconOptions as r, resolveViteHubUIDefaults as s, ResolvedViteHubUIDefaults as t, ViteHubUIComponentName as u };
|