feat(feed): Phase 0 — foundations (types, NIP-92 imeta parser, blurhash decoder)#396
Merged
Merged
Conversation
…hash decoder Phase 0 of the feed overhaul. New `src/lib/feed/` module with no runtime side-effects, no production wiring; everything downstream phases need is in place. - types.ts: FeedNoteVM, MediaItem, RepostVM, EmbedVM, FeedTab, FeedCursor, FeedSourceState. Framework-free; will be recomputed from cached NDK events on read (no IndexedDB schema impact). - imeta.ts: parseImeta(event) reads NIP-92 imeta tags (url, m, dim, blurhash, alt, x, fallback) and falls back to URL extraction from event.content when no imeta tags are present. Mirrors the hostname + extension heuristics used by NoteContent.svelte so the fallback path produces the same media list the current feed does. - blurhash.ts: hand-ported canonical blurhash decoder (~200 LOC) so we don't pull the npm dep. Exports isValidBlurhash, decodeBlurhash (pixel buffer), and blurhashToDataUrl (PNG data URL via canvas). SSR-safe — returns null when no canvas is available so callers paint a solid bg-secondary tile instead. - imeta.test.ts (20 tests) + blurhash.test.ts (11 tests): covers empty events, single/multiple imeta tags, mime inference, fallback splitting, dim parsing edge cases, URL extraction dedupe, and decoder validity / range guarantees. All 31 tests pass; `pnpm check` and `tsc --noEmit` are clean.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 0 of the planned feed overhaul. Lays down the type and parsing primitives that subsequent phases depend on, with no production wiring and no runtime side-effects. Nothing is visible to users in this PR.
See `/Users/daniel/.claude/plans/cached-waddling-treasure.md` for the full overhaul plan (8 phases). This is the smallest, safest first slice.
What's new
Test plan
What's NOT in this PR
The Phase 1 PR (`feat/feed-media-gallery`) will be the first user-visible step — adding the gallery grid + Lightbox components behind a dev-only demo route.