@promptctl/rich-js 0.24.0 → 0.24.1
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.
- package/THIRD-PARTY-NOTICES +29 -1
- package/dist/core/animation.d.ts +78 -0
- package/dist/core/animation.js +107 -0
- package/dist/core/cell-widths.d.ts +9 -0
- package/dist/core/cell-widths.js +140 -0
- package/dist/core/cells.d.ts +17 -11
- package/dist/core/cells.js +100 -25
- package/dist/core/console.js +5 -5
- package/dist/core/easing.d.ts +110 -10
- package/dist/core/easing.js +269 -36
- package/dist/core/json.js +2 -1
- package/dist/core/measure.js +2 -2
- package/dist/core/place.js +2 -1
- package/dist/core/pretty.js +2 -2
- package/dist/core/protocol.d.ts +73 -19
- package/dist/core/protocol.js +56 -15
- package/dist/core/render.js +2 -1
- package/dist/core/segment.d.ts +18 -1
- package/dist/core/segment.js +45 -44
- package/dist/core/strip.d.ts +3 -2
- package/dist/core/strip.js +11 -7
- package/dist/core/style.js +17 -6
- package/dist/core/text.js +22 -14
- package/dist/core/timeline.d.ts +84 -0
- package/dist/core/timeline.js +144 -0
- package/dist/core/tween.d.ts +49 -0
- package/dist/core/tween.js +69 -0
- package/dist/host/app.js +2 -2
- package/dist/index.d.ts +10 -7
- package/dist/index.js +13 -4
- package/dist/renderables/align.d.ts +3 -2
- package/dist/renderables/align.js +3 -0
- package/dist/renderables/columns.d.ts +3 -2
- package/dist/renderables/columns.js +7 -2
- package/dist/renderables/constrain.d.ts +3 -2
- package/dist/renderables/constrain.js +5 -1
- package/dist/renderables/effect.d.ts +43 -58
- package/dist/renderables/effect.js +58 -64
- package/dist/renderables/effects.d.ts +16 -14
- package/dist/renderables/effects.js +64 -45
- package/dist/renderables/embed.js +3 -2
- package/dist/renderables/flexStrip.d.ts +3 -2
- package/dist/renderables/flexStrip.js +6 -1
- package/dist/renderables/frames.d.ts +40 -19
- package/dist/renderables/frames.js +48 -21
- package/dist/renderables/group.d.ts +3 -2
- package/dist/renderables/group.js +5 -2
- package/dist/renderables/html-entities.d.ts +8 -0
- package/dist/renderables/html-entities.js +386 -0
- package/dist/renderables/layout.d.ts +3 -2
- package/dist/renderables/layout.js +15 -2
- package/dist/renderables/list-view.d.ts +3 -2
- package/dist/renderables/list-view.js +12 -5
- package/dist/renderables/live.js +2 -2
- package/dist/renderables/markdown-parse.d.ts +109 -0
- package/dist/renderables/markdown-parse.js +1421 -0
- package/dist/renderables/markdown-url.d.ts +19 -0
- package/dist/renderables/markdown-url.js +314 -0
- package/dist/renderables/markdown.d.ts +5 -7
- package/dist/renderables/markdown.js +356 -683
- package/dist/renderables/padding.d.ts +8 -20
- package/dist/renderables/padding.js +32 -50
- package/dist/renderables/panel.d.ts +26 -26
- package/dist/renderables/panel.js +67 -103
- package/dist/renderables/progress.d.ts +4 -2
- package/dist/renderables/progress.js +11 -2
- package/dist/renderables/progressBar.js +2 -2
- package/dist/renderables/python-space.d.ts +13 -0
- package/dist/renderables/python-space.js +24 -0
- package/dist/renderables/spinner.d.ts +26 -14
- package/dist/renderables/spinner.js +49 -37
- package/dist/renderables/syntax.js +2 -1
- package/dist/renderables/table.d.ts +19 -11
- package/dist/renderables/table.js +140 -156
- package/dist/renderables/traceback.d.ts +1 -1
- package/dist/renderables/traceback.js +6 -5
- package/dist/renderables/tree.d.ts +6 -5
- package/dist/renderables/tree.js +11 -7
- package/dist/renderables/viewport.d.ts +13 -5
- package/dist/renderables/viewport.js +41 -20
- package/dist/template-bindings/animation-funcs.js +2 -2
- package/dist/template-bindings/index.js +2 -1
- package/dist/themes/ramp.d.ts +18 -3
- package/dist/themes/ramp.js +23 -2
- package/dist/widgets/focus-manager.d.ts +21 -14
- package/dist/widgets/focus-manager.js +28 -29
- package/dist/widgets/index.d.ts +1 -1
- package/dist/widgets/static-item.d.ts +4 -3
- package/dist/widgets/static-item.js +9 -7
- package/dist/widgets/text-input.d.ts +28 -18
- package/dist/widgets/text-input.js +144 -101
- package/dist/widgets/widget-app.d.ts +19 -3
- package/dist/widgets/widget-app.js +39 -21
- package/dist/widgets/widget-base.js +0 -3
- package/package.json +2 -5
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Markdown's parse, with no dependency: a source read into blocks, then the
|
|
3
|
+
* text of each block read into inlines — the two passes markdown-it, Rich's
|
|
4
|
+
* parser, makes. Nothing here reads a `RenderOptions`, so a `Markdown` parses
|
|
5
|
+
* its source once, when it is made, as Rich's does, and every render after
|
|
6
|
+
* only walks the tokens.
|
|
7
|
+
*
|
|
8
|
+
* Block structure is read as CommonMark reads it: a blockquote and a list
|
|
9
|
+
* item are both containers, their lines tokenized as Markdown of their own
|
|
10
|
+
* once the container's marker or indentation is cut off. A table, which
|
|
11
|
+
* CommonMark has none of, and an HTML block are read as markdown-it reads
|
|
12
|
+
* them.
|
|
13
|
+
*/
|
|
14
|
+
/** Where a table column's cells sit, from the colons on its delimiter cell. None is GFM's no alignment, which Rich leaves to its column: left. */
|
|
15
|
+
export type CellAlign = "left" | "center" | "right" | undefined;
|
|
16
|
+
interface TableColumn<Text> {
|
|
17
|
+
readonly header: Text;
|
|
18
|
+
readonly align: CellAlign;
|
|
19
|
+
}
|
|
20
|
+
/** A heading's level: an ATX heading's count of `#`s, or 1 and 2 for a setext heading's `=` and `-`. */
|
|
21
|
+
export type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
22
|
+
/**
|
|
23
|
+
* A block, its text as `Text`: the source's own text after the block pass,
|
|
24
|
+
* and that text read into inlines after the inline pass, which is what
|
|
25
|
+
* `parseMarkdown` hands back. `Mark` is what the block pass keeps besides:
|
|
26
|
+
* none, once the inline pass has dropped its marks.
|
|
27
|
+
*/
|
|
28
|
+
export type MdToken<Text = readonly Inline[], Mark = never> = {
|
|
29
|
+
type: "heading";
|
|
30
|
+
level: HeadingLevel;
|
|
31
|
+
text: Text;
|
|
32
|
+
} | {
|
|
33
|
+
type: "paragraph";
|
|
34
|
+
text: Text;
|
|
35
|
+
} | {
|
|
36
|
+
type: "code_block";
|
|
37
|
+
code: string;
|
|
38
|
+
} | {
|
|
39
|
+
type: "hr";
|
|
40
|
+
}
|
|
41
|
+
/** `start` is an ordered list's first number, as its source writes it; a bullet list has none. Each item is its blocks. */
|
|
42
|
+
| {
|
|
43
|
+
type: "list";
|
|
44
|
+
start: number | undefined;
|
|
45
|
+
items: readonly (readonly MdToken<Text, Mark>[])[];
|
|
46
|
+
} | {
|
|
47
|
+
type: "blockquote";
|
|
48
|
+
children: readonly MdToken<Text, Mark>[];
|
|
49
|
+
}
|
|
50
|
+
/** Each row holds one cell per column: a short row filled out with empty cells, a long one cut. */
|
|
51
|
+
| {
|
|
52
|
+
type: "table";
|
|
53
|
+
columns: readonly TableColumn<Text>[];
|
|
54
|
+
rows: readonly (readonly Text[])[];
|
|
55
|
+
}
|
|
56
|
+
/** Kept, though nothing draws it, as Rich exits it like any other block. */
|
|
57
|
+
| {
|
|
58
|
+
type: "html_block";
|
|
59
|
+
} | Mark;
|
|
60
|
+
/** The element markdown-it makes of a pair of delimiters. */
|
|
61
|
+
type EmphasisTag = "em" | "strong" | "s";
|
|
62
|
+
/**
|
|
63
|
+
* CommonMark's inlines, as one block's text reads: a code span, emphasis or a
|
|
64
|
+
* link holding inlines of its own, an autolink, an image, inline HTML, a line
|
|
65
|
+
* ending, and text — a backslash escape and a character reference already the
|
|
66
|
+
* characters they stand for. Emphasis is named by the element markdown-it
|
|
67
|
+
* makes of it, GFM's strikethrough `s` among them.
|
|
68
|
+
*/
|
|
69
|
+
export type Inline = {
|
|
70
|
+
kind: "text";
|
|
71
|
+
text: string;
|
|
72
|
+
} | {
|
|
73
|
+
kind: "code";
|
|
74
|
+
code: string;
|
|
75
|
+
} | {
|
|
76
|
+
kind: "emphasis";
|
|
77
|
+
tag: EmphasisTag;
|
|
78
|
+
children: readonly Inline[];
|
|
79
|
+
} | {
|
|
80
|
+
kind: "link";
|
|
81
|
+
children: readonly Inline[];
|
|
82
|
+
url: string;
|
|
83
|
+
}
|
|
84
|
+
/** `text` is the URL as written, normalized as markdown-it shows it, never read as Markdown. */
|
|
85
|
+
| {
|
|
86
|
+
kind: "autolink";
|
|
87
|
+
text: string;
|
|
88
|
+
url: string;
|
|
89
|
+
}
|
|
90
|
+
/** `alt` is as written, never read as Markdown. */
|
|
91
|
+
| {
|
|
92
|
+
kind: "image";
|
|
93
|
+
alt: string;
|
|
94
|
+
src: string;
|
|
95
|
+
}
|
|
96
|
+
/** `content` is the tag as written, markdown-it's `html_inline` content. */
|
|
97
|
+
| {
|
|
98
|
+
kind: "html";
|
|
99
|
+
content: string;
|
|
100
|
+
}
|
|
101
|
+
/** markdown-it's `softbreak` and `hardbreak`: tokens of their own, never joined to the text beside them. */
|
|
102
|
+
| {
|
|
103
|
+
kind: "softbreak";
|
|
104
|
+
} | {
|
|
105
|
+
kind: "hardbreak";
|
|
106
|
+
};
|
|
107
|
+
/** `source` read as Markdown: its blocks, and the text in each read into inlines. A line ends at `\r\n`, `\r` or `\n`, as markdown-it normalizes them. */
|
|
108
|
+
export declare function parseMarkdown(source: string): MdToken[];
|
|
109
|
+
export {};
|