@illuma-ai/codeviz 1.0.0

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.
@@ -0,0 +1,17 @@
1
+ import { default as React } from 'react';
2
+ import { CodeVizProps, CodeVizHandle } from './types';
3
+
4
+ /**
5
+ * CodeViz — A lightweight single-file React/HTML preview component.
6
+ *
7
+ * Drop-in Sandpack replacement for Ranger artifacts. Features:
8
+ * - Monaco editor with syntax highlighting and VS Code-style diff decorations
9
+ * - Sucrase in-browser JSX/TSX transpilation (no remote bundler)
10
+ * - Import maps + esm.sh CDN for dependency resolution
11
+ * - Streaming API for live LLM token-by-token updates
12
+ * - Structured error reporting with line numbers
13
+ * - Code/Preview tab switching; side-by-side Split at wide screens or fullscreen
14
+ * - Window controls: fullscreen (Fullscreen API) + close (event to parent)
15
+ */
16
+ export declare const CodeViz: React.MemoExoticComponent<React.ForwardRefExoticComponent<CodeVizProps & React.RefAttributes<CodeVizHandle>>>;
17
+ //# sourceMappingURL=CodeViz.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CodeViz.d.ts","sourceRoot":"","sources":["../src/CodeViz.tsx"],"names":[],"mappings":"AAAA,OAAO,KAQN,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAgB,MAAM,SAAS,CAAC;AAqBzE;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,OAAO,+GA+VnB,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { default as React } from 'react';
2
+ import { editor } from 'monaco-editor';
3
+
4
+ export interface EditorPaneProps {
5
+ code: string;
6
+ language: string;
7
+ onChange?: (value: string) => void;
8
+ theme?: 'light' | 'dark';
9
+ readOnly?: boolean;
10
+ options?: editor.IStandaloneEditorConstructionOptions;
11
+ editorRef?: React.MutableRefObject<editor.IStandaloneCodeEditor | null>;
12
+ /** Base code for diff decorations — lines that differ get gutter markers */
13
+ baseCode?: string | null;
14
+ }
15
+ /**
16
+ * Monaco editor with VS Code-style inline diff decorations.
17
+ *
18
+ * When `baseCode` is provided, computes a line-level diff and shows:
19
+ * - Green gutter bar: new/added lines
20
+ * - Blue gutter bar: modified lines
21
+ *
22
+ * Uses Monaco's `deltaDecorations` API (not DiffEditor) for inline markers.
23
+ */
24
+ export declare const EditorPane: React.NamedExoticComponent<EditorPaneProps>;
25
+ //# sourceMappingURL=EditorPane.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EditorPane.d.ts","sourceRoot":"","sources":["../src/EditorPane.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+C,MAAM,OAAO,CAAC;AAEpE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAG5C,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC,oCAAoC,CAAC;IACtD,SAAS,CAAC,EAAE,KAAK,CAAC,gBAAgB,CAAC,MAAM,CAAC,qBAAqB,GAAG,IAAI,CAAC,CAAC;IACxE,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,6CAwHrB,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { default as React } from 'react';
2
+
3
+ /**
4
+ * CodeSandbox-style loading animation with three bouncing cubes.
5
+ * Pure CSS animation — no external dependencies.
6
+ */
7
+ export declare const Loader: React.NamedExoticComponent<{
8
+ size?: "sm" | "md" | "lg";
9
+ label?: string;
10
+ }>;
11
+ //# sourceMappingURL=Loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Loader.d.ts","sourceRoot":"","sources":["../src/Loader.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAe,MAAM,OAAO,CAAC;AAEpC;;;GAGG;AACH,eAAO,MAAM,MAAM;WAIV,IAAI,GAAG,IAAI,GAAG,IAAI;YACjB,MAAM;EAwBd,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { default as React } from 'react';
2
+ import { ImportMap, PreviewTemplate, PreviewError } from './types';
3
+
4
+ export interface PreviewPaneProps {
5
+ code: string;
6
+ template: PreviewTemplate;
7
+ importMap?: ImportMap;
8
+ dependencies?: Record<string, string>;
9
+ cdnBase?: string;
10
+ tailwindCdn?: string | false;
11
+ externalResources?: string[];
12
+ files?: Record<string, string>;
13
+ onError?: (error: PreviewError) => void;
14
+ onLoad?: () => void;
15
+ theme?: 'light' | 'dark';
16
+ showLoader?: boolean;
17
+ loader?: React.ReactNode;
18
+ }
19
+ /**
20
+ * Iframe-based preview pane that transpiles code with Sucrase and
21
+ * renders it using import maps + esm.sh CDN.
22
+ *
23
+ * Returns structured PreviewError objects with line numbers and
24
+ * source context for agent consumption.
25
+ */
26
+ export declare const PreviewPane: React.NamedExoticComponent<PreviewPaneProps>;
27
+ //# sourceMappingURL=PreviewPane.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PreviewPane.d.ts","sourceRoot":"","sources":["../src/PreviewPane.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqD,MAAM,OAAO,CAAC;AAC1E,OAAO,KAAK,EAAiB,SAAS,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAMvF,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,eAAe,CAAC;IAC1B,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAC7B,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IACxC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC1B;AAmBD;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,8CA2ItB,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { default as React } from 'react';
2
+ import { PreviewError } from './types';
3
+
4
+ interface StatusBarProps {
5
+ errors: PreviewError[];
6
+ isLoading: boolean;
7
+ isStreaming: boolean;
8
+ language: string;
9
+ theme: 'light' | 'dark';
10
+ }
11
+ /**
12
+ * VS Code-style status bar showing build state, errors, and language.
13
+ */
14
+ export declare const StatusBar: React.NamedExoticComponent<StatusBarProps>;
15
+ export {};
16
+ //# sourceMappingURL=StatusBar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StatusBar.d.ts","sourceRoot":"","sources":["../src/StatusBar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAe,MAAM,OAAO,CAAC;AACpC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,UAAU,cAAc;IACtB,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,eAAO,MAAM,SAAS,4CAuDpB,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { default as React } from 'react';
2
+
3
+ export type ViewMode = 'split' | 'code' | 'preview';
4
+ interface ToolbarProps {
5
+ view: ViewMode;
6
+ onViewChange: (view: ViewMode) => void;
7
+ onRefresh: () => void;
8
+ errorCount: number;
9
+ isLoading: boolean;
10
+ theme: 'light' | 'dark';
11
+ /** Whether the component is in fullscreen mode */
12
+ isFullscreen?: boolean;
13
+ /** Toggle fullscreen on the container */
14
+ onFullscreenToggle?: () => void;
15
+ /** Download the current content */
16
+ onDownload?: () => void;
17
+ /** Close button — emits event for parent (Ranger) to handle */
18
+ onClose?: () => void;
19
+ }
20
+ /**
21
+ * Modern toolbar with view switcher, window controls (fullscreen, close).
22
+ *
23
+ * Split view only available at wide screen (>=768px) or in fullscreen.
24
+ * Right side has refresh, fullscreen toggle, and close — like window operations.
25
+ */
26
+ export declare const Toolbar: React.NamedExoticComponent<ToolbarProps>;
27
+ export {};
28
+ //# sourceMappingURL=Toolbar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Toolbar.d.ts","sourceRoot":"","sources":["../src/Toolbar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAiD,MAAM,OAAO,CAAC;AAEtE,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;AAEpD,UAAU,YAAY;IACpB,IAAI,EAAE,QAAQ,CAAC;IACf,YAAY,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;IACvC,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC;IACxB,kDAAkD;IAClD,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,yCAAyC;IACzC,kBAAkB,CAAC,EAAE,MAAM,IAAI,CAAC;IAChC,mCAAmC;IACnC,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,+DAA+D;IAC/D,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAKD;;;;;GAKG;AACH,eAAO,MAAM,OAAO,0CAgPlB,CAAC"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * File types that CodeViz can render.
3
+ * Use this to tell the agent what it CAN produce as artifacts.
4
+ */
5
+ export declare const RENDERABLE_TYPES: {
6
+ readonly 'application/vnd.react': {
7
+ readonly description: "React TSX component (single file, default export)";
8
+ readonly extension: ".tsx";
9
+ readonly template: "react-ts";
10
+ readonly example: "export default function App() { return <h1>Hello</h1>; }";
11
+ };
12
+ readonly 'text/html': {
13
+ readonly description: "Static HTML (rendered directly, Tailwind CSS available)";
14
+ readonly extension: ".html";
15
+ readonly template: "html";
16
+ readonly example: "<div class=\"p-4\"><h1 class=\"text-2xl font-bold\">Hello</h1></div>";
17
+ };
18
+ readonly 'text/markdown': {
19
+ readonly description: "Markdown with Mermaid diagram support (GFM, rendered with github-markdown-css)";
20
+ readonly extension: ".md";
21
+ readonly template: "markdown";
22
+ readonly example: "# Hello\n\nSome text\n\n```mermaid\ngraph TD\n A-->B\n```";
23
+ };
24
+ readonly 'application/vnd.mermaid': {
25
+ readonly description: "Standalone Mermaid diagram with zoom/pan viewer (flowchart, sequence, gantt, etc.)";
26
+ readonly extension: ".mermaid";
27
+ readonly template: "mermaid";
28
+ readonly example: "graph TD\n A[Start] --> B{Decision}\n B -->|Yes| C[OK]\n B -->|No| D[End]";
29
+ };
30
+ readonly 'image/svg+xml': {
31
+ readonly description: "SVG image with zoom/pan viewer";
32
+ readonly extension: ".svg";
33
+ readonly template: "svg";
34
+ readonly example: "<svg viewBox=\"0 0 100 100\"><circle cx=\"50\" cy=\"50\" r=\"40\" fill=\"#818cf8\"/></svg>";
35
+ };
36
+ readonly 'text/csv': {
37
+ readonly description: "CSV data rendered as a styled, sortable table";
38
+ readonly extension: ".csv";
39
+ readonly template: "csv";
40
+ readonly example: "Name,Age,City\nAlice,30,NYC\nBob,25,LA";
41
+ };
42
+ readonly 'application/json': {
43
+ readonly description: "JSON data with collapsible tree view and syntax highlighting";
44
+ readonly extension: ".json";
45
+ readonly template: "json";
46
+ readonly example: "{\"users\": [{\"name\": \"Alice\", \"role\": \"admin\"}]}";
47
+ };
48
+ };
49
+ export type RenderableType = keyof typeof RENDERABLE_TYPES;
50
+ /**
51
+ * Get the list of renderable artifact types for agent context.
52
+ */
53
+ export declare function getRenderableTypes(): typeof RENDERABLE_TYPES;
54
+ /**
55
+ * Returns a complete system prompt section for the LLM agent.
56
+ *
57
+ * Include this in the agent's system prompt so it knows:
58
+ * 1. What artifact types it can render
59
+ * 2. What packages are available (no install needed)
60
+ * 3. What templates to start from
61
+ * 4. Rules for producing valid artifacts
62
+ *
63
+ * This saves tokens because the agent doesn't need to guess.
64
+ */
65
+ export declare function getAgentSystemPrompt(): string;
66
+ /**
67
+ * Pick the best template for a user query.
68
+ * Convenience re-export for Ranger integration.
69
+ */
70
+ export { pickTemplate } from './templates';
71
+ //# sourceMappingURL=agentContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agentContext.d.ts","sourceRoot":"","sources":["../src/agentContext.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2CnB,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,gBAAgB,CAAC;AAE3D;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,OAAO,gBAAgB,CAE5D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAmC7C;AAED;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { ImportMap } from './types';
2
+
3
+ /**
4
+ * Builds a batteries-included import map for the preview iframe.
5
+ *
6
+ * The goal: the agent writes `import { format } from 'date-fns'` instead
7
+ * of generating a custom date formatter — saving tokens and reducing errors.
8
+ *
9
+ * Uses esm.sh CDN with `?external=react,react-dom` so that all packages
10
+ * emit bare `import 'react'` specifiers, resolved by the browser to a
11
+ * SINGLE React instance via the import map scopes.
12
+ */
13
+ export declare function buildImportMap(options?: {
14
+ cdnBase?: string;
15
+ dependencies?: Record<string, string>;
16
+ overrides?: ImportMap;
17
+ }): ImportMap;
18
+ /**
19
+ * Serialize an import map to a <script type="importmap"> tag string
20
+ */
21
+ export declare function importMapToScript(map: ImportMap): string;
22
+ /**
23
+ * Returns a human-readable list of all available packages for agent prompts.
24
+ * Agents can include this in their system prompt so the LLM knows what's available.
25
+ */
26
+ export declare function getAvailablePackages(): string;
27
+ //# sourceMappingURL=importMap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"importMap.d.ts","sourceRoot":"","sources":["../src/importMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAIzC;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC5B,OAAO,GAAE;IACP,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,SAAS,CAAC,EAAE,SAAS,CAAC;CAClB,GACL,SAAS,CAmNX;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,SAAS,GAAG,MAAM,CAExD;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CA+B7C"}