@meistrari/chat-nuxt 4.13.0-rc.7 → 4.13.0-rc.9

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/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@meistrari/chat-nuxt",
3
3
  "configKey": "chatNuxt",
4
- "version": "4.13.0-rc.7",
4
+ "version": "4.13.0-rc.9",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "unknown"
@@ -12,6 +12,7 @@ const props = defineProps({
12
12
  const code = computed(() => props.node.code ?? props.node.content ?? "");
13
13
  const host = {
14
14
  prose: OpenuiMarkdownProse,
15
+ expanded: true,
15
16
  components: { Questions: ChatExportQuestions, FileCard: ChatExportFile, Image: OpenuiImage, Citation: OpenuiCitation, CodeBlock: ChatExportCodeBlock, Steps: ChatExportSteps }
16
17
  };
17
18
  </script>
@@ -6,8 +6,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_ModelProps, {},
6
6
  } & {
7
7
  create: (canvasTools: CanvasTool[]) => any;
8
8
  }, string, import("vue").PublicProps, Readonly<__VLS_ModelProps> & Readonly<{
9
- onCreate?: ((canvasTools: CanvasTool[]) => any) | undefined;
10
9
  "onUpdate:modelValue"?: ((value: boolean | undefined) => any) | undefined;
10
+ onCreate?: ((canvasTools: CanvasTool[]) => any) | undefined;
11
11
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
12
12
  declare const _default: typeof __VLS_export;
13
13
  export default _default;
@@ -6,8 +6,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_ModelProps, {},
6
6
  } & {
7
7
  create: (canvasTools: CanvasTool[]) => any;
8
8
  }, string, import("vue").PublicProps, Readonly<__VLS_ModelProps> & Readonly<{
9
- onCreate?: ((canvasTools: CanvasTool[]) => any) | undefined;
10
9
  "onUpdate:modelValue"?: ((value: boolean | undefined) => any) | undefined;
10
+ onCreate?: ((canvasTools: CanvasTool[]) => any) | undefined;
11
11
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
12
12
  declare const _default: typeof __VLS_export;
13
13
  export default _default;
@@ -15,23 +15,23 @@ type __VLS_Props = {
15
15
  };
16
16
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
17
17
  delete: () => any;
18
- openDrawer: () => any;
19
- copyLink: () => any;
20
- openOutdatedSettings: () => any;
21
18
  rename: () => any;
22
19
  duplicate: () => any;
23
20
  export: () => any;
21
+ copyLink: () => any;
24
22
  debug: () => any;
23
+ openDrawer: () => any;
24
+ openOutdatedSettings: () => any;
25
25
  tabChange: (tab: TopbarTab) => any;
26
26
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
27
27
  onDelete?: (() => any) | undefined;
28
- onOpenDrawer?: (() => any) | undefined;
29
- onCopyLink?: (() => any) | undefined;
30
- onOpenOutdatedSettings?: (() => any) | undefined;
31
28
  onRename?: (() => any) | undefined;
32
29
  onDuplicate?: (() => any) | undefined;
33
30
  onExport?: (() => any) | undefined;
31
+ onCopyLink?: (() => any) | undefined;
34
32
  onDebug?: (() => any) | undefined;
33
+ onOpenDrawer?: (() => any) | undefined;
34
+ onOpenOutdatedSettings?: (() => any) | undefined;
35
35
  onTabChange?: ((tab: TopbarTab) => any) | undefined;
36
36
  }>, {
37
37
  showDrawerButton: boolean;
@@ -15,23 +15,23 @@ type __VLS_Props = {
15
15
  };
16
16
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
17
17
  delete: () => any;
18
- openDrawer: () => any;
19
- copyLink: () => any;
20
- openOutdatedSettings: () => any;
21
18
  rename: () => any;
22
19
  duplicate: () => any;
23
20
  export: () => any;
21
+ copyLink: () => any;
24
22
  debug: () => any;
23
+ openDrawer: () => any;
24
+ openOutdatedSettings: () => any;
25
25
  tabChange: (tab: TopbarTab) => any;
26
26
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
27
27
  onDelete?: (() => any) | undefined;
28
- onOpenDrawer?: (() => any) | undefined;
29
- onCopyLink?: (() => any) | undefined;
30
- onOpenOutdatedSettings?: (() => any) | undefined;
31
28
  onRename?: (() => any) | undefined;
32
29
  onDuplicate?: (() => any) | undefined;
33
30
  onExport?: (() => any) | undefined;
31
+ onCopyLink?: (() => any) | undefined;
34
32
  onDebug?: (() => any) | undefined;
33
+ onOpenDrawer?: (() => any) | undefined;
34
+ onOpenOutdatedSettings?: (() => any) | undefined;
35
35
  onTabChange?: ((tab: TopbarTab) => any) | undefined;
36
36
  }>, {
37
37
  showDrawerButton: boolean;
@@ -66,46 +66,46 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
66
66
  } & {
67
67
  delete: () => any;
68
68
  cancel: () => any;
69
- settings: () => any;
70
- send: (content: string, files: FileUploadInput[], agentInputs?: TelaAgentExecutionInput[] | undefined) => any;
71
- newConversation: (groupId?: string | null | undefined) => any;
72
- selectExecutionProfile: (profile: ChatExecutionProfile) => any;
73
- copyLink: () => any;
74
69
  rename: () => any;
75
70
  duplicate: () => any;
76
71
  export: () => any;
72
+ copyLink: () => any;
77
73
  debug: () => any;
74
+ selectConversation: (id: string) => any;
75
+ send: (content: string, files: FileUploadInput[], agentInputs?: TelaAgentExecutionInput[] | undefined) => any;
76
+ settings: () => any;
77
+ newConversation: (groupId?: string | null | undefined) => any;
78
+ selectExecutionProfile: (profile: ChatExecutionProfile) => any;
78
79
  tabChange: (tab: TopbarTab) => any;
79
80
  switchWorkspace: () => any;
80
81
  signout: () => any;
81
82
  cancelEditing: () => any;
82
83
  dismissOutdatedBanner: () => any;
83
84
  saveTitle: () => any;
84
- selectConversation: (id: string) => any;
85
85
  "update:drawerOpen": (value: boolean) => any;
86
86
  "update:editTitle": (value: string) => any;
87
87
  "update:workspaceSheetOpen": (value: boolean) => any;
88
88
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
89
89
  onDelete?: (() => any) | undefined;
90
90
  onCancel?: (() => any) | undefined;
91
- onSettings?: (() => any) | undefined;
91
+ onRename?: (() => any) | undefined;
92
+ onDuplicate?: (() => any) | undefined;
93
+ onExport?: (() => any) | undefined;
94
+ onCopyLink?: (() => any) | undefined;
95
+ onDebug?: (() => any) | undefined;
96
+ onSelectConversation?: ((id: string) => any) | undefined;
92
97
  onSend?: ((content: string, files: FileUploadInput[], agentInputs?: TelaAgentExecutionInput[] | undefined) => any) | undefined;
98
+ onSettings?: (() => any) | undefined;
93
99
  onNewConversation?: ((groupId?: string | null | undefined) => any) | undefined;
94
100
  onSelectExecutionProfile?: ((profile: ChatExecutionProfile) => any) | undefined;
95
101
  "onUpdate:selectedModel"?: ((value: string | null) => any) | undefined;
96
102
  "onUpdate:selectedReasoningEffort"?: ((value: any) => any) | undefined;
97
- onCopyLink?: (() => any) | undefined;
98
- onRename?: (() => any) | undefined;
99
- onDuplicate?: (() => any) | undefined;
100
- onExport?: (() => any) | undefined;
101
- onDebug?: (() => any) | undefined;
102
103
  onTabChange?: ((tab: TopbarTab) => any) | undefined;
103
104
  onSwitchWorkspace?: (() => any) | undefined;
104
105
  onSignout?: (() => any) | undefined;
105
106
  onCancelEditing?: (() => any) | undefined;
106
107
  onDismissOutdatedBanner?: (() => any) | undefined;
107
108
  onSaveTitle?: (() => any) | undefined;
108
- onSelectConversation?: ((id: string) => any) | undefined;
109
109
  "onUpdate:drawerOpen"?: ((value: boolean) => any) | undefined;
110
110
  "onUpdate:editTitle"?: ((value: string) => any) | undefined;
111
111
  "onUpdate:workspaceSheetOpen"?: ((value: boolean) => any) | undefined;
@@ -66,46 +66,46 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
66
66
  } & {
67
67
  delete: () => any;
68
68
  cancel: () => any;
69
- settings: () => any;
70
- send: (content: string, files: FileUploadInput[], agentInputs?: TelaAgentExecutionInput[] | undefined) => any;
71
- newConversation: (groupId?: string | null | undefined) => any;
72
- selectExecutionProfile: (profile: ChatExecutionProfile) => any;
73
- copyLink: () => any;
74
69
  rename: () => any;
75
70
  duplicate: () => any;
76
71
  export: () => any;
72
+ copyLink: () => any;
77
73
  debug: () => any;
74
+ selectConversation: (id: string) => any;
75
+ send: (content: string, files: FileUploadInput[], agentInputs?: TelaAgentExecutionInput[] | undefined) => any;
76
+ settings: () => any;
77
+ newConversation: (groupId?: string | null | undefined) => any;
78
+ selectExecutionProfile: (profile: ChatExecutionProfile) => any;
78
79
  tabChange: (tab: TopbarTab) => any;
79
80
  switchWorkspace: () => any;
80
81
  signout: () => any;
81
82
  cancelEditing: () => any;
82
83
  dismissOutdatedBanner: () => any;
83
84
  saveTitle: () => any;
84
- selectConversation: (id: string) => any;
85
85
  "update:drawerOpen": (value: boolean) => any;
86
86
  "update:editTitle": (value: string) => any;
87
87
  "update:workspaceSheetOpen": (value: boolean) => any;
88
88
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
89
89
  onDelete?: (() => any) | undefined;
90
90
  onCancel?: (() => any) | undefined;
91
- onSettings?: (() => any) | undefined;
91
+ onRename?: (() => any) | undefined;
92
+ onDuplicate?: (() => any) | undefined;
93
+ onExport?: (() => any) | undefined;
94
+ onCopyLink?: (() => any) | undefined;
95
+ onDebug?: (() => any) | undefined;
96
+ onSelectConversation?: ((id: string) => any) | undefined;
92
97
  onSend?: ((content: string, files: FileUploadInput[], agentInputs?: TelaAgentExecutionInput[] | undefined) => any) | undefined;
98
+ onSettings?: (() => any) | undefined;
93
99
  onNewConversation?: ((groupId?: string | null | undefined) => any) | undefined;
94
100
  onSelectExecutionProfile?: ((profile: ChatExecutionProfile) => any) | undefined;
95
101
  "onUpdate:selectedModel"?: ((value: string | null) => any) | undefined;
96
102
  "onUpdate:selectedReasoningEffort"?: ((value: any) => any) | undefined;
97
- onCopyLink?: (() => any) | undefined;
98
- onRename?: (() => any) | undefined;
99
- onDuplicate?: (() => any) | undefined;
100
- onExport?: (() => any) | undefined;
101
- onDebug?: (() => any) | undefined;
102
103
  onTabChange?: ((tab: TopbarTab) => any) | undefined;
103
104
  onSwitchWorkspace?: (() => any) | undefined;
104
105
  onSignout?: (() => any) | undefined;
105
106
  onCancelEditing?: (() => any) | undefined;
106
107
  onDismissOutdatedBanner?: (() => any) | undefined;
107
108
  onSaveTitle?: (() => any) | undefined;
108
- onSelectConversation?: ((id: string) => any) | undefined;
109
109
  "onUpdate:drawerOpen"?: ((value: boolean) => any) | undefined;
110
110
  "onUpdate:editTitle"?: ((value: string) => any) | undefined;
111
111
  "onUpdate:workspaceSheetOpen"?: ((value: boolean) => any) | undefined;
@@ -0,0 +1,9 @@
1
+ import type { DetectedFile } from '../content-detection.js';
2
+ type __VLS_Props = {
3
+ file: DetectedFile;
4
+ /** The text the author wrote for the link. */
5
+ label: string;
6
+ };
7
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
+ declare const _default: typeof __VLS_export;
9
+ export default _default;
@@ -0,0 +1,82 @@
1
+ <script setup>
2
+ import { useFilePreviewPanel } from "../composables/file-preview-panel";
3
+ import { useVault } from "../composables/vault";
4
+ import { getFileIcon } from "../icons";
5
+ import { normalizeMimeType } from "../mime";
6
+ import { isVaultPermalink } from "../vault-links";
7
+ const props = defineProps({
8
+ file: { type: Object, required: true },
9
+ label: { type: String, required: true }
10
+ });
11
+ const { openPreview, updatePreview, setError, currentFile } = useFilePreviewPanel();
12
+ const { getFileInfo, isVaultReference } = useVault();
13
+ const fileName = computed(() => props.file.hashParams?.filename ?? props.file.name);
14
+ const iconSrc = computed(() => props.file.mimeType === "unknown" ? null : getFileIcon(normalizeMimeType(props.file.mimeType)));
15
+ const open = ref(false);
16
+ async function resolveFile() {
17
+ const reference = props.file.reference;
18
+ const cleanReference = reference.split("#")[0] ?? reference;
19
+ if (isVaultReference(cleanReference)) {
20
+ const info = await getFileInfo(cleanReference);
21
+ return { resolvedUrl: info.url, resolvedMimeType: info.mimeType, originalFileName: info.originalFileName };
22
+ }
23
+ if (isVaultPermalink(reference)) {
24
+ const metadata = await $fetch("/api/vault/permalink-metadata", {
25
+ method: "POST",
26
+ body: { url: reference }
27
+ }).catch(() => ({}));
28
+ return { resolvedUrl: reference, resolvedMimeType: metadata.mimeType, originalFileName: metadata.originalFileName, fileSize: metadata.fileSize };
29
+ }
30
+ return { resolvedUrl: reference };
31
+ }
32
+ async function openInPanel() {
33
+ const file = props.file;
34
+ const stillOpen = () => toRaw(currentFile.value?.file) === toRaw(file);
35
+ open.value = false;
36
+ openPreview({ file });
37
+ try {
38
+ const resolved = await resolveFile();
39
+ if (stillOpen())
40
+ updatePreview(resolved);
41
+ } catch {
42
+ if (stillOpen())
43
+ setError();
44
+ }
45
+ }
46
+ </script>
47
+
48
+ <template>
49
+ <TelaPopover v-model:open="open">
50
+ <TelaPopoverTrigger as-child>
51
+ <button type="button" class="chat-file-ref" data-chat-file="reference">
52
+ <img v-if="iconSrc" :src="iconSrc" alt="" class="chat-file-ref-icon chat-file-ref-icon--type"><span v-else i-ph-file-text class="chat-file-ref-icon" />{{ label }}
53
+ </button>
54
+ </TelaPopoverTrigger>
55
+ <TelaPopoverContent
56
+ side="top"
57
+ align="start"
58
+ :side-offset="3"
59
+ class="popover-enter-exit origin-[var(--reka-popover-content-transform-origin)] w-300px p-12px rounded-12px! bg border-0.5px! border! [box-shadow:0_4px_16px_0_rgba(85,91,98,0.14)]!"
60
+ >
61
+ <div flex="~ col" gap-8px>
62
+ <p text-13px leading-18px font-580 text-neutral-900 break-words>
63
+ {{ fileName }}
64
+ </p>
65
+ <button
66
+ type="button"
67
+ self-start inline-flex items-center gap-4px
68
+ text-12px leading-16px font-580 text-neutral-900
69
+ cursor-pointer hover:underline
70
+ @click="openInPanel"
71
+ >
72
+ <span i-ph-arrow-square-out text-13px />
73
+ Abrir arquivo
74
+ </button>
75
+ </div>
76
+ </TelaPopoverContent>
77
+ </TelaPopover>
78
+ </template>
79
+
80
+ <style scoped>
81
+ .chat-file-ref{background:transparent;border:0;border-radius:5px;color:inherit;cursor:pointer;display:inline;font:inherit;margin:0 -2px;padding:1px 3px;text-decoration:underline;text-decoration-color:#a3a3a3;text-decoration-style:dotted;text-decoration-thickness:1px;text-underline-offset:3px;transition:background-color .15s ease,text-decoration-color .15s ease}.chat-file-ref:hover{background-color:#f5f5f5;text-decoration-color:#525252}.chat-file-ref-icon{display:inline-block;font-size:.85em;margin-right:.25em;vertical-align:-.08em}.chat-file-ref-icon--type{height:1em;vertical-align:-.15em;width:1em}
82
+ </style>
@@ -0,0 +1,9 @@
1
+ import type { DetectedFile } from '../content-detection.js';
2
+ type __VLS_Props = {
3
+ file: DetectedFile;
4
+ /** The text the author wrote for the link. */
5
+ label: string;
6
+ };
7
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
+ declare const _default: typeof __VLS_export;
9
+ export default _default;
@@ -3,7 +3,10 @@ import { isCitationUrl, parseCitationUrl } from "../../citations/citation-links"
3
3
  import ChatUrlCitation from "../../citations/components/chat-url-citation.vue";
4
4
  import { parseUrlCitation } from "../../citations/url-citation";
5
5
  import { useEmbedConfig } from "../../embed/composables/embed-config";
6
+ import { CHAT_MESSAGE_CONTEXT_KEY } from "../../types/messages";
6
7
  import { detectFileFromUrl } from "../content-detection";
8
+ import { hasTextOutside, isLabelledFileLink } from "../file-reference";
9
+ import ChatFileReference from "./chat-file-reference.vue";
7
10
  const props = defineProps({
8
11
  node: { type: Object, required: true },
9
12
  indexKey: { type: [Number, String], required: true },
@@ -17,6 +20,18 @@ const linkText = computed(() => {
17
20
  }
18
21
  return props.node.text || props.node.href;
19
22
  });
23
+ const labelled = computed(() => isLabelledFileLink(linkText.value, props.node.href));
24
+ const message = inject(CHAT_MESSAGE_CONTEXT_KEY, null);
25
+ const root = ref(null);
26
+ const aloneInBlock = ref(false);
27
+ const standalone = computed(() => aloneInBlock.value && !message?.streaming.value);
28
+ function measureBlock() {
29
+ const element = root.value;
30
+ const block = element?.closest(".paragraph-node, p, td, th");
31
+ aloneInBlock.value = Boolean(element && block && !hasTextOutside(block, element));
32
+ }
33
+ onMounted(measureBlock);
34
+ watch(() => message?.streaming.value, () => nextTick(measureBlock));
20
35
  const detectedCitation = computed(() => {
21
36
  if (!embedConfig?.citations.value)
22
37
  return null;
@@ -33,8 +48,23 @@ const detectedUrlCitation = computed(() => parseUrlCitation(props.node.href, lin
33
48
  </script>
34
49
 
35
50
  <template>
51
+ <span v-if="detectedFile && labelled" ref="root">
52
+ <ChatFilePreview
53
+ v-if="standalone"
54
+ :file="detectedFile"
55
+ inline-block
56
+ align-middle
57
+ w-full
58
+ my-4px
59
+ />
60
+ <ChatFileReference
61
+ v-else
62
+ :file="detectedFile"
63
+ :label="linkText"
64
+ />
65
+ </span>
36
66
  <ChatFilePreview
37
- v-if="detectedFile"
67
+ v-else-if="detectedFile"
38
68
  :file="detectedFile"
39
69
  inline-block
40
70
  align-middle
@@ -0,0 +1,14 @@
1
+ /** A markdown link whose text the author wrote, as opposed to an autolink that shows its own address. */
2
+ export declare function isLabelledFileLink(label: string, href: string): boolean;
3
+ type TextTreeNode = {
4
+ nodeType: number;
5
+ textContent: string | null;
6
+ childNodes: ArrayLike<unknown>;
7
+ };
8
+ /**
9
+ * Whether `block` holds any text outside `inner`. A file link with none is the whole block:
10
+ * the file is being handed over, not cited in a sentence. What `inner` itself renders is left
11
+ * out on purpose, so the answer does not change while a file card swaps in or still loads.
12
+ */
13
+ export declare function hasTextOutside(block: TextTreeNode, inner: TextTreeNode): boolean;
14
+ export {};
@@ -0,0 +1,14 @@
1
+ export function isLabelledFileLink(label, href) {
2
+ const text = label.trim();
3
+ return text !== "" && text !== href.trim();
4
+ }
5
+ const TEXT_NODE = 3;
6
+ export function hasTextOutside(block, inner) {
7
+ for (const child of Array.from(block.childNodes)) {
8
+ if (child === inner)
9
+ continue;
10
+ if (child.nodeType === TEXT_NODE ? (child.textContent ?? "").trim() !== "" : hasTextOutside(child, inner))
11
+ return true;
12
+ }
13
+ return false;
14
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meistrari/chat-nuxt",
3
- "version": "4.13.0-rc.7",
3
+ "version": "4.13.0-rc.9",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -52,7 +52,7 @@
52
52
  "@iconify-json/ph": "^1.2.2",
53
53
  "@iconify/vue": "^5.0.0",
54
54
  "@meistrari/auth-nuxt": "3.31.0",
55
- "@meistrari/chat-ui-lang": "0.8.0-rc.3",
55
+ "@meistrari/chat-ui-lang": "0.8.0",
56
56
  "@meistrari/logger": "^2.1.3",
57
57
  "@meistrari/tela-build": "^1.79.0",
58
58
  "@openuidev/lang-core": "1.0.0",