@illuma-ai/codeviz 1.0.0 → 1.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 (45) hide show
  1. package/dist/CodeViz.d.ts +1 -1
  2. package/dist/CodeViz.d.ts.map +1 -1
  3. package/dist/ErrorPanel.d.ts +16 -0
  4. package/dist/ErrorPanel.d.ts.map +1 -0
  5. package/dist/PreviewPane.d.ts.map +1 -1
  6. package/dist/StatusBar.d.ts +8 -1
  7. package/dist/StatusBar.d.ts.map +1 -1
  8. package/dist/Toolbar.d.ts +16 -6
  9. package/dist/Toolbar.d.ts.map +1 -1
  10. package/dist/__tests__/transpiler-scenarios.test.d.ts +2 -0
  11. package/dist/__tests__/transpiler-scenarios.test.d.ts.map +1 -0
  12. package/dist/__tests__/transpiler.test.d.ts +2 -0
  13. package/dist/__tests__/transpiler.test.d.ts.map +1 -0
  14. package/dist/__tests__/ui-components.test.d.ts +2 -0
  15. package/dist/__tests__/ui-components.test.d.ts.map +1 -0
  16. package/dist/__tests__/utils.test.d.ts +2 -0
  17. package/dist/__tests__/utils.test.d.ts.map +1 -0
  18. package/dist/agentContext.d.ts +19 -1
  19. package/dist/agentContext.d.ts.map +1 -1
  20. package/dist/constants.d.ts +11 -0
  21. package/dist/constants.d.ts.map +1 -0
  22. package/dist/importMap.d.ts.map +1 -1
  23. package/dist/index.cjs +812 -769
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.d.ts +7 -2
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +9622 -5429
  28. package/dist/index.js.map +1 -1
  29. package/dist/previewTemplate.d.ts +4 -0
  30. package/dist/previewTemplate.d.ts.map +1 -1
  31. package/dist/templates.d.ts +23 -12
  32. package/dist/templates.d.ts.map +1 -1
  33. package/dist/transpiler.d.ts +26 -4
  34. package/dist/transpiler.d.ts.map +1 -1
  35. package/dist/types.d.ts +26 -4
  36. package/dist/types.d.ts.map +1 -1
  37. package/dist/ui/components.d.ts +21 -0
  38. package/dist/ui/components.d.ts.map +1 -0
  39. package/dist/ui/index.d.ts +9 -0
  40. package/dist/ui/index.d.ts.map +1 -0
  41. package/dist/ui/theme.d.ts +14 -0
  42. package/dist/ui/theme.d.ts.map +1 -0
  43. package/dist/utils.d.ts +17 -0
  44. package/dist/utils.d.ts.map +1 -0
  45. package/package.json +8 -3
@@ -15,5 +15,9 @@ export declare function buildPreviewHtml(options: {
15
15
  tailwindCdn?: string | false;
16
16
  externalResources?: string[];
17
17
  extraFiles?: Record<string, string>;
18
+ /** Theme CSS injected as a <style> tag — agent never sees this */
19
+ themeCSS?: string;
20
+ /** Pre-transpiled component code prepended to user code — agent uses them directly */
21
+ componentsPreamble?: string;
18
22
  }): string;
19
23
  //# sourceMappingURL=previewTemplate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"previewTemplate.d.ts","sourceRoot":"","sources":["../src/previewTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAK1D;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE;IACxC,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,eAAe,CAAC;IAC1B,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAC7B,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACrC,GAAG,MAAM,CA6CT"}
