@markii/ansi 0.0.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.
Files changed (73) hide show
  1. package/dist/ansi.d.ts +79 -0
  2. package/dist/ansi.js +136 -0
  3. package/dist/box.d.ts +47 -0
  4. package/dist/box.js +209 -0
  5. package/dist/components/badge.d.ts +10 -0
  6. package/dist/components/badge.js +44 -0
  7. package/dist/components/callout.d.ts +20 -0
  8. package/dist/components/callout.js +71 -0
  9. package/dist/components/card.d.ts +12 -0
  10. package/dist/components/card.js +44 -0
  11. package/dist/components/cell.d.ts +18 -0
  12. package/dist/components/cell.js +31 -0
  13. package/dist/components/chart.d.ts +15 -0
  14. package/dist/components/chart.js +129 -0
  15. package/dist/components/details.d.ts +12 -0
  16. package/dist/components/details.js +25 -0
  17. package/dist/components/divider.d.ts +4 -0
  18. package/dist/components/divider.js +80 -0
  19. package/dist/components/figure.d.ts +20 -0
  20. package/dist/components/figure.js +53 -0
  21. package/dist/components/index.d.ts +34 -0
  22. package/dist/components/index.js +109 -0
  23. package/dist/components/kbd.d.ts +7 -0
  24. package/dist/components/kbd.js +8 -0
  25. package/dist/components/layout-wrapper.d.ts +35 -0
  26. package/dist/components/layout-wrapper.js +62 -0
  27. package/dist/components/progress.d.ts +15 -0
  28. package/dist/components/progress.js +78 -0
  29. package/dist/components/rating.d.ts +9 -0
  30. package/dist/components/rating.js +28 -0
  31. package/dist/components/row.d.ts +26 -0
  32. package/dist/components/row.js +67 -0
  33. package/dist/components/stat.d.ts +13 -0
  34. package/dist/components/stat.js +79 -0
  35. package/dist/components/tab.d.ts +13 -0
  36. package/dist/components/tab.js +17 -0
  37. package/dist/components/table-grid.d.ts +34 -0
  38. package/dist/components/table-grid.js +124 -0
  39. package/dist/components/table.d.ts +16 -0
  40. package/dist/components/table.js +101 -0
  41. package/dist/components/tabs.d.ts +18 -0
  42. package/dist/components/tabs.js +30 -0
  43. package/dist/failure-presentation.d.ts +58 -0
  44. package/dist/failure-presentation.js +124 -0
  45. package/dist/href-resolve.d.ts +21 -0
  46. package/dist/href-resolve.js +25 -0
  47. package/dist/image-resolve.d.ts +41 -0
  48. package/dist/image-resolve.js +28 -0
  49. package/dist/index.d.ts +15 -0
  50. package/dist/index.js +17 -0
  51. package/dist/layout.d.ts +73 -0
  52. package/dist/layout.js +144 -0
  53. package/dist/measure.d.ts +25 -0
  54. package/dist/measure.js +108 -0
  55. package/dist/registry.d.ts +227 -0
  56. package/dist/registry.js +121 -0
  57. package/dist/render.d.ts +69 -0
  58. package/dist/render.js +889 -0
  59. package/dist/resolve.d.ts +60 -0
  60. package/dist/resolve.js +152 -0
  61. package/dist/sanitize.d.ts +51 -0
  62. package/dist/sanitize.js +101 -0
  63. package/dist/style.d.ts +9 -0
  64. package/dist/style.js +13 -0
  65. package/dist/theme.d.ts +36 -0
  66. package/dist/theme.js +79 -0
  67. package/dist/url-resolve.d.ts +54 -0
  68. package/dist/url-resolve.js +82 -0
  69. package/dist/value-format.d.ts +13 -0
  70. package/dist/value-format.js +16 -0
  71. package/dist/value-types.d.ts +37 -0
  72. package/dist/value-types.js +17 -0
  73. package/package.json +61 -0
