@meistrari/chat-nuxt 4.13.0-rc.11 → 4.13.0-rc.12

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.11",
4
+ "version": "4.13.0-rc.12",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "unknown"
@@ -1,8 +1,8 @@
1
1
  <script setup>
2
2
  import { useFilePreviewPanel } from "../composables/file-preview-panel";
3
3
  import { useVault } from "../composables/vault";
4
+ import { fileReferenceMimeType } from "../file-reference";
4
5
  import { getFileIcon } from "../icons";
5
- import { normalizeMimeType } from "../mime";
6
6
  import { isVaultPermalink } from "../vault-links";
7
7
  const props = defineProps({
8
8
  file: { type: Object, required: true },
@@ -11,7 +11,10 @@ const props = defineProps({
11
11
  const { openPreview, updatePreview, setError, currentFile } = useFilePreviewPanel();
12
12
  const { getFileInfo, isVaultReference } = useVault();
13
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)));
14
+ const iconSrc = computed(() => {
15
+ const mimeType = fileReferenceMimeType(props.file);
16
+ return mimeType ? getFileIcon(mimeType) : null;
17
+ });
15
18
  const open = ref(false);
16
19
  async function resolveFile() {
17
20
  const reference = props.file.reference;
@@ -1,3 +1,4 @@
1
+ import type { DetectedFile } from './content-detection.js';
1
2
  /** A markdown link whose text the author wrote, as opposed to an autolink that shows its own address. */
2
3
  export declare function isLabelledFileLink(label: string, href: string): boolean;
3
4
  type TextTreeNode = {
@@ -11,4 +12,10 @@ type TextTreeNode = {
11
12
  * out on purpose, so the answer does not change while a file card swaps in or still loads.
12
13
  */
13
14
  export declare function hasTextOutside(block: TextTreeNode, inner: TextTreeNode): boolean;
15
+ /**
16
+ * The type a file reference can show before anything is fetched. A permalink is detected with
17
+ * an unknown type, since its address says nothing about the file; the name the link was
18
+ * written with usually does.
19
+ */
20
+ export declare function fileReferenceMimeType(file: Pick<DetectedFile, 'mimeType' | 'name' | 'hashParams'>): string | null;
14
21
  export {};
@@ -1,3 +1,4 @@
1
+ import { getMimeTypeFromExtension, normalizeMimeType } from "./mime.js";
1
2
  export function isLabelledFileLink(label, href) {
2
3
  const text = label.trim();
3
4
  return text !== "" && text !== href.trim();
@@ -12,3 +13,10 @@ export function hasTextOutside(block, inner) {
12
13
  }
13
14
  return false;
14
15
  }
16
+ export function fileReferenceMimeType(file) {
17
+ if (file.mimeType !== "unknown")
18
+ return normalizeMimeType(file.mimeType);
19
+ const extension = /\.([a-z0-9]+)$/i.exec(file.hashParams?.filename ?? file.name)?.[1]?.toLowerCase();
20
+ const mimeType = extension ? getMimeTypeFromExtension(extension) : "unknown";
21
+ return mimeType === "unknown" ? null : mimeType;
22
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meistrari/chat-nuxt",
3
- "version": "4.13.0-rc.11",
3
+ "version": "4.13.0-rc.12",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {