@arbidocs/react 0.5.165 → 0.5.166
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/dist/ai/MessageArtifactCard.js +16 -0
- package/dist/ai/MessageArtifactCard.js.map +2 -2
- package/dist/artifacts/artifact-kind.js +12 -1
- package/dist/artifacts/artifact-kind.js.map +2 -2
- package/dist/artifacts/index.cjs +58 -47
- package/dist/artifacts/index.cjs.map +1 -1
- package/dist/artifacts/index.d.ts +3 -20
- package/dist/artifacts/index.js +3 -1
- package/dist/artifacts/index.js.map +2 -2
- package/dist/calls/livekit/index.cjs +51 -51
- package/dist/chat/ChatBubble.js +56 -65
- package/dist/chat/ChatBubble.js.map +2 -2
- package/dist/chat/open-document.js +4 -1
- package/dist/chat/open-document.js.map +2 -2
- package/dist/{chunk-XSJNRWLD.cjs → chunk-3DPOR5IR.cjs} +9 -6
- package/dist/chunk-3DPOR5IR.cjs.map +1 -0
- package/dist/{chunk-ZBRJEM25.cjs → chunk-4TWXQFHU.cjs} +70 -70
- package/dist/{chunk-ZBRJEM25.cjs.map → chunk-4TWXQFHU.cjs.map} +1 -1
- package/dist/{chunk-ZZBCZRA5.cjs → chunk-5QOZLKAY.cjs} +5 -2
- package/dist/chunk-5QOZLKAY.cjs.map +1 -0
- package/dist/{chunk-B3W7WDVY.cjs → chunk-BI4SYRLX.cjs} +73 -66
- package/dist/chunk-BI4SYRLX.cjs.map +1 -0
- package/dist/{chunk-ONAYOSSV.cjs → chunk-HRQS27DO.cjs} +39 -39
- package/dist/{chunk-ONAYOSSV.cjs.map → chunk-HRQS27DO.cjs.map} +1 -1
- package/dist/{chunk-DQODLWFX.cjs → chunk-KULS4YWP.cjs} +3 -3
- package/dist/{chunk-DQODLWFX.cjs.map → chunk-KULS4YWP.cjs.map} +1 -1
- package/dist/{chunk-V5WCKJEH.cjs → chunk-Q7BGWKHP.cjs} +44 -44
- package/dist/{chunk-V5WCKJEH.cjs.map → chunk-Q7BGWKHP.cjs.map} +1 -1
- package/dist/{chunk-352P2C4E.cjs → chunk-TX7UCN73.cjs} +14 -14
- package/dist/{chunk-352P2C4E.cjs.map → chunk-TX7UCN73.cjs.map} +1 -1
- package/dist/{chunk-WJIRX5MS.cjs → chunk-W4W75MSO.cjs} +134 -25
- package/dist/chunk-W4W75MSO.cjs.map +1 -0
- package/dist/chunk-WABJGKVA.cjs +246 -0
- package/dist/chunk-WABJGKVA.cjs.map +1 -0
- package/dist/databases.js.map +2 -2
- package/dist/directmessages/DmComposer.js +26 -10
- package/dist/directmessages/DmComposer.js.map +2 -2
- package/dist/directmessages/index.js +2 -0
- package/dist/directmessages/index.js.map +2 -2
- package/dist/directmessages/useChats.js +11 -0
- package/dist/directmessages/useChats.js.map +2 -2
- package/dist/document-tools/core.cjs +102 -102
- package/dist/document-tools/core.d.ts +2 -2
- package/dist/document-tools/index.cjs +104 -104
- package/dist/document-tools/index.d.ts +2 -2
- package/dist/entities/DocumentEntity.js +8 -3
- package/dist/entities/DocumentEntity.js.map +2 -2
- package/dist/entities/EntityActionsMenu.js +53 -0
- package/dist/entities/EntityActionsMenu.js.map +7 -0
- package/dist/entities/EntityPill.js +50 -16
- package/dist/entities/EntityPill.js.map +2 -2
- package/dist/entities/ProjectEntity.js +4 -0
- package/dist/entities/ProjectEntity.js.map +2 -2
- package/dist/entities/TagEntity.js +1 -0
- package/dist/entities/TagEntity.js.map +2 -2
- package/dist/entities/UserEntity.js +25 -3
- package/dist/entities/UserEntity.js.map +2 -2
- package/dist/entities/links.js +9 -0
- package/dist/entities/links.js.map +7 -0
- package/dist/entities/reference-data.js +56 -0
- package/dist/entities/reference-data.js.map +7 -0
- package/dist/{file-shares.d-Bwy9k3Db.d.ts → file-shares.d-Dlt7pKRi.d.ts} +3 -0
- package/dist/host/config.js.map +2 -2
- package/dist/index.cjs +2537 -2449
- package/dist/index.cjs.map +1 -1
- package/dist/{index.d-Dy_Pz6Vl.d.ts → index.d-BaZUctD1.d.ts} +34 -10
- package/dist/index.d.ts +164 -20
- package/dist/index.js +5 -0
- package/dist/index.js.map +2 -2
- package/dist/query-keys.js +3 -0
- package/dist/query-keys.js.map +2 -2
- package/dist/session/conversation-panels.js +5 -3
- package/dist/session/conversation-panels.js.map +2 -2
- package/dist/session/layout.js +5 -0
- package/dist/session/layout.js.map +2 -2
- package/dist/shell/index.cjs +40 -40
- package/dist/{stored-markdown.d-Bp18vrbr.d.ts → stored-markdown.d-BLQPny3e.d.ts} +21 -1
- package/dist/ui/index.cjs +168 -164
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +2 -0
- package/dist/ui/index.js.map +2 -2
- package/dist/viewers/AudioViewer.js +13 -3
- package/dist/viewers/AudioViewer.js.map +2 -2
- package/dist/viewers/MediaTranscriptPlayer.js +171 -0
- package/dist/viewers/MediaTranscriptPlayer.js.map +7 -0
- package/dist/viewers/VideoViewer.js +4 -11
- package/dist/viewers/VideoViewer.js.map +2 -2
- package/dist/viewers/index.cjs +16 -12
- package/dist/viewers/index.d.ts +17 -3
- package/dist/viewers/index.js +2 -0
- package/dist/viewers/index.js.map +2 -2
- package/package.json +3 -3
- package/dist/chunk-B3W7WDVY.cjs.map +0 -1
- package/dist/chunk-TMPDW7J5.cjs +0 -79
- package/dist/chunk-TMPDW7J5.cjs.map +0 -1
- package/dist/chunk-WJIRX5MS.cjs.map +0 -1
- package/dist/chunk-XSJNRWLD.cjs.map +0 -1
- package/dist/chunk-ZZBCZRA5.cjs.map +0 -1
|
@@ -2,6 +2,20 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { AppWindow, FileText, Image as ImageIcon, Presentation } from "lucide-react";
|
|
3
3
|
import { Card } from "../ui/card.js";
|
|
4
4
|
const LABELS = {
|
|
5
|
+
pdf: {
|
|
6
|
+
Icon: FileText,
|
|
7
|
+
busy: "Saving PDF\u2026",
|
|
8
|
+
ready: "PDF saved",
|
|
9
|
+
action: "Open PDF",
|
|
10
|
+
untitled: "PDF document"
|
|
11
|
+
},
|
|
12
|
+
file: {
|
|
13
|
+
Icon: FileText,
|
|
14
|
+
busy: "Saving file\u2026",
|
|
15
|
+
ready: "File saved",
|
|
16
|
+
action: "Open file",
|
|
17
|
+
untitled: "Output file"
|
|
18
|
+
},
|
|
5
19
|
document: {
|
|
6
20
|
Icon: FileText,
|
|
7
21
|
busy: "Drafting\u2026",
|
|
@@ -32,6 +46,8 @@ const LABELS = {
|
|
|
32
46
|
}
|
|
33
47
|
};
|
|
34
48
|
function labelsFor(mode) {
|
|
49
|
+
if (mode === "pdf") return LABELS.pdf;
|
|
50
|
+
if (mode === "file") return LABELS.file;
|
|
35
51
|
if (mode === "image") return LABELS.image;
|
|
36
52
|
if (mode === "presentation") return LABELS.presentation;
|
|
37
53
|
if (mode === "html" || mode === "react") return LABELS.live;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/ai/MessageArtifactCard.tsx"],
|
|
4
|
-
"sourcesContent": ["import React from 'react'\nimport { AppWindow, FileText, Image as ImageIcon, Presentation } from 'lucide-react'\nimport type {
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import React from 'react'\nimport { AppWindow, FileText, Image as ImageIcon, Presentation } from 'lucide-react'\nimport type { ArtifactDisplayMode } from '../artifacts/artifact-kind'\nimport { Card } from '../ui/card'\n\n/**\n * The minimal artifact shape this card renders. A structural subset of the\n * ARBI app's `StreamingDocument`, defined here so the light package doesn't\n * depend on the app store \u2014 any object carrying these fields is accepted.\n */\nexport interface MessageArtifact {\n /** External id of the drafted document; opened in the docked viewer. */\n docExtId: string\n /** Display title; falls back when empty. */\n title: string\n /** Whether generation has finished. */\n isComplete: boolean\n /**\n * Content mode. `markdown` / `text` are document drafts, which the server stores as Word\n * documents (.docx); `html` / `react` are live UI artifacts; `image` is a generated image;\n * `presentation` is a slide deck (.pptx), opened in the slides editor.\n */\n mode: ArtifactDisplayMode\n}\n\nconst LABELS = {\n pdf: {\n Icon: FileText,\n busy: 'Saving PDF\u2026',\n ready: 'PDF saved',\n action: 'Open PDF',\n untitled: 'PDF document',\n },\n file: {\n Icon: FileText,\n busy: 'Saving file\u2026',\n ready: 'File saved',\n action: 'Open file',\n untitled: 'Output file',\n },\n document: {\n Icon: FileText,\n busy: 'Drafting\u2026',\n ready: 'Draft ready',\n action: 'Open in Editor',\n untitled: 'Untitled draft',\n },\n live: {\n Icon: AppWindow,\n busy: 'Building\u2026',\n ready: 'Preview ready',\n action: 'Open preview',\n untitled: 'Untitled app',\n },\n presentation: {\n Icon: Presentation,\n busy: 'Building slides\u2026',\n ready: 'Slides saved',\n action: 'Open slides',\n untitled: 'Untitled presentation',\n },\n image: {\n Icon: ImageIcon,\n busy: 'Generating\u2026',\n ready: 'Image ready',\n action: 'View image',\n untitled: 'Generated image',\n },\n} as const\n\nfunction labelsFor(mode: MessageArtifact['mode']) {\n if (mode === 'pdf') return LABELS.pdf\n if (mode === 'file') return LABELS.file\n if (mode === 'image') return LABELS.image\n if (mode === 'presentation') return LABELS.presentation\n if (mode === 'html' || mode === 'react') return LABELS.live\n return LABELS.document\n}\n\ninterface MessageArtifactCardProps {\n /** The streaming/drafted document linked to this assistant message. */\n artifact: MessageArtifact\n /** Opens the drafted document (docExtId) in the docked viewer. */\n onOpen: (docExtId: string) => void\n}\n\n/**\n * Inline \"Open in Editor\" (document drafts) / \"Open preview\" / \"View image\" affordance shown inside the assistant message that\n * produced a drafted document \u2014 so the artifact lives in the conversation\n * narrative (dyad-style) instead of only a hidden docked panel.\n *\n * Clean-ARBI contract: flat outline card, one chat type size, brand\n * accent on the action, tap-friendly (a real button \u2014 no hover-only).\n */\nexport function MessageArtifactCard({\n artifact,\n onOpen,\n}: MessageArtifactCardProps): React.JSX.Element {\n const { docExtId, title, isComplete, mode } = artifact\n const labels = labelsFor(mode)\n const Icon = labels.Icon\n return (\n <Card\n variant=\"outline\"\n className=\"mt-3 flex items-center gap-3 px-3 py-2.5\"\n data-testid={`message-artifact-card-${docExtId}`}\n >\n <Icon className=\"h-4 w-4 shrink-0 text-muted-foreground\" aria-hidden />\n <div className=\"min-w-0 flex-1\">\n <div\n className=\"truncate text-chat font-semibold text-foreground\"\n data-testid=\"artifact-title\"\n >\n {title || labels.untitled}\n </div>\n <div className=\"text-sm text-muted-foreground\" data-testid=\"artifact-status\">\n {isComplete ? labels.ready : labels.busy}\n </div>\n </div>\n <button\n type=\"button\"\n onClick={() => onOpen(docExtId)}\n className=\"shrink-0 rounded-md bg-secondary/15 px-3 py-1.5 text-sm font-semibold text-secondary transition-colors hover:bg-secondary/25\"\n data-testid={`view-artifact-button-${docExtId}`}\n >\n {labels.action}\n </button>\n </Card>\n )\n}\n"],
|
|
5
|
+
"mappings": "AA2GM,cACA,YADA;AA1GN,SAAS,WAAW,UAAU,SAAS,WAAW,oBAAoB;AAEtE,SAAS,YAAY;AAsBrB,MAAM,SAAS;AAAA,EACb,KAAK;AAAA,IACH,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,UAAU;AAAA,EACZ;AAAA,EACA,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,UAAU;AAAA,EACZ;AAAA,EACA,UAAU;AAAA,IACR,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,UAAU;AAAA,EACZ;AAAA,EACA,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,UAAU;AAAA,EACZ;AAAA,EACA,cAAc;AAAA,IACZ,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,UAAU;AAAA,EACZ;AAAA,EACA,OAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,UAAU;AAAA,EACZ;AACF;AAEA,SAAS,UAAU,MAA+B;AAChD,MAAI,SAAS,MAAO,QAAO,OAAO;AAClC,MAAI,SAAS,OAAQ,QAAO,OAAO;AACnC,MAAI,SAAS,QAAS,QAAO,OAAO;AACpC,MAAI,SAAS,eAAgB,QAAO,OAAO;AAC3C,MAAI,SAAS,UAAU,SAAS,QAAS,QAAO,OAAO;AACvD,SAAO,OAAO;AAChB;AAiBO,SAAS,oBAAoB;AAAA,EAClC;AAAA,EACA;AACF,GAAgD;AAC9C,QAAM,EAAE,UAAU,OAAO,YAAY,KAAK,IAAI;AAC9C,QAAM,SAAS,UAAU,IAAI;AAC7B,QAAM,OAAO,OAAO;AACpB,SACE;AAAA,IAAC;AAAA;AAAA,MACC,SAAQ;AAAA,MACR,WAAU;AAAA,MACV,eAAa,yBAAyB,QAAQ;AAAA,MAE9C;AAAA,4BAAC,QAAK,WAAU,0CAAyC,eAAW,MAAC;AAAA,QACrE,qBAAC,SAAI,WAAU,kBACb;AAAA;AAAA,YAAC;AAAA;AAAA,cACC,WAAU;AAAA,cACV,eAAY;AAAA,cAEX,mBAAS,OAAO;AAAA;AAAA,UACnB;AAAA,UACA,oBAAC,SAAI,WAAU,iCAAgC,eAAY,mBACxD,uBAAa,OAAO,QAAQ,OAAO,MACtC;AAAA,WACF;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,MAAK;AAAA,YACL,SAAS,MAAM,OAAO,QAAQ;AAAA,YAC9B,WAAU;AAAA,YACV,eAAa,wBAAwB,QAAQ;AAAA,YAE5C,iBAAO;AAAA;AAAA,QACV;AAAA;AAAA;AAAA,EACF;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
function savedArtifactMode(fileName) {
|
|
2
|
+
const name = (fileName ?? "").toLowerCase();
|
|
3
|
+
if (/\.(png|jpe?g|gif|webp|tiff?|bmp)$/.test(name)) return "image";
|
|
4
|
+
if (name.endsWith(".pdf")) return "pdf";
|
|
5
|
+
if (name.endsWith(".pptx")) return "presentation";
|
|
6
|
+
const live = artifactKindFromFileName(fileName);
|
|
7
|
+
if (live) return live;
|
|
8
|
+
if (!/\.[a-z0-9]+$/.test(name) || /\.(docx|md|markdown|txt)$/.test(name)) return "markdown";
|
|
9
|
+
return "file";
|
|
10
|
+
}
|
|
1
11
|
function artifactKindFromFileName(fileName) {
|
|
2
12
|
const ext = (fileName ?? "").toLowerCase().match(/\.[a-z0-9]+$/)?.[0];
|
|
3
13
|
if (ext === ".html" || ext === ".htm") return "html";
|
|
@@ -8,13 +18,14 @@ function artifactKindFromMode(mode) {
|
|
|
8
18
|
return mode === "html" || mode === "react" ? mode : null;
|
|
9
19
|
}
|
|
10
20
|
function viewerTabForArtifactMode(mode) {
|
|
11
|
-
if (mode === "image") return "pdf";
|
|
21
|
+
if (mode === "image" || mode === "pdf" || mode === "file") return "pdf";
|
|
12
22
|
if (mode === "presentation") return "slides";
|
|
13
23
|
return artifactKindFromMode(mode) ? "preview" : "edit";
|
|
14
24
|
}
|
|
15
25
|
export {
|
|
16
26
|
artifactKindFromFileName,
|
|
17
27
|
artifactKindFromMode,
|
|
28
|
+
savedArtifactMode,
|
|
18
29
|
viewerTabForArtifactMode
|
|
19
30
|
};
|
|
20
31
|
//# sourceMappingURL=artifact-kind.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/artifacts/artifact-kind.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Which live renderer, if any, an artifact maps to. Kept free of heavy imports (no compiler) so the\n * document viewer can use it without pulling the preview code into its bundle.\n *\n * The backend persists an artifact's render mode in the saved file's extension: .html / .jsx are live\n * artifacts; document drafts are stored as .docx and open in the Word editor.\n */\nexport type ArtifactPreviewKind = 'html' | 'react'\n\nexport function artifactKindFromFileName(fileName?: string | null): ArtifactPreviewKind | null {\n const ext = (fileName ?? '').toLowerCase().match(/\\.[a-z0-9]+$/)?.[0]\n if (ext === '.html' || ext === '.htm') return 'html'\n if (ext === '.jsx') return 'react'\n return null\n}\n\nexport function artifactKindFromMode(mode?: string | null): ArtifactPreviewKind | null {\n return mode === 'html' || mode === 'react' ? mode : null\n}\n\n/**\n * The viewer tab an artifact opens on: a generated image on its media view ('pdf'), an html/react\n * artifact on its rendered Preview, a slide deck ARBI saved (a .pptx) in the slides editor, and a\n * document draft (stored as .docx) in the Word editor.\n */\nexport function viewerTabForArtifactMode(\n mode?: string | null\n): 'pdf' | 'preview' | 'edit' | 'slides' {\n if (mode === 'image') return 'pdf'\n if (mode === 'presentation') return 'slides'\n return artifactKindFromMode(mode) ? 'preview' : 'edit'\n}\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/**\n * Which live renderer, if any, an artifact maps to. Kept free of heavy imports (no compiler) so the\n * document viewer can use it without pulling the preview code into its bundle.\n *\n * The backend persists an artifact's render mode in the saved file's extension: .html / .jsx are live\n * artifacts; document drafts are stored as .docx and open in the Word editor.\n */\nexport type ArtifactPreviewKind = 'html' | 'react'\nexport type ArtifactDisplayMode =\n 'markdown' | 'text' | 'html' | 'react' | 'image' | 'presentation' | 'pdf' | 'file'\n\n/** Saved outputs include PDFs and binary files as well as authored drafts. */\nexport function savedArtifactMode(fileName?: string | null): ArtifactDisplayMode {\n const name = (fileName ?? '').toLowerCase()\n if (/\\.(png|jpe?g|gif|webp|tiff?|bmp)$/.test(name)) return 'image'\n if (name.endsWith('.pdf')) return 'pdf'\n if (name.endsWith('.pptx')) return 'presentation'\n const live = artifactKindFromFileName(fileName)\n if (live) return live\n if (!/\\.[a-z0-9]+$/.test(name) || /\\.(docx|md|markdown|txt)$/.test(name)) return 'markdown'\n return 'file'\n}\n\nexport function artifactKindFromFileName(fileName?: string | null): ArtifactPreviewKind | null {\n const ext = (fileName ?? '').toLowerCase().match(/\\.[a-z0-9]+$/)?.[0]\n if (ext === '.html' || ext === '.htm') return 'html'\n if (ext === '.jsx') return 'react'\n return null\n}\n\nexport function artifactKindFromMode(mode?: string | null): ArtifactPreviewKind | null {\n return mode === 'html' || mode === 'react' ? mode : null\n}\n\n/**\n * The viewer tab an artifact opens on: a generated image on its media view ('pdf'), an html/react\n * artifact on its rendered Preview, a slide deck ARBI saved (a .pptx) in the slides editor, and a\n * document draft (stored as .docx) in the Word editor.\n */\nexport function viewerTabForArtifactMode(\n mode?: string | null\n): 'pdf' | 'preview' | 'edit' | 'slides' {\n if (mode === 'image' || mode === 'pdf' || mode === 'file') return 'pdf'\n if (mode === 'presentation') return 'slides'\n return artifactKindFromMode(mode) ? 'preview' : 'edit'\n}\n"],
|
|
5
|
+
"mappings": "AAYO,SAAS,kBAAkB,UAA+C;AAC/E,QAAM,QAAQ,YAAY,IAAI,YAAY;AAC1C,MAAI,oCAAoC,KAAK,IAAI,EAAG,QAAO;AAC3D,MAAI,KAAK,SAAS,MAAM,EAAG,QAAO;AAClC,MAAI,KAAK,SAAS,OAAO,EAAG,QAAO;AACnC,QAAM,OAAO,yBAAyB,QAAQ;AAC9C,MAAI,KAAM,QAAO;AACjB,MAAI,CAAC,eAAe,KAAK,IAAI,KAAK,4BAA4B,KAAK,IAAI,EAAG,QAAO;AACjF,SAAO;AACT;AAEO,SAAS,yBAAyB,UAAsD;AAC7F,QAAM,OAAO,YAAY,IAAI,YAAY,EAAE,MAAM,cAAc,IAAI,CAAC;AACpE,MAAI,QAAQ,WAAW,QAAQ,OAAQ,QAAO;AAC9C,MAAI,QAAQ,OAAQ,QAAO;AAC3B,SAAO;AACT;AAEO,SAAS,qBAAqB,MAAkD;AACrF,SAAO,SAAS,UAAU,SAAS,UAAU,OAAO;AACtD;AAOO,SAAS,yBACd,MACuC;AACvC,MAAI,SAAS,WAAW,SAAS,SAAS,SAAS,OAAQ,QAAO;AAClE,MAAI,SAAS,eAAgB,QAAO;AACpC,SAAO,qBAAqB,IAAI,IAAI,YAAY;AAClD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/artifacts/index.cjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var chunkB3W7WDVY_cjs = require('../chunk-B3W7WDVY.cjs');
|
|
3
|
+
var chunkQ7BGWKHP_cjs = require('../chunk-Q7BGWKHP.cjs');
|
|
4
|
+
var chunkBI4SYRLX_cjs = require('../chunk-BI4SYRLX.cjs');
|
|
6
5
|
var chunk3AADNIOK_cjs = require('../chunk-3AADNIOK.cjs');
|
|
7
|
-
var
|
|
6
|
+
var chunk5QOZLKAY_cjs = require('../chunk-5QOZLKAY.cjs');
|
|
8
7
|
require('../chunk-N73IMVFF.cjs');
|
|
9
|
-
var
|
|
8
|
+
var chunkKULS4YWP_cjs = require('../chunk-KULS4YWP.cjs');
|
|
9
|
+
var chunkVOFNX4P6_cjs = require('../chunk-VOFNX4P6.cjs');
|
|
10
|
+
var chunkEM6DP62E_cjs = require('../chunk-EM6DP62E.cjs');
|
|
10
11
|
require('../chunk-5NOZDH3F.cjs');
|
|
11
12
|
require('../chunk-S6A6FSG7.cjs');
|
|
12
|
-
var chunkVOFNX4P6_cjs = require('../chunk-VOFNX4P6.cjs');
|
|
13
13
|
var react = require('react');
|
|
14
14
|
var reactQuery = require('@tanstack/react-query');
|
|
15
15
|
var jsxRuntime = require('react/jsx-runtime');
|
|
@@ -270,24 +270,24 @@ var isRefusal = (error) => {
|
|
|
270
270
|
return code === 401 || code === 403;
|
|
271
271
|
};
|
|
272
272
|
function useArtifactText(docId, options) {
|
|
273
|
-
const arbi =
|
|
273
|
+
const arbi = chunk5QOZLKAY_cjs.useArbi();
|
|
274
274
|
const { attempts, baseDelayMs, maxDelayMs } = {
|
|
275
275
|
...DEFAULT_ARTIFACT_TEXT_RETRY,
|
|
276
276
|
...options?.retry
|
|
277
277
|
};
|
|
278
|
-
const enabled = (options?.enabled ?? true) &&
|
|
278
|
+
const enabled = (options?.enabled ?? true) && chunkKULS4YWP_cjs.isDocumentId(docId) && arbi.hasWorkspace;
|
|
279
279
|
const query = reactQuery.useQuery({
|
|
280
280
|
// Under the shared `parsedDoc` key, so a document's invalidation reaches it too.
|
|
281
|
-
queryKey: [...
|
|
281
|
+
queryKey: [...chunk5QOZLKAY_cjs.arbiQueryKeys.parsedDoc(docId ?? "", "marker"), "artifact-text"],
|
|
282
282
|
queryFn: async () => {
|
|
283
|
-
const { docId: plainId, version } =
|
|
283
|
+
const { docId: plainId, version } = chunkKULS4YWP_cjs.parseVersionRef(docId);
|
|
284
284
|
const parsed = await arbi.documents.getParsedContent(
|
|
285
285
|
plainId,
|
|
286
286
|
"marker",
|
|
287
287
|
version ?? void 0
|
|
288
288
|
);
|
|
289
289
|
if (!parsed.chunks?.some((c) => c.content?.trim())) throw new NotParsedYetError();
|
|
290
|
-
return
|
|
290
|
+
return chunkKULS4YWP_cjs.flattenChunks(parsed.chunks, { unescape: true });
|
|
291
291
|
},
|
|
292
292
|
enabled,
|
|
293
293
|
retry: (failureCount, error) => !isRefusal(error) && failureCount < attempts,
|
|
@@ -325,22 +325,22 @@ function useArtifactText(docId, options) {
|
|
|
325
325
|
|
|
326
326
|
// src/artifacts/useArtifactSession.ts
|
|
327
327
|
function useArtifactVersions(workspaceId, docId) {
|
|
328
|
-
const plainId = docId ?
|
|
329
|
-
const { data: documents } =
|
|
328
|
+
const plainId = docId ? chunkKULS4YWP_cjs.parseVersionRef(docId).docId : null;
|
|
329
|
+
const { data: documents } = chunkQ7BGWKHP_cjs.useDocuments(workspaceId);
|
|
330
330
|
const listed = react.useMemo(
|
|
331
331
|
() => (documents ?? []).find((d) => d.external_id === plainId),
|
|
332
332
|
[documents, plainId]
|
|
333
333
|
);
|
|
334
|
-
const { data: history } =
|
|
334
|
+
const { data: history } = chunkBI4SYRLX_cjs.useDocumentVersionList(plainId, {
|
|
335
335
|
enabled: !!plainId && documents !== void 0 && !listed
|
|
336
336
|
});
|
|
337
337
|
return react.useMemo(
|
|
338
|
-
() => listed ?
|
|
338
|
+
() => listed ? chunkKULS4YWP_cjs.documentVersions(listed) : chunkKULS4YWP_cjs.toArtifactVersions(plainId, history),
|
|
339
339
|
[listed, history, plainId]
|
|
340
340
|
);
|
|
341
341
|
}
|
|
342
342
|
function useSaveArtifactVersion() {
|
|
343
|
-
const arbi =
|
|
343
|
+
const arbi = chunk5QOZLKAY_cjs.useArbi();
|
|
344
344
|
const queryClient = reactQuery.useQueryClient();
|
|
345
345
|
return reactQuery.useMutation({
|
|
346
346
|
mutationFn: async ({ title, content, versionOf, configId, wpType, autosave }) => {
|
|
@@ -351,15 +351,15 @@ function useSaveArtifactVersion() {
|
|
|
351
351
|
{
|
|
352
352
|
wpType: wpType ?? "artifact",
|
|
353
353
|
autosave,
|
|
354
|
-
versionOf: versionOf ?
|
|
354
|
+
versionOf: versionOf ? chunkKULS4YWP_cjs.parseVersionRef(versionOf).docId : void 0,
|
|
355
355
|
configExtId: configId ?? void 0
|
|
356
356
|
}
|
|
357
357
|
);
|
|
358
358
|
const docId = result.doc_ext_ids?.[0];
|
|
359
|
-
if (docId) await
|
|
360
|
-
await queryClient.invalidateQueries({ queryKey:
|
|
359
|
+
if (docId) await chunkQ7BGWKHP_cjs.refreshDocuments(queryClient, arbi, [docId]);
|
|
360
|
+
await queryClient.invalidateQueries({ queryKey: chunk5QOZLKAY_cjs.arbiQueryKeys.allDocumentVersions() });
|
|
361
361
|
if (docId)
|
|
362
|
-
await queryClient.invalidateQueries({ queryKey:
|
|
362
|
+
await queryClient.invalidateQueries({ queryKey: chunk5QOZLKAY_cjs.arbiQueryKeys.parsedDocument(docId) });
|
|
363
363
|
return { docId, version: result.version ?? void 0 };
|
|
364
364
|
}
|
|
365
365
|
});
|
|
@@ -379,7 +379,7 @@ function useArtifactSession(options) {
|
|
|
379
379
|
const [saved, setSaved] = react.useState(null);
|
|
380
380
|
const adopted = saved && saved.forId === hostDocId ? saved : null;
|
|
381
381
|
const docId = adopted?.id ?? hostDocId;
|
|
382
|
-
const isLocal = !
|
|
382
|
+
const isLocal = !chunkKULS4YWP_cjs.isDocumentId(docId);
|
|
383
383
|
const [ownCompareId, setOwnCompareId] = react.useState(null);
|
|
384
384
|
const activeCompareId = compareId === void 0 ? ownCompareId : compareId;
|
|
385
385
|
const changeCompare = react.useCallback(
|
|
@@ -396,7 +396,7 @@ function useArtifactSession(options) {
|
|
|
396
396
|
});
|
|
397
397
|
const saveVersion = useSaveArtifactVersion();
|
|
398
398
|
const autosaveVersion = saveVersion.mutateAsync;
|
|
399
|
-
const current =
|
|
399
|
+
const current = chunkKULS4YWP_cjs.findVersion(versions, docId);
|
|
400
400
|
const save = react.useCallback(
|
|
401
401
|
async (content) => {
|
|
402
402
|
const result = await saveVersion.mutateAsync({
|
|
@@ -412,7 +412,7 @@ function useArtifactSession(options) {
|
|
|
412
412
|
);
|
|
413
413
|
const handleSaved = react.useCallback(
|
|
414
414
|
(result, content) => {
|
|
415
|
-
if (!
|
|
415
|
+
if (!chunkKULS4YWP_cjs.isDocumentId(hostDocId) && result.docId)
|
|
416
416
|
setSaved({ forId: hostDocId, id: result.docId, text: content });
|
|
417
417
|
onSaved?.(result, content);
|
|
418
418
|
},
|
|
@@ -457,7 +457,7 @@ function useArtifactSession(options) {
|
|
|
457
457
|
]);
|
|
458
458
|
react.useEffect(() => {
|
|
459
459
|
if (!docId) return;
|
|
460
|
-
return
|
|
460
|
+
return chunkQ7BGWKHP_cjs.registerDocumentTurnFlush(docId, async () => {
|
|
461
461
|
if (session.hasChanges && !await session.save())
|
|
462
462
|
throw new Error("Save the document before sending your message.");
|
|
463
463
|
});
|
|
@@ -471,7 +471,7 @@ function useArtifactSession(options) {
|
|
|
471
471
|
isLoading,
|
|
472
472
|
status,
|
|
473
473
|
versions,
|
|
474
|
-
labelOf: (id) =>
|
|
474
|
+
labelOf: (id) => chunkKULS4YWP_cjs.versionLabel(versions, id),
|
|
475
475
|
view: {
|
|
476
476
|
content: session.baseline,
|
|
477
477
|
isEditing: session.isEditing,
|
|
@@ -518,9 +518,9 @@ function useArtifactSession(options) {
|
|
|
518
518
|
);
|
|
519
519
|
}
|
|
520
520
|
function useArtifactSource(documentId, enabled = true) {
|
|
521
|
-
const arbi =
|
|
521
|
+
const arbi = chunk5QOZLKAY_cjs.useArbi();
|
|
522
522
|
return reactQuery.useQuery({
|
|
523
|
-
queryKey:
|
|
523
|
+
queryKey: chunk5QOZLKAY_cjs.arbiQueryKeys.artifactSource(documentId ?? ""),
|
|
524
524
|
queryFn: async () => (await arbi.documents.download(documentId)).text(),
|
|
525
525
|
enabled: enabled && !!documentId && arbi.isLoggedIn,
|
|
526
526
|
staleTime: 5 * 60 * 1e3
|
|
@@ -547,7 +547,7 @@ function useStreamedArtifact({
|
|
|
547
547
|
const started = react.useRef(null);
|
|
548
548
|
const content = artifact?.content ?? "";
|
|
549
549
|
const title = artifact?.title ?? "Draft";
|
|
550
|
-
const passThrough = !!artifact &&
|
|
550
|
+
const passThrough = !!artifact && chunkKULS4YWP_cjs.isDocumentId(artifact.doc_ext_id);
|
|
551
551
|
const needsSave = settled && !!artifact && !passThrough && !!content.trim() && !!workspaceId;
|
|
552
552
|
react.useEffect(() => {
|
|
553
553
|
const key = `${attempt}:${content}`;
|
|
@@ -557,7 +557,7 @@ function useStreamedArtifact({
|
|
|
557
557
|
let stored;
|
|
558
558
|
if (clean) stored = clean(content);
|
|
559
559
|
else {
|
|
560
|
-
const report =
|
|
560
|
+
const report = chunkKULS4YWP_cjs.cleanDraftWithReport(content);
|
|
561
561
|
stored = report.text;
|
|
562
562
|
setCleaned(report);
|
|
563
563
|
onCleaned?.(report);
|
|
@@ -596,6 +596,16 @@ function useStreamedArtifact({
|
|
|
596
596
|
}
|
|
597
597
|
|
|
598
598
|
// src/artifacts/artifact-kind.ts
|
|
599
|
+
function savedArtifactMode(fileName) {
|
|
600
|
+
const name = (fileName ?? "").toLowerCase();
|
|
601
|
+
if (/\.(png|jpe?g|gif|webp|tiff?|bmp)$/.test(name)) return "image";
|
|
602
|
+
if (name.endsWith(".pdf")) return "pdf";
|
|
603
|
+
if (name.endsWith(".pptx")) return "presentation";
|
|
604
|
+
const live = artifactKindFromFileName(fileName);
|
|
605
|
+
if (live) return live;
|
|
606
|
+
if (!/\.[a-z0-9]+$/.test(name) || /\.(docx|md|markdown|txt)$/.test(name)) return "markdown";
|
|
607
|
+
return "file";
|
|
608
|
+
}
|
|
599
609
|
function artifactKindFromFileName(fileName) {
|
|
600
610
|
const ext = (fileName ?? "").toLowerCase().match(/\.[a-z0-9]+$/)?.[0];
|
|
601
611
|
if (ext === ".html" || ext === ".htm") return "html";
|
|
@@ -606,7 +616,7 @@ function artifactKindFromMode(mode) {
|
|
|
606
616
|
return mode === "html" || mode === "react" ? mode : null;
|
|
607
617
|
}
|
|
608
618
|
function viewerTabForArtifactMode(mode) {
|
|
609
|
-
if (mode === "image") return "pdf";
|
|
619
|
+
if (mode === "image" || mode === "pdf" || mode === "file") return "pdf";
|
|
610
620
|
if (mode === "presentation") return "slides";
|
|
611
621
|
return artifactKindFromMode(mode) ? "preview" : "edit";
|
|
612
622
|
}
|
|
@@ -625,71 +635,71 @@ Object.defineProperty(exports, "revertRedlineRegion", {
|
|
|
625
635
|
});
|
|
626
636
|
Object.defineProperty(exports, "cleanDraftMarkdown", {
|
|
627
637
|
enumerable: true,
|
|
628
|
-
get: function () { return
|
|
638
|
+
get: function () { return chunkKULS4YWP_cjs.cleanDraftMarkdown; }
|
|
629
639
|
});
|
|
630
640
|
Object.defineProperty(exports, "cleanDraftWithReport", {
|
|
631
641
|
enumerable: true,
|
|
632
|
-
get: function () { return
|
|
642
|
+
get: function () { return chunkKULS4YWP_cjs.cleanDraftWithReport; }
|
|
633
643
|
});
|
|
634
644
|
Object.defineProperty(exports, "documentVersions", {
|
|
635
645
|
enumerable: true,
|
|
636
|
-
get: function () { return
|
|
646
|
+
get: function () { return chunkKULS4YWP_cjs.documentVersions; }
|
|
637
647
|
});
|
|
638
648
|
Object.defineProperty(exports, "findVersion", {
|
|
639
649
|
enumerable: true,
|
|
640
|
-
get: function () { return
|
|
650
|
+
get: function () { return chunkKULS4YWP_cjs.findVersion; }
|
|
641
651
|
});
|
|
642
652
|
Object.defineProperty(exports, "flattenChunks", {
|
|
643
653
|
enumerable: true,
|
|
644
|
-
get: function () { return
|
|
654
|
+
get: function () { return chunkKULS4YWP_cjs.flattenChunks; }
|
|
645
655
|
});
|
|
646
656
|
Object.defineProperty(exports, "isDocumentId", {
|
|
647
657
|
enumerable: true,
|
|
648
|
-
get: function () { return
|
|
658
|
+
get: function () { return chunkKULS4YWP_cjs.isDocumentId; }
|
|
649
659
|
});
|
|
650
660
|
Object.defineProperty(exports, "parseVersionRef", {
|
|
651
661
|
enumerable: true,
|
|
652
|
-
get: function () { return
|
|
662
|
+
get: function () { return chunkKULS4YWP_cjs.parseVersionRef; }
|
|
653
663
|
});
|
|
654
664
|
Object.defineProperty(exports, "promoteBoldTitle", {
|
|
655
665
|
enumerable: true,
|
|
656
|
-
get: function () { return
|
|
666
|
+
get: function () { return chunkKULS4YWP_cjs.promoteBoldTitle; }
|
|
657
667
|
});
|
|
658
668
|
Object.defineProperty(exports, "repairParsedStructure", {
|
|
659
669
|
enumerable: true,
|
|
660
|
-
get: function () { return
|
|
670
|
+
get: function () { return chunkKULS4YWP_cjs.repairParsedStructure; }
|
|
661
671
|
});
|
|
662
672
|
Object.defineProperty(exports, "repairParsedTitle", {
|
|
663
673
|
enumerable: true,
|
|
664
|
-
get: function () { return
|
|
674
|
+
get: function () { return chunkKULS4YWP_cjs.repairParsedTitle; }
|
|
665
675
|
});
|
|
666
676
|
Object.defineProperty(exports, "savedFromId", {
|
|
667
677
|
enumerable: true,
|
|
668
|
-
get: function () { return
|
|
678
|
+
get: function () { return chunkKULS4YWP_cjs.savedFromId; }
|
|
669
679
|
});
|
|
670
680
|
Object.defineProperty(exports, "stripAgentPreamble", {
|
|
671
681
|
enumerable: true,
|
|
672
|
-
get: function () { return
|
|
682
|
+
get: function () { return chunkKULS4YWP_cjs.stripAgentPreamble; }
|
|
673
683
|
});
|
|
674
684
|
Object.defineProperty(exports, "toArtifactVersions", {
|
|
675
685
|
enumerable: true,
|
|
676
|
-
get: function () { return
|
|
686
|
+
get: function () { return chunkKULS4YWP_cjs.toArtifactVersions; }
|
|
677
687
|
});
|
|
678
688
|
Object.defineProperty(exports, "unescapeMarkdown", {
|
|
679
689
|
enumerable: true,
|
|
680
|
-
get: function () { return
|
|
690
|
+
get: function () { return chunkKULS4YWP_cjs.unescapeMarkdown; }
|
|
681
691
|
});
|
|
682
692
|
Object.defineProperty(exports, "unwrapCitationLinks", {
|
|
683
693
|
enumerable: true,
|
|
684
|
-
get: function () { return
|
|
694
|
+
get: function () { return chunkKULS4YWP_cjs.unwrapCitationLinks; }
|
|
685
695
|
});
|
|
686
696
|
Object.defineProperty(exports, "versionLabel", {
|
|
687
697
|
enumerable: true,
|
|
688
|
-
get: function () { return
|
|
698
|
+
get: function () { return chunkKULS4YWP_cjs.versionLabel; }
|
|
689
699
|
});
|
|
690
700
|
Object.defineProperty(exports, "versionRef", {
|
|
691
701
|
enumerable: true,
|
|
692
|
-
get: function () { return
|
|
702
|
+
get: function () { return chunkKULS4YWP_cjs.versionRef; }
|
|
693
703
|
});
|
|
694
704
|
Object.defineProperty(exports, "normalizeMarkdown", {
|
|
695
705
|
enumerable: true,
|
|
@@ -700,6 +710,7 @@ exports.artifactKindFromFileName = artifactKindFromFileName;
|
|
|
700
710
|
exports.artifactKindFromMode = artifactKindFromMode;
|
|
701
711
|
exports.mainThreadRedlineEngine = mainThreadRedlineEngine;
|
|
702
712
|
exports.renderArtifactMarkdown = renderArtifactMarkdown;
|
|
713
|
+
exports.savedArtifactMode = savedArtifactMode;
|
|
703
714
|
exports.useArtifactEditSession = useArtifactEditSession;
|
|
704
715
|
exports.useArtifactSession = useArtifactSession;
|
|
705
716
|
exports.useArtifactSource = useArtifactSource;
|