mviz 1.6.4 → 1.6.7

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 (47) hide show
  1. package/README.md +8 -8
  2. package/dist/charts/area.js +8 -36
  3. package/dist/charts/bar.js +8 -26
  4. package/dist/charts/bubble.js +9 -7
  5. package/dist/charts/combo.js +17 -39
  6. package/dist/charts/dumbbell.js +15 -14
  7. package/dist/charts/funnel.js +12 -7
  8. package/dist/charts/heatmap.js +8 -6
  9. package/dist/charts/line.js +6 -27
  10. package/dist/charts/scatter.js +7 -5
  11. package/dist/cli.js +4 -3
  12. package/dist/components/big_value.d.ts +23 -1
  13. package/dist/components/big_value.js +84 -25
  14. package/dist/components/delta.d.ts +24 -1
  15. package/dist/components/delta.js +63 -17
  16. package/dist/components/table-interactivity.d.ts +69 -0
  17. package/dist/components/table-interactivity.js +216 -0
  18. package/dist/components/table.d.ts +6 -1
  19. package/dist/components/table.js +53 -12
  20. package/dist/core/chart-helpers.d.ts +59 -5
  21. package/dist/core/chart-helpers.js +84 -5
  22. package/dist/core/formatting.d.ts +61 -4
  23. package/dist/core/formatting.js +216 -17
  24. package/dist/core/lint-rules/registry.d.ts +4 -2
  25. package/dist/core/lint-rules/registry.js +6 -1
  26. package/dist/core/lint-rules/rules/index.d.ts +1 -0
  27. package/dist/core/lint-rules/rules/index.js +1 -0
  28. package/dist/core/lint-rules/rules/pct-scalar-gt-one.d.ts +13 -0
  29. package/dist/core/lint-rules/rules/pct-scalar-gt-one.js +46 -0
  30. package/dist/core/lint-rules/types.d.ts +12 -0
  31. package/dist/core/linter.d.ts +10 -2
  32. package/dist/core/linter.js +60 -12
  33. package/dist/layout/block-loader.d.ts +31 -0
  34. package/dist/layout/block-loader.js +143 -0
  35. package/dist/layout/layout-resolver.d.ts +33 -0
  36. package/dist/layout/layout-resolver.js +73 -0
  37. package/dist/layout/markdown-parser.d.ts +34 -0
  38. package/dist/layout/markdown-parser.js +395 -0
  39. package/dist/layout/parser-types.d.ts +116 -0
  40. package/dist/layout/parser-types.js +11 -0
  41. package/dist/layout/parser.d.ts +31 -22
  42. package/dist/layout/parser.js +118 -1006
  43. package/dist/layout/renderer.d.ts +33 -0
  44. package/dist/layout/renderer.js +450 -0
  45. package/dist/types.d.ts +1 -1
  46. package/package.json +6 -6
  47. package/schema/mviz.v1.schema.json +402 -33
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Shared types for the markdown dashboard pipeline.
3
+ *
4
+ * The pipeline runs in phases (see parser.ts orchestrator):
5
+ * 1. Markdown parse -> RawSection[] (with RawCodeBlockItem for unloaded code blocks)
6
+ * 2. Block load -> Section[] (with ParsedItem; data resolved, spec linted)
7
+ * 3. Layout resolve -> Section[] (auto sizes resolved, print-mode validated)
8
+ * 4. Render -> HTML string
9
+ */
10
+ import type { PageOrientation, Theme } from '../types.js';
11
+ /**
12
+ * Frontmatter parsed from a markdown dashboard's leading YAML block.
13
+ */
14
+ export interface ParsedFrontmatter {
15
+ theme: Theme;
16
+ pageTitle: string;
17
+ pageTitleFromFrontmatter: boolean;
18
+ continuous: boolean;
19
+ orientation: PageOrientation;
20
+ printMode: boolean;
21
+ currency: string | undefined;
22
+ /** Lines of the markdown body after the closing `---`. */
23
+ remainingLines: string[];
24
+ /** Number of lines consumed by frontmatter (for absolute line reporting). */
25
+ frontmatterEndLine: number;
26
+ }
27
+ /**
28
+ * A parsed dashboard item with its spec fully resolved.
29
+ *
30
+ * Used after the load phase. Code blocks become this once their file
31
+ * references and inline JSON are merged and converted.
32
+ */
33
+ export interface ParsedItem {
34
+ type: string;
35
+ spec: Record<string, unknown>;
36
+ size?: [number, number] | 'auto' | null;
37
+ }
38
+ /**
39
+ * A code-block item before file/JSON have been loaded.
40
+ * Carries the raw header info and inline body lines so the load phase
41
+ * can resolve `file=` references and parse the inline JSON.
42
+ */
43
+ export interface RawCodeBlockItem {
44
+ kind: 'code';
45
+ type: string;
46
+ inlineLines: string[];
47
+ file: string | null;
48
+ size: [number, number] | 'auto' | null;
49
+ /** 1-indexed line number where the opening ``` appeared, for error messages. */
50
+ startLine: number;
51
+ }
52
+ /**
53
+ * A non-code item (markdown text, markdown table, inline header) that does not
54
+ * require loading. Already shaped like a final `ParsedItem`.
55
+ */
56
+ export interface RawResolvedItem {
57
+ kind: 'resolved';
58
+ item: ParsedItem;
59
+ }
60
+ /**
61
+ * Items emitted by the parse phase, before loading.
62
+ */
63
+ export type RawItem = RawCodeBlockItem | RawResolvedItem;
64
+ /**
65
+ * Section in the raw (pre-load) IR.
66
+ */
67
+ export interface RawSection {
68
+ title: string;
69
+ rows: RawItem[][];
70
+ pageBreak?: boolean;
71
+ hasDivider?: boolean;
72
+ }
73
+ /**
74
+ * Section in the resolved (post-load) IR.
75
+ */
76
+ export interface Section {
77
+ title: string;
78
+ rows: ParsedItem[][];
79
+ pageBreak?: boolean;
80
+ hasDivider?: boolean;
81
+ }
82
+ /**
83
+ * Test-harness item tracked while rendering.
84
+ */
85
+ export interface TestItem {
86
+ id: string;
87
+ name: string;
88
+ type: string;
89
+ spec: Record<string, unknown>;
90
+ section: string;
91
+ }
92
+ /**
93
+ * A mermaid block that needs async rendering after the sync pipeline returns.
94
+ */
95
+ export interface MermaidBlock {
96
+ id: string;
97
+ spec: Record<string, unknown>;
98
+ theme: string;
99
+ }
100
+ /**
101
+ * Result returned by parseMarkdownToDashboard / parseMarkdownToTestHarness.
102
+ */
103
+ export interface ParseResult {
104
+ html: string;
105
+ errors: string[];
106
+ mermaidBlocks: MermaidBlock[];
107
+ }
108
+ /**
109
+ * Output of the markdown parse phase.
110
+ */
111
+ export interface ParsedMarkdown {
112
+ frontmatter: ParsedFrontmatter;
113
+ sections: RawSection[];
114
+ pageTitle: string;
115
+ }
116
+ //# sourceMappingURL=parser-types.d.ts.map
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Shared types for the markdown dashboard pipeline.
3
+ *
4
+ * The pipeline runs in phases (see parser.ts orchestrator):
5
+ * 1. Markdown parse -> RawSection[] (with RawCodeBlockItem for unloaded code blocks)
6
+ * 2. Block load -> Section[] (with ParsedItem; data resolved, spec linted)
7
+ * 3. Layout resolve -> Section[] (auto sizes resolved, print-mode validated)
8
+ * 4. Render -> HTML string
9
+ */
10
+ export {};
11
+ //# sourceMappingURL=parser-types.js.map
@@ -1,42 +1,51 @@
1
1
  /**
2
- * Markdown dashboard parser for mviz
2
+ * Markdown dashboard parser for mviz — orchestrator.
3
3
  *
4
- * Parses markdown files with embedded chart/component specs and generates HTML.
4
+ * Pipeline:
5
+ * 1. parseMarkdown (markdown-parser.ts) — markdown -> raw IR
6
+ * 2. loadSections (block-loader.ts) — resolve file refs, parse JSON, lint specs
7
+ * 3. resolveLayout (layout-resolver.ts) — resolve auto sizes + print-mode validation
8
+ * 4. renderSections (renderer.ts) — IR -> componentsHtml + chartScripts
9
+ * 5. generate{Dashboard,TestHarness}Html (templates.ts) — final page assembly
10
+ *
11
+ * Public surface (these are imported by cli.ts / index.ts):
12
+ * - parseMarkdownToDashboard
13
+ * - parseMarkdownToDashboardAsync
14
+ * - parseMarkdownToTestHarness
15
+ * - parseMarkdownToTestHarnessAsync
16
+ * - parseMarkdownLayout (legacy)
17
+ * - MermaidBlock, ParseResult (types)
5
18
  */
