Files
Alex Gleason 0b220f250a Upgrade note-content skill with advancements from Ditto
Replaces the minimal NoteContent component with the full-featured
version from ~/Projects/ditto, and bundles the helper modules and
minimal companion stubs needed to make it work standalone.

New capabilities:
- BOLT11 lightning-invoice detection (renders LightningInvoiceCard)
- Inline image / video / audio / webxdc embeds with MIME detection
- Consecutive images grouped into an ImageGallery with shared Lightbox
- NIP-94 imeta-declared media appended when absent from content
- Embedded nevent / naddr cards, with relay and author hints pulled
  from q tags; supports naddr1 fragments embedded in external URLs
- Bare and @-prefixed NIP-19 identifiers (no nostr: prefix required)
- Line-end-aware link rendering: URLs at the end of a line become
  preview cards, mid-sentence URLs stay inline
- Trailing-punctuation stripping on URLs so 'see https://x.com.'
  links correctly
- wss:// relay URLs routed to /r/<encoded>
- Unicode-aware hashtag regex (matches non-ASCII letters)
- NIP-30 custom emoji via :shortcode: with per-event and viewer-wide
  fallback collections (useCustomEmojis)
- Flag emoji linkified to /i/iso3166:<CC>
- 'Emoji-only' posts auto-rendered at large size
- dir="auto" for RTL content
- Whitespace normalization around block embeds
- disableEmbeds / disableMediaEmbeds / disableNoteEmbeds /
  hideEmbedImages props for recursive embed cards and preview
  contexts

New bundled files:
- lib/: mediaUrls.ts, sanitizeUrl.ts, imeta.ts, customEmoji.ts,
  getDisplayName.ts, avatarShape.ts, countries.ts
- hooks/: useCustomEmojis.ts (stub), useBlossomFallback.ts (stub),
  useProfileUrl.ts (stub)
- components/: LinkEmbed, EmbeddedNote, EmbeddedNaddr,
  LightningInvoiceCard, VideoPlayer, AudioVisualizer, WebxdcEmbed,
  ImageGallery + Lightbox, ProfileHoverCard, CustomEmoji \u2014 all
  minimal but functional stubs; each file documents how to upgrade
  to a richer implementation

SKILL.md rewritten with full file list, upgrade paths for each
stub, routing expectations, and a patterns-to-render table.

Validated: tsc --noEmit clean, vitest run passes all 5 NoteContent
tests, vite build succeeds \u2014 when all skill files are staged
into src/ alongside the component.
2026-04-26 19:38:31 -05:00

44 lines
1.3 KiB
TypeScript

/** Parsed imeta entry from NIP-94 tags. */
export interface ImetaEntry {
url: string;
thumbnail?: string;
mime?: string;
/** Summary text (used as webxdc app name for webxdc attachments). */
summary?: string;
/** Webxdc session UUID — present when the attachment is a stateful webxdc app. */
webxdc?: string;
/** Pixel dimensions from NIP-94 `dim` tag, e.g. "1280x720". */
dim?: string;
/** Blurhash placeholder from NIP-94 `blurhash` tag. */
blurhash?: string;
}
/** Parse all imeta tags into a map keyed by URL. Works for any event kind. */
export function parseImetaMap(tags: string[][]): Map<string, ImetaEntry> {
const map = new Map<string, ImetaEntry>();
for (const tag of tags) {
if (tag[0] !== 'imeta') continue;
const entry: Record<string, string> = {};
for (let i = 1; i < tag.length; i++) {
const part = tag[i];
const spaceIdx = part.indexOf(' ');
if (spaceIdx === -1) continue;
const key = part.slice(0, spaceIdx);
const value = part.slice(spaceIdx + 1);
entry[key] = value;
}
if (entry.url) {
map.set(entry.url, {
url: entry.url,
thumbnail: entry.image,
mime: entry.m,
summary: entry.summary,
webxdc: entry.webxdc,
dim: entry.dim,
blurhash: entry.blurhash,
});
}
}
return map;
}