-
Notifications
You must be signed in to change notification settings - Fork 9
feat: add @runtimed/components package and migrate output components #729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 11 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
e346d37
feat: add @runtimed/components package and migrate output components
markmiro 36afdd0
Add @runtimed/components dev command to ecosystem file
markmiro 5040765
Bump version
markmiro 064cb7e
Remove unused @runtimed/components
markmiro b0821c2
Fix iframe outputs docker build
markmiro bd48f29
Make min iframe height taller
markmiro 923401e
Add text to incrementor component
markmiro 6dcb096
Watch styles during dev build
markmiro 11caa4c
Bump version
markmiro a3aafa1
Fix iframe height
markmiro 704b598
Build package in CI
markmiro 7e438f6
Allow removing message handler
markmiro c214c61
Fix type-check command failing because of .ts imports
markmiro 218dbf2
Set iframeUri from parent
markmiro 7d78b4a
Show url in iframe output demo page
markmiro 6350b97
Remove jsr.json
markmiro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,177 @@ | ||
| # @runtimed/components | ||
|
|
||
| React components for rendering notebook cell outputs. This package provides a comprehensive set of output renderers for displaying code execution results, including rich multimedia formats, terminal output, AI tool interactions, and geographic data. | ||
|
|
||
| ## Installation | ||
|
|
||
| ```bash | ||
| pnpm add @runtimed/components | ||
| # or | ||
| npm install @runtimed/components | ||
| ``` | ||
|
|
||
| **Peer Dependencies**: React 19+ | ||
|
|
||
| ## Quick Start | ||
|
|
||
| ```tsx | ||
| import { SingleOutput, OutputsContainer } from "@runtimed/components"; | ||
| import "@runtimed/components/styles.css"; | ||
|
|
||
| function NotebookOutputs({ outputs }) { | ||
| return ( | ||
| <OutputsContainer> | ||
| {outputs.map((output) => ( | ||
| <SingleOutput key={output.id} output={output} /> | ||
| ))} | ||
| </OutputsContainer> | ||
| ); | ||
| } | ||
| ``` | ||
|
|
||
| ## Components | ||
|
|
||
| ### Output Renderers | ||
|
|
||
| | Component | Description | | ||
| | ------------------- | ----------------------------------------------------------------------- | | ||
| | `SingleOutput` | Smart router that selects the appropriate renderer based on output type | | ||
| | `OutputsContainer` | Wrapper for consistent output styling | | ||
| | `RichOutputContent` | Renders multimedia content by MIME type | | ||
|
|
||
| ### Specific Renderers | ||
|
|
||
| | Component | MIME Types | | ||
| | ------------------ | ------------------------------------------------------ | | ||
| | `PlainTextOutput` | `text/plain` | | ||
| | `MarkdownRenderer` | `text/markdown` - GFM, KaTeX math, syntax highlighting | | ||
| | `HtmlOutput` | `text/html` | | ||
| | `JsonOutput` | `application/json` - interactive tree view | | ||
| | `ImageOutput` | `image/png`, `image/jpeg`, `image/gif`, `image/webp` | | ||
| | `SvgOutput` | `image/svg+xml` | | ||
| | `AnsiOutput` | Terminal output with ANSI color codes | | ||
| | `GeoJsonMapOutput` | `application/geo+json` - MapLibre-powered maps | | ||
|
|
||
| ### AI Tool Components | ||
|
|
||
| | Component | Purpose | | ||
| | ---------------------- | ------------------------------------------- | | ||
| | `AiToolCallOutput` | Displays AI tool invocation details | | ||
| | `AiToolResultOutput` | Renders tool execution results | | ||
| | `AiToolApprovalOutput` | UI for human-in-the-loop approval workflows | | ||
|
|
||
| ### Iframe Integration | ||
|
|
||
| For sandboxed output rendering: | ||
|
|
||
| ```tsx | ||
| import { IframeReactApp, IframeOutput } from "@runtimed/components"; | ||
|
|
||
| // Parent: embed outputs in an iframe | ||
| <IframeOutput outputs={cellOutputs} /> | ||
|
|
||
| // Child iframe: render the app | ||
| <IframeReactApp /> | ||
| ``` | ||
|
|
||
| Communication utilities: | ||
|
|
||
| ```tsx | ||
| import { | ||
| useIframeCommsParent, | ||
| useIframeCommsChild, | ||
| sendToIframe, | ||
| sendFromIframe, | ||
| } from "@runtimed/components"; | ||
| ``` | ||
|
|
||
| ### UI Components | ||
|
|
||
| Basic UI building blocks: | ||
|
|
||
| ```tsx | ||
| import { Button, Card, Spinner } from "@runtimed/components"; | ||
|
|
||
| <Button variant="outline" size="sm">Click me</Button> | ||
| <Spinner size="md" /> | ||
| ``` | ||
|
|
||
| ## Utilities | ||
|
|
||
| ```tsx | ||
| import { cn, groupConsecutiveStreamOutputs } from "@runtimed/components"; | ||
|
|
||
| // Merge Tailwind classes | ||
| cn("px-2 py-1", condition && "bg-blue-500"); | ||
|
|
||
| // Group stdout/stderr streams for cleaner display | ||
| const grouped = groupConsecutiveStreamOutputs(outputs); | ||
| ``` | ||
|
|
||
| ## Styling | ||
|
|
||
| Import the CSS for proper styling: | ||
|
|
||
| ```tsx | ||
| import "@runtimed/components/styles.css"; | ||
| ``` | ||
|
|
||
| The package uses Tailwind CSS v4. Components are designed to work in both light and dark themes. | ||
|
|
||
| ## Features | ||
|
|
||
| - **Lazy loading**: Heavy components like `MarkdownRenderer` are dynamically imported | ||
| - **Error boundaries**: Outputs gracefully handle rendering failures | ||
| - **Artifact support**: Handles both inline data and artifact URLs for large outputs | ||
| - **Suspense-ready**: Built-in loading states with `SuspenseSpinner` | ||
|
|
||
| ## Output Data Format | ||
|
|
||
| Components expect outputs conforming to `@runtimed/schema` types: | ||
|
|
||
| ```typescript | ||
| import type { OutputData, OutputType } from "@runtimed/components"; | ||
|
|
||
| interface OutputData { | ||
| id: string; | ||
| outputType: | ||
| | "multimedia_display" | ||
| | "multimedia_result" | ||
| | "terminal" | ||
| | "markdown" | ||
| | "error"; | ||
| data?: string | null; | ||
| representations?: Record<string, MediaContainer>; | ||
| streamName?: "stdout" | "stderr"; | ||
| } | ||
| ``` | ||
|
|
||
| ## Development | ||
|
|
||
| ```bash | ||
| # Build | ||
| pnpm build | ||
|
|
||
| # Watch mode | ||
| pnpm dev | ||
|
|
||
| # Type check | ||
| pnpm type-check | ||
|
|
||
| # Lint | ||
| pnpm lint | ||
| ``` | ||
|
|
||
| ## Demo | ||
|
|
||
| The package includes a demo page for testing all output types: | ||
|
|
||
| ```tsx | ||
| import { OutputTypesDemoPage } from "@runtimed/components"; | ||
|
|
||
| <OutputTypesDemoPage />; | ||
| ``` | ||
|
|
||
| ## License | ||
|
|
||
| MIT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "name": "@runtimed/components", | ||
| "version": "0.3.0-beta.1", | ||
| "exports": "./src/index.ts", | ||
| "license": "BSD-3-Clause" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| { | ||
| "name": "@runtimed/components", | ||
| "version": "0.3.0-beta.1", | ||
| "description": "React components for rendering notebook cell outputs", | ||
| "main": "dist/index.js", | ||
| "module": "dist/index.mjs", | ||
| "types": "dist/index.d.ts", | ||
| "source": "src/index.ts", | ||
| "files": [ | ||
| "dist", | ||
| "src" | ||
| ], | ||
| "exports": { | ||
| ".": { | ||
| "types": "./dist/index.d.ts", | ||
| "import": "./dist/index.mjs", | ||
| "require": "./dist/index.js", | ||
| "default": "./dist/index.mjs" | ||
| }, | ||
| "./styles.css": "./dist/styles.css" | ||
| }, | ||
| "scripts": { | ||
| "type-check": "tsc --noEmit", | ||
| "lint": "eslint src/", | ||
| "lint:check": "eslint src/ --max-warnings 0", | ||
| "format": "prettier --write .", | ||
| "format:check": "prettier --check .", | ||
| "build": "tsdown; pnpm build:css", | ||
| "build:css": "tailwindcss -i src/styles.css -o dist/styles.css --minify", | ||
| "dev": "tsdown --watch & tailwindcss -i src/styles.css -o dist/styles.css --watch", | ||
| "prepublishOnly": "pnpm build" | ||
| }, | ||
| "peerDependencies": { | ||
| "react": "^19.0.0", | ||
| "react-dom": "^19.0.0" | ||
| }, | ||
| "dependencies": { | ||
| "@uiw/react-json-view": "2.0.0-alpha.40", | ||
| "react-error-boundary": "^6.0.0", | ||
| "@radix-ui/react-slot": "^1.2.3", | ||
| "@runtimed/schema": "workspace:*", | ||
| "ansi-to-react": "^6.1.6", | ||
| "class-variance-authority": "^0.7.1", | ||
| "clsx": "^2.1.1", | ||
| "geojson-map-fit-mercator": "^1.1.0", | ||
| "katex": "^0.16.22", | ||
| "lucide-react": "^0.545.0", | ||
| "maplibre-gl": "^5.7.1", | ||
| "maplibre-react-components": "^0.2.6", | ||
| "react-markdown": "^10.1.0", | ||
| "react-syntax-highlighter": "^15.6.1", | ||
| "react-use": "^17.6.0", | ||
| "rehype-katex": "^7.0.1", | ||
| "rehype-raw": "^7.0.0", | ||
| "remark-gfm": "^4.0.1", | ||
| "remark-math": "^6.0.0", | ||
| "tailwind-merge": "^3.3.1" | ||
| }, | ||
| "devDependencies": { | ||
| "@tailwindcss/cli": "^4.1.10", | ||
| "@types/node": "^24.0.10", | ||
| "@types/react": "^19.1.8", | ||
| "@types/react-dom": "^19.1.6", | ||
| "@types/react-syntax-highlighter": "^15.5.13", | ||
| "@typescript-eslint/eslint-plugin": "^8.35.1", | ||
| "@typescript-eslint/parser": "^8.35.1", | ||
| "eslint": "^9.30.1", | ||
| "prettier": "^3.6.0", | ||
| "react": "19.2.1", | ||
| "react-dom": "19.2.1", | ||
| "tsdown": "0.20.0-beta.1", | ||
| "typescript": "^5.8.3" | ||
| }, | ||
| "engines": { | ||
| "node": ">=23.0.0", | ||
| "pnpm": ">=10.9.0" | ||
| }, | ||
| "keywords": [ | ||
| "react", | ||
| "components", | ||
| "notebook", | ||
| "outputs", | ||
| "runt", | ||
| "anode" | ||
| ], | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/runtimed/anode.git", | ||
| "directory": "packages/components" | ||
| }, | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "author": "Runt Team", | ||
| "license": "MIT" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import { useState } from "react"; | ||
|
|
||
| export function Incrementor() { | ||
| const [count, setCount] = useState(0); | ||
| return <button onClick={() => setCount(count + 1)}>Count is {count}</button>; | ||
| } | ||
markmiro marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.