6
- import type { DashboardSpec, CustomTheme } from '../types.js';
19
+ import type { CustomTheme, DashboardSpec } from '../types.js';
20
+ import type { ParseResult } from './parser-types.js';
21
+ export type { MermaidBlock, ParseResult } from './parser-types.js';
7
22
  /**
8
- * Parse markdown layout and return HTML
23
+ * Parse a markdown dashboard into HTML.
24
+ *
25
+ * Synchronous variant — mermaid blocks are emitted as placeholders and must be
26
+ * resolved by `parseMarkdownToDashboardAsync` for final rendering.
9
27
  */
10
- /** Mermaid block to be rendered */
11
- export interface MermaidBlock {
12
- id: string;
13
- spec: Record<string, unknown>;
14
- theme: string;
15
- }
16
- /** Result from parsing markdown to dashboard */
17
- export interface ParseResult {
18
- html: string;
19
- errors: string[];
20
- mermaidBlocks: MermaidBlock[];
21
- }
22
- export declare function parseMarkdownToDashboard(markdown: string, baseTheme?: string, _baseDir?: string, strict?: boolean, testMode?: boolean, customTheme?: CustomTheme): ParseResult;
28
+ export declare function parseMarkdownToDashboard(markdown: string, baseTheme?: string, baseDir?: string, strict?: boolean, testMode?: boolean, customTheme?: CustomTheme, lintMode?: 'generate' | 'lint'): ParseResult;
23
29
  /**
24
- * Async version that renders mermaid blocks with beautiful-mermaid
30
+ * Async variant that resolves mermaid placeholders to inline SVG.
25
31
  */
