@runtypelabs/ink-components 0.3.14 → 0.3.16

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/dist/index.js +36 -28
  2. package/package.json +6 -5
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
+ import { createRequire } from "node:module";
1
2
  import { Box, Text } from "ink";
2
3
  import InkSpinner from "ink-spinner";
3
4
  import { jsx, jsxs } from "react/jsx-runtime";
4
5
  import { memo, useMemo } from "react";
5
6
  import chalk from "chalk";
6
- import { marked } from "marked";
7
- import { markedTerminal } from "marked-terminal";
7
+ import { Marked } from "marked";
8
8
  import stripAnsi from "strip-ansi";
9
9
  // src/theme.ts
10
10
  const theme = {
@@ -123,30 +123,38 @@ const markdownHighlightTheme = {
123
123
  addition: successText,
124
124
  deletion: chalk.hex(theme.danger)
125
125
  };
126
- marked.use(markedTerminal({
127
- code: successText,
128
- blockquote: mutedText,
129
- html: subtleText,
130
- heading: accentText,
131
- firstHeading: accentActiveText.bold,
132
- hr: subtleText,
133
- listitem: bodyText,
134
- list: (body) => bodyText(body),
135
- table: mutedText,
136
- paragraph: bodyText,
137
- strong: accentActiveText.bold,
138
- em: accentText.italic,
139
- codespan: successText,
140
- del: subtleText.strikethrough,
141
- link: accentActiveText,
142
- href: mutedText.underline,
143
- text: bodyText,
144
- showSectionPrefix: false,
145
- reflowText: false
146
- }, {
147
- ignoreIllegals: true,
148
- theme: markdownHighlightTheme
149
- }));
126
+ const requireFromHere = createRequire(import.meta.url);
127
+ let terminalMarked;
128
+ function parseMarkdownForTerminal(markdown) {
129
+ if (!terminalMarked) {
130
+ const { markedTerminal } = requireFromHere("marked-terminal");
131
+ terminalMarked = new Marked(markedTerminal({
132
+ code: successText,
133
+ blockquote: mutedText,
134
+ html: subtleText,
135
+ heading: accentText,
136
+ firstHeading: accentActiveText.bold,
137
+ hr: subtleText,
138
+ listitem: bodyText,
139
+ list: (body) => bodyText(body),
140
+ table: mutedText,
141
+ paragraph: bodyText,
142
+ strong: accentActiveText.bold,
143
+ em: accentText.italic,
144
+ codespan: successText,
145
+ del: subtleText.strikethrough,
146
+ link: accentActiveText,
147
+ href: mutedText.underline,
148
+ text: bodyText,
149
+ showSectionPrefix: false,
150
+ reflowText: false
151
+ }, {
152
+ ignoreIllegals: true,
153
+ theme: markdownHighlightTheme
154
+ }));
155
+ }
156
+ return terminalMarked.parse(markdown).trimEnd();
157
+ }
150
158
  /**
151
159
  * Render raw markdown content to terminal-styled text with ANSI color codes.
152
160
  * Uses the module-level `marked` + `marked-terminal` configuration.
@@ -154,13 +162,13 @@ marked.use(markedTerminal({
154
162
  function renderMarkdownToTerminal(content) {
155
163
  const stripped = stripAnsi(content);
156
164
  if (!stripped) return "";
157
- return marked.parse(stripped).trimEnd();
165
+ return parseMarkdownForTerminal(stripped);
158
166
  }
159
167
  const StreamOutput = memo(function StreamOutput({ content, isStreaming, enableMarkdown = true, maxVisibleLines, scrollOffset = 0 }) {
160
168
  const rendered = useMemo(() => {
161
169
  const stripped = stripAnsi(content);
162
170
  if (!stripped) return "";
163
- if (enableMarkdown) return marked.parse(stripped).trimEnd();
171
+ if (enableMarkdown) return parseMarkdownForTerminal(stripped);
164
172
  return stripped;
165
173
  }, [content, enableMarkdown]);
166
174
  const lines = useMemo(() => rendered.split("\n"), [rendered]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runtypelabs/ink-components",
3
- "version": "0.3.14",
3
+ "version": "0.3.16",
4
4
  "description": "Shared Ink (React for CLI) components for the Runtype CLI — spinners, status bars, streaming output, and error displays.",
5
5
  "license": "MIT",
6
6
  "author": "Runtype",
@@ -27,11 +27,12 @@
27
27
  "strip-ansi": "^7.2.0"
28
28
  },
29
29
  "devDependencies": {
30
+ "@types/node": "^25.3.3",
30
31
  "@types/react": "^19.2.18",
31
32
  "ink-testing-library": "4.0.0",
32
- "tsdown": "^0.23.2",
33
+ "tsdown": "^0.23.7",
33
34
  "typescript": "^6.0.3",
34
- "vitest": "^5.0.5"
35
+ "vitest": "^5.1.0"
35
36
  },
36
37
  "keywords": [
37
38
  "runtype",
@@ -55,12 +56,12 @@
55
56
  "access": "public"
56
57
  },
57
58
  "engines": {
58
- "node": ">=22.0.0"
59
+ "node": ">=22.12.0"
59
60
  },
60
61
  "sideEffects": false,
61
62
  "scripts": {
62
63
  "build": "tsdown",
63
- "test": "vitest run",
64
+ "test": "vitest run --passWithNoTests",
64
65
  "type-check": "tsrs --noEmit",
65
66
  "dev": "tsdown --watch",
66
67
  "typecheck": "tsrs --noEmit",