mirror of
https://gitlab.com/soapbox-pub/mkstack.git
synced 2026-12-05 16:33:36 +00:00
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.
28 lines
1.0 KiB
TypeScript
28 lines
1.0 KiB
TypeScript
/**
|
|
* An avatar shape is stored in kind-0 metadata as the `shape` property.
|
|
* Typically an emoji glyph used as a mask (e.g. "🐱", "⭐").
|
|
*
|
|
* This minimal stub exposes just enough surface for `NoteContent` to
|
|
* read the shape and pass it into `AudioVisualizer`. The stubbed
|
|
* `AudioVisualizer` ignores it; a richer implementation would use
|
|
* the shape to generate a CSS mask URL for the avatar.
|
|
*/
|
|
export type AvatarShape = string;
|
|
|
|
/**
|
|
* Extract the avatar shape from Nostr metadata. Returns `undefined`
|
|
* when the metadata is missing or has no `shape` field.
|
|
*/
|
|
export function getAvatarShape(
|
|
metadata: { [key: string]: unknown } | undefined,
|
|
): AvatarShape | undefined {
|
|
if (!metadata) return undefined;
|
|
const shape = metadata.shape;
|
|
if (typeof shape !== 'string') return undefined;
|
|
// Light guard: only return short, non-ASCII values (emoji-like)
|
|
if (shape.length === 0 || shape.length > 20) return undefined;
|
|
// eslint-disable-next-line no-control-regex
|
|
if (!/[^\x00-\x7F]/.test(shape)) return undefined;
|
|
return shape;
|
|
}
|