@lapis-notes/api 0.2.8 → 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.
@@ -1,4 +1,5 @@
1
1
  import { basename, dirname, joinPath, normalizePath } from "./path";
2
+ import { vaultResourceContentType } from "./vault-resource-type";
2
3
  import { clearVaultScopedState, deleteVaultProfile, generateBrowserVaultId, getDefaultVaultStateStore, getVaultProfile, listVaultProfiles, saveVaultProfile, ScopedVaultStore, } from "./vault-state";
3
4
  function createFsError(code, path) {
4
5
  const error = new Error(`${code}: ${path}`);
@@ -685,7 +686,7 @@ export class BrowserHandleVaultAdapter {
685
686
  }
686
687
  async getResourceUrl(normalizedPath) {
687
688
  const data = await this.readBinary(normalizedPath);
688
- return URL.createObjectURL(new Blob([data]));
689
+ return URL.createObjectURL(new Blob([data], { type: vaultResourceContentType(normalizedPath) }));
689
690
  }
690
691
  revokeResourceUrl(url) {
691
692
  URL.revokeObjectURL(url);
@@ -0,0 +1 @@
1
+ export declare function vaultResourceContentType(path: string): string;
@@ -0,0 +1,37 @@
1
+ /** Passive media types supported by vault readers; unknown files stay binary. */
2
+ const resourceTypes = {
3
+ svg: "image/svg+xml",
4
+ png: "image/png",
5
+ apng: "image/apng",
6
+ jpg: "image/jpeg",
7
+ jpeg: "image/jpeg",
8
+ gif: "image/gif",
9
+ webp: "image/webp",
10
+ avif: "image/avif",
11
+ bmp: "image/bmp",
12
+ ico: "image/vnd.microsoft.icon",
13
+ tif: "image/tiff",
14
+ tiff: "image/tiff",
15
+ mp3: "audio/mpeg",
16
+ wav: "audio/wav",
17
+ ogg: "audio/ogg",
18
+ oga: "audio/ogg",
19
+ opus: "audio/ogg",
20
+ flac: "audio/flac",
21
+ m4a: "audio/mp4",
22
+ aac: "audio/aac",
23
+ mp4: "video/mp4",
24
+ m4v: "video/mp4",
25
+ webm: "video/webm",
26
+ ogv: "video/ogg",
27
+ mov: "video/quicktime",
28
+ pdf: "application/pdf",
29
+ };
30
+ export function vaultResourceContentType(path) {
31
+ const name = path.slice(path.lastIndexOf("/") + 1);
32
+ const dot = name.lastIndexOf(".");
33
+ return dot < 0
34
+ ? "application/octet-stream"
35
+ : (resourceTypes[name.slice(dot + 1).toLowerCase()] ??
36
+ "application/octet-stream");
37
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lapis-notes/api",
3
- "version": "0.2.8",
3
+ "version": "0.3.1",
4
4
  "description": "Lapis Notes API",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -22,8 +22,8 @@
22
22
  "@iconify/types": "^2.0.0",
23
23
  "@iconify/utils": "^2.3.0",
24
24
  "@lapismd/ai-host": "^0.3.0",
25
- "@lapismd/design-core": "^0.12.1",
26
- "@lapismd/mira": "~0.1.4",
25
+ "@lapismd/design-core": "^0.13.0",
26
+ "@lapismd/mira": "~0.1.5",
27
27
  "@lezer/common": "^1.2.3",
28
28
  "@lezer/lr": "^1.4.2",
29
29
  "@lucide/svelte": "^0.523.0",
@@ -108,8 +108,8 @@
108
108
  "@codemirror/view": "^6.35.0",
109
109
  "@dnd-kit/dom": "^0.4.0",
110
110
  "@dnd-kit/svelte": "^0.4.0",
111
- "@lapis-notes/ui": "^0.1.8",
112
- "@lapismd/design-core": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.12.0",
111
+ "@lapis-notes/ui": "^0.1.9",
112
+ "@lapismd/design-core": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.12.0 || ^0.13.0",
113
113
  "@lapismd/mira": "~0.1.3",
114
114
  "@lezer/highlight": "^1.2.1",
115
115
  "@lezer/markdown": "^1.4.3",