ansimax 1.3.7 → 1.4.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/CHANGELOG.md +217 -0
- package/README.es.md +58 -2
- package/README.md +58 -2
- package/dist/index.d.mts +189 -1
- package/dist/index.d.ts +189 -1
- package/dist/index.js +401 -41
- package/dist/index.mjs +397 -41
- package/examples/all-in-one.cjs +1 -1
- package/examples/all-in-one.mjs +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,76 @@
|
|
|
1
|
+
/** Visual theme for rendered output. */
|
|
2
|
+
type MarkdownTheme = 'dark' | 'light';
|
|
3
|
+
interface MarkdownOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Maximum width in columns. Long lines wrap. Default: terminal width
|
|
6
|
+
* or 80 if unavailable.
|
|
7
|
+
*/
|
|
8
|
+
width?: number;
|
|
9
|
+
/**
|
|
10
|
+
* Color theme. `'dark'` (default) uses bright colors for dark backgrounds.
|
|
11
|
+
* `'light'` uses dimmer/contrast colors for light backgrounds.
|
|
12
|
+
*/
|
|
13
|
+
theme?: MarkdownTheme;
|
|
14
|
+
/**
|
|
15
|
+
* Override the gradient used for top-level (`# H1`) headings. Receives
|
|
16
|
+
* a list of hex colors. Default uses the dracula palette.
|
|
17
|
+
*/
|
|
18
|
+
headingGradient?: string[];
|
|
19
|
+
/**
|
|
20
|
+
* Render code blocks inside an ASCII box. Default `true`. If `false`,
|
|
21
|
+
* code blocks render as indented dim text.
|
|
22
|
+
*/
|
|
23
|
+
boxCodeBlocks?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Inline code background tint. Default `true`. If `false`, inline code
|
|
26
|
+
* shows only as dim text (cleaner in some terminals).
|
|
27
|
+
*/
|
|
28
|
+
inlineCodeBackground?: boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Internal options shape passed to `parseInline`. Exposed for advanced
|
|
32
|
+
* use cases that bypass `render` (custom block handlers, etc.).
|
|
33
|
+
*
|
|
34
|
+
* @since 1.4.0
|
|
35
|
+
*/
|
|
36
|
+
interface InlineOptions {
|
|
37
|
+
theme: MarkdownTheme;
|
|
38
|
+
inlineCodeBackground: boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Block-level token after parsing the markdown into structural pieces.
|
|
42
|
+
* Tokens contain raw inline text — inline parsing happens at render time.
|
|
43
|
+
*
|
|
44
|
+
* @since 1.4.0
|
|
45
|
+
*/
|
|
46
|
+
type Block = {
|
|
47
|
+
type: 'heading';
|
|
48
|
+
level: number;
|
|
49
|
+
text: string;
|
|
50
|
+
} | {
|
|
51
|
+
type: 'paragraph';
|
|
52
|
+
text: string;
|
|
53
|
+
} | {
|
|
54
|
+
type: 'codeblock';
|
|
55
|
+
lang: string;
|
|
56
|
+
code: string;
|
|
57
|
+
} | {
|
|
58
|
+
type: 'list';
|
|
59
|
+
ordered: boolean;
|
|
60
|
+
items: string[];
|
|
61
|
+
} | {
|
|
62
|
+
type: 'blockquote';
|
|
63
|
+
text: string;
|
|
64
|
+
} | {
|
|
65
|
+
type: 'table';
|
|
66
|
+
headers: string[];
|
|
67
|
+
rows: string[][];
|
|
68
|
+
} | {
|
|
69
|
+
type: 'hr';
|
|
70
|
+
} | {
|
|
71
|
+
type: 'blank';
|
|
72
|
+
};
|
|
73
|
+
|
|
1
74
|
/** Color rendering capability. 'none' suppresses all color output. */
|
|
2
75
|
type ColorMode = 'none' | 'basic' | '256' | 'truecolor' | 'auto';
|
|
3
76
|
/** Animation pacing multiplier preset. */
|
|
@@ -2713,6 +2786,46 @@ interface GridOptions {
|
|
|
2713
2786
|
* use the max width of the widest block in their column.
|
|
2714
2787
|
*/
|
|
2715
2788
|
cellWidth?: number | null;
|
|
2789
|
+
/**
|
|
2790
|
+
* **v1.4.1+** Fix each row to this height (in lines). When the block has
|
|
2791
|
+
* fewer lines, it is padded (using `alignY`). When it has more lines, it
|
|
2792
|
+
* is truncated. If omitted (default), rows take the natural height of
|
|
2793
|
+
* their tallest block.
|
|
2794
|
+
*
|
|
2795
|
+
* @since 1.4.1
|
|
2796
|
+
*/
|
|
2797
|
+
cellHeight?: number | null;
|
|
2798
|
+
/**
|
|
2799
|
+
* **v1.4.1+** Per-block column span. `colSpan[i]` is the number of
|
|
2800
|
+
* columns block `i` occupies. Defaults to `1` for every block when
|
|
2801
|
+
* omitted or shorter than `blocks`.
|
|
2802
|
+
*
|
|
2803
|
+
* The auto-flow algorithm wraps to the next row when the current row's
|
|
2804
|
+
* remaining capacity is less than the next block's span. Spans that
|
|
2805
|
+
* exceed `columns` are clamped to `columns`.
|
|
2806
|
+
*
|
|
2807
|
+
* @example
|
|
2808
|
+
* ```js
|
|
2809
|
+
* // Header spans full width, then 2 cells in a row
|
|
2810
|
+
* panels.grid([header, left, right], {
|
|
2811
|
+
* columns: 2,
|
|
2812
|
+
* colSpan: [2, 1, 1],
|
|
2813
|
+
* });
|
|
2814
|
+
* ```
|
|
2815
|
+
*
|
|
2816
|
+
* @since 1.4.1
|
|
2817
|
+
*/
|
|
2818
|
+
colSpan?: number[];
|
|
2819
|
+
/**
|
|
2820
|
+
* **v1.4.1+** Auto-flow direction. `'row'` (default) fills cells
|
|
2821
|
+
* left-to-right then wraps to the next row — matches CSS Grid's
|
|
2822
|
+
* `grid-auto-flow: row`. `'column'` fills top-to-bottom then wraps to
|
|
2823
|
+
* the next column. Not applicable when `colSpan` is set with any
|
|
2824
|
+
* span > 1 (forces 'row' mode).
|
|
2825
|
+
*
|
|
2826
|
+
* @since 1.4.1
|
|
2827
|
+
*/
|
|
2828
|
+
flow?: 'row' | 'column';
|
|
2716
2829
|
}
|
|
2717
2830
|
/**
|
|
2718
2831
|
* Arrange blocks in a grid of N columns, flowing left-to-right then
|
|
@@ -2887,6 +3000,66 @@ declare const json: {
|
|
|
2887
3000
|
pretty: (value: unknown, opts?: PrettyOptions) => string;
|
|
2888
3001
|
};
|
|
2889
3002
|
|
|
3003
|
+
/**
|
|
3004
|
+
* Parse markdown source into a flat sequence of block tokens.
|
|
3005
|
+
* Tokens contain raw inline text — inline parsing happens at render time.
|
|
3006
|
+
*
|
|
3007
|
+
* @since 1.4.0
|
|
3008
|
+
*/
|
|
3009
|
+
declare const parseBlocks: (source: string) => Block[];
|
|
3010
|
+
|
|
3011
|
+
/**
|
|
3012
|
+
* Apply inline markdown markup (bold/italic/code/links/etc.) to a string.
|
|
3013
|
+
*
|
|
3014
|
+
* @since 1.4.0
|
|
3015
|
+
*/
|
|
3016
|
+
declare const parseInline: (text: string, opts?: InlineOptions) => string;
|
|
3017
|
+
|
|
3018
|
+
/**
|
|
3019
|
+
* Render a markdown source string to a terminal-ready string with ANSI
|
|
3020
|
+
* styling. Handles headings, paragraphs, code blocks, lists, blockquotes,
|
|
3021
|
+
* tables, inline emphasis, links, and horizontal rules.
|
|
3022
|
+
*
|
|
3023
|
+
* @example
|
|
3024
|
+
* ```ts
|
|
3025
|
+
* import { markdown } from 'ansimax';
|
|
3026
|
+
*
|
|
3027
|
+
* const out = markdown.render(`
|
|
3028
|
+
* # Welcome
|
|
3029
|
+
*
|
|
3030
|
+
* This is **bold** with \`inline code\` and [a link](https://example.com).
|
|
3031
|
+
*
|
|
3032
|
+
* - First item
|
|
3033
|
+
* - Second item
|
|
3034
|
+
*
|
|
3035
|
+
* \`\`\`js
|
|
3036
|
+
* const x = 42;
|
|
3037
|
+
* \`\`\`
|
|
3038
|
+
* `);
|
|
3039
|
+
*
|
|
3040
|
+
* console.log(out);
|
|
3041
|
+
* ```
|
|
3042
|
+
*
|
|
3043
|
+
* @since 1.4.0
|
|
3044
|
+
*/
|
|
3045
|
+
declare const render: (source: string, opts?: MarkdownOptions) => string;
|
|
3046
|
+
|
|
3047
|
+
/**
|
|
3048
|
+
* Markdown → terminal renderer. Use `markdown.render(source, opts?)` to
|
|
3049
|
+
* convert a markdown string to an ANSI-styled string ready for
|
|
3050
|
+
* `console.log` or `process.stdout.write`.
|
|
3051
|
+
*
|
|
3052
|
+
* Lower-level helpers `parseBlocks` and `parseInline` are also exposed
|
|
3053
|
+
* for advanced use cases (custom block handlers, partial rendering).
|
|
3054
|
+
*
|
|
3055
|
+
* @since 1.4.0
|
|
3056
|
+
*/
|
|
3057
|
+
declare const markdown: {
|
|
3058
|
+
render: (source: string, opts?: MarkdownOptions) => string;
|
|
3059
|
+
parseBlocks: (source: string) => Block[];
|
|
3060
|
+
parseInline: (text: string, opts?: InlineOptions) => string;
|
|
3061
|
+
};
|
|
3062
|
+
|
|
2890
3063
|
type EasingFunction = (t: number) => number;
|
|
2891
3064
|
/**
|
|
2892
3065
|
* Union of all built-in easing names in the comprehensive Robert Penner
|
|
@@ -3088,6 +3261,21 @@ declare const ansimax: {
|
|
|
3088
3261
|
clearAnsiCache: () => void;
|
|
3089
3262
|
};
|
|
3090
3263
|
configure: (opts?: AnsimaxConfig, meta?: ConfigureOptions) => void;
|
|
3264
|
+
panels: {
|
|
3265
|
+
vsplit: (blocks: string[], opts?: VsplitOptions) => string;
|
|
3266
|
+
hsplit: (blocks: string[], opts?: HsplitOptions) => string;
|
|
3267
|
+
center: (block: string, opts: CenterOptions) => string;
|
|
3268
|
+
frame: (block: string, opts?: FrameOptions) => string;
|
|
3269
|
+
grid: (blocks: string[], opts: GridOptions) => string;
|
|
3270
|
+
};
|
|
3271
|
+
json: {
|
|
3272
|
+
pretty: (value: unknown, opts?: PrettyOptions) => string;
|
|
3273
|
+
};
|
|
3274
|
+
markdown: {
|
|
3275
|
+
render: (source: string, opts?: MarkdownOptions) => string;
|
|
3276
|
+
parseBlocks: (source: string) => Block[];
|
|
3277
|
+
parseInline: (text: string, opts?: InlineOptions) => string;
|
|
3278
|
+
};
|
|
3091
3279
|
};
|
|
3092
3280
|
|
|
3093
|
-
export { ASCII_RAMPS, type Alignment, type AnimateGradientController, type AnimateGradientOptions, type AnimationHooks, type AnimationSpeed, type AnsiCode, type AnsimaxConfig, type AsciiRamp, BEL, BG, type BadgeOptions, type BallOptions, type BannerOptions, type BoxOptions, type BoxStyle, type BreatheOptions, DEFAULTS as CONFIG_DEFAULTS, CSI, type Canvas, type CanvasRenderOptions, type CenterOptions, type ColorChain, type ColorFn, type ColorLevel, type ColorMode, type ColorSpace, type ColorSupport, type ColumnsOptions, type ConfigChangeListener, type ConfigKey, type ConfigKeyListener, type ConfigureOptions, type CountdownOptions, type CustomOptions, DEFAULT_TERM_COLS, DEFAULT_TERM_ROWS, type DebounceOptions, type DiffType, type Dimensions, type DividerOptions, type DotsOptions, ESC, type EasingFn, type EasingFunction, type EasingLibraryName, type EasingName, type EraseMode, FG, FRAME_MS, type FadeOptions, type FigletFont, type FigletOptions, type FontMap, type FontName, type FrameCallback, type FrameHandle, type FrameOptions, type FromImageOptions, type GlitchOptions, type Glyph, type GradientOptions, type GradientRectOptions, type GridOptions, type HSL, type HsplitOptions, type PrettyOptions as JsonPrettyOptions, type LineDiff, type LiveController, type LiveOptions, type LoadingBarOptions, type LogoOptions, MENU_CANCELLED, type MemoizeOptions, type MenuInput, type MenuOptions, type MenuOutput, type MenuResult, type MultiLoader, type MultiLoaderItem, OSC, type Oklab, type OnResizeOptions, type OutputBuffer, type ParallelOptions, type ParallelStep, type Pixel, type PixelGrid, type PlayController, type PlayOptions, type PresetName, type ProgressAnimateOptions, type ProgressBarOptions, type ProgressOptions, type PulseOptions, type RGB, type RGBA, type RegisterFontOptions, type RenderOptions$1 as RenderOptions, type ResizeListener, type ReusableGradient, type RevealOptions, SPINNERS, SPRITES, ST, STYLE, type SectionOptions, type SleepOptions, type SlideOptions, type SpinOptions, type SpinnerType, type StatusOptions, type StatusType, type StopFn, type StreamOptions, type TableBorderStyle, type TableOptions, type Task, type TaskResult, type TasksOptions, type Theme, type BannerOpts as ThemeBannerOpts, type ThemeChangeListener, type ThemeInstance, type ThemeStyleName, type TimelineEvent, type TimelineOptions, type TreeData, type TreeDimensions, type TreeNode, type RenderOptions as TreeRenderOptions, type TreeStyle, type TypeDeleteOptions, type TypewriterOptions, type VsplitOptions, type WalkVisitor, type WaveOptions, type WriteAsyncOptions, animate, animateGradient, ascii, bell, bg256, bgRgb, box, canAnimate, cancelTerminalFrame, center$1 as center, center as centerBlock, chain, charWidth, clamp, clampByte, clampInt, clampPercent, clearAnsiCache, clearColorCache, clearLine, clearRenderCache, clearThemeColorCache, color, colorLevel, presets as colorPresets, components, compose, configure, countNodes, createCanvas, createGradient, createOutputBuffer, createTheme, cursor, debounce, ansimax as default, diffLines, easings, escapeForRegex, escapeRegex, fg256, fgRgb, figletText, filterTree, findInTree, flipHorizontal, flipVertical, frame, frames, fromImage, getConfig, getConfigValue, getRenderCacheSize, getSpeedMultiplier, getTerminalHeight, getTerminalWidth, gradient, gradientColor, gradientRect, gradientStops, graphemes, grid, hasFont, hexToRgb, hideCursor, hslToRgb, hsplit, hyperlink, images, isFiniteNumber, isHexColor, isNoColor, json, pretty as jsonPretty, lerp, lerpColor, link, listFonts, listPresets, loader, mapTree, measureBlock, measureTree, memoize, mixColors, nextTick, oklabToRgb, onConfigChange, onConfigKeyChange, onResize, once, padBoth, padEnd, padStart, panels, parseFiglet, pauseListeners, presetNames, presets, quantizeColor, rainbow, registerFont, registerPreset, renderPixelArt, renderTree, renderTreeStream, repeatVisible, requestTerminalFrame, reset, resetColorSupportCache, resetConfig, resetCursorRefCount, resetFramesCursorCount, resetLoaderCursorCount, resetNoColor, resolveEasingByName, resumeListeners, reverseGradient, rgbTo256, rgbToHex, rgbToHsl, rgbToOklab, rotate90, safeInt, safeJson, screen, setConfigValue, setNoColor, setTitle, sgr, showCursor, sleep, sleepFrame, sliceAnsi, stripAnsi$2 as stripAnsi, stripAnsi$1 as stripAnsiCodes, stripAnsi as stripAnsiColors, subscribeConfig, supportsColor, supportsColorLevel, termSize, themes, throttle, tree, trees, truncateAnsi, visibleLen, vsplit, walkTree, withConfig, wordWrap, wrapAnsi, write, writeAsync, writeErr, writeln, writelnErr };
|
|
3281
|
+
export { ASCII_RAMPS, type Alignment, type AnimateGradientController, type AnimateGradientOptions, type AnimationHooks, type AnimationSpeed, type AnsiCode, type AnsimaxConfig, type AsciiRamp, BEL, BG, type BadgeOptions, type BallOptions, type BannerOptions, type BoxOptions, type BoxStyle, type BreatheOptions, DEFAULTS as CONFIG_DEFAULTS, CSI, type Canvas, type CanvasRenderOptions, type CenterOptions, type ColorChain, type ColorFn, type ColorLevel, type ColorMode, type ColorSpace, type ColorSupport, type ColumnsOptions, type ConfigChangeListener, type ConfigKey, type ConfigKeyListener, type ConfigureOptions, type CountdownOptions, type CustomOptions, DEFAULT_TERM_COLS, DEFAULT_TERM_ROWS, type DebounceOptions, type DiffType, type Dimensions, type DividerOptions, type DotsOptions, ESC, type EasingFn, type EasingFunction, type EasingLibraryName, type EasingName, type EraseMode, FG, FRAME_MS, type FadeOptions, type FigletFont, type FigletOptions, type FontMap, type FontName, type FrameCallback, type FrameHandle, type FrameOptions, type FromImageOptions, type GlitchOptions, type Glyph, type GradientOptions, type GradientRectOptions, type GridOptions, type HSL, type HsplitOptions, type PrettyOptions as JsonPrettyOptions, type LineDiff, type LiveController, type LiveOptions, type LoadingBarOptions, type LogoOptions, MENU_CANCELLED, type MarkdownOptions, type MarkdownTheme, type MemoizeOptions, type MenuInput, type MenuOptions, type MenuOutput, type MenuResult, type MultiLoader, type MultiLoaderItem, OSC, type Oklab, type OnResizeOptions, type OutputBuffer, type ParallelOptions, type ParallelStep, type Pixel, type PixelGrid, type PlayController, type PlayOptions, type PresetName, type ProgressAnimateOptions, type ProgressBarOptions, type ProgressOptions, type PulseOptions, type RGB, type RGBA, type RegisterFontOptions, type RenderOptions$1 as RenderOptions, type ResizeListener, type ReusableGradient, type RevealOptions, SPINNERS, SPRITES, ST, STYLE, type SectionOptions, type SleepOptions, type SlideOptions, type SpinOptions, type SpinnerType, type StatusOptions, type StatusType, type StopFn, type StreamOptions, type TableBorderStyle, type TableOptions, type Task, type TaskResult, type TasksOptions, type Theme, type BannerOpts as ThemeBannerOpts, type ThemeChangeListener, type ThemeInstance, type ThemeStyleName, type TimelineEvent, type TimelineOptions, type TreeData, type TreeDimensions, type TreeNode, type RenderOptions as TreeRenderOptions, type TreeStyle, type TypeDeleteOptions, type TypewriterOptions, type VsplitOptions, type WalkVisitor, type WaveOptions, type WriteAsyncOptions, animate, animateGradient, ascii, bell, bg256, bgRgb, box, canAnimate, cancelTerminalFrame, center$1 as center, center as centerBlock, chain, charWidth, clamp, clampByte, clampInt, clampPercent, clearAnsiCache, clearColorCache, clearLine, clearRenderCache, clearThemeColorCache, color, colorLevel, presets as colorPresets, components, compose, configure, countNodes, createCanvas, createGradient, createOutputBuffer, createTheme, cursor, debounce, ansimax as default, diffLines, easings, escapeForRegex, escapeRegex, fg256, fgRgb, figletText, filterTree, findInTree, flipHorizontal, flipVertical, frame, frames, fromImage, getConfig, getConfigValue, getRenderCacheSize, getSpeedMultiplier, getTerminalHeight, getTerminalWidth, gradient, gradientColor, gradientRect, gradientStops, graphemes, grid, hasFont, hexToRgb, hideCursor, hslToRgb, hsplit, hyperlink, images, isFiniteNumber, isHexColor, isNoColor, json, pretty as jsonPretty, lerp, lerpColor, link, listFonts, listPresets, loader, mapTree, markdown, measureBlock, measureTree, memoize, mixColors, nextTick, oklabToRgb, onConfigChange, onConfigKeyChange, onResize, once, padBoth, padEnd, padStart, panels, parseFiglet, parseBlocks as parseMarkdownBlocks, parseInline as parseMarkdownInline, pauseListeners, presetNames, presets, quantizeColor, rainbow, registerFont, registerPreset, render as renderMarkdown, renderPixelArt, renderTree, renderTreeStream, repeatVisible, requestTerminalFrame, reset, resetColorSupportCache, resetConfig, resetCursorRefCount, resetFramesCursorCount, resetLoaderCursorCount, resetNoColor, resolveEasingByName, resumeListeners, reverseGradient, rgbTo256, rgbToHex, rgbToHsl, rgbToOklab, rotate90, safeInt, safeJson, screen, setConfigValue, setNoColor, setTitle, sgr, showCursor, sleep, sleepFrame, sliceAnsi, stripAnsi$2 as stripAnsi, stripAnsi$1 as stripAnsiCodes, stripAnsi as stripAnsiColors, subscribeConfig, supportsColor, supportsColorLevel, termSize, themes, throttle, tree, trees, truncateAnsi, visibleLen, vsplit, walkTree, withConfig, wordWrap, wrapAnsi, write, writeAsync, writeErr, writeln, writelnErr };
|