@yaebal/rich 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +27 -27
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  `sendRichMessage` / `sendRichMessageDraft` — telegram's block-tree message format. one dual-dialect builder set, a draft/streaming session that owns the 30s ttl, and full read-side coverage (type guards + plain-text flattening) of everything telegram can hand back on `message.rich_message`.
4
4
 
5
- unlike classic `parse_mode`/entities (see [`@yaebal/fmt`](https://www.npmjs.com/package/@yaebal/fmt)), a rich message isn't a flat `{ text, entities }` pair — it's a document: paragraphs, headings, tables, lists, collages, slideshows, block quotes, a collapsible `<details>`, even a `<tg-thinking>` placeholder for streaming an in-progress answer. you write extended html (or markdown), telegram parses it server-side into a `RichMessage.blocks` tree, and that same tree is what you read back.
5
+ unlike classic `parse_mode`/entities (see [`@yaebal/fmt`](https://npmx.dev/package/@yaebal/fmt)), a rich message isn't a flat `{ text, entities }` pair — it's a document: paragraphs, headings, tables, lists, collages, slideshows, block quotes, a collapsible `<details>`, even a `<tg-thinking>` placeholder for streaming an in-progress answer. you write extended html (or markdown), telegram parses it server-side into a `RichMessage.blocks` tree, and that same tree is what you read back.
6
6
 
7
7
  ## install
8
8
 
@@ -20,7 +20,7 @@ import { html, md, heading, paragraph, bold, link, sendRichMessage } from "@yaeb
20
20
  const title = "release notes";
21
21
  const body = [
22
22
  heading(1, title),
23
- paragraph("yaebal ", bold("0.1"), " is out — see ", link("https://yaeb.al", "the docs"), "."),
23
+ paragraph("yaebal ", bold("0.1"), " is out — see ", link("https://yaebal.pages.dev", "the docs"), "."),
24
24
  ];
25
25
 
26
26
  await sendRichMessage(ctx.api, ctx.chat.id, html(body)); // <h1>…</h1><p>…</p>
@@ -33,7 +33,7 @@ there is no `md.bold`/`md.paragraph` shadow api to learn, nothing to keep in syn
33
33
  const doc = html`
34
34
  ${heading(1, title)}
35
35
 
36
- ${paragraph("yaebal ", bold("0.1"), " is out — see ", link("https://yaeb.al", "the docs"), ".")}
36
+ ${paragraph("yaebal ", bold("0.1"), " is out — see ", link("https://yaebal.pages.dev", "the docs"), ".")}
37
37
  `;
38
38
 
39
39
  await sendRichMessage(ctx.api, ctx.chat.id, doc);
@@ -41,13 +41,13 @@ await sendRichMessage(ctx.api, ctx.chat.id, doc);
41
41
 
42
42
  literal template text passes through unchanged; only `${…}` interpolation is touched:
43
43
 
44
- | interpolation | what happens |
45
- |:----------------------------------|:-----------------------------------------------------------------|
46
- | `${string}` / `${number}` / `${bigint}` | dialect-escaped — renders literally, can't inject formatting |
47
- | `${builderNode}` | rendered into the template's dialect |
48
- | `${anotherDocument}` | inlined as-is if dialects match, throws `RichError` if they don't |
49
- | `${array}` | each item rendered and concatenated |
50
- | `${null \| undefined \| false}` | empty string — so `cond && bold("x")` composes cleanly |
44
+ | interpolation | what happens |
45
+ |:----------------------------------------|:-------------------------------------------------------------------|
46
+ | `${string}` / `${number}` / `${bigint}` | dialect-escaped — renders literally, can't inject formatting |
47
+ | `${builderNode}` | rendered into the template's dialect |
48
+ | `${anotherDocument}` | inlined as-is if dialects match, throws `RichError` if they don't |
49
+ | `${array}` | each item rendered and concatenated |
50
+ | `${null \| undefined \| false}` | empty string — so `cond && bold("x")` composes cleanly |
51
51
 
52
52
  multi-line templates are **dedented** (common leading indentation stripped) so you can write at your code's natural indent level. `html`/`md` also accept a plain string (passed through as-is, no escaping/dedent — for already-formatted content) or an array of blocks (each rendered and, for markdown, blank-line-joined — the form to reach for when composing from data instead of prose):
53
53
 
@@ -158,23 +158,23 @@ in html this is a full `<table>` with `colspan`/`rowspan`/`valign`/per-cell `<th
158
158
 
159
159
  ## api
160
160
 
161
- | export | what |
162
- |:-------------------------------------------------------------------------------------------------------|:--------------------------------------------------------------------------|
163
- | `html` / `md` | tagged templates — same builders, either dialect, auto-escaped interpolation |
164
- | `document` | options-object form: assemble blocks into a `RichDocument` with an explicit dialect |
165
- | `RichDocument` | the sendable result — `.rtl()`/`.noEntityDetection()`, `toInputRichMessage()`/`toJSON()` |
166
- | `bold`/`italic`/`underline`/`strikethrough`/`spoiler`/`code`/`marked`/`subscript`/`superscript`/`br` | inline marks |
167
- | `link`/`textMention`/`anchor`/`anchorLink`/`customEmoji`/`dateTime`/`math`/`reference`/`referenceLink` | inline nodes with data |
168
- | `paragraph`/`heading`/`h1`–`h6`/`preformatted`/`footer`/`divider`/`mathBlock`/`anchorBlock` | simple blocks |
169
- | `blockquote`/`pullquote`/`details`/`list`/`item`/`table`/`cell`/`join` | structural blocks & composition |
170
- | `collage`/`slideshow`/`map`/`image`/`video`/`audio`/`thinking` | media & draft-only blocks |
171
- | `RichNode`/`isRichNode`/`makeNode`/`Dialect`/`Level`/`RichError` | the node contract, for writing your own dual-dialect builder |
172
- | `escapeMarkdown`/`escapeMarkdownUrl` | the raw markdown escapers the builders use internally |
173
- | `sendRichMessage`/`sendRichMessageDraft` | standalone send functions, no plugin required |
174
- | `rich()` | plugin: adds `ctx.sendRichMessage`/`ctx.richMessageDraft` |
175
- | `RichMessageDraft` | the draft/streaming session class — `rewrite()`/`write()`/`send()`/`cancel()` |
176
- | `isParagraph`, `isTable`, `isCustomEmoji`, … | one type guard per `RichBlock`/`RichText` variant |
177
- | `richTextToPlainText`/`richBlockToPlainText`/`richMessageToPlainText` | flatten to plain text |
161
+ | export | what |
162
+ |:-------------------------------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------------|
163
+ | `html` / `md` | tagged templates — same builders, either dialect, auto-escaped interpolation |
164
+ | `document` | options-object form: assemble blocks into a `RichDocument` with an explicit dialect |
165
+ | `RichDocument` | the sendable result — `.rtl()`/`.noEntityDetection()`, `toInputRichMessage()`/`toJSON()` |
166
+ | `bold`/`italic`/`underline`/`strikethrough`/`spoiler`/`code`/`marked`/`subscript`/`superscript`/`br` | inline marks |
167
+ | `link`/`textMention`/`anchor`/`anchorLink`/`customEmoji`/`dateTime`/`math`/`reference`/`referenceLink` | inline nodes with data |
168
+ | `paragraph`/`heading`/`h1`–`h6`/`preformatted`/`footer`/`divider`/`mathBlock`/`anchorBlock` | simple blocks |
169
+ | `blockquote`/`pullquote`/`details`/`list`/`item`/`table`/`cell`/`join` | structural blocks & composition |
170
+ | `collage`/`slideshow`/`map`/`image`/`video`/`audio`/`thinking` | media & draft-only blocks |
171
+ | `RichNode`/`isRichNode`/`makeNode`/`Dialect`/`Level`/`RichError` | the node contract, for writing your own dual-dialect builder |
172
+ | `escapeMarkdown`/`escapeMarkdownUrl` | the raw markdown escapers the builders use internally |
173
+ | `sendRichMessage`/`sendRichMessageDraft` | standalone send functions, no plugin required |
174
+ | `rich()` | plugin: adds `ctx.sendRichMessage`/`ctx.richMessageDraft` |
175
+ | `RichMessageDraft` | the draft/streaming session class — `rewrite()`/`write()`/`send()`/`cancel()` |
176
+ | `isParagraph`, `isTable`, `isCustomEmoji`, … | one type guard per `RichBlock`/`RichText` variant |
177
+ | `richTextToPlainText`/`richBlockToPlainText`/`richMessageToPlainText` | flatten to plain text |
178
178
 
179
179
  plus the full generated type surface (`RichMessage`, `RichBlock`, `RichText`, and every `RichBlock*`/`RichText*` interface) re-exported from `@yaebal/types` for convenience.
180
180
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yaebal/rich",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "yaebal rich — sendRichMessage / sendRichMessageDraft: a typed block builder, a 30s-ttl draft/streaming session, and full read-side coverage of telegram's rich message model.",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -16,12 +16,12 @@
16
16
  "src"
17
17
  ],
18
18
  "dependencies": {
19
- "@yaebal/types": "10.1.0",
20
- "@yaebal/core": "0.0.8"
19
+ "@yaebal/core": "0.0.9",
20
+ "@yaebal/types": "10.1.0"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@types/node": "latest",
24
- "@yaebal/test": "0.2.0"
24
+ "@yaebal/test": "0.2.1"
25
25
  },
26
26
  "engines": {
27
27
  "node": ">=20"