applesauce-core
Advanced tools
Comparing version 0.0.0-next-20250103191026 to 0.0.0-next-20250105215133
@@ -16,3 +16,4 @@ export * from "./bolt11.js"; | ||
export * from "./mailboxes.js"; | ||
export * from "./media-attachment.js"; | ||
export * from "./file-metadata.js"; | ||
export * from "./media-post.js"; | ||
export * from "./pointers.js"; | ||
@@ -19,0 +20,0 @@ export * from "./profile.js"; |
@@ -16,3 +16,4 @@ export * from "./bolt11.js"; | ||
export * from "./mailboxes.js"; | ||
export * from "./media-attachment.js"; | ||
export * from "./file-metadata.js"; | ||
export * from "./media-post.js"; | ||
export * from "./pointers.js"; | ||
@@ -19,0 +20,0 @@ export * from "./profile.js"; |
@@ -5,6 +5,11 @@ import { NostrEvent } from "nostr-tools"; | ||
url: string; | ||
/** mime type */ | ||
/** MIME type */ | ||
type?: string; | ||
/** sha256 hash of the file */ | ||
sha256?: string; | ||
/** | ||
* The original sha256 hash before the file was transformed | ||
* @deprecated | ||
*/ | ||
originalSha256?: string; | ||
/** size of the file in bytes */ | ||
@@ -19,3 +24,3 @@ size?: number; | ||
/** URL to a thumbnail */ | ||
thumb?: string; | ||
thumbnail?: string; | ||
/** URL to a preview image with the same dimensions */ | ||
@@ -27,2 +32,6 @@ image?: string; | ||
alt?: string; | ||
/** blurhash */ | ||
blurhash?: string; | ||
/** fallback URLs */ | ||
fallback?: string[]; | ||
}; | ||
@@ -29,0 +38,0 @@ /** |
@@ -9,2 +9,3 @@ import { getOrComputeCachedValue } from "./cache.js"; | ||
const fields = {}; | ||
let fallback = undefined; | ||
for (const part of parts) { | ||
@@ -14,3 +15,10 @@ const match = part.match(/^(.+?)\s(.+)$/); | ||
const [_, name, value] = match; | ||
fields[name] = value; | ||
switch (name) { | ||
case "fallback": | ||
fallback = fallback ? [...fallback, value] : [value]; | ||
break; | ||
default: | ||
fields[name] = value; | ||
break; | ||
} | ||
} | ||
@@ -20,3 +28,3 @@ } | ||
throw new Error("Missing required url in attachment"); | ||
const attachment = { url: fields.url }; | ||
const attachment = { url: fields.url, fallback }; | ||
// parse size | ||
@@ -30,2 +38,4 @@ if (fields.size) | ||
attachment.sha256 = fields.x; | ||
if (fields.ox) | ||
attachment.originalSha256 = fields.ox; | ||
if (fields.dim) | ||
@@ -38,3 +48,3 @@ attachment.dimensions = fields.dim; | ||
if (fields.thumb) | ||
attachment.thumb = fields.thumb; | ||
attachment.thumbnail = fields.thumb; | ||
if (fields.image) | ||
@@ -46,2 +56,4 @@ attachment.image = fields.image; | ||
attachment.alt = fields.alt; | ||
if (fields.blurhash) | ||
attachment.blurhash = fields.blurhash; | ||
return attachment; | ||
@@ -48,0 +60,0 @@ } |
{ | ||
"name": "applesauce-core", | ||
"version": "0.0.0-next-20250103191026", | ||
"version": "0.0.0-next-20250105215133", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "type": "module", |
149783
115
3745