-
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
├── 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
component/
├── HTMLMapper.ts # Public entry: toComponents(), getRootElement(), pre-processing
├── HTMLMapper.test.ts
├── Component.ts # ComponentType/TextType unions, interfaces, is* guards
├── Component.test.ts
├── mapping/
│ ├── Mapping.ts # reduceComponents reducer + recursive detection engine
│ ├── Mapping.schema.ts # Zod schemas: Params, Mapping, filters, component mappings
│ ├── Mapping.constants.ts# Tag/attribute allow-lists
│ ├── Mapping.utils.ts # Leaf helpers (sanitizeNode, matchesPattern, processTextLinks…)
│ ├── Mapping.embeds.ts # Social-embed converters/detectors (Instagram, TikTok, YouTube…)
│ └── Mapping.test.ts
├── node/
│ ├── Node.ts # himalaya AST node types + helpers (getAttributes, findDescendants, SetUtils)
│ └── 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 (mapping/,node/,schema/) with their tests colocated.Mapping.tsholds the recursive detection engine; its leaf concerns 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