26
- export declare function parseMarkdownToDashboardAsync(markdown: string, baseTheme?: string, baseDir?: string, strict?: boolean, testMode?: boolean, customTheme?: CustomTheme): Promise<{
32
+ export declare function parseMarkdownToDashboardAsync(markdown: string, baseTheme?: string, baseDir?: string, strict?: boolean, testMode?: boolean, customTheme?: CustomTheme, lintMode?: 'generate' | 'lint'): Promise<{
27
33
  html: string;
28
34
  errors: string[];
29
35
  }>;
30
36
  /**
31
- * Parse markdown layout into dashboard spec (legacy API for compatibility)
37
+ * Parse markdown layout into a DashboardSpec (legacy API for compatibility).
38
+ *
39
+ * Returns frontmatter only; the row IR is intentionally empty since this
40
+ * legacy path was only ever consumed for its frontmatter.
32
41
  */
33
42
  export declare function parseMarkdownLayout(markdown: string, _baseDir?: string): DashboardSpec;
34
43
  /**
35
- * Parse markdown into test harness HTML with navigation and summary
44
+ * Parse markdown into test-harness HTML with navigation and summary.
36
45
  */
37
46
  export declare function parseMarkdownToTestHarness(markdown: string, baseTheme?: string, baseDir?: string, strict?: boolean): ParseResult;
38
47
  /**
39
- * Async version of parseMarkdownToTestHarness that renders mermaid blocks
48
+ * Async variant of parseMarkdownToTestHarness.
40
49
  */
41
50
  export declare function parseMarkdownToTestHarnessAsync(markdown: string, baseTheme?: string, baseDir?: string, strict?: boolean): Promise<{
42
51
  html: string;