1
+ {"version":3,"file":"previewTemplate.d.ts","sourceRoot":"","sources":["../src/previewTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAK1D;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE;IACxC,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,eAAe,CAAC;IAC1B,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAC7B,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sFAAsF;IACtF,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,GAAG,MAAM,CAgET"}
@@ -1,13 +1,11 @@
1
1
  /**
2
- * Pre-built starter templates for Ranger's LLM agent.
2
+ * Template Registry lightweight API for managing preview templates.
3
3
  *
4
- * KEY DESIGN: Every template includes the FULL dependency preamble (even unused
5
- * imports). This means the agent NEVER hits missing-dep errors — it just
6
- * uses whatever it needs from the imports already present. Unused imports
7
- * are tree-shaken by the browser (never fetched if not used).
4
+ * The library ships NO templates. Consumers register their own
5
+ * templates at startup via `registerTemplate()` / `registerTemplates()`.
8
6
  *
9
- * The agent picks a template based on user query, then edits the body.
10
- * The preamble + structure stays intact, saving hundreds of tokens.
7
+ * The agent system prompt, template picker, and CodeViz component all read
8
+ * from this shared registry.
11
9
  */
12
10
  export interface Template {
13
11
  id: string;
@@ -16,21 +14,34 @@ export interface Template {
16
14
  /** Keywords that help the agent pick this template from a user query */
17
15
  keywords: string[];
18
16
  code: string;
19
- type: 'react-ts' | 'html' | 'markdown' | 'mermaid' | 'svg' | 'csv' | 'json';
17
+ type: 'react-ts' | 'html' | 'markdown' | 'mermaid' | 'svg' | 'csv' | 'json' | 'dot' | 'latex' | 'architecture';
20
18
  language: string;
21
19
  }
20
+ /** Internal registry — consumers populate via registerTemplate(). */
22
21
  export declare const templates: Record<string, Template>;
23
- /** Get a template by ID */
22
+ /** Register a single template. Overwrites if id already exists. */
23
+ export declare function registerTemplate(template: Template): void;
24
+ /** Register multiple templates at once. */
25
+ export declare function registerTemplates(list: Template[]): void;
26
+ /** Remove a template by ID. */
27
+ export declare function unregisterTemplate(id: string): void;
28
+ /** Remove all registered templates. */
29
+ export declare function clearTemplates(): void;
30
+ /** Get a template by ID. */
24
31
  export declare function getTemplate(id: string): Template | undefined;
25
- /** Get all template IDs */
32
+ /** Get all template IDs. */
26
33
  export declare function getTemplateIds(): string[];
34
+ /** Get all registered templates as an array. */
35
+ export declare function getTemplates(): Template[];
27
36
  /**
28
37
  * Returns a summary of all templates for agent system prompts.
38
+ * Each line: `- **id**: description [keywords: ...]`
29
39
  */
30
40
  export declare function getTemplateSummary(): string;
31
41
  /**
32
42
  * Pick the best template based on user query keywords.
33
- * Returns the template ID, or 'blank' if no strong match.
43
+ * Returns the template ID with the highest keyword overlap.
44
+ * Falls back to the first registered template, or empty string if none.
34
45
  */
35
- export declare function pickTemplate(query: string): string;
46
+ export declare function pickTemplate(query: string, fallback?: string): string;
36
47
  //# sourceMappingURL=templates.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../src/templates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,wEAAwE;IACxE,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,UAAU,GAAG,SAAS,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC;IAC5E,QAAQ,EAAE,MAAM,CAAC;CAClB;AAyCD,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAiyB9C,CAAC;AAEF,2BAA2B;AAC3B,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAE5D;AAED,2BAA2B;AAC3B,wBAAgB,c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GAGG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAM3C;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAmBrE"}
@@ -1,15 +1,37 @@
1
1
  import { PreviewError } from './types';
2
2
 
3
+ /** A named section found in the source via @section markers */
4
+ export interface SectionMarker {
5
+ /** Section name (e.g., "overview", "KPI Cards", "Revenue Chart") */
6
+ name: string;
7
+ /** Start line (1-indexed) — the line containing the @section comment */
8
+ startLine: number;
9
+ /** End line (1-indexed) — line before the next @section or end of enclosing block */
10
+ endLine: number;
11
+ }
3
12
  export interface TranspileResult {
4
13
  code: string;
14
+ /** Primary error (first in errors array), or null if clean */
5
15
  error: PreviewError | null;
16
+ /** All errors — transpilation + ES module validation */
17
+ errors: PreviewError[];
18
+ /**
19
+ * Structure map — named sections found via `{/* @section: name *\/}` markers.
20
+ * Returned on EVERY transpile (success or error) so the agent can always
21
+ * locate sections without reading the whole file.
22
+ */
23
+ sections: SectionMarker[];
6
24
  }
7
25
  /**
8
- * Transpile TSX/JSX source code to plain JavaScript using Sucrase.
26
+ * Transpile TSX/JSX source code to plain JavaScript using Sucrase,
27
+ * then validate the output with acorn (ES module parser) to catch
28
+ * issues Sucrase doesn't flag (e.g., duplicate `export default`).
29
+ *
30
+ * This is the SINGLE SOURCE OF TRUTH for code validation —
31
+ * both CodeViz preview and server-side verify call this function.
9
32
  *
10
- * Sucrase is ~20x faster than Babel and handles JSX/TypeScript
11
- * without a full bundler. The output uses ES module imports which
12
- * are resolved by the browser via import maps.
33
+ * Pipeline: Source → Sucrase (strip TS + JSX) acorn (validate ES module)
34
+ * scope analysis (undeclared refs) result
13
35
  *
14
36
  * Returns structured errors with line/column for agent consumption.
15
37
  */
@@ -1 +1 @@
1
- {"version":3,"file":"transpiler.d.ts","sourceRoot":"","sources":["../src/transpiler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAA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B;AAiOD;;GAEG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC5B,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAMjC"}
package/dist/types.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { editor } from 'monaco-editor';
2
2
 
3
3
  /** Supported preview template types */
4
- export type PreviewTemplate = 'react' | 'react-ts' | 'html' | 'markdown' | 'mermaid' | 'svg' | 'csv' | 'json';
4
+ export type PreviewTemplate = 'react' | 'react-ts' | 'html' | 'markdown' | 'mermaid' | 'svg' | 'csv' | 'json' | 'dot' | 'latex' | 'architecture';
5
5
  /** Import map structure for the preview iframe */
6
6
  export interface ImportMap {
7
7
  imports: Record<string, string>;
@@ -33,9 +33,16 @@ export interface PreviewError {
33
33
  column?: number;
34
34
  /**
35
35
  * Surrounding source lines for context.
36
- * Format: "lineNum: content" per line.
36
+ * Format: "lineNum: content" per line. Error line marked with >>>.
37
37
  */
38
38
  sourceContext?: string;
39
+ /**
40
+ * Human-readable location in the file — tells the agent WHERE the error is
41
+ * without reading the whole file.
42
+ *
43
+ * Example: "inside export default function App (line 85), inside activePage === 'overview' block (line 120)"
44
+ */
45
+ location?: string;
39
46
  /** ISO 8601 timestamp */
40
47
  timestamp: string;
41
48
  }
@@ -91,15 +98,30 @@ export interface CodeVizProps {
91
98
  showToolbar?: boolean;
92
99
  /** Show/hide the status bar (default: true) */
93
100
  showStatusBar?: boolean;
94
- /** Called when the close button is clicked — Ranger can unmount or hide the preview */
101
+ /** Called when the close button is clicked — host app can unmount or hide the preview */
95
102
  onClose?: () => void;
96
103
  /** Called when fullscreen state changes */
97
104
  onFullscreenChange?: (isFullscreen: boolean) => void;
105
+ /** Filename to display in the status bar / footer center */
106
+ filename?: string;
107
+ /** Hide the split view option from the toolbar */
108
+ hideSplit?: boolean;
109
+ /** Custom React node rendered in the status bar (e.g., version controls) */
110
+ footerSlot?: React.ReactNode;
111
+ /**
112
+ * External streaming flag — controlled by the host app.
113
+ *
114
+ * When true, CodeViz stays in code view and won't auto-switch to preview.
115
+ * When it transitions from true → false, CodeViz attempts the preview switch
116
+ * (if no errors). This lets the host (e.g., Ranger's `isSubmitting`) control
117
+ * the full agent lifecycle — including verify/edit steps after commitCode().
118
+ */
119
+ isStreaming?: boolean;
98
120
  }
99
121
  /**
100
122
  * Imperative handle exposed by CodeViz via React.forwardRef.
101
123
  *
102
- * This is the primary API for Ranger to control the preview programmatically.
124
+ * This is the primary API for the host app to control the preview programmatically.
103
125
  * Matches CodeSandboxHandle patterns where applicable.
104
126
  *
105
127
  * @example
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAM5C,uCAAuC;AACvC,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,UAAU,GAAG,MAAM,GAAG,UAAU,GAAG,SAAS,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC;AAE9G,kDAAkD;AAClD,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACjD;AAMD,yDAAyD;AACzD,MAAM,MAAM,oBAAoB,GAC5B,eAAe,GACf,SAAS,GACT,QAAQ,GACR,eAAe,GACf,qBAAqB,CAAC;AAE1B,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AAEhE;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,kCAAkC;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,qBAAqB;IACrB,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,qBAAqB;IACrB,QAAQ,EAAE,oBAAoB,CAAC;IAC/B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vB;AAMD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,WAAW,aAAa;IAG5B,uCAAuC;IACvC,OAAO,EAAE,MAAM,MAAM,CAAC;IAEtB,iEAAiE;IACjE,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAIhC;;;;;;OAMG;IACH,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAEnC;;;OAGG;IACH,UAAU,EAAE,MAAM,IAAI,CAAC;IAIvB,uCAAuC;IACvC,OAAO,EAAE,MAAM,IAAI,CAAC;IAEpB,uBAAuB;IACvB,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAItD;;;;;;OAMG;IACH,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;IAItD,gCAAgC;IAChC,SAAS,EAAE,MAAM,YAAY,EAAE,CAAC;IAEhC,uBAAuB;IACvB,WAAW,EAAE,MAAM,IAAI,CAAC;IAIxB,+CAA+C;IAC/C,SAAS,EAAE,MAAM,OAAO,CAAC;CAC1B;AAMD,6DAA6D;AAC7D,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,EAAE,OAAO,GAAG,OAAO,GAAG,SAAS,CAAC;IACtC,OAAO,CAAC,EAAE;QACR,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;CACH"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Built-in UI components — pre-transpiled and prepended to user code in the iframe.
3
+ *
4
+ * These components are available in every template without imports.
5
+ * The agent just uses them: <DataTable columns={...} data={...} />
6
+ *
7
+ * Written as a TSX source string, transpiled once at build time via Sucrase,
8
+ * then injected before the user's code in the iframe module.
9
+ *
10
+ * Design: shadcn/Tailwind patterns + banking theme utility classes.
11
+ * The agent doesn't manage or even see these — they're library code.
12
+ */
13
+ /**
14
+ * TSX source for all built-in components.
15
+ * Uses the same imports as the template (React hooks, lucide-react icons).
16
+ * Gets transpiled by the same Sucrase pipeline as user code.
17
+ */
18
+ export declare const BUILTIN_COMPONENTS_TSX = "\n// \u2500\u2500 Built-in UI Components (auto-injected by CodeViz) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// Agent code can use these directly: <DataTable />, <MetricCard />, etc.\n// Do NOT remove or modify \u2014 these are managed by the platform.\n\n/**\n * DataTable \u2014 Searchable, sortable, paginated table.\n * Banking standard: right-aligned numerics, formatted values.\n *\n * @param columns - Array of { key, label, align?, render?, sortable? }\n * @param data - Array of row objects\n * @param searchable - Show search bar (default: true)\n * @param pageSize - Rows per page (default: 10)\n * @param onRowClick - Optional row click handler\n */\nfunction DataTable({ columns = [], data = [], searchable = true, pageSize = 10, onRowClick }) {\n const [search, setSearch] = useState('');\n const [sortKey, setSortKey] = useState(null);\n const [sortDir, setSortDir] = useState('asc');\n const [page, setPage] = useState(0);\n\n const filtered = useMemo(() => {\n if (!search.trim()) return data;\n const q = search.toLowerCase();\n return data.filter(row =>\n columns.some(col => String(row[col.key] ?? '').toLowerCase().includes(q))\n );\n }, [data, search, columns]);\n\n const sorted = useMemo(() => {\n if (!sortKey) return filtered;\n return [...filtered].sort((a, b) => {\n const av = a[sortKey] ?? '', bv = b[sortKey] ?? '';\n const cmp = typeof av === 'number' && typeof bv === 'number'\n ? av - bv\n : String(av).localeCompare(String(bv));\n return sortDir === 'asc' ? cmp : -cmp;\n });\n }, [filtered, sortKey, sortDir]);\n\n const totalPages = Math.max(1, Math.ceil(sorted.length / pageSize));\n const pageData = sorted.slice(page * pageSize, (page + 1) * pageSize);\n\n const handleSort = (key) => {\n if (sortKey === key) {\n setSortDir(d => d === 'asc' ? 'desc' : 'asc');\n } else {\n setSortKey(key);\n setSortDir('asc');\n }\n };\n\n return (\n <div className=\"bg-surface-secondary border border-border-light rounded-lg overflow-hidden\">\n {searchable && (\n <div className=\"px-4 py-3 border-b border-border-light\">\n <input\n type=\"text\"\n placeholder=\"Search...\"\n value={search}\n onChange={e => { setSearch(e.target.value); setPage(0); }}\n className=\"w-full px-3 py-1.5 text-sm rounded-md bg-surface-tertiary text-text-primary border border-border-light focus:outline-none focus:border-[#00C1D5] placeholder:text-text-tertiary\"\n />\n </div>\n )}\n <div className=\"overflow-x-auto\">\n <table className=\"w-full\">\n <thead>\n <tr className=\"bg-surface-tertiary\">\n {columns.map(col => (\n <th\n key={col.key}\n onClick={() => col.sortable !== false && handleSort(col.key)}\n className={cn(\n 'px-4 py-2.5 text-xs font-semibold text-text-secondary whitespace-nowrap',\n col.align === 'right' ? 'text-right' : 'text-left',\n col.sortable !== false && 'cursor-pointer hover:text-text-primary select-none'\n )}\n >\n <span className=\"inline-flex items-center gap-1\">\n {col.label}\n {sortKey === col.key && (\n <span className=\"text-[10px]\">{sortDir === 'asc' ? '\u25B2' : '\u25BC'}</span>\n )}\n </span>\n </th>\n ))}\n </tr>\n </thead>\n <tbody className=\"divide-y divide-border-light\">\n {pageData.map((row, idx) => (\n <tr\n key={idx}\n onClick={() => onRowClick && onRowClick(row, idx)}\n className={cn('transition-colors', onRowClick && 'cursor-pointer', 'hover:bg-surface-tertiary')}\n >\n {columns.map(col => (\n <td\n key={col.key}\n className={cn(\n 'px-4 py-2.5 text-sm',\n col.align === 'right' ? 'text-right tabular-nums' : 'text-left',\n 'text-text-primary'\n )}\n >\n {col.render ? col.render(row[col.key], row) : row[col.key]}\n </td>\n ))}\n </tr>\n ))}\n {pageData.length === 0 && (\n <tr>\n <td colSpan={columns.length} className=\"px-4 py-8 text-center text-text-tertiary text-sm\">\n {search ? 'No results found' : 'No data'}\n </td>\n </tr>\n )}\n </tbody>\n </table>\n </div>\n {totalPages > 1 && (\n <div className=\"flex items-center justify-between px-4 py-2.5 border-t border-border-light text-xs text-text-secondary\">\n <span>{sorted.length} row{sorted.length !== 1 ? 's' : ''}</span>\n <div className=\"flex items-center gap-2\">\n <button\n onClick={() => setPage(p => Math.max(0, p - 1))}\n disabled={page === 0}\n className=\"px-2 py-1 rounded bg-surface-tertiary disabled:opacity-40 hover:bg-surface-primary\"\n >\n Prev\n </button>\n <span>{page + 1} / {totalPages}</span>\n <button\n onClick={() => setPage(p => Math.min(totalPages - 1, p + 1))}\n disabled={page >= totalPages - 1}\n className=\"px-2 py-1 rounded bg-surface-tertiary disabled:opacity-40 hover:bg-surface-primary\"\n >\n Next\n </button>\n </div>\n </div>\n )}\n </div>\n );\n}\n\n/**\n * MetricCard \u2014 Single KPI display with trend indicator.\n * Banking standard: formatted value, comparison period, trend arrow.\n *\n * @param label - Metric name (e.g., \"Total AUM\")\n * @param value - Formatted value (e.g., \"$1.2B\")\n * @param trend - Trend percentage (e.g., \"+3.2%\") \u2014 positive = green, negative = red\n * @param trendLabel - Comparison period (e.g., \"vs last quarter\")\n * @param icon - Optional lucide-react icon component\n * @param iconColor - Optional icon color (default: #00C1D5)\n */\nfunction MetricCard({ label, value, trend, trendLabel, icon, iconColor = '#00C1D5' }) {\n const isPositive = trend && !trend.startsWith('-');\n const isNegative = trend && trend.startsWith('-');\n const IconComp = icon;\n\n return (\n <div className=\"bg-surface-secondary border border-border-light rounded-xl p-5\">\n <div className=\"flex items-center justify-between mb-3\">\n <p className=\"text-text-secondary text-xs font-medium uppercase tracking-wide\">{label}</p>\n {IconComp && <IconComp className=\"w-4 h-4\" style={{ color: iconColor }} />}\n </div>\n <p className=\"text-2xl font-bold text-text-primary tabular-nums\">{value}</p>\n {trend && (\n <div className=\"flex items-center gap-1.5 mt-2\">\n <span className={cn('text-xs font-semibold', isPositive && 'text-status-positive', isNegative && 'text-status-negative')}>\n {isPositive && '\u25B2'}{isNegative && '\u25BC'} {trend}\n </span>\n {trendLabel && <span className=\"text-text-tertiary text-xs\">{trendLabel}</span>}\n </div>\n )}\n </div>\n );\n}\n\n/**\n * StatusBadge \u2014 Colored pill for status display.\n * Banking standard: green (active/on-track), amber (watch), red (action needed).\n *\n * @param status - \"positive\" | \"negative\" | \"warning\" | \"neutral\"\n * @param label - Display text\n */\nfunction StatusBadge({ status = 'neutral', label }) {\n const styles = {\n positive: 'bg-[rgba(22,163,74,0.12)] text-status-positive',\n negative: 'bg-[rgba(220,38,38,0.12)] text-status-negative',\n warning: 'bg-[rgba(217,119,6,0.12)] text-status-warning',\n neutral: 'bg-surface-tertiary text-text-secondary',\n };\n\n return (\n <span className={cn('inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium', styles[status] || styles.neutral)}>\n {label}\n </span>\n );\n}\n\n/**\n * DetailCard \u2014 Entity header with key fields + optional tabbed content.\n * For: client profiles, account detail, loan summary.\n *\n * @param title - Entity name/title\n * @param subtitle - Secondary info (ID, type)\n * @param status - Optional StatusBadge props { status, label }\n * @param fields - Array of { label, value } for the key metrics row\n * @param tabs - Optional array of { id, label, content: ReactNode }\n * @param children - Content below the header (if no tabs)\n */\nfunction DetailCard({ title, subtitle, status, fields = [], tabs, children }) {\n const [activeTab, setActiveTab] = useState(tabs?.[0]?.id || '');\n\n return (\n <div className=\"bg-surface-secondary border border-border-light rounded-xl overflow-hidden\">\n <div className=\"p-5 border-b border-border-light\">\n <div className=\"flex items-start justify-between mb-3\">\n <div>\n <h2 className=\"text-xl font-bold text-text-primary\">{title}</h2>\n {subtitle && <p className=\"text-text-secondary text-sm mt-0.5\">{subtitle}</p>}\n </div>\n {status && <StatusBadge status={status.status} label={status.label} />}\n </div>\n {fields.length > 0 && (\n <div className=\"flex flex-wrap gap-6 mt-4\">\n {fields.map((f, i) => (\n <div key={i}>\n <p className=\"text-text-tertiary text-xs uppercase tracking-wide\">{f.label}</p>\n <p className=\"text-text-primary font-semibold text-sm mt-0.5 tabular-nums\">{f.value}</p>\n </div>\n ))}\n </div>\n )}\n </div>\n {tabs && tabs.length > 0 && (\n <>\n <div className=\"flex border-b border-border-light\">\n {tabs.map(tab => (\n <button\n key={tab.id}\n onClick={() => setActiveTab(tab.id)}\n className={cn(\n 'px-4 py-2.5 text-sm font-medium transition-colors',\n activeTab === tab.id\n ? 'text-[#00C1D5] border-b-2 border-[#00C1D5]'\n : 'text-text-secondary hover:text-text-primary'\n )}\n >\n {tab.label}\n </button>\n ))}\n </div>\n <div className=\"p-5\">\n {tabs.find(t => t.id === activeTab)?.content}\n </div>\n </>\n )}\n {!tabs && children && <div className=\"p-5\">{children}</div>}\n </div>\n );\n}\n\n/**\n * StepWizard \u2014 Multi-step form with progress indicator.\n * For: loan origination, account opening, KYC onboarding.\n *\n * @param steps - Array of { id, label, content: ReactNode, validate?: () => boolean }\n * @param onComplete - Called when final step is submitted\n */\nfunction StepWizard({ steps = [], onComplete }) {\n const [current, setCurrent] = useState(0);\n\n const next = () => {\n const step = steps[current];\n if (step.validate && !step.validate()) return;\n if (current < steps.length - 1) setCurrent(c => c + 1);\n else if (onComplete) onComplete();\n };\n\n const prev = () => setCurrent(c => Math.max(0, c - 1));\n\n return (\n <div className=\"bg-surface-secondary border border-border-light rounded-xl overflow-hidden\">\n <div className=\"flex items-center px-5 py-3 border-b border-border-light gap-2\">\n {steps.map((step, i) => (\n <div key={step.id} className=\"flex items-center gap-2\">\n <div className={cn(\n 'flex items-center justify-center w-7 h-7 rounded-full text-xs font-bold',\n i < current && 'bg-[#00C1D5] text-white',\n i === current && 'bg-[#00C1D5] text-white ring-2 ring-[#00C1D5]/30',\n i > current && 'bg-surface-tertiary text-text-tertiary'\n )}>\n {i < current ? '\u2713' : i + 1}\n </div>\n <span className={cn('text-sm hidden sm:inline', i === current ? 'text-text-primary font-medium' : 'text-text-tertiary')}>\n {step.label}\n </span>\n {i < steps.length - 1 && <div className=\"w-8 h-px bg-border-light\" />}\n </div>\n ))}\n </div>\n <div className=\"p-5 min-h-[200px]\">\n {steps[current]?.content}\n </div>\n <div className=\"flex items-center justify-between px-5 py-3 border-t border-border-light\">\n <button\n onClick={prev}\n disabled={current === 0}\n className=\"px-4 py-1.5 text-sm rounded-lg bg-surface-tertiary text-text-secondary disabled:opacity-40 hover:bg-surface-primary\"\n >\n Back\n </button>\n <button\n onClick={next}\n className=\"px-4 py-1.5 text-sm rounded-lg bg-[#00C1D5] text-white hover:bg-[#00a8b9]\"\n >\n {current === steps.length - 1 ? 'Submit' : 'Next'}\n </button>\n </div>\n </div>\n );\n}\n\n// \u2500\u2500 End built-in components \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n";
19
+ /** List of component names — used to add to BUILTIN_GLOBALS in the transpiler */
20
+ export declare const BUILTIN_COMPONENT_NAMES: readonly ["DataTable", "MetricCard", "StatusBadge", "DetailCard", "StepWizard"];
21
+ //# sourceMappingURL=components.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/ui/components.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,q5aAwUlC,CAAC;AAEF,iFAAiF;AACjF,eAAO,MAAM,uBAAuB,iFAM1B,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Built-in UI module — theme + components auto-injected into the preview iframe.
3
+ *
4
+ * The host app (Ranger) configures which UI set to use.
5
+ * CodeViz handles injection into the iframe HTML + transpiler globals.
6
+ */
7
+ export { BANKING_THEME_CSS } from './theme';
8
+ export { BUILTIN_COMPONENTS_TSX, BUILTIN_COMPONENT_NAMES } from './components';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Banking theme CSS — injected as a <style> tag in the preview iframe.
3
+ *
4
+ * Provides CSS custom properties + utility classes that auto-switch
5
+ * with dark/light mode via .theme-dark / .theme-light root classes.
6
+ *
7
+ * The agent never sees this CSS — it's injected automatically.
8
+ * Agent just uses the utility classes: bg-surface-secondary, text-text-primary, etc.
9
+ *
10
+ * IMPORTANT: Keep in sync with ranger/client/src/utils/codeviz/templates.ts
11
+ * and ranger/api/server/services/Tools/templateDefinitions.js
12
+ */
13
+ export declare const BANKING_THEME_CSS = "\n/* \u2500\u2500 Banking Theme: CSS Custom Properties \u2500\u2500 */\n.theme-light {\n --surface-primary: #ffffff;\n --surface-secondary: #f7f7f8;\n --surface-tertiary: #ececf1;\n --text-primary: #212121;\n --text-secondary: #666666;\n --text-tertiary: #999999;\n --border-light: #e5e5e5;\n --border-medium: #d1d1d1;\n --accent-cyan: #00C1D5;\n --accent-navy: #000033;\n --status-positive: #16a34a;\n --status-negative: #dc2626;\n --status-warning: #d97706;\n}\n.theme-dark {\n --surface-primary: #0d0d0d;\n --surface-secondary: #212121;\n --surface-tertiary: #2f2f2f;\n --text-primary: #ececec;\n --text-secondary: #a0a0a0;\n --text-tertiary: #737373;\n --border-light: #3a3a3b;\n --border-medium: #4a4a4b;\n --accent-cyan: #00C1D5;\n --accent-navy: #000033;\n --status-positive: #22c55e;\n --status-negative: #ef4444;\n --status-warning: #f59e0b;\n}\n\n/* \u2500\u2500 Utility Classes (Tailwind-style) \u2500\u2500 */\n.bg-surface-primary { background-color: var(--surface-primary); }\n.bg-surface-secondary { background-color: var(--surface-secondary); }\n.bg-surface-tertiary { background-color: var(--surface-tertiary); }\n.text-text-primary { color: var(--text-primary); }\n.text-text-secondary { color: var(--text-secondary); }\n.text-text-tertiary { color: var(--text-tertiary); }\n.border-border-light { border-color: var(--border-light); }\n.border-border-medium { border-color: var(--border-medium); }\n.text-accent-cyan { color: var(--accent-cyan); }\n.text-accent-navy { color: var(--accent-navy); }\n.bg-accent-cyan { background-color: var(--accent-cyan); }\n.bg-accent-navy { background-color: var(--accent-navy); }\n.text-status-positive { color: var(--status-positive); }\n.text-status-negative { color: var(--status-negative); }\n.text-status-warning { color: var(--status-warning); }\n.bg-status-positive { background-color: var(--status-positive); }\n.bg-status-negative { background-color: var(--status-negative); }\n.bg-status-warning { background-color: var(--status-warning); }\n";
14
+ //# sourceMappingURL=theme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/ui/theme.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,iBAAiB,o/DAoD7B,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { PreviewTemplate } from './types';
2
+
3
+ /** Returns true if the given template type supports live preview */
4
+ export declare function hasPreviewSupport(template: string): boolean;
5
+ /** Auto-detect preview template from language/file extension */
6
+ export declare function inferTemplate(lang: string): PreviewTemplate;
7
+ /**
8
+ * Build downloadable content based on file type.
9
+ * TSX/JSX -> self-contained HTML with import maps (runs standalone in browser).
10
+ * Everything else -> native format.
11
+ */
12
+ export declare function buildDownload(code: string, template: PreviewTemplate, lang: string): {
13
+ filename: string;
14
+ content: string;
15
+ mime: string;
16
+ };
17
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAK/C,oEAAoE;AACpE,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAE3D;AAED,gEAAgE;AAChE,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CA2C3D;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,eAAe,EACzB,IAAI,EAAE,MAAM,GACX;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAuErD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@illuma-ai/codeviz",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Multi-format code & content preview — Monaco editor, live React/HTML/Markdown/SVG/CSV/JSON rendering, streaming API, zoom/pan, download",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -18,11 +18,13 @@
18
18
  "dist"
19
19
  ],
20
20
  "scripts": {
21
- "dev": "vite serve demo",
21
+ "dev": "vite serve --config vite.demo.config.ts",
22
22
  "build": "vite build",
23
23
  "build:demo": "vite build --config vite.demo.config.ts",
24
24
  "preview": "vite preview",
25
25
  "typecheck": "tsc --noEmit",
26
+ "test": "vitest run",
27
+ "test:watch": "vitest",
26
28
  "prepublishOnly": "npm run build"
27
29
  },
28
30
  "peerDependencies": {
@@ -31,6 +33,8 @@
31
33
  },
32
34
  "dependencies": {
33
35
  "@monaco-editor/react": "^4.6.0",
36
+ "acorn": "^8.16.0",
37
+ "acorn-walk": "^8.3.5",
34
38
  "monaco-editor": "^0.47.0",
35
39
  "sucrase": "^3.35.0"
36
40
  },
@@ -43,7 +47,8 @@
43
47
  "typescript": "^5.3.0",
44
48
  "vite": "^5.4.0",
45
49
  "vite-plugin-css-injected-by-js": "^3.5.0",
46
- "vite-plugin-dts": "^3.9.0"
50
+ "vite-plugin-dts": "^3.9.0",
51
+ "vitest": "^4.1.1"
47
52
  },
48
53
  "repository": {
49
54
  "type": "git",