@@ -0,0 +1,69 @@
1
+ import { parse } from '@markii/core';
2
+ import type { MarkNode } from '@markii/core';
3
+ import { type ColorOption } from './ansi.js';
4
+ import { type AnsiTheme } from './theme.js';
5
+ import type { AnsiRegistry } from './registry.js';
6
+ import { type OnDiagnostic } from '@markii/stdlib';
7
+ import { type ResolveImageSrc } from './image-resolve.js';
8
+ import { type ResolveHref } from './href-resolve.js';
9
+ import type { AnsiValueStore, AnsiVaultStore } from './value-types.js';
10
+ type MarkRoot = ReturnType<typeof parse>;
11
+ /**
12
+ * Options for `renderMarkToAnsi`/`renderMarkNodeToAnsi`/`renderMarkInlineToAnsi`.
13
+ * `store`/`vault` are offered both here and as positional parameters; when
14
+ * both are given, the option wins (matching `@markii/html`'s
15
+ * `RenderMarkOptions`).
16
+ */
17
+ export interface RenderMarkOptions {
18
+ readonly width?: number;
19
+ readonly color?: ColorOption;
20
+ readonly theme?: AnsiTheme;
21
+ readonly resolveImageSrc?: ResolveImageSrc;
22
+ readonly resolveHref?: ResolveHref;
23
+ readonly onDiagnostic?: OnDiagnostic;
24
+ readonly store?: AnsiValueStore;
25
+ readonly vault?: AnsiVaultStore;
26
+ }
27
+ /**
28
+ * Renders Markii text to a plain string (optionally carrying ANSI SGR/OSC 8
29
+ * escapes) using `registry` to resolve directive names. `registry` is
30
+ * OPTIONAL here, unlike the other two engines' required parameter, and
31
+ * defaults to `defaultAnsiRegistry` (empty in this phase; every directive
32
+ * therefore renders the unknown-component fallback).
33
+ *
34
+ * Pipeline: `@markii/core`'s `toHast` (parse -> tag directive nodes ->
35
+ * remark-rehype -> sanitize URLs) -> a width-aware hast walk that swaps
36
+ * directive elements for registry components (or the unknown-directive
37
+ * fallback), folds script fences into a one-line marker, and wraps every
38
+ * paragraph, heading, and list item to `options.width` (default 80). Pure
39
+ * and never-throwing: parsing is tolerant, unknown names always render a
40
+ * fallback, and any unexpected internal error degrades to the "failed to
41
+ * render document" line.
42
+ *
43
+ * `options.color` resolves via `./ansi.js`'s `resolveColorOption`: `'auto'`
44
+ * and `undefined` both mean "no escapes" here, since this engine has no
45
+ * environment knowledge of its own — a caller that wants automatic
46
+ * detection calls `detectColorLevel` itself and passes the result as
47
+ * `'16'`/`'256'`/`'truecolor'`.
48
+ *
49
+ * `store`/`vault` and `resolveImageSrc`/`resolveHref`/`onDiagnostic` carry
50
+ * the same meaning as `@markii/html`'s identical options.
51
+ */
52
+ export declare function renderMarkToAnsi(text: string, registry?: AnsiRegistry, store?: AnsiValueStore, vault?: AnsiVaultStore, options?: RenderMarkOptions): string;
53
+ /**
54
+ * The block-level twin of `renderMarkToAnsi`: renders one already-parsed
55
+ * mdast node OR a whole already-parsed mdast document (`@markii/core`'s
56
+ * `MarkNode`, or the `Root` `parse` itself returns) instead of raw document
57
+ * text. Same registry resolution, same fallbacks, same purity and
58
+ * never-throw guarantees, same options.
59
+ */
60
+ export declare function renderMarkNodeToAnsi(node: MarkNode | MarkRoot, registry?: AnsiRegistry, store?: AnsiValueStore, vault?: AnsiVaultStore, options?: RenderMarkOptions): string;
61
+ /**
62
+ * Renders `text` as a single, standalone inline directive when that is all
63
+ * it is, mirroring `@markii/html`'s identical `renderMarkInlineToHtml`: a
64
+ * source whose only parsed block is a paragraph holding exactly one text
65
+ * directive renders that directive alone. Any other source falls back to
66
+ * the exact same rendering `renderMarkToAnsi` would produce.
67
+ */
68
+ export declare function renderMarkInlineToAnsi(text: string, registry?: AnsiRegistry, store?: AnsiValueStore, vault?: AnsiVaultStore, options?: RenderMarkOptions): string;
69
+ export {};