clone

tiny dependency-free nostr libraries for plain html, each under 5kb and named for an element. public domain

Document the family

Dami committed 3907f34
commit
3907f34ef71afdc004134c25eee6317f9a1c2ff0
parent
4681ae6188416706206bdca752bbae56e016305d
author
Dami <dami.etoile@gmail.com>
1 file changed, +85 -0
AREADME.md85++++++++++++++++++++++++++++++
A README.md +85 -0
@@ -0,0 +1,85 @@
1+# nobel2+3+nobel is a family of small nostr libraries for plain HTML, each a lightweight take on something bigger and each named for an element. Every library is one dependency-free script under 5kb unminified, and connects to the others only through DOM events, the way the [fixi project](https://fixiproject.org) libraries do. Attributes and events take `n` plus the element's symbol: `nxe-filter`, `nhy:config`, `window.nhyCfg`.4+5+| group | library | size (raw/br) | miniature of | provides | prefix |6+|---|---|---|---|---|---|7+| nonmetal | ๐Ÿ’ง [hydrogen](hydrogen/) | 2.8/1.2kb | a relay pool | relays, signing and the family's hooks | `nhy-` |8+| noble gas | ๐Ÿ›ฐ๏ธ [xenon](xenon/) | 3.1/1.2kb | a nostr client | subscribe, render and publish in HTML | `nxe-` |9+| noble gas | ๐Ÿ”‘ [krypton](krypton/) | 3.8/1.6kb | @noble/secp256k1 | keys, Schnorr signing and verification | `nkr-` |10+| noble gas | ๐Ÿ“ฆ [argon](argon/) | 2.5/1.0kb | a relay | IndexedDB cache, offline-first feeds | `nar-` |11+| noble gas | ๐ŸŽˆ [helium](helium/) | 5.0/2.0kb | Negentropy | NIP-77 sync between argon and relays | `nhe-` |12+| noble gas | ๐Ÿ”— [neon](neon/) | 3.9/1.8kb | nip19 | npub/nevent/naddr, linked content, times | `nne-` |13+| noble gas | ๐Ÿชช [radon](radon/) | 3.1/1.3kb | a profile loader | names, pictures, NIP-05 | `nrn-` |14+| noble gas | ๐Ÿ‘ป [oganesson](oganesson/) | 4.7/1.8kb | a chat app's live layer | presence, typing, cursors (ephemeral) | `nog-` |15+| halogen | ๐Ÿงช [fluorine](fluorine/) | 3.4/1.4kb | NIP-44 | encryption for krypton's keys | `nfl-` |16+| halogen | ๐Ÿ”Œ [chlorine](chlorine/) | 4.6/1.8kb | a NIP-46 client | remote signing behind a NIP-07 face | `ncl-` |17+| halogen | โœ‰๏ธ [iodine](iodine/) | 3.9/1.6kb | an encrypted messenger | NIP-17 private messages | `nio-` |18+| transition metal | ๐Ÿฅ‡ [gold](gold/) | 2.2/1.0kb | a NIP-42 client | relay AUTH for members-only relays | `nau-` |19+| transition metal | โ˜ฟ๏ธ [mercury](mercury/) | 3.5/1.5kb | rexi.js | NIP-98 and Blossom signed HTTP | `nhg-` |20+| lanthanide | ๐Ÿชž [praseodymium](praseodymium/) | 3.2/1.3kb | fiatjaf's nostr-name and nostr-picture | profile cards, chips, avatars, copy | `npr-` |21+| lanthanide | ๐Ÿ”ด [europium](europium/) | 2.7/1.1kb | fiatjaf's nostr-note | note embeds | `neu-` |22+| lanthanide | ๐ŸŽจ [cerium](cerium/) | 2.8/0.9kb | a theme | the one stylesheet for the lanthanides | `nce-` |23+24+hydrogen is the base: relays, signatures and three hooks (`nhy:config`, `nhy:event`, `nhy:message`) that every other library plugs into. The noble gases are the core, inert pieces for data and transport. The halogens handle secrets and trust. The transition metals do signed exchanges outside plain subscriptions. The lanthanides are visual presets: they only write markup you could have written by hand from the other libraries' attributes, in the light DOM, and leave anything you wrote alone. cerium holds all of their styling, in one zero-specificity layer you can override or drop.25+26+```html27+<script src="neon.js"></script>28+<script src="krypton.js"></script>29+<script src="argon.js"></script>30+<script src="hydrogen.js"></script>31+<script src="xenon.js"></script>32+<script src="radon.js"></script>33+34+<form nhy-relay="wss://relay.example" nxe-publish>35+ <textarea name="content"></textarea><button>Post</button>36+</form>37+<ol nhy-relay="wss://relay.example" nxe-filter='{"kinds":[1],"limit":50}'>38+ <template>39+ <li><b nrn-profile="{pubkey}" nrn-field="name">{npub}</b> <time nne-ago="{created_at}">{ago}</time><p>{content}</p></li>40+ </template>41+</ol>42+```43+44+That page posts and reads notes, signs with a NIP-07 extension or a local key, shows names and linked content, and opens instantly from cache on reload.45+46+Load hydrogen before the libraries that use it, and the peers before xenon so their listeners are in place when it starts. `deno task bundle` writes all of them, in a working order, to `dist/nobel.js` and `dist/nobel.min.js` (42kb, 15kb brotli).47+48+## Use it49+50+Every library is a plain script. Take them from jsDelivr, pinned to a commit or following `main`:51+52+```html53+<script src="https://cdn.jsdelivr.net/gh/FelineStateMachine/nobel@main/hydrogen/hydrogen.js"></script>54+<script src="https://cdn.jsdelivr.net/gh/FelineStateMachine/nobel@main/xenon/xenon.js"></script>55+```56+57+Or copy the files into your project: each is one file with no dependencies. The site at [felinestatemachine.github.io/nobel](https://felinestatemachine.github.io/nobel/) always serves the latest `main`, including the bundle `dist/nobel.min.js` and the demos.58+59+## Naming60+61+Each library is an element, and its prefix is `n` plus the element's symbol in lower case, so prefixes never collide. Elements with one-letter symbols add the next letter of their name that doesn't spell another element's symbol. Groups of the periodic table gather libraries by character, and new members join the group that fits. There is nothing about cryptocurrency here, by design.62+63+## Development64+65+```sh66+deno task dev # http://localhost:8000/demo/ with an in-memory relay at /relay67+deno task test # parity, protocol and headless browser tests for every library68+deno task size # raw/gzip/brotli per library, fails over the 5kb budget69+deno task bundle # dist/nobel.js and dist/nobel.min.js70+deno task site # _site/: the static site published to GitHub Pages on every push to main71+```72+73+Demos: `/demo/` (feed), `/demo/iodine.html` (private messages), `/demo/oganesson.html` (presence, typing, cursors), `/demo/lanthanides.html` (profiles and theme), `/demo/europium.html` (note embeds).74+75+Some tests reach beyond the repo, and skip themselves when their dependency is missing:76+77+- helium reconciles against bindws's Negentropy when `../bindws` is checked out. `NOBEL_RELAYS="wss://a ws://b" deno test -A test/live.test.js` syncs against real relays.78+- chlorine runs against a real `nak bunker` when `nak` is on the PATH.79+- gold creates members-only tenants on a local tinyrelay container named `noble-tiny`.80+- mercury checks NIP-86 and Blossom on tinyrelay when `NHG_TINY` and `NHG_KEY` are set.81+- The browser tests use the Chromium headless shell in the Playwright cache, or `CHROMIUM=/path/to/chrome`.82+83+## License84+85+Public domain, via the [Unlicense](LICENSE).