-
Notifications
You must be signed in to change notification settings - Fork 0
Project Structure
A map of src/ and where to find things. The design rationale is on the Architecture page.
← Back to Home
src/
├── index.ts # Public entry point — re-exports the whole API
├── setupTests.ts # Vitest global setup (exposes SUPPORT_PATH / FEEDS_PATH)
├── himalaya.d.ts # Ambient types for himalaya (ships no types)
├── rss/ # Feed parsing pipeline
└── component/ # HTML → component pipeline
rss/
├── RSSFeed.ts # The RSSFeed class: validate() and build()
├── RSS.ts # Typed RSS / Channel / Item / media interfaces
├── ParsedXml.ts # Typed view of the raw fast-xml-parser output
├── Tag.ts # Required-tag & valid-tag allow-lists (rss / channel / item)
├── Attributes.ts # Attribute helpers for fast-xml-parser output
├── RSSFeed.test.ts # Feed parsing/validation tests
└── RSSFeed.coverage.test.ts
component/
├── Component.ts # ComponentType/TextType unions, interfaces, is* guards
├── Component.test.ts
├── html/
│ ├── HTMLMapper.ts # Public entry: toComponents(), getRootElement(), pre-processing
│ └── HTMLMapper.*.test.ts# Tests split by component family (text/embeds/media/table/container/mapping)
├── mapping/
│ ├── Mapping.ts # reduceComponents reducer + the recursive detection engine
│ ├── Mapping.media.ts # image / picture / figure / video / audio / gallery / iframe / twitter
│ ├── Mapping.embeds.ts # Social-embed converters/detectors (Instagram, TikTok, YouTube, Vimeo…)
│ ├── Mapping.container.ts# container / columns / live_container / link & figure containers / buttons
│ ├── Mapping.table.ts # toHTMLTable (<table> → htmltable)
│ ├── Mapping.custom.ts # toCustom (custom component)
│ ├── Mapping.text.ts # toText (text components)
│ ├── Mapping.utils.ts # Leaf helpers (sanitizeNode, sanitizeContentHtml, matchesPattern…)
│ ├── Mapping.constants.ts# Tag/attribute allow-lists
│ ├── Mapping.schema.ts # Zod schemas: Params, Mapping, filters, component mappings
│ └── Mapping.test.ts
├── node/
│ ├── Node.ts # himalaya AST node types + helpers (getAttributes, findDescendants, removeDescendants, SetUtils; DescendantsReducer type)
│ └── Node.test.ts
└── schema/
├── Schema.ts # Zod schemas for recipe (JSON-LD) extraction
└── Schema.test.ts
The
component/sources are grouped into per-concern folders (html/,mapping/,node/,schema/) with their tests colocated.Mapping.tsholds the recursive detection engine (reduceComponents/fromNode); the per-family converters are extracted into the siblingMapping.*modules and re-exported so the public API is unchanged.
Real RSS feeds and HTML snippets live under src/support/ (feeds/ and html/). setupTests.ts exposes process.env.SUPPORT_PATH and process.env.FEEDS_PATH so tests read fixtures without hardcoded paths. See Testing.
npm run build (vp pack) compiles src/index.ts into dist/ as unbundled ESM modules plus .d.mts declarations (configured under the pack key in vite.config.ts). Only dist/ is published.
-
Public classes are
RSSFeedandHTMLMapper. -
Mapping internals are grouped under
component/mapping/with aMapping.<concern>.tsname. -
Type guards are
is<Type>Component(e.g.isImageComponent), defined inComponent.ts. -
Tests are colocated as
*.test.tsnext to the file they cover.
Start here
Reference
Operations