Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

Replace JSON viewer to remove MUI and Emotion (#10865)

Myles Scolnickd82cc21222dc
diff --git a/frontend/e2e-tests/components.spec.ts b/frontend/e2e-tests/components.spec.ts
index 70bbfa5f71..9c60713e0e 100644
--- a/frontend/e2e-tests/components.spec.ts
+++ b/frontend/e2e-tests/components.spec.ts
@@ -267,6 +267,7 @@ test("table", async ({ page }) => {
await expect(element).toBeVisible();
// Click first checkbox to select all
await page.getByRole("checkbox").first().click();
+ // Compare textContent; innerText adds line breaks around viewer containers.
await expect(
helper.cell(3).locator(".marimo-json-output").first(),
).toHaveText(
@@ -281,8 +282,7 @@ test("table", async ({ page }) => {
"last_name":"Schrute"
}
]
- `.trim(),
- { useInnerText: true },
+ `.trim().replaceAll("\n", ""),
);
// Click second checkbox to remove first row
@@ -297,8 +297,7 @@ test("table", async ({ page }) => {
"last_name":"Schrute"
}
]
-`.trim(),
- { useInnerText: true },
+`.trim().replaceAll("\n", ""),
);
await takeScreenshot(page, _filename);
@@ -364,8 +363,7 @@ test.skip("complex - array", async ({ page }) => {
1:5
2:2020-01-20
]
-`.trim(),
- { useInnerText: true },
+`.trim().replaceAll("\n", ""),
);
await takeScreenshot(page, _filename);
@@ -393,8 +391,7 @@ test.skip("complex - batch", async ({ page }) => {
"name":"hi again marimo"
"date":2020-04-20
}
-`.trim(),
- { useInnerText: true },
+`.trim().replaceAll("\n", ""),
);
await takeScreenshot(page, _filename);
@@ -431,8 +428,7 @@ test("complex - dictionary", async ({ page }) => {
2:1
]
}
-`.trim(),
- { useInnerText: true },
+`.trim().replaceAll("\n", ""),
);
await takeScreenshot(page, _filename);
diff --git a/frontend/islands/vite.config.mts b/frontend/islands/vite.config.mts
index adff33819f..899f2c5572 100644
--- a/frontend/islands/vite.config.mts
+++ b/frontend/islands/vite.config.mts
@@ -79,7 +79,7 @@ export default defineConfig({
customLogger: createViteLogger(),
resolve: {
tsconfigPaths: true,
- dedupe: ["react", "react-dom", "@emotion/react", "@emotion/cache"],
+ dedupe: ["react", "react-dom"],
alias: [
// Islands run read-only and never render the slide code editor, so
// swap `SlideCellView` for a no-op stub. This keeps CodeMirror, the
diff --git a/frontend/package.json b/frontend/package.json
index 850c8f2281..d46918ba7d 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -43,8 +43,6 @@
"@dnd-kit/modifiers": "^9.0.0",
"@dnd-kit/sortable": "^10.0.0",
"@dnd-kit/utilities": "^3.2.2",
- "@emotion/cache": "^11.14.0",
- "@emotion/react": "^11.14.0",
"@glideapps/glide-data-grid": "6.0.4-alpha24",
"@hookform/resolvers": "^5.9.1",
"@img-comparison-slider/react": "^8.0.2",
@@ -62,7 +60,6 @@
"@marimo-team/marimo-api": "workspace:*",
"@marimo-team/react-slotz": "^0.2.0",
"@marimo-team/smart-cells": "workspace:*",
- "@mui/material": "^6.5.0",
"@paralleldrive/cuid2": "^2.3.1",
"@radix-ui/colors": "^3.0.0",
"@radix-ui/react-icons": "~1.3.2",
@@ -74,7 +71,6 @@
"@tailwindcss/typography": "^0.5.20",
"@tanstack/react-table": "^8.21.3",
"@tanstack/react-virtual": "^3.14.10",
- "@textea/json-viewer": "^4.0.1",
"@types/humanize-duration": "^3.27.4",
"@types/js-cookie": "^3.0.6",
"@types/jsdom": "^21.1.7",
@@ -82,6 +78,7 @@
"@uidotdev/usehooks": "^2.4.1",
"@uiw/codemirror-extensions-langs": "^4.25.11",
"@uiw/react-codemirror": "4.25.11",
+ "@uiw/react-json-view": "2.0.0-alpha.43",
"@uwdata/flechette": "^1.1.2",
"@valtown/codemirror-codeium": "^1.1.1",
"@xterm/addon-attach": "^0.12.0",
@@ -215,9 +212,9 @@
"jsdom": "^24.1.3",
"msw": "^2.15.0",
"npm-run-all2": "^6.2.6",
+ "oxc-transform-react": "0.145.0",
"oxfmt": "^0.64.0",
"oxlint": "^1.79.0",
- "oxc-transform-react": "0.145.0",
"postcss": "^8.5.26",
"postcss-prefix-selector": "^2.2.0",
"react": "^19.2.8",
diff --git a/frontend/src/components/data-table/columns.tsx b/frontend/src/components/data-table/columns.tsx
index 233030fafa..fa9105669c 100644
--- a/frontend/src/components/data-table/columns.tsx
+++ b/frontend/src/components/data-table/columns.tsx
@@ -20,7 +20,6 @@ import { Maps } from "@/utils/maps";
import { maxFractionalDigits } from "@/utils/numbers";
import { Objects } from "@/utils/objects";
import { parseContent } from "@/utils/url-parser";
-import { EmotionCacheProvider } from "../editor/output/EmotionCacheProvider";
import { JsonOutput } from "../editor/output/JsonOutput";
import { CopyClipboardIcon } from "../icons/copy-icon";
import { Button } from "../ui/button";
@@ -412,76 +411,74 @@ const PopoutColumn = ({
: rawStringValue;
return (
- <EmotionCacheProvider container={null}>
- <Popover>
- <PopoverTrigger
- ref={triggerRef}
- className={cn(cellStyles, "max-w-fit outline-hidden")}
- onClick={selectCell}
- onMouseDown={(e) => {
- // Prevent cell underneath from being selected
- e.stopPropagation();
- }}
- >
- <span
- className={cn(
- "cursor-pointer hover:text-link",
- wrapped && COLUMN_WRAPPING_STYLES,
- )}
- title={rawStringValue}
- >
- {edges ? <WhitespaceMarkers value={edges.leading} /> : null}
- {displayText}
- {edges ? <WhitespaceMarkers value={edges.trailing} /> : null}
- </span>
- </PopoverTrigger>
- <PopoverContent
+ <Popover>
+ <PopoverTrigger
+ ref={triggerRef}
+ className={cn(cellStyles, "max-w-fit outline-hidden")}
+ onClick={selectCell}
+ onMouseDown={(e) => {
+ // Prevent cell underneath from being selected
+ e.stopPropagation();
+ }}
+ >
+ <span
className={cn(
- contentClassName,
- scrollable && "flex flex-col overflow-hidden",
+ "cursor-pointer hover:text-link",
+ wrapped && COLUMN_WRAPPING_STYLES,
)}
- align="start"
- alignOffset={10}
- onInteractOutside={(event) => {
- // Radix sees the shadow host as the target. Resolve the original
- // target so pointer-down does not dismiss before click toggles.
- const target = Events.composedTarget(event.detail.originalEvent);
- if (triggerRef.current?.contains(target)) {
- event.preventDefault();
- }
- }}
+ title={rawStringValue}
>
- <div
- className={cn(
- "flex -mt-3 -mr-2",
- scrollable ? "shrink-0 justify-end" : "float-right",
- )}
- >
- <CopyClipboardIcon
- value={rawStringValue}
- className="size-3 hover:text-link"
- buttonClassName="flex size-5 items-center justify-center"
- tooltip={false}
- />
- <PopoverClose asChild={true}>
- <Button
- variant="link"
- size="xs"
- className={cn("size-5 p-0", !buttonText && "ml-1.5 mr-1")}
- aria-label="Close"
- >
- {buttonText ?? "Close"}
- </Button>
- </PopoverClose>
- </div>
- {scrollable ? (
- <div className="min-h-0 overflow-auto">{children}</div>
- ) : (
- children
+ {edges ? <WhitespaceMarkers value={edges.leading} /> : null}
+ {displayText}
+ {edges ? <WhitespaceMarkers value={edges.trailing} /> : null}
+ </span>
+ </PopoverTrigger>
+ <PopoverContent
+ className={cn(
+ contentClassName,
+ scrollable && "flex flex-col overflow-hidden",
+ )}
+ align="start"
+ alignOffset={10}
+ onInteractOutside={(event) => {
+ // Radix sees the shadow host as the target. Resolve the original
+ // target so pointer-down does not dismiss before click toggles.
+ const target = Events.composedTarget(event.detail.originalEvent);
+ if (triggerRef.current?.contains(target)) {
+ event.preventDefault();
+ }
+ }}
+ >
+ <div
+ className={cn(
+ "flex -mt-3 -mr-2",
+ scrollable ? "shrink-0 justify-end" : "float-right",
)}
- </PopoverContent>
- </Popover>
- </EmotionCacheProvider>
+ >
+ <CopyClipboardIcon
+ value={rawStringValue}
+ className="size-3 hover:text-link"
+ buttonClassName="flex size-5 items-center justify-center"
+ tooltip={false}
+ />
+ <PopoverClose asChild={true}>
+ <Button
+ variant="link"
+ size="xs"
+ className={cn("size-5 p-0", !buttonText && "ml-1.5 mr-1")}
+ aria-label="Close"
+ >
+ {buttonText ?? "Close"}
+ </Button>
+ </PopoverClose>
+ </div>
+ {scrollable ? (
+ <div className="min-h-0 overflow-auto">{children}</div>
+ ) : (
+ children
+ )}
+ </PopoverContent>
+ </Popover>
);
};
diff --git a/frontend/src/components/editor/output/EmotionCacheProvider.tsx b/frontend/src/components/editor/output/EmotionCacheProvider.tsx
deleted file mode 100644
index 9d5e8fa25e..0000000000
--- a/frontend/src/components/editor/output/EmotionCacheProvider.tsx
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright 2026 Marimo. All rights reserved. */
-
-import createCache from "@emotion/cache";
-import { CacheProvider } from "@emotion/react";
-import { type PropsWithChildren, useMemo } from "react";
-
-/**
- * Custom Emotion cache provider that works in shadow roots.
- * We don't directly use Emotion, but some of our dependencies do (via MUI).
- */
-export const EmotionCacheProvider: React.FC<
- PropsWithChildren<{ container: ShadowRoot | null }>
-> = ({ container, children }) => {
- const cache = useMemo(() => {
- if (!container) {
- return createCache({ key: "mo", prepend: true });
- }
- let emotionRoot = container.querySelector("style");
- // Create a new style element if one doesn't exist
- if (!emotionRoot) {
- emotionRoot = document.createElement("style");
- container.append(emotionRoot);
- }
- return createCache({
- key: "mo",
- prepend: true,
- container: emotionRoot,
- });
- }, [container]);
-
- return <CacheProvider value={cache}>{children}</CacheProvider>;
-};
diff --git a/frontend/src/components/editor/output/JsonOutput.tsx b/frontend/src/components/editor/output/JsonOutput.tsx
index d970926762..b6c2789138 100644
--- a/frontend/src/components/editor/output/JsonOutput.tsx
+++ b/frontend/src/components/editor/output/JsonOutput.tsx
@@ -1,656 +1,206 @@
/* Copyright 2026 Marimo. All rights reserved. */
-
+import JsonView from "@uiw/react-json-view";
import {
- booleanType,
- type DataItemProps,
- type DataType,
- defineDataType,
- floatType,
- intType,
- JsonViewer,
- type JsonViewerKeyRenderer,
- nullType,
- objectType,
- stringType,
-} from "@textea/json-viewer";
-import { CheckIcon, CopyIcon } from "lucide-react";
-import { memo, useState } from "react";
-import type { OutputMessage } from "@/core/kernel/messages";
+ type ComponentProps,
+ memo,
+ useCallback,
+ useMemo,
+ useState,
+} from "react";
+import { useEvent } from "@/hooks/useEvent";
+import { useTheme } from "@/theme/useTheme";
import { cn } from "@/utils/cn";
-import { copyToClipboard } from "@/utils/copy";
-import { jsonParseWithSpecialChar } from "@/utils/json/json-parser";
-import { isUrl } from "@/utils/urls";
-import { useTheme } from "../../../theme/useTheme";
-import { logNever } from "../../../utils/assertNever";
-import { OutputRenderer } from "../Output";
-import { HtmlOutput } from "./HtmlOutput";
-import { ImageOutput } from "./ImageOutput";
-import { VideoOutput } from "./VideoOutput";
+import { CopyClipboardIcon } from "../../icons/copy-icon";
+import { getCopyValue } from "./json-output/formatting";
+import {
+ determineMaxDisplayLength,
+ PAGE_SIZE,
+ paginateJson,
+ shouldExpandNode,
+} from "./json-output/pagination";
+import {
+ COLLAPSED_TEXT_LENGTH,
+ JSON_NULL_RENDER,
+ PYTHON_FALSE_RENDER,
+ PYTHON_NULL_RENDER,
+ PYTHON_TRUE_RENDER,
+ renderArrow,
+ renderKeyName,
+ renderKeyQuote,
+ renderStringValue,
+} from "./json-output/renderers";
+import { marimoDarkTheme, marimoLightTheme } from "./json-output/themes";
interface Props {
- /**
- * The data to display
- */
data: unknown;
-
format?: "auto" | "tree" | "raw";
-
- /**
- * A text label for the JSON viewer. If `false`, no label is used.
- */
+ /** If false, omit the root label. */
name?: string | false;
-
className?: string;
-
- /**
- * The value types to use for the JSON viewer.
- */
+ /** Python mode decodes MIME leaves and uses True/False/None. */
valueTypes?: "json" | "python";
}
-// oxlint-disable-next-line typescript/no-explicit-any
-const CopyButton: React.FC<DataItemProps<any>> = ({ value }) => {
- const skipCopy =
- typeof value === "string" &&
- (value.startsWith("text/html:") ||
- value.startsWith("image/") ||
- value.startsWith("video/"));
- const [copied, setCopied] = useState(false);
-
- const handleCopy = async (evt: React.MouseEvent) => {
- evt.stopPropagation();
- await copyToClipboard(value);
- setCopied(true);
- setTimeout(() => setCopied(false), 1000);
- };
-
- if (skipCopy) {
- return null;
- }
- return (
- <button
- onClick={handleCopy}
- className={cn(
- "inline-flex ml-2 copy-button rounded w-6 h-3 justify-center items-center relative",
- )}
- aria-label="Copy to clipboard"
- type="button"
- >
- {copied ? (
- <CheckIcon className="w-5 h-5 absolute -top-0.5 p-1 hover:bg-muted rounded" />
- ) : (
- <CopyIcon className="w-5 h-5 absolute -top-0.5 p-1 hover:bg-muted rounded" />
- )}
- </button>
- );
-};
-
-// oxlint-disable-next-line typescript/no-explicit-any
-const JSONCopyButton: React.FC<DataItemProps<any>> = (props) => {
- // if
- return <CopyButton {...props} value={JSON.stringify(props.value, null, 2)} />;
-};
-
-// oxlint-disable-next-line typescript/no-explicit-any
-const PyCopyButton: React.FC<DataItemProps<any>> = (props) => {
- return <CopyButton {...props} value={getCopyValue(props.value)} />;
-};
-
-/**
- * Output component for JSON data.
- */
-export const JsonOutput: React.FC<Props> = memo(
- ({
- data,
- format = "auto",
- name = false,
- valueTypes = "python",
- className,
- }) => {
- const { theme } = useTheme();
- if (format === "auto") {
- format = inferBestFormat(data);
- }
-
- const valueTypesMap: Record<string, typeof PYTHON_VALUE_TYPES> = {
- python: PYTHON_VALUE_TYPES,
- json: JSON_VALUE_TYPES,
- };
-
- switch (format) {
- case "tree":
- return (
- <JsonViewer
- className={cn("marimo-json-output", className)}
- rootName={name}
- theme={theme}
- displayDataTypes={false}
- value={data}
- style={{
- backgroundColor: "transparent",
- }}
- collapseStringsAfterLength={COLLAPSED_TEXT_LENGTH}
- // leave the default valueTypes as it was - 'python', only 'json' is changed
- valueTypes={valueTypesMap[valueTypes]}
- // Render dict keys that carry Python type info (e.g. `int`, `tuple`).
- // See `_key_formatter` in marimo/_output/formatters/structures.py.
- keyRenderer={valueTypes === "python" ? keyRenderer : undefined}
- // Don't group arrays, it will make the tree view look like there are nested arrays
- groupArraysAfterLength={Number.MAX_SAFE_INTEGER}
- // Built-in clipboard shifts content on hover
- // so we provide our own copy button
- enableClipboard={false}
- // Improve perf for large arrays
- maxDisplayLength={determineMaxDisplayLength(data)}
- />
- );
-
- case "raw":
- return <pre className={className}>{JSON.stringify(data, null, 2)}</pre>;
- default:
- logNever(format);
- return <pre className={className}>{JSON.stringify(data, null, 2)}</pre>;
- }
- },
-);
-JsonOutput.displayName = "JsonOutput";
-
-function inferBestFormat(data: unknown): "tree" | "raw" {
- return typeof data === "object" && data !== null ? "tree" : "raw";
-}
-
-const COLLAPSED_TEXT_LENGTH = 100;
-// Text with length > COLLAPSED_TEXT_LENGTH is collapsed by default, and can be expanded by clicking on it.
-const CollapsibleTextOutput = (props: { text: string }) => {
- const [isCollapsed, setIsCollapsed] = useState(true);
-
- // Doesn't need to be collapsed
- if (props.text.length <= COLLAPSED_TEXT_LENGTH) {
- return <span className="break-all">{props.text}</span>;
- }
-
- if (isCollapsed) {
+export const JsonOutput = memo(function JsonOutput({
+ data,
+ format = "auto",
+ ...props
+}: Props) {
+ if (format === "raw" || data === null || typeof data !== "object") {
return (
- <span
- className="cursor-pointer hover:opacity-90 break-all"
- onClick={() => setIsCollapsed(false)}
- >
- {props.text.slice(0, COLLAPSED_TEXT_LENGTH)}
- {props.text.length > COLLAPSED_TEXT_LENGTH && "..."}
- </span>
+ <pre className={props.className}>{JSON.stringify(data, null, 2)}</pre>
);
}
-
- return (
- <span
- className="cursor-pointer hover:opacity-90 break-all"
- onClick={() => setIsCollapsed(true)}
- >
- {props.text}
- </span>
- );
-};
-
-type LeafRenderer = (
- data: string,
- mimeType: OutputMessage["mimetype"],
-) => React.ReactNode;
-
-/**
- * Map from mimetype-prefix to render function.
- *
- * Render function takes leaf data as input.
- */
-const LEAF_RENDERERS: Record<string, LeafRenderer> = {
- "image/": (value) => <ImageOutput src={value} />,
- "video/": (value) => <VideoOutput src={value} />,
- "text/html:": (value) => (
- <HtmlOutput html={value} inline={true} alwaysSanitizeHtml={false} />
- ),
- "text/markdown:": (value) => (
- <HtmlOutput html={value} inline={true} alwaysSanitizeHtml={true} />
- ),
- "text/plain+float:": (value) => <span>{value}</span>,
- "text/plain+bigint:": (value) => <span>{value}</span>,
- "text/plain+set:": (value) => <span>{formatSetPayload(value)}</span>,
- "text/plain+frozenset:": (value) => (
- <span>{formatFrozensetPayload(value)}</span>
- ),
- "text/plain+tuple:": (value) => <span>{value}</span>,
- "text/plain:": (value) => <CollapsibleTextOutput text={value} />,
- "application/json:": (value) => (
- <JsonOutput data={JSON.parse(value)} format="auto" />
- ),
- "application/": (value, mimeType) => {
- return (
- <OutputRenderer
- message={{
- channel: "output",
- data: value,
- mimetype: mimeType,
- }}
- // The fallback is just re-constructing the leaf and rendering it as a span
- // This could be the case where mime-type parsing is a false positive
- renderFallback={() => (
- <span>
- {mimeType}:{value}
- </span>
- )}
- />
- );
- },
-};
-
-// oxlint-disable-next-line typescript/no-explicit-any
-const MIME_TYPES: DataType<any>[] = Object.entries(LEAF_RENDERERS).map(
- ([leafType, render]) => ({
- is: (value) => typeof value === "string" && value.startsWith(leafType),
- PostComponent: PyCopyButton,
- Component: (props) => renderLeaf(props.value, render),
- }),
-);
-
-const PYTHON_BOOLEAN_TYPE = defineDataType<boolean>({
- ...booleanType,
- PostComponent: PyCopyButton,
- Component: ({ value }) => <span>{value ? "True" : "False"}</span>,
-});
-
-const PYTHON_NONE_TYPE = defineDataType<null>({
- ...nullType,
- PostComponent: PyCopyButton,
- Component: () => <span>None</span>,
-});
-
-const JSON_BOOLEAN_TYPE = defineDataType<boolean>({
- ...booleanType,
- PostComponent: JSONCopyButton,
-});
-
-const JSON_NONE_TYPE = defineDataType<null>({
- ...nullType,
- PostComponent: JSONCopyButton,
- Component: () => <span>null</span>,
+ return <JsonTree {...props} data={data} />;
});
-const URL_TYPE = defineDataType<string>({
- ...stringType,
- is: (value) => isUrl(value),
- PostComponent: PyCopyButton,
- Component: ({ value }) => (
- <a
- href={value}
- target="_blank"
- rel="noopener noreferrer"
- className="text-link hover:underline"
- >
- {value}
- </a>
- ),
-});
-
-const INTEGER_TYPE = defineDataType<number>({
- ...intType,
- PostComponent: JSONCopyButton,
-});
-
-const FLOAT_TYPE = defineDataType<number>({
- ...floatType,
- PostComponent: JSONCopyButton,
-});
-
-const FALLBACK_RENDERER = defineDataType<string>({
- ...stringType,
- PostComponent: PyCopyButton,
-});
-
-const OBJECT_TYPE = defineDataType<object>({
- ...objectType,
- PreComponent: (props) => (
- <>
- {objectType.PreComponent && <objectType.PreComponent {...props} />}
- <PyCopyButton {...props} />
- </>
- ),
-});
-
-const JSON_OBJECT_TYPE = defineDataType<object>({
- ...objectType,
- PreComponent: (props) => (
- <>
- {objectType.PreComponent && <objectType.PreComponent {...props} />}
- <JSONCopyButton {...props} />
- </>
- ),
-});
-
-const JSON_FALLBACK_RENDERER = defineDataType<string>({
- ...stringType,
- PostComponent: JSONCopyButton,
-});
-
-const PYTHON_VALUE_TYPES = [
- INTEGER_TYPE,
- PYTHON_BOOLEAN_TYPE,
- PYTHON_NONE_TYPE,
- ...MIME_TYPES,
- URL_TYPE,
- OBJECT_TYPE,
- FALLBACK_RENDERER,
-].toReversed();
-// Last one wins, so we reverse the array.
-
-const JSON_VALUE_TYPES = [
- INTEGER_TYPE,
- FLOAT_TYPE,
- JSON_BOOLEAN_TYPE,
- JSON_NONE_TYPE,
- JSON_OBJECT_TYPE,
- JSON_FALLBACK_RENDERER,
-].toReversed();
-
-function leafData(leaf: string): string {
- return leafDataAndMimeType(leaf)[0];
-}
-
-function leafDataAndMimeType(
- leaf: string,
-): [string, OutputMessage["mimetype"] | undefined] {
- const delimIndex = leaf.indexOf(":");
- if (delimIndex === -1) {
- return [leaf, undefined];
- }
- return [
- leaf.slice(delimIndex + 1),
- leaf.slice(0, delimIndex) as OutputMessage["mimetype"],
- ];
-}
-
-/**
- * Render a leaf.
- *
- * Leaf must have the format
- *
- * <mimetype>:<data>
- *
- * where mimetype cannot contain ":".
- */
-function renderLeaf(leaf: string, render: LeafRenderer): React.ReactNode {
- const [data, mimeType] = leafDataAndMimeType(leaf);
- if (mimeType) {
- return render(data, mimeType);
- }
- return <span>{leaf}</span>;
-}
-
-// Prefix marking keys that carry encoded type information from Python.
-// See `_key_formatter` in marimo/_output/formatters/structures.py.
-const KEY_ENCODED_PREFIX = "text/plain+";
-
-// Format elements for a Python collection literal. Non-finite floats
-// (NaN / Infinity / -Infinity) parse as JS `number` via
-// `jsonParseWithSpecialChar`; `JSON.stringify` on those returns `null`,
-// so render them as the same `float(...)` literals we use for scalar
-// float keys (see `decodeKeyForCopy`).
-function formatCollectionItems(items: unknown[]): string {
- return items
- .map((x) => {
- if (typeof x === "number" && !Number.isFinite(x)) {
- if (Number.isNaN(x)) {
- return "float('nan')";
- }
- return x > 0 ? "float('inf')" : "-float('inf')";
+type TreeProps = Omit<Props, "data" | "format"> & { data: object };
+type RowRenderer = NonNullable<
+ ComponentProps<typeof JsonView.Row<"div">>["render"]
+>;
+type CountRenderer = NonNullable<
+ ComponentProps<typeof JsonView.CountInfo<"span">>["render"]
+>;
+
+function JsonTree({
+ data,
+ name = false,
+ valueTypes = "python",
+ className,
+}: TreeProps) {
+ const { theme } = useTheme();
+ const isPython = valueTypes === "python";
+ const pageSize = determineMaxDisplayLength(data) ?? PAGE_SIZE;
+ const [pagination, setPagination] = useState<{
+ data: object;
+ limits: Record<string, number>;
+ }>({ data, limits: {} });
+ if (pagination.data !== data) {
+ setPagination({ data, limits: {} });
+ }
+ const { limits } = pagination;
+ const tree = useMemo(
+ () => paginateJson(data, { limits, pageSize }),
+ [data, limits, pageSize],
+ );
+ const showMore = useEvent((path: string) => {
+ setPagination((prev) => ({
+ ...prev,
+ limits: {
+ ...prev.limits,
+ [path]: (prev.limits[path] ?? pageSize) + pageSize,
+ },
+ }));
+ });
+
+ // Render callbacks need current render state; useEvent reads committed state.
+ const renderCopyButton = useCallback(
+ (value: unknown) => {
+ if (
+ isPython &&
+ typeof value === "string" &&
+ /^(text\/html:|image\/|video\/)/.test(value)
+ ) {
+ return null;
}
- return JSON.stringify(x);
- })
- .join(", ");
-}
-
-// Format a JSON-list payload as a Python tuple literal. 1-element tuples
-// need a trailing comma — `(1)` is just `1` in Python, `(1,)` is the tuple.
-// Uses `jsonParseWithSpecialChar` so bare `NaN`/`Infinity`/`-Infinity`
-// emitted by Python's json.dumps round-trip cleanly.
-function formatTuplePayload(jsonList: string): string {
- const items = jsonParseWithSpecialChar<unknown[]>(jsonList);
- // `jsonParseWithSpecialChar` returns `{}` when both parse passes fail;
- // fall back to the raw payload so a malformed wire form doesn't crash
- // rendering/copy. Matches the defensive pattern in `formatSetPayload`.
- if (!Array.isArray(items)) {
- return jsonList;
- }
- if (items.length === 0) {
- return "()";
- }
- const inner = formatCollectionItems(items);
- if (items.length === 1) {
- return `(${inner},)`;
- }
- return `(${inner})`;
-}
-
-// Format a JSON-list payload as a Python frozenset literal. Empty → `frozenset()`
-// rather than `frozenset({})` (which reads like a dict).
-function formatFrozensetPayload(jsonList: string): string {
- const items = jsonParseWithSpecialChar<unknown[]>(jsonList);
- if (!Array.isArray(items)) {
- return jsonList;
- }
- if (items.length === 0) {
- return "frozenset()";
- }
- const inner = formatCollectionItems(items);
- return `frozenset({${inner}})`;
-}
-
-// Format a JSON-list payload as a Python set literal. Empty → `set()`
-// (not `{}`, which is a dict literal in Python).
-function formatSetPayload(jsonList: string): string {
- const items = jsonParseWithSpecialChar<unknown[]>(jsonList);
- if (!Array.isArray(items)) {
- // Back-compat: older wire form was `text/plain+set:{1, 2, 3}` (Python
- // set-literal string, not JSON). Pass it through as-is rather than crash.
- return jsonList;
- }
- if (items.length === 0) {
- return "set()";
- }
- const inner = formatCollectionItems(items);
- return `{${inner}}`;
-}
-
-// Renderers for decoded non-string keys. Visual affordances match Python:
-// unquoted primitives, parens for tuple, `frozenset({...})` for frozenset,
-// and the `text/plain+str:` escape re-quotes the original string.
-const KEY_DECODERS: Record<string, (data: string) => React.ReactNode> = {
- "text/plain+int:": (v) => <span>{v}</span>,
- "text/plain+float:": (v) => <span>{v}</span>,
- "text/plain+bool:": (v) => <span>{v === "True" ? "True" : "False"}</span>,
- "text/plain+none:": () => <span>None</span>,
- "text/plain+tuple:": (v) => <span>{formatTuplePayload(v)}</span>,
- "text/plain+frozenset:": (v) => <span>{formatFrozensetPayload(v)}</span>,
- "text/plain+str:": (v) => <span>"{v}"</span>,
-};
-
-function isEncodedKey(key: unknown): key is string {
- return typeof key === "string" && key.startsWith(KEY_ENCODED_PREFIX);
-}
-
-// `@textea/json-viewer` drops quotes from integer-like string keys, which
-// makes the string `"2"` visually identical to the decoded int `2`. Match
-// the same keys the viewer strips and render them with explicit quotes.
-const INT_LIKE_STRING = /^-?\d+$/;
-
-const keyRenderer: JsonViewerKeyRenderer = Object.assign(
- ({ path }: DataItemProps) => {
- const key = path[path.length - 1];
- if (typeof key !== "string") {
- return <span>{String(key)}</span>;
- }
- if (isEncodedKey(key)) {
- const [data, mimeType] = leafDataAndMimeType(key);
- const render = KEY_DECODERS[`${mimeType}:`];
- return render ? render(data) : <span>{key}</span>;
- }
- // Plain integer-like string — quote it so it's distinct from a decoded int.
- return <span>"{key}"</span>;
- },
- {
- when: ({ path }: DataItemProps) => {
- const key = path[path.length - 1];
return (
- isEncodedKey(key) ||
- (typeof key === "string" && INT_LIKE_STRING.test(key))
+ <CopyClipboardIcon
+ value={() =>
+ isPython
+ ? getCopyValue(tree.getOriginal(value))
+ : JSON.stringify(tree.getOriginal(value), null, 2)
+ }
+ tooltip={false}
+ buttonClassName="inline-flex ml-2 copy-button rounded w-6 h-3 justify-center items-center relative"
+ className="w-5 h-5 absolute -top-0.5 p-1 hover:bg-muted rounded"
+ />
);
},
- },
-);
-
-const MIME_PREFIXES = Object.keys(LEAF_RENDERERS);
-const REPLACE_PREFIX = "<marimo-replace>";
-const REPLACE_SUFFIX = "</marimo-replace>";
-/**
- * Get the string representation (as Python) of a value.
- * - recursively handles lists and dictionaries
- * - trims mimetype prefix
- * - maps booleans to True and False
- * - maps null/undefined to None
- */
-function pythonJsonReplacer(_key: string, value: unknown): unknown {
- if (value == null) {
- return `${REPLACE_PREFIX}None${REPLACE_SUFFIX}`;
- }
- if (typeof value === "object") {
- return value;
- }
- if (typeof value === "bigint") {
- return `${REPLACE_PREFIX}${value}${REPLACE_SUFFIX}`;
- }
- if (Array.isArray(value)) {
- return value;
- }
- if (typeof value === "string") {
- // If float, we want to keep the quotes around the number.
- if (value.startsWith("text/plain+float:")) {
- return `${REPLACE_PREFIX}${leafData(value)}${REPLACE_SUFFIX}`;
- }
- if (value.startsWith("text/plain+bigint:")) {
- // Use BigInt to avoid precision loss
- const number = BigInt(leafData(value));
- return `${REPLACE_PREFIX}${number}${REPLACE_SUFFIX}`;
- }
- if (value.startsWith("text/plain+tuple:")) {
- // replace first and last characters [] with ()
- return `${REPLACE_PREFIX}(${leafData(value).slice(1, -1)})${REPLACE_SUFFIX}`;
- }
- if (value.startsWith("text/plain+set:")) {
- return `${REPLACE_PREFIX}${formatSetPayload(leafData(value))}${REPLACE_SUFFIX}`;
- }
- if (value.startsWith("text/plain+frozenset:")) {
- return `${REPLACE_PREFIX}${formatFrozensetPayload(leafData(value))}${REPLACE_SUFFIX}`;
- }
-
- if (MIME_PREFIXES.some((prefix) => value.startsWith(prefix))) {
- return leafData(value);
- }
- return value;
- }
- if (typeof value === "boolean") {
- return `${REPLACE_PREFIX}${value ? "True" : "False"}${REPLACE_SUFFIX}`;
- }
- return value;
-}
-
-// Rewrite an encoded key string into the Python literal that should appear
-// unquoted in the copy output. Wrapping in REPLACE_PREFIX/SUFFIX makes the
-// final regex pass strip the surrounding JSON quotes.
-function decodeKeyForCopy(key: string): string {
- const [data, mimeType] = leafDataAndMimeType(key);
- const wrap = (s: string) => `${REPLACE_PREFIX}${s}${REPLACE_SUFFIX}`;
- switch (`${mimeType}:`) {
- case "text/plain+int:":
- return wrap(data);
- case "text/plain+float:":
- if (data === "nan") {
- return wrap("float('nan')");
- }
- if (data === "inf") {
- return wrap("float('inf')");
- }
- if (data === "-inf") {
- return wrap("-float('inf')");
- }
- return wrap(data);
- case "text/plain+bool:":
- return wrap(data === "True" ? "True" : "False");
- case "text/plain+none:":
- return wrap("None");
- case "text/plain+tuple:":
- return wrap(formatTuplePayload(data));
- case "text/plain+frozenset:":
- return wrap(formatFrozensetPayload(data));
- case "text/plain+str:":
- // `data` is the original Python string; it stays quoted.
- return data;
- default:
- return key;
- }
-}
-
-function rewriteEncodedKeys(value: unknown): unknown {
- if (Array.isArray(value)) {
- return value.map(rewriteEncodedKeys);
- }
- if (typeof value === "object" && value !== null) {
- const out: Record<string, unknown> = {};
- for (const [k, v] of Object.entries(value)) {
- const newKey = isEncodedKey(k) ? decodeKeyForCopy(k) : k;
- out[newKey] = rewriteEncodedKeys(v);
- }
- return out;
- }
- return value;
-}
-
-export function getCopyValue(value: unknown): string {
- // Because this results in valid json, it adds quotes around None and True/False.
- // but we want to make this look like Python, so we remove the quotes.
- return JSON.stringify(rewriteEncodedKeys(value), pythonJsonReplacer, 2)
- .replaceAll(`"${REPLACE_PREFIX}`, "")
- .replaceAll(`${REPLACE_SUFFIX}"`, "");
-}
-
-/**
- * Determine the max display length for a given data.
- * - For 3D arrays, we return 5
- * - For 2D arrays, return undefined <= 20 items, 10 >= 20 items, 5 >= 50 items
- * - For 1D arrays and other types, we return undefined
- *
- * @param data - The data to determine the max display length for.
- * @returns The max display length, or undefined to use the default.
- */
-export function determineMaxDisplayLength(data: unknown): number | undefined {
- if (Array.isArray(data)) {
- const sampleElements = data.slice(0, 15);
-
- let maxLength = 0;
- for (const element of sampleElements) {
- if (Array.isArray(element)) {
- // Check for 3D arrays and return early
- const nextSample = element.slice(0, 5);
- for (const nextElement of nextSample) {
- if (Array.isArray(nextElement)) {
- return 5;
- }
- }
-
- maxLength = Math.max(maxLength, element.length);
- }
- }
+ [isPython, tree],
+ );
- if (maxLength <= 20) {
- return undefined;
- }
+ const renderString = useCallback(
+ (
+ props: Record<string, unknown>,
+ result: { type: string; value?: unknown },
+ ) => renderStringValue(props, result, valueTypes),
+ [valueTypes],
+ );
+ const renderRow = useCallback<RowRenderer>(
+ (props, { value }) => {
+ const page = tree.getPage(value);
+ return (
+ <div {...props}>
+ {page ? (
+ <button
+ type="button"
+ className="cursor-pointer text-link hover:underline"
+ onClick={(event) => {
+ event.stopPropagation();
+ showMore(page.path);
+ }}
+ >
+ ... {page.remaining} more items
+ </button>
+ ) : (
+ <>
+ {props.children}
+ {renderCopyButton(value)}
+ </>
+ )}
+ </div>
+ );
+ },
+ [tree, showMore, renderCopyButton],
+ );
+ const renderCount = useCallback<CountRenderer>(
+ (props, { value }) => {
+ const original = tree.getOriginal(value);
+ const count = Array.isArray(original)
+ ? original.length
+ : original && typeof original === "object"
+ ? Object.keys(original).length
+ : 0;
+ return (
+ <span {...props}>
+ {count} {count === 1 ? "Item" : "Items"}
+ </span>
+ );
+ },
+ [tree],
+ );
+ const renderContainerCopy = useCallback(
+ (_props: Record<string, unknown>, { value }: { value?: unknown }) =>
+ renderCopyButton(value),
+ [renderCopyButton],
+ );
- return maxLength >= 50 ? 5 : 10;
- }
+ return (
+ <JsonView
+ className={cn("marimo-json-output", className)}
+ keyName={name || undefined}
+ value={tree.data}
+ style={theme === "dark" ? marimoDarkTheme : marimoLightTheme}
+ displayDataTypes={false}
+ enableClipboard={false}
+ highlightUpdates={false}
+ shortenTextAfterLength={COLLAPSED_TEXT_LENGTH}
+ collapsed={false}
+ shouldExpandNodeInitially={shouldExpandNode}
+ >
+ <JsonView.String render={renderString} />
+ <JsonView.Colon style={{ marginRight: 4 }} />
+ <JsonView.Arrow render={renderArrow} />
+ <JsonView.CountInfo<"span"> render={renderCount} />
+ <JsonView.KeyName render={isPython ? renderKeyName : undefined} />
+ <JsonView.Quote render={isPython ? renderKeyQuote : undefined} />
+ <JsonView.True render={isPython ? PYTHON_TRUE_RENDER : undefined} />
+ <JsonView.False render={isPython ? PYTHON_FALSE_RENDER : undefined} />
+ <JsonView.Null
+ render={isPython ? PYTHON_NULL_RENDER : JSON_NULL_RENDER}
+ />
+ <JsonView.Row<"div"> render={renderRow} />
+ <JsonView.CountInfoExtra render={renderContainerCopy} />
+ </JsonView>
+ );
}
diff --git a/frontend/src/components/editor/output/Outputs.css b/frontend/src/components/editor/output/Outputs.css
index baca7de111..d708e57560 100644
--- a/frontend/src/components/editor/output/Outputs.css
+++ b/frontend/src/components/editor/output/Outputs.css
@@ -20,15 +20,13 @@
@apply text-link;
}
-.output {
- position: relative;
-}
-
.output > * {
max-width: 100%;
}
.output {
+ position: relative;
+
/* Unset max-width on .markdown. Instead, we will apply
to individual elements so it does not affect UI elements in markdown. */
.markdown {
@@ -65,31 +63,65 @@
.marimo-json-output {
padding-top: 2px;
padding-bottom: 2px;
- /* content-visibility is set by material UI;
- * when set on an element that has overflow auto, causes abrupt jumps when
- * scrolling in Chrome */
- content-visibility: unset;
- /* Coarse hack to stop children from overflowing; doesn't seem to affect
- * margin collapse. */
overflow: auto;
overscroll-behavior: contain;
@apply text-xs;
- .data-key-pair:not(:last-child) {
+ .w-rjv-wrap > :not(:last-child) {
margin-top: 0.2rem;
margin-bottom: 0.2rem;
}
- .copy-button {
- @apply invisible;
+ .w-rjv-wrap {
+ padding-left: 0.9rem !important;
+ margin-left: 0.3rem !important;
+ }
+
+ .w-rjv-line > span:first-child,
+ .w-rjv-colon,
+ .w-rjv-inner > span,
+ &.w-rjv-inner > span {
+ opacity: 0.8;
+ letter-spacing: 0.03125rem;
+ line-height: 1.5;
+ }
+
+ .w-rjv-inner > div:last-child:not(.w-rjv-wrap),
+ &.w-rjv-inner > div:last-child:not(.w-rjv-wrap) {
+ line-height: 1.5;
+ padding-left: 0 !important;
+ }
+
+ .w-rjv-line > button:only-child {
+ line-height: 1.5;
+ }
+
+ .w-rjv-arrow {
+ transition: transform 0.3s !important;
}
- .data-key-pair:hover > .copy-button {
- @apply visible;
+ @media (prefers-reduced-motion: reduce) {
+ .w-rjv-arrow {
+ transition: none !important;
+ }
+ }
+
+ .w-rjv-object-size {
+ padding-left: 4px !important;
+ }
+
+ .copy-button {
+ opacity: 0;
}
- .data-key-pair:hover > .data-key > .copy-button {
- @apply visible;
+ .copy-button:focus-visible,
+ .w-rjv-line:hover > .copy-button,
+ .w-rjv-inner:hover > span > .copy-button,
+ /* Root element has both .marimo-json-output and .w-rjv-inner on the same node */
+ &.w-rjv-inner:hover
+ > span
+ > .copy-button {
+ opacity: 1;
}
}
diff --git a/frontend/src/components/editor/output/__tests__/JsonOutput-interactions.test.tsx b/frontend/src/components/editor/output/__tests__/JsonOutput-interactions.test.tsx
new file mode 100644
index 0000000000..63976dbd2e
--- /dev/null
+++ b/frontend/src/components/editor/output/__tests__/JsonOutput-interactions.test.tsx
@@ -0,0 +1,254 @@
+/* Copyright 2026 Marimo. All rights reserved. */
+import { fireEvent, render, waitFor } from "@testing-library/react";
+import { describe, expect, it, vi } from "vitest";
+import { copyToClipboard } from "@/utils/copy";
+import { JsonOutput } from "../JsonOutput";
+
+vi.mock("@/utils/copy", () => ({
+ copyToClipboard: vi.fn().mockResolvedValue(undefined),
+}));
+
+describe("JsonOutput interactions", () => {
+ it("copies all descendants of a paginated parent and shows the real size", async () => {
+ const data = { rows: Array.from({ length: 120 }, (_, i) => i) };
+ const { getAllByRole, getByText } = render(
+ <JsonOutput data={data} valueTypes="json" />,
+ );
+ expect(getByText("120 Items")).toBeInTheDocument();
+ fireEvent.click(getAllByRole("button", { name: "Copy to clipboard" })[0]);
+ await waitFor(() =>
+ expect(copyToClipboard).toHaveBeenLastCalledWith(
+ JSON.stringify(data, null, 2),
+ ),
+ );
+ });
+
+ it("paginates independently and resets when the data changes", () => {
+ const values = Array.from({ length: 70 }, (_, i) => i);
+ const { getAllByRole, queryByRole, rerender } = render(
+ <JsonOutput data={{ "a.b": values, a: { b: values } }} />,
+ );
+ fireEvent.click(getAllByRole("button", { name: "... 40 more items" })[0]);
+ expect(getAllByRole("button", { name: "... 40 more items" })).toHaveLength(
+ 1,
+ );
+ expect(
+ queryByRole("button", { name: "... 10 more items" }),
+ ).toBeInTheDocument();
+ rerender(<JsonOutput data={{ "a.b": values, a: { b: values } }} />);
+ expect(
+ queryByRole("button", { name: "... 10 more items" }),
+ ).not.toBeInTheDocument();
+ expect(getAllByRole("button", { name: "... 40 more items" })).toHaveLength(
+ 2,
+ );
+ });
+
+ it("exposes expansion controls and long text as buttons", () => {
+ const text = "a".repeat(150);
+ const { getByRole, getAllByRole, queryByText } = render(
+ <JsonOutput data={{ text, plain: `text/plain:${text}` }} />,
+ );
+ const root = getByRole("button", { name: "Collapse root" });
+ expect(root).toHaveAttribute("aria-expanded", "true");
+ fireEvent.click(root);
+ expect(queryByText("plain")).not.toBeInTheDocument();
+ const collapsedRoot = getByRole("button", { name: "Expand root" });
+ expect(collapsedRoot).toHaveAttribute("aria-expanded", "false");
+ fireEvent.click(collapsedRoot);
+ expect(getByRole("button", { name: "Collapse root" })).toHaveAttribute(
+ "aria-expanded",
+ "true",
+ );
+ expect(queryByText("plain")).toBeInTheDocument();
+ const buttons = getAllByRole("button", { name: `${"a".repeat(100)}...` });
+ expect(buttons).toHaveLength(2);
+ fireEvent.keyDown(buttons[0], { key: "Enter" });
+ expect(buttons[0]).toHaveAttribute("aria-expanded", "true");
+ fireEvent.keyDown(buttons[0], { key: " " });
+ expect(buttons[0]).toHaveAttribute("aria-expanded", "false");
+ });
+ it("initially collapses containers below the fifth level", () => {
+ const data = {
+ one: { two: { three: { four: { five: { leaf: "value" } } } } },
+ };
+ const { getByRole, queryByText, getByText } = render(
+ <JsonOutput data={data} />,
+ );
+ expect(queryByText("leaf")).not.toBeInTheDocument();
+ const collapsed = getByRole("button", { name: "Expand five" });
+ expect(collapsed).toHaveAttribute("aria-expanded", "false");
+ fireEvent.click(collapsed);
+ expect(getByText("leaf")).toBeInTheDocument();
+ const expanded = getByRole("button", { name: "Collapse five" });
+ expect(expanded).toHaveAttribute("aria-expanded", "true");
+ fireEvent.click(expanded);
+ expect(queryByText("leaf")).not.toBeInTheDocument();
+ expect(getByRole("button", { name: "Expand five" })).toHaveAttribute(
+ "aria-expanded",
+ "false",
+ );
+ });
+ it.each([null, undefined, true, 42, Number.NaN, "text"])(
+ "renders scalar %j without tree state",
+ (data) => {
+ const { container } = render(<JsonOutput data={data} />);
+ expect(container.textContent).toBe(JSON.stringify(data) ?? "");
+ expect(container.querySelector(".marimo-json-output")).toBeNull();
+ },
+ );
+
+ it("updates Python and JSON renderers when the mode changes", () => {
+ const data = {
+ yes: true,
+ no: false,
+ none: null,
+ "text/plain+int:2": "value",
+ };
+ const { container, rerender } = render(<JsonOutput data={data} />);
+ expect(container.textContent).toContain("True");
+ expect(container.textContent).not.toContain("text/plain+int:2");
+ rerender(<JsonOutput data={data} valueTypes="json" />);
+ expect(container.textContent).toContain("true");
+ expect(container.textContent).toContain("false");
+ expect(container.textContent).toContain("null");
+ expect(container.textContent).not.toContain("True");
+ expect(container.textContent).toContain('"text/plain+int:2"');
+ rerender(<JsonOutput data={data} valueTypes="python" />);
+ expect(container.textContent).toContain("True");
+ expect(container.textContent).not.toContain("text/plain+int:2");
+ });
+
+ it.each(["python", "json"] as const)(
+ "copies marker-like user strings in %s mode",
+ async (valueTypes) => {
+ const data = {
+ marker: "\u0000show_more\u000042|$",
+ replacement: "<marimo-replace>None</marimo-replace>",
+ };
+ const { getAllByRole } = render(
+ <JsonOutput data={data} valueTypes={valueTypes} />,
+ );
+ expect(
+ getAllByRole("button", { name: "Copy to clipboard" }),
+ ).toHaveLength(3);
+ fireEvent.click(getAllByRole("button", { name: "Copy to clipboard" })[0]);
+ await waitFor(() =>
+ expect(copyToClipboard).toHaveBeenLastCalledWith(
+ JSON.stringify(data, null, 2),
+ ),
+ );
+ },
+ );
+
+ it("paginates arrays after expanding beyond the former depth cutoff", () => {
+ const data = {
+ a: {
+ b: {
+ c: {
+ d: { e: { f: { rows: Array.from({ length: 100 }, (_, i) => i) } } },
+ },
+ },
+ },
+ };
+ const { getByRole, getByText, queryByRole } = render(
+ <JsonOutput data={data} />,
+ );
+ for (const name of ["e", "f", "rows"]) {
+ fireEvent.click(getByRole("button", { name: `Expand ${name}` }));
+ }
+ expect(getByText("100 Items")).toBeInTheDocument();
+ fireEvent.click(getByRole("button", { name: "... 70 more items" }));
+ expect(
+ getByRole("button", { name: "... 40 more items" }),
+ ).toBeInTheDocument();
+ expect(
+ queryByRole("button", { name: "... 70 more items" }),
+ ).not.toBeInTheDocument();
+ });
+});
+
+describe("JsonOutput interaction regressions", () => {
+ it("removes the page control after the last page without collapsing the tree", () => {
+ const data = Array.from({ length: 31 }, (_, i) => i);
+ const { getByRole, queryByRole, getByText } = render(
+ <JsonOutput data={data} />,
+ );
+ fireEvent.click(getByRole("button", { name: "... 1 more items" }));
+ expect(
+ queryByRole("button", { name: /more items/ }),
+ ).not.toBeInTheDocument();
+ expect(getByRole("button", { name: "Collapse root" })).toBeInTheDocument();
+ expect(getByText("31 Items")).toBeInTheDocument();
+ });
+
+ it("does not reuse a previous dataset's page size", () => {
+ const matrix = Array.from({ length: 10 }, () =>
+ Array.from({ length: 60 }, (_, i) => i),
+ );
+ const { rerender, getByRole, queryByRole } = render(
+ <JsonOutput data={matrix} />,
+ );
+ const data = Array.from({ length: 70 }, (_, i) => i);
+ rerender(<JsonOutput data={data} />);
+ fireEvent.click(getByRole("button", { name: "... 40 more items" }));
+ expect(
+ getByRole("button", { name: "... 10 more items" }),
+ ).toBeInTheDocument();
+ expect(
+ queryByRole("button", { name: "... 35 more items" }),
+ ).not.toBeInTheDocument();
+ });
+
+ it("does not copy stale data or use the previous display mode", async () => {
+ const { rerender, getAllByRole, getByRole } = render(
+ <JsonOutput data={{ old: true }} />,
+ );
+ const data = { fresh: false, text: "text/plain:literal" };
+ rerender(<JsonOutput data={data} valueTypes="json" />);
+ fireEvent.click(getAllByRole("button", { name: "Copy to clipboard" })[0]);
+ await waitFor(() =>
+ expect(copyToClipboard).toHaveBeenLastCalledWith(
+ JSON.stringify(data, null, 2),
+ ),
+ );
+ expect(getByRole("button", { name: "Collapse root" })).toBeInTheDocument();
+ rerender(<JsonOutput data={data} valueTypes="python" />);
+ fireEvent.click(getAllByRole("button", { name: "Copy to clipboard" })[0]);
+ await waitFor(() =>
+ expect(copyToClipboard).toHaveBeenLastCalledWith(
+ '{\n "fresh": False,\n "text": "literal"\n}',
+ ),
+ );
+ });
+
+ it("does not retain decoded MIME text after switching to JSON", () => {
+ const data = {
+ tuple: "text/plain+tuple:[42]",
+ html: "text/html:<b>rich</b>",
+ };
+ const { container, rerender, getAllByRole } = render(
+ <JsonOutput data={data} />,
+ );
+ expect(container.querySelector("b")).toHaveTextContent("rich");
+ expect(getAllByRole("button", { name: "Copy to clipboard" })).toHaveLength(
+ 2,
+ );
+ rerender(<JsonOutput data={data} valueTypes="json" />);
+ expect(container.querySelector("b")).toBeNull();
+ expect(container.textContent).toContain('"tuple":"text/plain+tuple:[42]"');
+ expect(container.textContent).toContain('"html":"text/html:<b>rich</b>"');
+ expect(getAllByRole("button", { name: "Copy to clipboard" })).toHaveLength(
+ 3,
+ );
+ });
+
+ it("ignores unrelated keys on long-text controls", () => {
+ const text = "x".repeat(150);
+ const { getByRole } = render(<JsonOutput data={{ text }} />);
+ const button = getByRole("button", { name: `${"x".repeat(100)}...` });
+ fireEvent.keyDown(button, { key: "Escape" });
+ fireEvent.keyDown(button, { key: "ArrowDown" });
+ expect(button).toHaveAttribute("aria-expanded", "false");
+ });
+});
diff --git a/frontend/src/components/editor/output/__tests__/JsonOutput-mimetype.test.tsx b/frontend/src/components/editor/output/__tests__/JsonOutput-mimetype.test.tsx
index a4b407111f..7fa6675477 100644
--- a/frontend/src/components/editor/output/__tests__/JsonOutput-mimetype.test.tsx
+++ b/frontend/src/components/editor/output/__tests__/JsonOutput-mimetype.test.tsx
@@ -1,27 +1,10 @@
/* Copyright 2026 Marimo. All rights reserved. */
import { render } from "@testing-library/react";
-import { beforeAll, describe, expect, it, vi } from "vitest";
+import { describe, expect, it } from "vitest";
import { JsonOutput } from "../JsonOutput";
-// Mock window.matchMedia for JsonViewer
-beforeAll(() => {
- Object.defineProperty(window, "matchMedia", {
- writable: true,
- value: vi.fn().mockImplementation((query) => ({
- matches: false,
- media: query,
- onchange: null,
- addListener: vi.fn(),
- removeListener: vi.fn(),
- addEventListener: vi.fn(),
- removeEventListener: vi.fn(),
- dispatchEvent: vi.fn(),
- })),
- });
-});
-
-describe("JsonOutput with enhanced mimetype handling", () => {
- it("should render data with various mimetypes without crashing", () => {
+describe("JsonOutput MIME rendering", () => {
+ it("renders text, rich content, and Python collections", () => {
const data = {
text: "text/plain:Hello",
html: "text/html:<strong>Bold</strong>",
@@ -35,16 +18,42 @@ describe("JsonOutput with enhanced mimetype handling", () => {
const { container } = render(<JsonOutput data={data} format="auto" />);
- // Verify component renders without crashing
- expect(container).toBeInTheDocument();
- expect(container.querySelector(".marimo-json-output")).toBeInTheDocument();
+ expect(container.textContent).toContain('"text":Hello');
+ expect(container.querySelector("strong")).toHaveTextContent("Bold");
+ expect(container.querySelector("img")).toHaveAttribute(
+ "src",
+ "data:image/png;base64,xyz...",
+ );
+ expect(container.textContent).toContain('"set":{1, 2, 3}');
+ expect(container.textContent).toContain('"tuple":(10, 20)');
+ expect(container.textContent).toContain("application/custom:data");
+ expect(container.textContent).toContain('"boolean":True');
+ });
+
+ it("keeps MIME strings literal in JSON mode", () => {
+ const { container } = render(
+ <JsonOutput
+ data={{ value: "text/plain+tuple:[42]" }}
+ valueTypes="json"
+ />,
+ );
+ expect(container.textContent).toContain('"value":"text/plain+tuple:[42]"');
+ });
+
+ it("renders singleton tuples and escaped collection strings", () => {
+ const { container } = render(
+ <JsonOutput
+ data={{
+ tuple: "text/plain+tuple:[42]",
+ set: 'text/plain+set:["text/plain:literal"]',
+ }}
+ />,
+ );
+ expect(container.textContent).toContain('"tuple":(42,)');
+ expect(container.textContent).toContain('"set":{"text/plain:literal"}');
});
it("renders encoded non-string keys with Python-style affordances", () => {
- // Server-side `_key_formatter` encodes non-string dict keys with
- // mimetype prefixes; the frontend `keyRenderer` must decode them
- // so users see the original Python types (unquoted ints, parens for
- // tuples, etc.) instead of the raw encoded strings.
const data = {
"text/plain+int:2": "int_val",
"text/plain+float:2.5": "float_val",
@@ -59,34 +68,23 @@ describe("JsonOutput with enhanced mimetype handling", () => {
const { container } = render(<JsonOutput data={data} format="tree" />);
const text = container.textContent ?? "";
- // `text/plain+str:` is the escape prefix — must never survive in output.
expect(text).not.toContain("text/plain+str:");
- // Other encoded prefixes must not leak as-is. (They can still appear
- // inside the unescaped original string key `"text/plain+int:2"`,
- // which is intentional — but not for types *other* than int.)
expect(text).not.toContain("text/plain+bool:True");
expect(text).not.toContain("text/plain+tuple:[");
expect(text).not.toContain("text/plain+frozenset:[");
expect(text).not.toContain("text/plain+none:");
- // Decoded visual forms are present with Python-style affordances.
expect(text).toContain('None:"none_val"');
expect(text).toContain('True:"bool_val"');
expect(text).toContain('2:"int_val"');
expect(text).toContain('2.5:"float_val"');
expect(text).toContain('(1, 2):"tuple_val"');
expect(text).toContain('frozenset({3, 4}):"fs_val"');
- // Escaped str key renders as the original literal string (quoted).
expect(text).toContain('"text/plain+int:2":"escaped_str_val"');
- // Plain string key unchanged.
expect(text).toContain('"plain":"unchanged"');
});
it("renders 1-tuple and empty-frozenset keys with correct Python syntax", () => {
- // Regressions caught in review: `(1)` is not a tuple (needs `(1,)`),
- // and `frozenset({})` reads like constructing from an empty dict
- // (should be `frozenset()`). Locks in the tree-view rendering so these
- // don't slip back.
const data = {
"text/plain+tuple:[42]": "one_tuple",
"text/plain+tuple:[]": "empty_tuple",
@@ -97,15 +95,13 @@ describe("JsonOutput with enhanced mimetype handling", () => {
const { container } = render(<JsonOutput data={data} format="tree" />);
const text = container.textContent ?? "";
- expect(text).toContain('(42,):"one_tuple"'); // trailing comma
+ expect(text).toContain('(42,):"one_tuple"');
expect(text).toContain('():"empty_tuple"');
- expect(text).toContain('frozenset():"empty_fs"'); // not `frozenset({})`
+ expect(text).toContain('frozenset():"empty_fs"');
expect(text).toContain('frozenset({1}):"one_fs"');
});
it("quotes integer-like string keys to distinguish them from int keys", () => {
- // Without this, `"2"` and the decoded int `2` look identical — the
- // textea viewer drops quotes from integer-like string keys by default.
const data = {
"2": "string_two",
"text/plain+int:2": "int_two",
@@ -114,9 +110,8 @@ describe("JsonOutput with enhanced mimetype handling", () => {
const { container } = render(<JsonOutput data={data} format="tree" />);
const text = container.textContent ?? "";
- expect(text).toContain('"2":"string_two"'); // quoted
- expect(text).toContain('2:"int_two"'); // unquoted
- // Non-integer string keys still render without our intervention.
- expect(text).not.toContain("text/plain+"); // prefix stripped from int key
+ expect(text).toContain('"2":"string_two"');
+ expect(text).toContain('2:"int_two"');
+ expect(text).not.toContain("text/plain+");
});
});
diff --git a/frontend/src/components/editor/output/__tests__/json-output.test.ts b/frontend/src/components/editor/output/__tests__/json-output-formatting.test.ts
similarity index 74%
rename from frontend/src/components/editor/output/__tests__/json-output.test.ts
rename to frontend/src/components/editor/output/__tests__/json-output-formatting.test.ts
index 2d61e57822..f8dd019299 100644
--- a/frontend/src/components/editor/output/__tests__/json-output.test.ts
+++ b/frontend/src/components/editor/output/__tests__/json-output-formatting.test.ts
@@ -1,6 +1,6 @@
/* Copyright 2026 Marimo. All rights reserved. */
import { describe, expect, it } from "vitest";
-import { determineMaxDisplayLength, getCopyValue } from "../JsonOutput";
+import { getCopyValue } from "../json-output/formatting";
describe("getCopyValue", () => {
it("should handle strings without MIME prefixes", () => {
@@ -178,7 +178,6 @@ describe("getCopyValue", () => {
});
it("should handle empty set", () => {
- // Empty set literal in Python is `set()`, not `{}` (which is a dict).
expect(getCopyValue("text/plain+set:[]")).toMatchInlineSnapshot(`"set()"`);
});
@@ -212,7 +211,7 @@ describe("getCopyValue", () => {
it("should handle tuples", () => {
const value = "text/plain+tuple:[1,2,3]";
const result = getCopyValue(value);
- expect(result).toMatchInlineSnapshot(`"(1,2,3)"`);
+ expect(result).toMatchInlineSnapshot(`"(1, 2, 3)"`);
});
it("should handle tuples in mixed types", () => {
@@ -226,7 +225,7 @@ describe("getCopyValue", () => {
`
"{
"key1": 42,
- "key2": (1,2,3),
+ "key2": (1, 2, 3),
"key3": True
}"
`,
@@ -240,8 +239,8 @@ describe("getCopyValue", () => {
expect(result).toMatchInlineSnapshot(`"18446744073709551616"`);
const nestedBigInt = {
- key1: bigint, // this will be just a string
- key2: `text/plain+bigint:${bigint}`, // this will convert to number
+ key1: bigint,
+ key2: `text/plain+bigint:${bigint}`,
key3: true,
};
const nestedResult = getCopyValue(nestedBigInt);
@@ -260,7 +259,7 @@ describe("getCopyValue", () => {
expect(bigintRawResult).toMatchInlineSnapshot(`"18446744073709551616"`);
const nestedBigIntRaw = {
- key1: bigintRaw, // raw number
+ key1: bigintRaw,
key2: `text/plain+bigint:${bigintRaw}`,
key3: true,
};
@@ -277,64 +276,8 @@ describe("getCopyValue", () => {
});
});
-describe("determineMaxDisplayLength", () => {
- const sample2DArray = [
- [1, 2, 3],
- [4, 5, 6],
- [7, 8, 9],
- [10, 11, 12],
- [13, 14, 15],
- [16, 17, 18],
- [19, 20, 21],
- [22, 23, 24],
- [25, 26, 27],
- [28, 29, 30],
- ];
-
- it("should return undefined for 1 level arrays", () => {
- const value = [1, 2, 3];
- const result = determineMaxDisplayLength(value);
- expect(result).toBeUndefined();
- });
-
- it("should return undefined for 2 level arrays with less than 20 items", () => {
- const value = sample2DArray;
- const result = determineMaxDisplayLength(value);
- expect(result).toBeUndefined();
- });
-
- it("should return 10 for 2 level arrays with more than 20 items", () => {
- const longArray = Array.from({ length: 21 }, (_, i) => i);
- const value = [...sample2DArray, longArray];
- const result = determineMaxDisplayLength(value);
- expect(result).toBe(10);
- });
-
- it("should return 5 for 2 level arrays with more than 50 items", () => {
- const longArray = Array.from({ length: 51 }, (_, i) => i);
- const value = [...sample2DArray, longArray];
- const result = determineMaxDisplayLength(value);
- expect(result).toBe(5);
- });
-
- it("should return 5 for 3 level arrays with more than 20 items", () => {
- const longArray = Array.from({ length: 21 }, (_, i) => i);
- const value = [[...sample2DArray], [...sample2DArray, longArray]];
- const result = determineMaxDisplayLength(value);
- expect(result).toBe(5);
- });
-});
-
describe("getCopyValue with encoded non-string keys", () => {
- // Keys are encoded by _key_formatter in
- // marimo/_output/formatters/structures.py. Frontend must round-trip them
- // to Python literals in the copy output.
-
it("decodes int keys unquoted", () => {
- // JS reorders integer-like string keys to the front of object iteration
- // (spec-mandated), so `"2"` appears before `"text/plain+int:2"` here.
- // This is pre-existing and unrelated to the encoding — both entries
- // survive, which is the regression this guards.
const value = { "text/plain+int:2": "no", "2": "oh" };
expect(getCopyValue(value)).toMatchInlineSnapshot(`
"{
@@ -375,7 +318,6 @@ describe("getCopyValue with encoded non-string keys", () => {
});
it("emits 1-element tuple keys with a trailing comma (Python syntax)", () => {
- // `(1)` is just `1` in Python — a 1-tuple needs `(1,)`.
const value = {
"text/plain+tuple:[1]": "one",
"text/plain+tuple:[]": "empty",
@@ -389,7 +331,6 @@ describe("getCopyValue with encoded non-string keys", () => {
});
it("emits empty frozenset keys as `frozenset()` not `frozenset({})`", () => {
- // `frozenset({})` reads like it's constructing from an empty dict.
const value = {
"text/plain+frozenset:[]": "empty",
"text/plain+frozenset:[1]": "single",
@@ -418,12 +359,6 @@ describe("getCopyValue with encoded non-string keys", () => {
});
it("parses tuple/frozenset payloads containing bare NaN/Infinity", () => {
- // Python's json.dumps emits bare `NaN`/`Infinity` inside the embedded
- // tuple/frozenset payload strings (JSON spec violation, but ECMA-262-
- // friendly via the fallback in jsonParseWithSpecialChar). The outer
- // JSON stays strict because those tokens live inside a JSON string
- // key/value. Regression for tuple-key payloads that previously broke
- // the frontend's `JSON.parse` and threw.
const value = {
"text/plain+tuple:[NaN]": "tn",
"text/plain+tuple:[Infinity, -Infinity]": "ti",
@@ -439,10 +374,6 @@ describe("getCopyValue with encoded non-string keys", () => {
});
it("falls back to the raw payload for malformed tuple/frozenset", () => {
- // `jsonParseWithSpecialChar` returns `{}` on parse failure rather
- // than throwing; without an `Array.isArray` guard, the formatters
- // would crash on `.length`/`.map`. Pass the raw payload through so
- // a malformed wire form doesn't break the whole render.
const value = {
"text/plain+tuple:not a json list": "t",
k: "text/plain+frozenset:also broken",
@@ -513,3 +444,110 @@ describe("getCopyValue with application/ mimetypes", () => {
expect(result).toContain('"number": 42');
});
});
+
+describe("Python copy fidelity", () => {
+ it.each([
+ "<marimo-replace>True</marimo-replace>",
+ "\u0000show_more\u000042|$",
+ 'quotes " backslash \\ newline\n',
+ ])("preserves literal text %j", (value) => {
+ expect(getCopyValue(value)).toBe(JSON.stringify(value));
+ });
+
+ it("preserves keys which used to collide after decoding", () => {
+ const data = JSON.parse(
+ '{"__proto__":1,"<marimo-replace>2</marimo-replace>":2,"text/plain+int:2":3}',
+ );
+ expect(getCopyValue(data)).toBe(
+ '{\n "__proto__": 1,\n "<marimo-replace>2</marimo-replace>": 2,\n 2: 3\n}',
+ );
+ });
+
+ it.each([
+ ["text/plain+tuple:[42]", "(42,)"],
+ ["text/plain+tuple:[]", "()"],
+ [
+ 'text/plain+tuple:["quote\\\"","back\\\\slash",true,null]',
+ '("quote\\\"", "back\\\\slash", True, None)',
+ ],
+ [
+ 'text/plain+set:[true,null,"text/plain:literal"]',
+ '{True, None, "text/plain:literal"}',
+ ],
+ ['text/plain+tuple:["text/plain+int:2"]', '("text/plain+int:2",)'],
+ ["text/plain+float:nan", "float('nan')"],
+ ["text/plain+float:inf", "float('inf')"],
+ ["text/plain+float:-inf", "-float('inf')"],
+ ["text/plain+float:1.0", "1.0"],
+ ])("copies %s as valid Python", (data, expected) => {
+ expect(getCopyValue(data)).toBe(expected);
+ });
+
+ it("distinguishes shared references from cycles", () => {
+ const shared = { x: true };
+ expect(getCopyValue([shared, shared])).toBe(
+ '[\n {\n "x": True\n },\n {\n "x": True\n }\n]',
+ );
+ const cyclic: unknown[] = [];
+ cyclic.push(cyclic);
+ expect(() => getCopyValue(cyclic)).toThrow("Cannot copy circular data");
+ });
+
+ it("copies sparse arrays and non-finite numbers as Python literals", () => {
+ const values = [0, Number.NaN, Infinity, -Infinity];
+ Reflect.deleteProperty(values, "0");
+ expect(getCopyValue(values)).toBe(
+ "[\n None,\n float('nan'),\n float('inf'),\n -float('inf')\n]",
+ );
+ });
+});
+
+describe("Python copy negative cases", () => {
+ it.each([
+ "text/plain+unknown:payload",
+ "text/plain+tuple",
+ "not-text/plain:payload",
+ "https://example.com:a:b",
+ ])("does not decode unrecognized leaf %j", (value) => {
+ expect(getCopyValue(value)).toBe(JSON.stringify(value));
+ expect(getCopyValue({ [value]: "literal" })).toBe(
+ `{\n ${JSON.stringify(value)}: "literal"\n}`,
+ );
+ });
+
+ it.each(["tuple", "set", "frozenset"])(
+ "does not invent a %s from malformed or non-array JSON",
+ (kind) => {
+ for (const payload of ["[broken", "null", "42", '{"x":1}']) {
+ expect(getCopyValue(`text/plain+${kind}:${payload}`)).toBe(payload);
+ }
+ },
+ );
+
+ it("decodes escaped keys and text exactly once", () => {
+ const data = {
+ "text/plain+str:text/plain+str:text/plain+int:2":
+ "text/plain:text/plain+tuple:[42]",
+ };
+ expect(getCopyValue(data)).toBe(
+ '{\n "text/plain+str:text/plain+int:2": "text/plain+tuple:[42]"\n}',
+ );
+ });
+
+ it("does not decode dictionary keys inside raw tuple payloads", () => {
+ expect(
+ getCopyValue(
+ 'text/plain+tuple:[{"text/plain+int:2":"text/plain:literal"}]',
+ ),
+ ).toBe('({"text/plain+int:2": "text/plain:literal"},)');
+ });
+
+ it("rejects indirect cycles without poisoning later copies", () => {
+ const data: Record<string, unknown> = { child: [] };
+ data.child = [data];
+ expect(() => getCopyValue(data)).toThrow("Cannot copy circular data");
+ expect(getCopyValue({ child: [true] })).toBe(
+ '{\n "child": [\n True\n ]\n}',
+ );
+ });
+});
diff --git a/frontend/src/components/editor/output/__tests__/json-output-pagination.test.ts b/frontend/src/components/editor/output/__tests__/json-output-pagination.test.ts
new file mode 100644
index 0000000000..6ee773786f
--- /dev/null
+++ b/frontend/src/components/editor/output/__tests__/json-output-pagination.test.ts
@@ -0,0 +1,252 @@
+/* Copyright 2026 Marimo. All rights reserved. */
+import { describe, expect, it, vi } from "vitest";
+import {
+ determineMaxDisplayLength,
+ estimateExpandedLines,
+ paginateJson,
+} from "../json-output/pagination";
+
+describe("determineMaxDisplayLength", () => {
+ const sample2DArray = [
+ [1, 2, 3],
+ [4, 5, 6],
+ [7, 8, 9],
+ [10, 11, 12],
+ [13, 14, 15],
+ [16, 17, 18],
+ [19, 20, 21],
+ [22, 23, 24],
+ [25, 26, 27],
+ [28, 29, 30],
+ ];
+
+ it("should return undefined for 1 level arrays", () => {
+ const value = [1, 2, 3];
+ const result = determineMaxDisplayLength(value);
+ expect(result).toBeUndefined();
+ });
+
+ it("should return undefined for 2 level arrays with less than 20 items", () => {
+ const value = sample2DArray;
+ const result = determineMaxDisplayLength(value);
+ expect(result).toBeUndefined();
+ });
+
+ it("should return 10 for 2 level arrays with more than 20 items", () => {
+ const longArray = Array.from({ length: 21 }, (_, i) => i);
+ const value = [...sample2DArray, longArray];
+ const result = determineMaxDisplayLength(value);
+ expect(result).toBe(10);
+ });
+
+ it("should return 5 for 2 level arrays with more than 50 items", () => {
+ const longArray = Array.from({ length: 51 }, (_, i) => i);
+ const value = [...sample2DArray, longArray];
+ const result = determineMaxDisplayLength(value);
+ expect(result).toBe(5);
+ });
+
+ it("should return 5 for 3 level arrays with more than 20 items", () => {
+ const longArray = Array.from({ length: 21 }, (_, i) => i);
+ const value = [[...sample2DArray], [...sample2DArray, longArray]];
+ const result = determineMaxDisplayLength(value);
+ expect(result).toBe(5);
+ });
+});
+
+describe("estimateExpandedLines", () => {
+ it("scalars count as 1", () => {
+ expect(estimateExpandedLines(42, 100)).toBe(1);
+ expect(estimateExpandedLines(null, 100)).toBe(1);
+ });
+
+ it("flat containers = child count", () => {
+ expect(estimateExpandedLines({ a: 1, b: 2, c: 3 }, 100)).toBe(3);
+ expect(estimateExpandedLines([1, 2, 3, 4], 100)).toBe(4);
+ });
+
+ it("small nested children expand recursively", () => {
+ expect(estimateExpandedLines({ a: { x: 1, y: 2 }, b: 3 }, 100)).toBe(3);
+ });
+
+ it("large children count as 1 collapsed line", () => {
+ const big = Array.from({ length: 20 }, (_, i) => i);
+ expect(estimateExpandedLines({ a: big, b: 1 }, 100)).toBe(2);
+ });
+
+ it("bails at cap", () => {
+ const big = Array.from({ length: 500 }, (_, i) => i);
+ expect(estimateExpandedLines(big, 50)).toBe(50);
+ });
+
+ it("bails at max depth", () => {
+ const data = { a: { b: { c: { d: { e: { f: 1 } } } } } };
+ expect(estimateExpandedLines(data, 100)).toBe(1);
+ });
+});
+
+describe("paginateJson", () => {
+ const options = { limits: {}, pageSize: 30 };
+
+ it("preserves full originals and reports the remaining count", () => {
+ const rows = Array.from({ length: 100 }, (_, i) => i);
+ const data = { rows };
+ const tree = paginateJson(data, options);
+ const displayRows: unknown[] = Reflect.get(tree.data, "rows");
+ expect(displayRows.slice(0, 30)).toEqual(rows.slice(0, 30));
+ expect(tree.getPage(displayRows[30])).toEqual({
+ path: '["rows"]',
+ remaining: 70,
+ });
+ expect(tree.getOriginal(tree.data)).toBe(data);
+ expect(tree.getOriginal(displayRows)).toBe(rows);
+ expect(tree.getOriginal("value")).toBe("value");
+ });
+
+ it("paginates arrays and objects at the boundary", () => {
+ for (const count of [0, 1, 29, 30, 31, 60]) {
+ const values = Array.from({ length: count }, (_, i) => i);
+ for (const data of [
+ values,
+ Object.fromEntries(values.map((i) => [`k${i}`, i])),
+ ]) {
+ const tree = paginateJson(data, options);
+ const displayed = Object.values(tree.data);
+ expect(displayed.slice(0, 30)).toEqual(values.slice(0, 30));
+ expect(displayed).toHaveLength(
+ Math.min(count, 30) + Number(count > 30),
+ );
+ expect(tree.getPage(displayed.at(-1))).toEqual(
+ count > 30 ? { path: "[]", remaining: count - 30 } : undefined,
+ );
+ }
+ }
+ });
+
+ it("keeps dotted, quoted, and empty keys distinct without reserving user strings", () => {
+ const values = Array.from({ length: 40 }, (_, i) => i);
+ const data = { "a.b": values, a: { b: values }, '"': values, "": values };
+ const tree = paginateJson(data, { ...options, limits: { '["a.b"]': 60 } });
+ expect(Reflect.get(tree.data, "a.b")).toEqual(values);
+ for (const path of [["a", "b"], ['"'], [""]]) {
+ const node = path.reduce(
+ (node: object, key) => Reflect.get(node, key),
+ tree.data,
+ );
+ expect(tree.getPage(Object.values(node).at(-1))).toEqual({
+ path: JSON.stringify(path),
+ remaining: 10,
+ });
+ }
+ expect(tree.getPage("\u0000show_more\u000040|$")).toBeUndefined();
+ expect(tree.getPage(Symbol("show more"))).toBeUndefined();
+ });
+
+ it("preserves __proto__ and empty keys when adding an object page", () => {
+ const data = { "": 1, ["__proto__"]: 2, other: 3 };
+ const tree = paginateJson(data, { limits: {}, pageSize: 2 });
+ expect(Object.values(tree.data).slice(0, 2)).toEqual([1, 2]);
+ expect(tree.getOriginal(tree.data)).toBe(data);
+ expect(tree.getPage(Object.values(tree.data).at(-1))).toEqual({
+ path: "[]",
+ remaining: 1,
+ });
+ });
+
+ it("does not traverse hidden branches, and caches visible children", () => {
+ const read = vi.fn(() => [1, 2]);
+ const hidden = vi.fn(() => [3, 4]);
+ const data = {
+ get visible() {
+ return read();
+ },
+ get hidden() {
+ return hidden();
+ },
+ };
+ const tree = paginateJson(data, { limits: {}, pageSize: 1 });
+ expect(read).not.toHaveBeenCalled();
+ const first = Reflect.get(tree.data, "visible");
+ expect(Reflect.get(tree.data, "visible")).toBe(first);
+ expect(read).toHaveBeenCalledOnce();
+ expect(hidden).not.toHaveBeenCalled();
+ });
+
+ it("paginates deep branches without a depth cutoff", () => {
+ const data = {
+ deep: {
+ more: {
+ levels: {
+ still: {
+ going: {
+ deeper: { rows: Array.from({ length: 100 }, (_, i) => i) },
+ },
+ },
+ },
+ },
+ },
+ };
+ const tree = paginateJson(data, options);
+ const keys = ["deep", "more", "levels", "still", "going", "deeper", "rows"];
+ const rows = keys.reduce(
+ (node: object, key) => Reflect.get(node, key),
+ tree.data,
+ );
+ expect(Object.values(rows)).toHaveLength(31);
+ expect(tree.getPage(Object.values(rows).at(-1))).toEqual({
+ path: JSON.stringify(keys),
+ remaining: 70,
+ });
+ });
+
+ it("preserves non-JSON objects and does not mutate input", () => {
+ const date = new Date("2026-01-01");
+ const data = Object.freeze({ date, values: Object.freeze([1, 2, 3]) });
+ const tree = paginateJson(data, { limits: {}, pageSize: 2 });
+ expect(Reflect.get(tree.data, "date")).toBe(date);
+ expect(Object.values(Reflect.get(tree.data, "values"))).toHaveLength(3);
+ expect(data.values).toEqual([1, 2, 3]);
+ });
+});
+
+describe("pagination negative cases", () => {
+ it("does not overwrite empty or NUL keys with pagination controls", () => {
+ const data = { "": "empty", "\0": "nul", "\0\0": "two", last: "last" };
+ const tree = paginateJson(data, { limits: {}, pageSize: 3 });
+ expect(Object.values(tree.data).slice(0, 3)).toEqual([
+ "empty",
+ "nul",
+ "two",
+ ]);
+ expect(tree.getPage(Object.values(tree.data).at(-1))).toEqual({
+ path: "[]",
+ remaining: 1,
+ });
+ expect(Object.keys(data)).toEqual(["", "\0", "\0\0", "last"]);
+ });
+
+ it("does not accept page markers from another tree", () => {
+ const first = paginateJson([1, 2], { limits: {}, pageSize: 1 });
+ const second = paginateJson([3, 4], { limits: {}, pageSize: 1 });
+ expect(second.getPage(Object.values(first.data).at(-1))).toBeUndefined();
+ });
+
+ it("does not read values beyond the visible page", () => {
+ const data = {
+ visible: 1,
+ get hidden() {
+ throw new Error("hidden value read");
+ },
+ };
+ const tree = paginateJson(data, { limits: {}, pageSize: 1 });
+ expect(Object.values(tree.data)[0]).toBe(1);
+ expect(tree.getOriginal(tree.data)).toBe(data);
+ });
+
+ it("does not expose inherited or non-enumerable fields", () => {
+ const data = Object.defineProperty({ visible: 1 }, "hidden", { value: 2 });
+ const tree = paginateJson(data, { limits: {}, pageSize: 30 });
+ expect(Object.entries(tree.data)).toEqual([["visible", 1]]);
+ expect(Reflect.get(tree.data, "toString")).toBeUndefined();
+ });
+});
diff --git a/frontend/src/components/editor/output/json-output/formatting.ts b/frontend/src/components/editor/output/json-output/formatting.ts
new file mode 100644
index 0000000000..323b7aadc0
--- /dev/null
+++ b/frontend/src/components/editor/output/json-output/formatting.ts
@@ -0,0 +1,167 @@
+/* Copyright 2026 Marimo. All rights reserved. */
+import { jsonParseWithSpecialChar } from "@/utils/json/json-parser";
+
+export function splitLeaf(leaf: string): [string, string | undefined] {
+ const index = leaf.indexOf(":");
+ return index < 0
+ ? [leaf, undefined]
+ : [leaf.slice(index + 1), leaf.slice(0, index)];
+}
+
+function formatFloat(value: string): string {
+ switch (value.toLowerCase()) {
+ case "nan":
+ return "float('nan')";
+ case "inf":
+ case "infinity":
+ return "float('inf')";
+ case "-inf":
+ case "-infinity":
+ return "-float('inf')";
+ default:
+ return value;
+ }
+}
+
+function formatCollection(
+ payload: string,
+ kind: "tuple" | "set" | "frozenset",
+): string {
+ const items = jsonParseWithSpecialChar<unknown>(payload);
+ // Older servers sent Python literals instead of JSON lists.
+ if (!Array.isArray(items)) {
+ return payload;
+ }
+ const inner = items.map((item) => formatPython(item, true)).join(", ");
+ switch (kind) {
+ case "tuple":
+ return `(${inner}${items.length === 1 ? "," : ""})`;
+ case "set":
+ return items.length ? `{${inner}}` : "set()";
+ case "frozenset":
+ return items.length ? `frozenset({${inner}})` : "frozenset()";
+ }
+}
+
+export const formatTuplePayload = (payload: string) =>
+ formatCollection(payload, "tuple");
+export const formatSetPayload = (payload: string) =>
+ formatCollection(payload, "set");
+export const formatFrozensetPayload = (payload: string) =>
+ formatCollection(payload, "frozenset");
+
+// Matches the key encoding in marimo/_output/formatters/structures.py.
+export function decodePythonKey(
+ key: unknown,
+): { text: string; quoted: boolean } | undefined {
+ if (typeof key !== "string") {
+ return undefined;
+ }
+ const [payload, mime] = splitLeaf(key);
+ switch (mime) {
+ case "text/plain+str":
+ return { text: payload, quoted: true };
+ case "text/plain+int":
+ case "text/plain+float":
+ return { text: payload, quoted: false };
+ case "text/plain+bool":
+ return { text: payload === "True" ? "True" : "False", quoted: false };
+ case "text/plain+none":
+ return { text: "None", quoted: false };
+ case "text/plain+tuple":
+ return { text: formatTuplePayload(payload), quoted: false };
+ case "text/plain+frozenset":
+ return { text: formatFrozensetPayload(payload), quoted: false };
+ default:
+ return undefined;
+ }
+}
+
+function formatKey(key: string): string {
+ const decoded = decodePythonKey(key);
+ if (!decoded) {
+ return JSON.stringify(key);
+ }
+ if (decoded.quoted) {
+ return JSON.stringify(decoded.text);
+ }
+ return key.startsWith("text/plain+float:")
+ ? formatFloat(decoded.text)
+ : decoded.text;
+}
+
+function formatString(value: string): string {
+ const [payload, mime] = splitLeaf(value);
+ switch (mime) {
+ case "text/plain+float":
+ return formatFloat(payload);
+ case "text/plain+bigint":
+ return BigInt(payload).toString();
+ case "text/plain+tuple":
+ return formatTuplePayload(payload);
+ case "text/plain+set":
+ return formatSetPayload(payload);
+ case "text/plain+frozenset":
+ return formatFrozensetPayload(payload);
+ case "text/plain":
+ case "text/html":
+ case "text/markdown":
+ return JSON.stringify(payload);
+ default:
+ return JSON.stringify(
+ mime && /^(image|video|application)\//.test(mime) ? payload : value,
+ );
+ }
+}
+
+function formatPython(value: unknown, compact = false): string {
+ const ancestors = new WeakSet<object>();
+ function format(node: unknown, depth: number): string {
+ if (node == null) {
+ return "None";
+ }
+ switch (typeof node) {
+ case "string":
+ return compact ? JSON.stringify(node) : formatString(node);
+ case "boolean":
+ return node ? "True" : "False";
+ case "number":
+ return formatFloat(String(node));
+ case "bigint":
+ return node.toString();
+ case "object":
+ if (ancestors.has(node)) {
+ throw new TypeError("Cannot copy circular data");
+ }
+ ancestors.add(node);
+ try {
+ const array = Array.isArray(node);
+ const entries = array
+ ? Array.from(node, (item) => format(item, depth + 1))
+ : Object.entries(node).map(
+ ([key, item]) =>
+ `${compact ? JSON.stringify(key) : formatKey(key)}: ${format(item, depth + 1)}`,
+ );
+ const [open, close] = array ? ["[", "]"] : ["{", "}"];
+ if (entries.length === 0) {
+ return open + close;
+ }
+ if (compact) {
+ return `${open}${entries.join(", ")}${close}`;
+ }
+ const indent = " ".repeat(depth);
+ return `${open}\n${indent} ${entries.join(`,\n${indent} `)}\n${indent}${close}`;
+ } finally {
+ ancestors.delete(node);
+ }
+
+ default:
+ return "None";
+ }
+ }
+ return format(value, 0);
+}
+
+export function getCopyValue(value: unknown): string {
+ return formatPython(value);
+}
diff --git a/frontend/src/components/editor/output/json-output/pagination.ts b/frontend/src/components/editor/output/json-output/pagination.ts
new file mode 100644
index 0000000000..e5fe96ea97
--- /dev/null
+++ b/frontend/src/components/editor/output/json-output/pagination.ts
@@ -0,0 +1,155 @@
+/* Copyright 2026 Marimo. All rights reserved. */
+import { isPlainObject } from "lodash-es";
+
+export const PAGE_SIZE = 30;
+
+interface Page {
+ path: string;
+ remaining: number;
+}
+
+interface Options {
+ limits: Record<string, number>;
+ pageSize: number;
+}
+
+export function paginateJson(data: object, { limits, pageSize }: Options) {
+ const originals = new WeakMap<object, object>();
+ const pages = new Map<symbol, Page>();
+
+ function visit(node: object, path: string[]): object {
+ if (!Array.isArray(node) && !isPlainObject(node)) {
+ return node;
+ }
+ const pathKey = JSON.stringify(path);
+ const limit = limits[pathKey] ?? pageSize;
+ const keys = Array.isArray(node)
+ ? Array.from({ length: Math.min(node.length, limit) }, (_, i) =>
+ String(i),
+ )
+ : Object.keys(node).slice(0, limit);
+ const count = Array.isArray(node) ? node.length : Object.keys(node).length;
+ const result: object = Array.isArray(node) ? [] : Object.create(null);
+ originals.set(result, node);
+
+ for (const key of keys) {
+ // Materialize only the branches the viewer reads, including after expansion.
+ Object.defineProperty(result, key, {
+ enumerable: true,
+ configurable: true,
+ get() {
+ const original: unknown = Reflect.get(node, key);
+ const value =
+ original !== null && typeof original === "object"
+ ? visit(original, [...path, key])
+ : original;
+ Object.defineProperty(result, key, {
+ value,
+ enumerable: true,
+ configurable: true,
+ });
+ return value;
+ },
+ });
+ }
+ if (count > limit) {
+ const marker = Symbol("show more");
+ pages.set(marker, { remaining: count - limit, path: pathKey });
+ let key = Array.isArray(node) ? String(limit) : "";
+ while (Object.hasOwn(result, key)) {
+ key += "\0";
+ }
+ Object.defineProperty(result, key, { value: marker, enumerable: true });
+ }
+ return result;
+ }
+
+ return {
+ data: visit(data, []),
+ getOriginal(value: unknown): unknown {
+ return value !== null && typeof value === "object"
+ ? (originals.get(value) ?? value)
+ : value;
+ },
+ getPage(value: unknown): Page | undefined {
+ return typeof value === "symbol" ? pages.get(value) : undefined;
+ },
+ };
+}
+
+export function estimateExpandedLines(
+ node: unknown,
+ cap: number,
+ depth = 0,
+): number {
+ if (
+ depth > 4 ||
+ node === null ||
+ node === undefined ||
+ typeof node !== "object"
+ ) {
+ return 1;
+ }
+ const children: unknown[] = Array.isArray(node) ? node : Object.values(node);
+ let lines = 0;
+ for (let i = 0; i < children.length && lines < cap; i++) {
+ const child = children[i];
+ if (child === null || child === undefined || typeof child !== "object") {
+ lines++;
+ } else {
+ const childLen = Array.isArray(child)
+ ? child.length
+ : Object.keys(child).length;
+ lines +=
+ childLen <= 8
+ ? estimateExpandedLines(child, cap - lines, depth + 1)
+ : 1;
+ }
+ }
+ return lines;
+}
+
+export function shouldExpandNode(
+ _isExpanded: boolean,
+ { value, level }: { value?: object; level: number },
+): boolean {
+ if (level <= 1) {
+ return true;
+ }
+ if (level > 5) {
+ return false;
+ }
+ if (value === null || value === undefined || typeof value !== "object") {
+ return true;
+ }
+ const len = Array.isArray(value) ? value.length : Object.keys(value).length;
+ if (len === 0) {
+ return true;
+ }
+ if (len > 200) {
+ return false;
+ }
+ return estimateExpandedLines(value, 150) <= 120;
+}
+
+export function determineMaxDisplayLength(data: unknown): number | undefined {
+ if (!Array.isArray(data)) {
+ return undefined;
+ }
+ const sample = data.slice(0, 15);
+ let maxLength = 0;
+ for (const el of sample) {
+ if (Array.isArray(el)) {
+ for (const next of el.slice(0, 5)) {
+ if (Array.isArray(next)) {
+ return 5;
+ }
+ }
+ maxLength = Math.max(maxLength, el.length);
+ }
+ }
+ if (maxLength <= 20) {
+ return undefined;
+ }
+ return maxLength >= 50 ? 5 : 10;
+}
diff --git a/frontend/src/components/editor/output/json-output/renderers.tsx b/frontend/src/components/editor/output/json-output/renderers.tsx
new file mode 100644
index 0000000000..edb738bfec
--- /dev/null
+++ b/frontend/src/components/editor/output/json-output/renderers.tsx
@@ -0,0 +1,196 @@
+/* Copyright 2026 Marimo. All rights reserved. */
+import { useState } from "react";
+import type { OutputMessage } from "@/core/kernel/messages";
+import { isUrl } from "@/utils/urls";
+import { OutputRenderer } from "../../Output";
+import { HtmlOutput } from "../HtmlOutput";
+import { ImageOutput } from "../ImageOutput";
+import { JsonOutput } from "../JsonOutput";
+import { VideoOutput } from "../VideoOutput";
+import {
+ decodePythonKey,
+ formatTuplePayload,
+ formatSetPayload,
+ formatFrozensetPayload,
+ splitLeaf,
+} from "./formatting";
+
+export const COLLAPSED_TEXT_LENGTH = 100;
+
+// Keep long text and quotes wrapping together.
+/* oxlint-disable jsx-a11y/prefer-tag-over-role */
+const CollapsibleTextOutput: React.FC<{ text: string }> = ({ text }) => {
+ const [collapsed, setCollapsed] = useState(true);
+ if (text.length <= COLLAPSED_TEXT_LENGTH) {
+ return <span className="break-all">{text}</span>;
+ }
+ return (
+ <span
+ className="cursor-pointer hover:opacity-90 break-all"
+ role="button"
+ tabIndex={0}
+ aria-expanded={!collapsed}
+ onClick={() => setCollapsed(!collapsed)}
+ onKeyDown={(event) => {
+ if (event.key === "Enter" || event.key === " ") {
+ event.preventDefault();
+ setCollapsed(!collapsed);
+ }
+ }}
+ >
+ {collapsed ? `${text.slice(0, COLLAPSED_TEXT_LENGTH)}...` : text}
+ </span>
+ );
+};
+
+/* oxlint-enable jsx-a11y/prefer-tag-over-role */
+
+type LeafRenderer = (
+ data: string,
+ mimeType: OutputMessage["mimetype"],
+) => React.ReactNode;
+
+const LEAF_RENDERERS: Record<string, LeafRenderer> = {
+ "image/": (v) => <ImageOutput src={v} />,
+ "video/": (v) => <VideoOutput src={v} />,
+ "text/html:": (v) => (
+ <HtmlOutput html={v} inline={true} alwaysSanitizeHtml={false} />
+ ),
+ "text/markdown:": (v) => (
+ <HtmlOutput html={v} inline={true} alwaysSanitizeHtml={true} />
+ ),
+ "text/plain+float:": (v) => <span>{v}</span>,
+ "text/plain+bigint:": (v) => <span>{v}</span>,
+ "text/plain+set:": (v) => <span>{formatSetPayload(v)}</span>,
+ "text/plain+frozenset:": (v) => <span>{formatFrozensetPayload(v)}</span>,
+ "text/plain+tuple:": (v) => <span>{formatTuplePayload(v)}</span>,
+ "text/plain:": (v) => <CollapsibleTextOutput text={v} />,
+ "application/json:": (v) => <JsonOutput data={JSON.parse(v)} />,
+ "application/": (v, mime) => (
+ <OutputRenderer
+ message={{ channel: "output", data: v, mimetype: mime }}
+ renderFallback={() => (
+ <span>
+ {mime}:{v}
+ </span>
+ )}
+ />
+ ),
+};
+
+function tryRenderMimeLeaf(value: string): React.ReactNode | null {
+ for (const prefix of Object.keys(LEAF_RENDERERS)) {
+ if (value.startsWith(prefix)) {
+ const [data, mime] = splitLeaf(value);
+ return mime
+ ? LEAF_RENDERERS[prefix](data, mime as OutputMessage["mimetype"])
+ : null;
+ }
+ }
+ return null;
+}
+
+interface KeyRenderResult {
+ keyName?: string | number;
+}
+
+export function renderKeyName(
+ props: Record<string, unknown>,
+ { keyName }: KeyRenderResult,
+): React.ReactNode {
+ const decoded = decodePythonKey(keyName);
+ if (!decoded) {
+ return undefined;
+ }
+ return <span {...props}>{decoded.text}</span>;
+}
+
+export function renderKeyQuote(
+ _props: Record<string, unknown>,
+ { keyName }: KeyRenderResult,
+): React.ReactNode {
+ // The viewer treats null/undefined as a request for its default quotes.
+ return decodePythonKey(keyName)?.quoted === false ? <span /> : undefined;
+}
+
+export interface RenderResult {
+ type: string;
+ value?: unknown;
+}
+
+export function renderStringValue(
+ _props: React.HTMLAttributes<HTMLSpanElement>,
+ result: RenderResult,
+ mode: "python" | "json",
+): React.ReactNode {
+ if (result.type !== "value" || typeof result.value !== "string") {
+ return undefined;
+ }
+ const { value } = result;
+ if (mode !== "python") {
+ return renderPlainString(value);
+ }
+
+ const mimeResult = tryRenderMimeLeaf(value);
+ if (mimeResult !== null) {
+ return <span className="w-rjv-value">{mimeResult}</span>;
+ }
+ if (isUrl(value)) {
+ return (
+ <span className="w-rjv-value">
+ <a
+ href={value}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="text-link hover:underline"
+ >
+ {value}
+ </a>
+ </span>
+ );
+ }
+ return renderPlainString(value);
+}
+
+function renderPlainString(value: string) {
+ if (value.length <= COLLAPSED_TEXT_LENGTH) {
+ return undefined;
+ }
+ return (
+ <span
+ className="inline-block"
+ style={{ color: "var(--w-rjv-type-string-color)" }}
+ >
+ &quot;
+ <CollapsibleTextOutput text={value} />
+ &quot;
+ </span>
+ );
+}
+
+export function renderArrow(
+ props: React.HTMLAttributes<HTMLSpanElement>,
+ { keyName }: KeyRenderResult,
+): React.ReactNode {
+ // alpha.43's data-expanded is inverted and omits initial collapse rules.
+ // NestedOpen's transform reflects the effective state.
+ const expanded = props.style?.transform === "rotate(0deg)";
+ return (
+ <button
+ {...props}
+ type="button"
+ aria-label={`${expanded ? "Collapse" : "Expand"} ${keyName ?? "root"}`}
+ aria-expanded={expanded}
+ />
+ );
+}
+
+function renderLiteral(text: string) {
+ return (_props: Record<string, unknown>, { type }: RenderResult) =>
+ type === "value" ? <span className="w-rjv-value">{text}</span> : undefined;
+}
+
+export const PYTHON_TRUE_RENDER = renderLiteral("True");
+export const PYTHON_FALSE_RENDER = renderLiteral("False");
+export const PYTHON_NULL_RENDER = renderLiteral("None");
+export const JSON_NULL_RENDER = renderLiteral("null");
diff --git a/frontend/src/components/editor/output/json-output/themes.ts b/frontend/src/components/editor/output/json-output/themes.ts
new file mode 100644
index 0000000000..705ee10aad
--- /dev/null
+++ b/frontend/src/components/editor/output/json-output/themes.ts
@@ -0,0 +1,52 @@
+/* Copyright 2026 Marimo. All rights reserved. */
+import type React from "react";
+
+type ViewerStyle = React.CSSProperties & Record<`--w-rjv-${string}`, string>;
+
+const BASE_THEME: ViewerStyle = {
+ fontSize: "var(--text-xs, .75rem)",
+ lineHeight: "var(--text-xs--line-height, 1rem)",
+ "--w-rjv-font-family": "monospace",
+ "--w-rjv-background-color": "transparent",
+ "--w-rjv-key-string": "var(--w-rjv-color)",
+ "--w-rjv-arrow-color": "var(--w-rjv-color)",
+ "--w-rjv-curlybraces-color": "var(--w-rjv-color)",
+ "--w-rjv-colon-color": "var(--w-rjv-color)",
+ "--w-rjv-brackets-color": "var(--w-rjv-color)",
+ "--w-rjv-quotes-color": "var(--w-rjv-color)",
+ "--w-rjv-ellipsis-color": "var(--w-rjv-type-string-color)",
+ "--w-rjv-quotes-string-color": "var(--w-rjv-type-string-color)",
+ "--w-rjv-type-bigint-color": "var(--w-rjv-type-int-color)",
+ "--w-rjv-type-url-color": "var(--link)",
+ "--w-rjv-type-nan-color": "var(--w-rjv-type-null-color)",
+};
+
+export const marimoLightTheme: ViewerStyle = {
+ ...BASE_THEME,
+ "--w-rjv-color": "#002b36",
+ "--w-rjv-key-number": "#6c71c4",
+ "--w-rjv-line-color": "rgb(235, 235, 235)",
+ "--w-rjv-info-color": "rgba(0, 0, 0, 0.3)",
+ "--w-rjv-type-string-color": "#cb4b16",
+ "--w-rjv-type-int-color": "#268bd2",
+ "--w-rjv-type-float-color": "#859900",
+ "--w-rjv-type-boolean-color": "#2aa198",
+ "--w-rjv-type-date-color": "#586e75",
+ "--w-rjv-type-null-color": "#d33682",
+ "--w-rjv-type-undefined-color": "#586e75",
+};
+
+export const marimoDarkTheme: ViewerStyle = {
+ ...BASE_THEME,
+ "--w-rjv-color": "#f8f8f8",
+ "--w-rjv-key-number": "#86c1b9",
+ "--w-rjv-line-color": "#383838",
+ "--w-rjv-info-color": "#b8b8b8",
+ "--w-rjv-type-string-color": "#dc9656",
+ "--w-rjv-type-int-color": "#a16946",
+ "--w-rjv-type-float-color": "#a1b56c",
+ "--w-rjv-type-boolean-color": "#ba8baf",
+ "--w-rjv-type-date-color": "#7cafc2",
+ "--w-rjv-type-null-color": "#ab4642",
+ "--w-rjv-type-undefined-color": "#d8d8d8",
+};
diff --git a/frontend/src/plugins/core/BadPlugin.tsx b/frontend/src/plugins/core/BadPlugin.tsx
index 152e32f04a..a897991f92 100644
--- a/frontend/src/plugins/core/BadPlugin.tsx
+++ b/frontend/src/plugins/core/BadPlugin.tsx
@@ -9,21 +9,15 @@ const AccordionTrigger = AccordionPrimitive.Trigger;
import type { JSX } from "react";
import { ZodError } from "zod";
-import { EmotionCacheProvider } from "@/components/editor/output/EmotionCacheProvider";
import { JsonOutput } from "@/components/editor/output/JsonOutput";
import { Alert, AlertTitle } from "../../components/ui/alert";
interface Props {
error: ZodError | Error;
- shadowRoot: ShadowRoot | null;
badData: Record<string, unknown>;
}
-export const BadPluginData: React.FC<Props> = ({
- error,
- badData,
- shadowRoot,
-}) => {
+export const BadPluginData: React.FC<Props> = ({ error, badData }) => {
if (error instanceof ZodError) {
return (
<Alert variant="destructive">
@@ -49,9 +43,7 @@ export const BadPluginData: React.FC<Props> = ({
View Data:
</AccordionTrigger>
<AccordionContent className="text-[0.84375rem]">
- <EmotionCacheProvider container={shadowRoot}>
- <JsonOutput data={badData} />
- </EmotionCacheProvider>
+ <JsonOutput data={badData} />
</AccordionContent>
</AccordionItem>
</Accordion>
@@ -65,9 +57,6 @@ export const BadPluginData: React.FC<Props> = ({
export function renderError(
error: ZodError | Error,
badData: Record<string, unknown>,
- shadowRoot: ShadowRoot | null,
): JSX.Element {
- return (
- <BadPluginData error={error} badData={badData} shadowRoot={shadowRoot} />
- );
+ return <BadPluginData error={error} badData={badData} />;
}
diff --git a/frontend/src/plugins/core/registerReactComponent.tsx b/frontend/src/plugins/core/registerReactComponent.tsx
index 60af78236a..c65c8a9b08 100644
--- a/frontend/src/plugins/core/registerReactComponent.tsx
+++ b/frontend/src/plugins/core/registerReactComponent.tsx
@@ -274,7 +274,6 @@ function PluginSlotInternal<T>(
Objects.mapValues(hostElement.dataset, (value) =>
typeof value === "string" ? parseAttrValue(value) : value,
),
- hostElement.shadowRoot,
);
}
diff --git a/frontend/src/plugins/layout/JsonOutputPlugin.tsx b/frontend/src/plugins/layout/JsonOutputPlugin.tsx
index 9be24dd2ca..dd18d3a57a 100644
--- a/frontend/src/plugins/layout/JsonOutputPlugin.tsx
+++ b/frontend/src/plugins/layout/JsonOutputPlugin.tsx
@@ -2,7 +2,6 @@
import type { JSX } from "react";
import { z } from "zod";
-import { EmotionCacheProvider } from "../../components/editor/output/EmotionCacheProvider";
import { JsonOutput } from "../../components/editor/output/JsonOutput";
import type {
IStatelessPlugin,
@@ -30,18 +29,16 @@ export class JsonOutputPlugin implements IStatelessPlugin<Data> {
valueTypes: z.enum(["json", "python"]).default("python"),
});
- render({ data, host }: IStatelessPluginProps<Data>): JSX.Element {
+ render({ data }: IStatelessPluginProps<Data>): JSX.Element {
// `false` defaults to no text label
const name = data.name === undefined ? false : data.name || "";
return (
- <EmotionCacheProvider container={host.shadowRoot}>
- <JsonOutput
- data={data.jsonData}
- format="auto"
- valueTypes={data.valueTypes}
- name={name}
- />
- </EmotionCacheProvider>
+ <JsonOutput
+ data={data.jsonData}
+ format="auto"
+ valueTypes={data.valueTypes}
+ name={name}
+ />
);
}
}
diff --git a/frontend/vite.config.mts b/frontend/vite.config.mts
index c92b64221c..cd7a5d6b15 100644
--- a/frontend/vite.config.mts
+++ b/frontend/vite.config.mts
@@ -310,8 +310,6 @@ export default defineConfig({
dedupe: [
"react",
"react-dom",
- "@emotion/react",
- "@emotion/cache",
"@codemirror/view",
"@codemirror/state",
// Dedupe react-dnd to prevent "Cannot have two HTML5 backends" errors
diff --git a/marimo/_plugins/stateless/inspect.py b/marimo/_plugins/stateless/inspect.py
index d8f0a7b72f..b96132df0d 100644
--- a/marimo/_plugins/stateless/inspect.py
+++ b/marimo/_plugins/stateless/inspect.py
@@ -443,7 +443,7 @@ def _format_method(name: str, method: object, docs: bool) -> str:
def _render_value_inline(value: object) -> str:
if isinstance(value, str):
- # Colors from @textea/json-viewer string rendering
+ # Colors match the JSON viewer string theme in json-output/themes.ts.
# Light mode: #cb4b16, Dark mode: #dc9656
return h.span(
f'"{html.escape(value)}"',
diff --git a/marimo/_smoke_tests/json_viewer.py b/marimo/_smoke_tests/json_viewer.py
new file mode 100644
index 0000000000..f7260fd21d
--- /dev/null
+++ b/marimo/_smoke_tests/json_viewer.py
@@ -0,0 +1,242 @@
+import marimo
+
+__generated_with = "0.24.0"
+app = marimo.App(width="medium")
+
+
+def _():
+ import json
+
+ import marimo as mo
+
+ return json, mo
+
+
[email protected](hide_code=True)
+def _(mo):
+ mo.md("""
+ # JSON viewer smoke test
+
+ Based on [PR #10865](https://github.com/marimo-team/marimo/pull/10865).
+ Repeat these checks in light and dark mode. Use Tab to focus controls,
+ then Enter or Space to expand nodes, reveal long strings, and copy values.
+ Paste copied values into a text editor to check their contents.
+
+ ## JSON versus Python
+
+ JSON should show `true`, `false`, and `null`; Python should show
+ `True`, `False`, and `None`. MIME-looking strings must remain literal
+ text in JSON mode. Expand the long string and check quotes and wrapping.
+ """)
+ return
+
+
+def _():
+ sample = {
+ "text": 'Quotes: "hello"; backslash: \\; newline:\nnext line',
+ "unicode": "こんにちは · café · 🐍",
+ "enabled": True,
+ "disabled": False,
+ "missing": None,
+ "numbers": [0, -7, 3.14159],
+ "empty": {"object": {}, "array": [], "string": ""},
+ "long": "Expand me! " * 25 + "END OF STRING",
+ "mime_strings": ["text/plain:literal", "text/html:<b>literal</b>"],
+ }
+ return (sample,)
+
+
+def _(mo, sample):
+ mo.json(sample, label="JSON values")
+ return
+
+
+def _(sample):
+ sample
+ return
+
+
[email protected](hide_code=True)
+def _(mo):
+ mo.md("""
+ ## Python types and rich leaves
+
+ Check tuples (including a singleton), sets, large integers, special floats,
+ and non-string keys. Copies should preserve Python literal syntax.
+ HTML and Markdown leaves should render inline without a leaf copy button.
+ """)
+ return
+
+
+def _(mo):
+ {
+ "tuple": (1, True, None),
+ "singleton": ("only",),
+ "set": {1, 2, 3},
+ "empty_set": set(),
+ "frozen": frozenset({"a", "b"}),
+ "big_integer": 2**80,
+ "special_floats": [float("nan"), float("inf"), -float("inf")],
+ "keys": {42: "integer", None: "none", (1, 2): "tuple"},
+ "html": mo.Html("<strong>Rich HTML leaf</strong>"),
+ "markdown": mo.md("**Rich Markdown leaf**"),
+ }
+ return
+
+
[email protected](hide_code=True)
+def _(mo):
+ mo.md("""
+ ## Pagination, counts, and copies
+
+ Each collection has **65 items**. Initially expect 30 visible entries and
+ **35 more items**; after one click, **5 more items**; after another, no
+ pagination button. Counts must stay at 65. Copy the root before expanding:
+ both collections must include every entry through index 64.
+
+ Expanding `a.b` must not change pagination for `a` → `b`, or vice versa.
+ Empty keys and `__proto__` must remain visible as ordinary data keys.
+ """)
+ return
+
+
+def _(mo):
+ mo.json(
+ {
+ "a.b": list(range(65)),
+ "a": {"b": list(range(100, 165))},
+ "object": {f"key_{i:02}": i for i in range(65)},
+ "": "empty key",
+ "__proto__": {"safe": True},
+ },
+ label="Independent pagination",
+ )
+ return
+
+
[email protected](hide_code=True)
+def _(mo):
+ mo.md("""
+ ## Matrix pagination and deep nesting
+
+ The 12 × 60 matrix should start with 5 rows and 5 items per row.
+ Copying it must include all 720 values. Expand the deep tree manually;
+ deeper levels should start collapsed and remain accessible.
+ """)
+ return
+
+
+def _(mo):
+ mo.json([[row * 100 + col for col in range(60)] for row in range(12)])
+ return
+
+
+def _(mo):
+ _tree = {"leaf": "Reached the bottom"}
+ for _level in range(8, 0, -1):
+ _tree = {f"level_{_level}": _tree}
+ mo.json(_tree)
+ return
+
+
[email protected](hide_code=True)
+def _(mo):
+ mo.md("""
+ ## Root values and JSON strings
+
+ Empty containers and scalar JSON roots should render without errors.
+ JSON text passed to `mo.json` should parse into a tree.
+ """)
+ return
+
+
+def _(mo):
+ mo.vstack(
+ [
+ mo.json({}, label="Empty object"),
+ mo.json([], label="Empty array"),
+ mo.json("null"),
+ mo.json("true"),
+ mo.json("42"),
+ mo.json('"hello"'),
+ mo.json('{"parsed": [true, null, {"nested": 1}]}'),
+ ]
+ )
+ return
+
+
[email protected](hide_code=True)
+def _(mo):
+ mo.md("""
+ ## Table popovers and inspector
+
+ Open the object, array, and JSON-string cells. Check expansion, copying,
+ and theme colors in each popover. The plain string should remain text.
+ The inspector should use consistent string colors.
+ """)
+ return
+
+
+def _(json, mo, sample):
+ mo.ui.table(
+ [
+ {
+ "object": sample,
+ "array": list(range(65)),
+ "json_string": json.dumps(sample),
+ "plain_string": "This is not JSON",
+ }
+ ],
+ selection=None,
+ )
+ return
+
+
+def _(mo):
+ from types import SimpleNamespace
+
+ mo.inspect(SimpleNamespace(name="Inspector string", values=[1, True, None]))
+ return
+
+
[email protected](hide_code=True)
+def _(mo):
+ mo.md("""
+ ## Plugin error details (intentional)
+
+ The next output deliberately supplies an invalid plugin option. Expect a
+ **Bad Data** alert. Open **View Data** and check that its JSON tree works.
+ This is an expected frontend validation error, not a Python cell failure.
+ """)
+ return
+
+
+def _(mo):
+ from marimo._plugins.core.web_component import build_stateless_plugin
+
+ mo.Html(
+ build_stateless_plugin(
+ component_name="marimo-json-output",
+ args={
+ "json-data": {"message": "Intentional invalid value-types"},
+ "value-types": "invalid-smoke-test-mode",
+ },
+ )
+ )
+ return
+
+
+if __name__ == "__main__":
+ app.run()
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 4aee403515..e1bec02cff 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -103,12 +103,6 @@ importers:
'@dnd-kit/utilities':
specifier: ^3.2.2
version: 3.2.2([email protected])
- '@emotion/cache':
- specifier: ^11.14.0
- version: 11.14.0
- '@emotion/react':
- specifier: ^11.14.0
- version: 11.14.0(@types/[email protected])([email protected])
'@glideapps/glide-data-grid':
specifier: 6.0.4-alpha24
@@ -160,9 +154,6 @@ importers:
'@marimo-team/smart-cells':
specifier: workspace:*
version: link:../packages/smart-cells
- '@mui/material':
- specifier: ^6.5.0
'@paralleldrive/cuid2':
specifier: ^2.3.1
version: 2.3.1
@@ -196,9 +187,6 @@ importers:
'@tanstack/react-virtual':
specifier: ^3.14.10
- '@textea/json-viewer':
- specifier: ^4.0.1
'@types/humanize-duration':
specifier: ^3.27.4
version: 3.27.4
@@ -220,6 +208,9 @@ importers:
'@uiw/react-codemirror':
specifier: 4.25.11
+ '@uiw/react-json-view':
+ specifier: 2.0.0-alpha.43
'@uwdata/flechette':
specifier: ^1.1.2
version: 1.1.2
@@ -1077,60 +1068,12 @@ packages:
'@emnapi/[email protected]':
resolution: {integrity: sha512-c95qOXkHdydNKhscBTebqEC1CVAZpyqOfVfBzQ1qgzyl3gfeldUjIggDbIZgDKsHLgnsM+igH7TJ/eAasaVuMA==}
- '@emotion/[email protected]':
- resolution: {integrity: sha512-pxHCpT2ex+0q+HH91/zsdHkw/lXd468DIN2zvfvLtPKLLMo6gQj7oLObq8PhkrxOZb/gGCq03S3Z7PDhS8pduQ==}
-
- '@emotion/[email protected]':
- resolution: {integrity: sha512-L/B1lc/TViYk4DcpGxtAVbx0ZyiKM5ktoIyafGkH6zg/tj+mA+NE//aPYKG0k8kCHSHVJrpLpcAlOBEXQ3SavA==}
-
- '@emotion/[email protected]':
- resolution: {integrity: sha512-MyqliTZGuOm3+5ZRSaaBGP3USLw6+EGykkwZns2EPC5g8jJ4z9OrdZY9apkl3+UP9+sdz76YYkwCKP5gh8iY3g==}
-
'@emotion/[email protected]':
resolution: {integrity: sha512-QgD4fyscGcbbKwJmqNvUMSE02OsHUa+lAWKdEUIJKgqe5IwRSKd7+KhibEWdaKwgjLj0DRSHA9biAIqGBk05lw==}
'@emotion/[email protected]':
resolution: {integrity: sha512-30FAj7/EoJ5mwVPOWhAyCX+FPfMDrVecJAM+Iw9NRoSl4BBAQeqj4cApHHUXOVvIPgLVDsCFoz/hGD+5QQD1GQ==}
- '@emotion/[email protected]':
- resolution: {integrity: sha512-O000MLDBDdk/EohJPFUqvnp4qnHeYkVP5B0xEG0D/L7cOKP9kefu2DXn8dj74cQfsEzUqh+sr1RzFqiL1o+PpA==}
- peerDependencies:
- '@types/react': '*'
- react: ^19.2.8
- peerDependenciesMeta:
- '@types/react':
- optional: true
-
- '@emotion/[email protected]':
- resolution: {integrity: sha512-EISGqt7sSNWHGI76hC7x1CksiXPahbxEOrC5RjmFRJTqLyEK9/9hZvBbiYn70dw4wuwMKiEMCUlR6ZXTSWQqxA==}
-
- '@emotion/[email protected]':
- resolution: {integrity: sha512-fTBW9/8r2w3dXWYM4HCB1Rdp8NLibOw2+XELH5m5+AkWiL/KqYX6dc0kKYlaYyKjrQ6ds33MCdMPEwgs2z1rqg==}
-
- '@emotion/[email protected]':
- resolution: {integrity: sha512-qEEJt42DuToa3gurlH4Qqc1kVpNq8wO8cJtDzU46TjlzWjDlsVyevtYCRijVq3SrHsROS+gVQ8Fnea108GnKzw==}
- peerDependencies:
- '@emotion/react': ^11.0.0-rc.0
- '@types/react': '*'
- react: ^19.2.8
- peerDependenciesMeta:
- '@types/react':
- optional: true
-
- '@emotion/[email protected]':
- resolution: {integrity: sha512-dFoMUuQA20zvtVTuxZww6OHoJYgrzfKM1t52mVySDJnMSEa08ruEvdYQbhvyu6soU+NeLVd3yKfTfT0NeV6qGg==}
-
- '@emotion/[email protected]':
- resolution: {integrity: sha512-yJMtVdH59sxi/aVJBpk9FQq+OR8ll5GT8oWd57UpeaKEVGab41JWaCFA7FRLoMLloOZF/c/wsPoe+bfGmRKgDg==}
- peerDependencies:
- react: ^19.2.8
-
- '@emotion/[email protected]':
- resolution: {integrity: sha512-3vLclRofFziIa3J2wDh9jjbkUz9qk5Vi3IZ/FSTKViB0k+ef0fPV7dYrUIugbgupYDx7v9ud/SjrtEP8Y4xLoA==}
-
- '@emotion/[email protected]':
- resolution: {integrity: sha512-snKqtPW01tN0ui7yu9rGv69aJXr/a/Ywvl11sUjNtEcRc+ng/mQriFL0wLXMef74iHa/EkftbDzU9F8iFbH+zg==}
-
'@esbuild/[email protected]':
resolution: {integrity: sha512-9fJMTNFTWZMh5qwrBItuziu834eOCUcEqymSH7pY+zoMVEZg3gcPuBNxH1EvfVYe9h0x/Ptw8KBzv7qxb7l8dg==}
engines: {node: '>=18'}
@@ -1738,86 +1681,6 @@ packages:
resolution: {integrity: sha512-VVPPgHyQ6ShqnrmDWuxjmUIsO9gWyOZFmuOfLd9LfBGQJwZfy0gvv9pbHSJuoFNIYC7ZDX9aoFwowjcdSC4E8w==}
engines: {node: '>=18'}
- resolution: {integrity: sha512-LGb8t8i6M2ZtS3Drn3GbTI1DVhDY6FJ9crEey2lZ0aN2EMZo8IZBZj9wRf4vqbZHaWjsYgtbOnJw5V8UWbmK2Q==}
-
- resolution: {integrity: sha512-yjvtXoFcrPLGtgKRxFaH6OQPtcLPhkloC0BML6rBG5UeldR0nPULR/2E2BfXdo5JNV7j7lOzrrLX2Qf/iSidow==}
- engines: {node: '>=14.0.0'}
- peerDependencies:
- '@emotion/react': ^11.5.0
- '@emotion/styled': ^11.3.0
- '@mui/material-pigment-css': ^6.5.0
- '@types/react': ^17.0.0 || ^18.0.0 || ^19.0.0
- react: ^19.2.8
- react-dom: ^19.2.8
- peerDependenciesMeta:
- '@emotion/react':
- optional: true
- '@emotion/styled':
- optional: true
- '@mui/material-pigment-css':
- optional: true
- '@types/react':
- optional: true
-
- resolution: {integrity: sha512-LktcVmI5X17/Q5SkwjCcdOLBzt1hXuc14jYa7NPShog0GBDCDvKtcnP0V7a2s6EiVRlv7BzbWEJzH6+l/zaCxw==}
- engines: {node: '>=14.0.0'}
- peerDependencies:
- '@types/react': ^17.0.0 || ^18.0.0 || ^19.0.0
- react: ^19.2.8
- peerDependenciesMeta:
- '@types/react':
- optional: true
-
- resolution: {integrity: sha512-8woC2zAqF4qUDSPIBZ8v3sakj+WgweolpyM/FXf8jAx6FMls+IE4Y8VDZc+zS805J7PRz31vz73n2SovKGaYgw==}
- engines: {node: '>=14.0.0'}
- peerDependencies:
- '@emotion/react': ^11.4.1
- '@emotion/styled': ^11.3.0
- react: ^19.2.8
- peerDependenciesMeta:
- '@emotion/react':
- optional: true
- '@emotion/styled':
- optional: true
-
- resolution: {integrity: sha512-XcbBYxDS+h/lgsoGe78ExXFZXtuIlSBpn/KsZq8PtZcIkUNJInkuDqcLd2rVBQrDC1u+rvVovdaWPf2FHKJf3w==}
- engines: {node: '>=14.0.0'}
- peerDependencies:
- '@emotion/react': ^11.5.0
- '@emotion/styled': ^11.3.0
- '@types/react': ^17.0.0 || ^18.0.0 || ^19.0.0
- react: ^19.2.8
- peerDependenciesMeta:
- '@emotion/react':
- optional: true
- '@emotion/styled':
- optional: true
- '@types/react':
- optional: true
-
- resolution: {integrity: sha512-3c8tRt/CbWZ+pEg7QpSwbdxOk36EfmhbKf6AGZsD1EcLDLTSZoxxJ86FVtcjxvjuhdyBiWKSTGZFaXCnidO2kw==}
- peerDependencies:
- '@types/react': ^17.0.0 || ^18.0.0 || ^19.0.0
- peerDependenciesMeta:
- '@types/react':
- optional: true
-
- resolution: {integrity: sha512-Y12Q9hbK9g+ZY0T3Rxrx9m2m10gaphDuUMgWxyV5kNJevVxXYCLclYUCC9vXaIk1/NdNDTcW2Yfr2OGvNFNmHg==}
- engines: {node: '>=14.0.0'}
- peerDependencies:
- '@types/react': ^17.0.0 || ^18.0.0 || ^19.0.0
- react: ^19.2.8
- peerDependenciesMeta:
- '@types/react':
- optional: true
-
'@napi-rs/[email protected]':
resolution: {integrity: sha512-UMduMbqO5s5zF2NkNacMT/yK5Y5QiKvWr2+50bzIIxFDwVJ2h49b+oyjaCGPhJxd2/gC2x39EHv/gHVuu36x2Q==}
engines: {node: ^20.19.0 || ^22.13.0 || >=23.5.0}
@@ -2534,9 +2397,6 @@ packages:
'@plotly/[email protected]':
resolution: {integrity: sha512-Mdk+vUACbQvjd0m/1JJjOOafmkp/EpmHjISsopEz5Av44CBq7rPC05HHNbYGKVyNUF2zmEoBS/TT0pd0SPFFyw==}
- '@popperjs/[email protected]':
- resolution: {integrity: sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A==}
-
'@radix-ui/[email protected]':
resolution: {integrity: sha512-FUOsGBkHrYJwCSEtWRCIfQbZG7q1e6DgxCIOe1SUQzDe/7rXXeA47s8yCn6fuTNQAj1Zq4oTFi9Yjp3wzElcxg==}
@@ -4529,15 +4389,6 @@ packages:
peerDependencies:
'@testing-library/dom': '>=7.21.4'
- '@textea/[email protected]':
- resolution: {integrity: sha512-7FH4ti3kVNyKhe/gl85w+8KllXJY9XQalY2KZnBn9ST1CjhqZQCWJLkYf24aX2FOv2D/8cvAllYkFX46A7C9KQ==}
- peerDependencies:
- '@emotion/react': ^11
- '@emotion/styled': ^11
- '@mui/material': ^6
- react: ^19.2.8
- react-dom: ^19.2.8
-
resolution: {integrity: sha512-9nKgKoF6ZOUsM+or0OtNf+TTJSfGvDNP7ZFv/ZGWVwOSCkumyctQiTeHwB4UNljHTnC41AqylgbunLDHoccNrA==}
cpu: [x64]
@@ -4798,9 +4649,6 @@ packages:
resolution: {integrity: sha512-Dh8vAsV36ig5wa9OX4pXvMc9D3Veibfw2wix0CUwYODLD8nkj9UsLjASr49nPg+2eKzxhBV+v7L8pXvT4e639Q==}
- '@types/[email protected]':
- resolution: {integrity: sha512-dISoDXWWQwUquiKsyZ4Ng+HX2KsPL7LyHKHQwgGFEA3IaKac4Obd+h2a/a6waisAoepJlBcx9paWqjA8/HVjCw==}
-
resolution: {integrity: sha512-j3pOPiEcWZ34R6a6mN07mUkM4o4Lwf6hPNt8eilOeZhTFbxFXmKhvXl9Y28jotFPaI1bpPDJsbCprUoNke6OrA==}
@@ -4810,9 +4658,6 @@ packages:
resolution: {integrity: sha512-krUVNut/+kd5Q8p10bFwv3e61s96s0HEIBMSbNCgCxgQ7FwzJW3ByRlO6cDBeTVEUQNPdPt/ZftlfrBLaX7uFg==}
- '@types/[email protected]':
- resolution: {integrity: sha512-F6bEyamV9jKGAFBEmlQnesRPGOQqS2+Uwi0Em15xenOxHaf2hv6L8YCVn3rPdPJOiJfPiCnLIRyvwVaqMY3MIw==}
-
resolution: {integrity: sha512-fMPwH9v7r/pp43yUd2/Mbiex5KouJwwR3dzHkhLREUC6764VyDsqxhAxv6OFEYR1RhjOyD1naqba8ECDBe7ZQg==}
peerDependencies:
@@ -4821,11 +4666,6 @@ packages:
resolution: {integrity: sha512-Cw7+sb3yyjtmxwwJiXtEXcu5h4cgs+sCGkHwHXsFmPyV30bf14LeD/fa2LwQovuD2HWxCcjIdNhDlcYGj95qGA==}
- '@types/[email protected]':
- resolution: {integrity: sha512-8TV6R3h2j7a91c+1DXdJi3Syo69zzIZbz7Lg5tORM5LEJG7X/E6a1V3drRyBRZq7/utz7A+c4OgYLiLcYGHG6w==}
- peerDependencies:
- '@types/react': '*'
-
resolution: {integrity: sha512-AnzbBERsrLKtk2XSfTbYRLjQPdy116Sty4q+T+Bp3IC4l6jNBvreVPAHmpq9qhXQM7CXZPjLVmGMw9sy+hxQ3w==}
@@ -4935,6 +4775,13 @@ packages:
react: ^19.2.8
react-dom: ^19.2.8
+ resolution: {integrity: sha512-PMj+6xRDCPbVGccfLUDhx7yGrmVBSeFx3py6bqDds4QIYScXo9GEgtTbWXn3gXpoehsmOu//6dveYTf872wu3Q==}
+ peerDependencies:
+ '@babel/runtime': '>=7.10.0'
+ react: ^19.2.8
+ react-dom: ^19.2.8
+
resolution: {integrity: sha512-WmoN8qaIAo7WTYWbAZuG8PYEhn5fkz7dZrqTBZ7dtt//lL2Gwms1IcnQ5yHqjDfX8Ft5j4YzDM23f87zBfDe9g==}
deprecated: Potential CWE-502 - Update to 1.3.1 or higher
@@ -5289,10 +5136,6 @@ packages:
resolution: {integrity: sha512-lHe62zvbTB5eEABUVi/AwVh0ZKY9rMMDhmm+eeyuuUQbQ3+J+fONVQOZyj+DdrvD4BY33uYniyRJ4UJIaSKAfw==}
- resolution: {integrity: sha512-Cg7TFGpIr01vOQNODXOOaGz2NpCU5gl8x1qJFbb6hbZxR7XrcE2vtbAsTAbJ7/xwJtUuJEw8K8Zr/AE0LHlesg==}
- engines: {node: '>=10', npm: '>=6'}
-
resolution: {integrity: sha512-0xO6mYd7JB2YesxDKplafRpsiOzPt9V02ddPCLbY1xYGPOX24NTyN50qnUxgCPcSoYMhKpAuBTjQoRZCAkUDRw==}
@@ -5662,9 +5505,6 @@ packages:
resolution: {integrity: sha512-ei8Aos7ja0weRpFzJnEA9UHJ/7XQmqglbRwnf2ATjcB9Wq874VKH9kfjjirM6UhU2/E5fFYadylyhFldcqSidQ==}
engines: {node: '>=18'}
- resolution: {integrity: sha512-2KV8NhB5JqC3ky0r9PMCAZKbUHSwtEo4CwCs0KXgruG43gX5PMqDEBbVU4OUzw2MuAWUfsuFmWvEKG5QRfSnJA==}
-
resolution: {integrity: sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ==}
@@ -5681,10 +5521,6 @@ packages:
resolution: {integrity: sha512-AzlgcsCbUMymkADOJtQm3wO9S3ltPfYOFD5033keQn9NJzIbtnZj+UdBJe7DYml/8TdbtHJW3j58SOnKhWY/5g==}
- resolution: {integrity: sha512-AdmX6xUzdNASswsFtmwSt7Vj8po9IuqXm0UXz7QKPuEUmPB4XyjGfaAr2PSuELMwkRMVH1EpIkX5bTZGRB3eCA==}
- engines: {node: '>=10'}
-
resolution: {integrity: sha512-itvL5h8RETACmOTFc4UfIyB2RfEHi71Ax6E/PivVxq9NseKbOWpeyHEOIbmAw1rs8Ak0VursQNww7lf7YtUwzg==}
engines: {node: '>=14'}
@@ -6158,9 +5994,6 @@ packages:
resolution: {integrity: sha512-7ZgogeTnjuHbo+ct10G9Ffp0mif17idi0IyWNVA/wcwcm7NPOD/WEHVP3n7n3MhXqxoIYm8d6MuZohYWIZ4T3w==}
- resolution: {integrity: sha512-nRCa7CK3VTrM2NmGkIy4cbK7IZlgBE/PYMn55rrXefr5xXDP0LdtfPnblFDoVdcAfslJ7or6iqAUnx0CCGIWQA==}
-
resolution: {integrity: sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==}
@@ -6315,10 +6148,6 @@ packages:
resolution: {integrity: sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==}
- resolution: {integrity: sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==}
- engines: {node: '>=10'}
-
resolution: {integrity: sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==}
engines: {node: '>=12'}
@@ -6500,9 +6329,6 @@ packages:
resolution: {integrity: sha512-S8KoZgRZN+a5rNwqTxlZZePjT/4cnm0ROV70LedRHZ0p8u9fRID0hJUZQpkKLzro8LfmC8sx23bY6tVNxv8pQA==}
engines: {node: '>= 18.0.0'}
- resolution: {integrity: sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==}
-
resolution: {integrity: sha512-jvElSjyuo4EMQGoTwo1uJU5pQMwTW5lS1x05zzfJuTIyLR3zwO27LYrxNg+dlvKpGOuGy/MzBdXh80g0ve5+HA==}
engines: {node: '>=0.10.0'}
@@ -8653,9 +8479,6 @@ packages:
resolution: {integrity: sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==}
- resolution: {integrity: sha512-Oe56aUPnkHyyDxxkvqtd7KkdQP5uIUfHxd5XTb3wE9d/kRnZLmKbDB0GWk919tdQ+mxxPtG6EAs6RMT6i1qtHg==}
-
resolution: {integrity: sha512-xaijuJB0kzGiUdG7nc2MOMDUDBWPyGAjZtUrow9XxUeua8IqeP+VlIfAZ3bphpcLTnSZXz6z9jcVC/TCwbfgdw==}
peerDependencies:
@@ -8720,12 +8543,6 @@ packages:
'@types/react':
optional: true
- resolution: {integrity: sha512-pZcd1MCJoiKiBR2NRxeCRg13uCXbydPnmB4EOeRrY7480qNWO8IIgQG6zlDkm6uRMsURXPuKq0GWtiM59a5Q6g==}
- peerDependencies:
- react: ^19.2.8
- react-dom: ^19.2.8
-
resolution: {integrity: sha512-wNchkFrrlz64QQOJOf5+dFjy+27bJEwtS1SgliRXVsU60wo3pSntNRlwDws2qPHwrAP/wlm5IyQHBlPCya0JIQ==}
peerDependencies:
@@ -9251,9 +9068,6 @@ packages:
engines: {node: '>=18.12.0'}
hasBin: true
- resolution: {integrity: sha512-Orov6g6BB1sDfYgzWfTHDOxamtX1bE/zo104Dh9e6fqJ3PooipYyfJ0pUmrZO2wAvO8YbEyeFrkV91XTsGMSrw==}
-
resolution: {integrity: sha512-5Z9ZpRzfuH6l/UAvCPAPUo3665Nk2wLaZU3x+TLHKVzIz33+sbJqbtrYoC3KD4/uVOr2Zp+L0LySezP9OHV9yA==}
@@ -9484,9 +9298,6 @@ packages:
resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==}
engines: {node: '>=8.0'}
- resolution: {integrity: sha512-BiZS+C1OS8g/q2RRbJmy59xpyghNBqrr6k5L/uKBGRsTfxmu3ffiRnd8mlGPUVayg8pvfi5urfnu8TU7DVOkLQ==}
-
resolution: {integrity: sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==}
engines: {node: '>=0.6'}
@@ -10232,10 +10043,6 @@ packages:
resolution: {integrity: sha512-2PTINUwsRqSd+s8XxKaJWQlUuEMHJQyEuh2edBbW8KNJz0SJPwUSD2zRWqezFEdN7IzAgeuYHFUCF7o8zRdZ0A==}
- resolution: {integrity: sha512-vIYeF1u3CjlhAFekPPAk2h/Kv4T3mAkMox5OymRiJQB0spDP10LHvt+K7G9Ny6NuuMAb25/6n1qyUjAcGNf/AA==}
- engines: {node: '>= 6'}
-
resolution: {integrity: sha512-2AvhNX3mb8zd6Zy7INTtSpl1F15HW6Wnqj0srWlkKLcpYl/gMIMJiyuGq2KeI2YFxUPjdlB+3Lc10seMLtL4cA==}
engines: {node: '>= 14.6'}
@@ -10948,89 +10755,12 @@ snapshots:
tslib: 2.8.1
optional: true
- '@emotion/[email protected]':
- dependencies:
- '@babel/helper-module-imports': 7.28.6
- '@babel/runtime': 7.27.6
- '@emotion/hash': 0.9.2
- '@emotion/memoize': 0.9.0
- '@emotion/serialize': 1.3.3
- babel-plugin-macros: 3.1.0
- convert-source-map: 1.9.0
- escape-string-regexp: 4.0.0
- find-root: 1.1.0
- source-map: 0.5.7
- stylis: 4.2.0
- transitivePeerDependencies:
- - supports-color
-
- '@emotion/[email protected]':
- dependencies:
- '@emotion/memoize': 0.9.0
- '@emotion/sheet': 1.4.0
- '@emotion/utils': 1.4.2
- '@emotion/weak-memoize': 0.4.0
- stylis: 4.2.0
-
- '@emotion/[email protected]': {}
-
'@emotion/[email protected]':
dependencies:
'@emotion/memoize': 0.9.0
'@emotion/[email protected]': {}
- dependencies:
- '@babel/runtime': 7.27.6
- '@emotion/babel-plugin': 11.13.5
- '@emotion/cache': 11.14.0
- '@emotion/serialize': 1.3.3
- '@emotion/use-insertion-effect-with-fallbacks': 1.2.0([email protected])
- '@emotion/utils': 1.4.2
- '@emotion/weak-memoize': 0.4.0
- hoist-non-react-statics: 3.3.2
- react: 19.2.8
- optionalDependencies:
- '@types/react': 19.2.18
- transitivePeerDependencies:
- - supports-color
-
- '@emotion/[email protected]':
- dependencies:
- '@emotion/hash': 0.9.2
- '@emotion/memoize': 0.9.0
- '@emotion/unitless': 0.10.0
- '@emotion/utils': 1.4.2
- csstype: 3.2.3
-
- '@emotion/[email protected]': {}
-
- dependencies:
- '@babel/runtime': 7.27.6
- '@emotion/babel-plugin': 11.13.5
- '@emotion/is-prop-valid': 1.4.0
- '@emotion/react': 11.14.0(@types/[email protected])([email protected])
- '@emotion/serialize': 1.3.3
- '@emotion/use-insertion-effect-with-fallbacks': 1.2.0([email protected])
- '@emotion/utils': 1.4.2
- react: 19.2.8
- optionalDependencies:
- '@types/react': 19.2.18
- transitivePeerDependencies:
- - supports-color
-
- '@emotion/[email protected]': {}
-
- dependencies:
- react: 19.2.8
-
- '@emotion/[email protected]': {}
-
- '@emotion/[email protected]': {}
-
'@esbuild/[email protected]':
optional: true
@@ -11589,83 +11319,6 @@ snapshots:
outvariant: 1.4.3
strict-event-emitter: 0.5.1
- '@mui/[email protected]': {}
-
- dependencies:
- '@babel/runtime': 7.27.6
- '@mui/core-downloads-tracker': 6.5.0
- '@mui/types': 7.2.24(@types/[email protected])
- '@mui/utils': 6.4.9(@types/[email protected])([email protected])
- '@popperjs/core': 2.11.8
- '@types/react-transition-group': 4.4.12(@types/[email protected])
- clsx: 2.1.1
- csstype: 3.2.3
- prop-types: 15.8.1
- react: 19.2.8
- react-dom: 19.2.8([email protected])
- react-is: 19.1.0
- react-transition-group: 4.4.5([email protected]([email protected]))([email protected])
- optionalDependencies:
- '@emotion/react': 11.14.0(@types/[email protected])([email protected])
- '@emotion/styled': 11.14.1(@emotion/[email protected](@types/[email protected])([email protected]))(@types/[email protected])([email protected])
- '@types/react': 19.2.18
-
- dependencies:
- '@babel/runtime': 7.27.6
- '@mui/utils': 6.4.9(@types/[email protected])([email protected])
- prop-types: 15.8.1
- react: 19.2.8
- optionalDependencies:
- '@types/react': 19.2.18
-
- dependencies:
- '@babel/runtime': 7.27.6
- '@emotion/cache': 11.14.0
- '@emotion/serialize': 1.3.3
- '@emotion/sheet': 1.4.0
- csstype: 3.2.3
- prop-types: 15.8.1
- react: 19.2.8
- optionalDependencies:
- '@emotion/react': 11.14.0(@types/[email protected])([email protected])
- '@emotion/styled': 11.14.1(@emotion/[email protected](@types/[email protected])([email protected]))(@types/[email protected])([email protected])
-
- dependencies:
- '@babel/runtime': 7.27.6
- '@mui/private-theming': 6.4.9(@types/[email protected])([email protected])
- '@mui/types': 7.2.24(@types/[email protected])
- '@mui/utils': 6.4.9(@types/[email protected])([email protected])
- clsx: 2.1.1
- csstype: 3.2.3
- prop-types: 15.8.1
- react: 19.2.8
- optionalDependencies:
- '@emotion/react': 11.14.0(@types/[email protected])([email protected])
- '@emotion/styled': 11.14.1(@emotion/[email protected](@types/[email protected])([email protected]))(@types/[email protected])([email protected])
- '@types/react': 19.2.18
-
- optionalDependencies:
- '@types/react': 19.2.18
-
- dependencies:
- '@babel/runtime': 7.27.6
- '@mui/types': 7.2.24(@types/[email protected])
- '@types/prop-types': 15.7.15
- clsx: 2.1.1
- prop-types: 15.8.1
- react: 19.2.8
- react-is: 19.1.0
- optionalDependencies:
- '@types/react': 19.2.18
-
dependencies:
'@emnapi/core': 1.11.0
@@ -12131,8 +11784,6 @@ snapshots:
'@plotly/[email protected]': {}
- '@popperjs/[email protected]': {}
-
'@radix-ui/[email protected]': {}
'@radix-ui/[email protected]': {}
@@ -14541,20 +14192,6 @@ snapshots:
dependencies:
'@testing-library/dom': 10.4.1
- dependencies:
- '@emotion/react': 11.14.0(@types/[email protected])([email protected])
- '@emotion/styled': 11.14.1(@emotion/[email protected](@types/[email protected])([email protected]))(@types/[email protected])([email protected])
- clsx: 2.1.1
- copy-to-clipboard: 3.3.3
- react: 19.2.8
- react-dom: 19.2.8([email protected])
- zustand: 4.5.7(@types/[email protected])([email protected])
- transitivePeerDependencies:
- - '@types/react'
- - immer
-
optional: true
@@ -14859,16 +14496,12 @@ snapshots:
dependencies:
undici-types: 7.18.2
- '@types/[email protected]': {}
-
'@types/[email protected]': {}
'@types/[email protected]': {}
'@types/[email protected]': {}
- '@types/[email protected]': {}
-
dependencies:
'@types/react': 19.2.18
@@ -14877,10 +14510,6 @@ snapshots:
dependencies:
'@types/react': 19.2.18
- dependencies:
- '@types/react': 19.2.18
-
dependencies:
csstype: 3.2.3
@@ -15014,6 +14643,12 @@ snapshots:
- '@codemirror/lint'
- '@codemirror/search'
+ dependencies:
+ '@babel/runtime': 7.27.6
+ react: 19.2.8
+ react-dom: 19.2.8([email protected])
+
'@ungap/[email protected]': {}
'@upsetjs/[email protected]':
@@ -15404,12 +15039,6 @@ snapshots:
- dependencies:
- '@babel/runtime': 7.27.6
- cosmiconfig: 7.1.0
- resolve: 1.22.10
-
@@ -15780,10 +15409,6 @@ snapshots:
- dependencies:
- toggle-selection: 1.0.6
-
@@ -15801,14 +15426,6 @@ snapshots:
dependencies:
layout-base: 2.0.1
- dependencies:
- '@types/parse-json': 4.0.2
- import-fresh: 3.3.1
- parse-json: 5.2.0
- path-type: 4.0.0
- yaml: 1.10.3
-
dependencies:
env-paths: 2.2.1
@@ -16312,11 +15929,6 @@ snapshots:
- dependencies:
- '@babel/runtime': 7.27.6
- csstype: 3.2.3
-
dependencies:
domelementtype: 2.3.0
@@ -16497,8 +16109,6 @@ snapshots:
-
@@ -16698,8 +16308,6 @@ snapshots:
transitivePeerDependencies:
- supports-color
-
dependencies:
path-exists: 2.1.0
@@ -19402,8 +19010,6 @@ snapshots:
-
dependencies:
'@types/hast': 3.0.4
@@ -19505,15 +19111,6 @@ snapshots:
optionalDependencies:
'@types/react': 19.2.18
- dependencies:
- '@babel/runtime': 7.27.6
- dom-helpers: 5.2.1
- loose-envify: 1.4.0
- prop-types: 15.8.1
- react: 19.2.8
- react-dom: 19.2.8([email protected])
-
dependencies:
react: 19.2.8
@@ -20290,8 +19887,6 @@ snapshots:
- supports-color
- typescript
-
@@ -20499,8 +20094,6 @@ snapshots:
dependencies:
is-number: 7.0.0
-
@@ -21445,8 +21038,6 @@ snapshots:
-
diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml
index 0b05442c3e..9666372cec 100644
--- a/pnpm-workspace.yaml
+++ b/pnpm-workspace.yaml
@@ -45,7 +45,6 @@ trustPolicyExclude:
- "@octokit/[email protected]"
- "@octokit/[email protected]"
- - "@textea/[email protected]"
- "[email protected] || 6.3.1"