✨ Innovative and open-source visualization application that transforms various data formats, such as JSON, YAML, XML and CSV into interactive graphs.
refactor: rename JsonCrack to JSONCrack for consistency
AykutSarac1d6a95848bc5
diff --git a/apps/vscode/src/App.tsx b/apps/vscode/src/App.tsxindex e6fbfd3f..d38ab811 100644--- a/apps/vscode/src/App.tsx+++ b/apps/vscode/src/App.tsx@@ -1,7 +1,7 @@import { useCallback, useEffect, useState } from "react";import { Anchor, Box, MantineProvider, Text } from "@mantine/core";import type { NodeData } from "jsoncrack-react";-import { JsonCrack } from "jsoncrack-react";+import { JSONCrack } from "jsoncrack-react";import { NodeModal } from "./components/NodeModal";function getTheme() {@@ -44,7 +44,7 @@ const App: React.FC = () => {return (<MantineProvider forceColorScheme={theme}><Box h="100vh" w="100vw">- <JsonCrack json={json} theme={theme} showControls={false} onNodeClick={handleNodeClick} />+ <JSONCrack json={json} theme={theme} showControls={false} onNodeClick={handleNodeClick} />{selectedNode && (<NodeModal opened={!!selectedNode} onClose={closeNodeModal} nodeData={selectedNode} />)}diff --git a/apps/www/src/features/editor/Toolbar/index.tsx b/apps/www/src/features/editor/Toolbar/index.tsxindex 9cfd4b4f..32b7f139 100644--- a/apps/www/src/features/editor/Toolbar/index.tsx+++ b/apps/www/src/features/editor/Toolbar/index.tsx@@ -5,7 +5,7 @@ import styled from "styled-components";import toast from "react-hot-toast";import { AiOutlineFullscreen } from "react-icons/ai";import { FaGithub } from "react-icons/fa6";-import { JSONCrackLogo } from "../../../layout/JsonCrackLogo";+import { JSONCrackLogo } from "../../../layout/JSONCrackBrandLogo";import { FileMenu } from "./FileMenu";import { ThemeToggle } from "./ThemeToggle";import { ToolsMenu } from "./ToolsMenu";diff --git a/apps/www/src/features/editor/views/GraphView/CustomNode/TextNode.tsx b/apps/www/src/features/editor/views/GraphView/CustomNode/TextNode.tsxindex 718ced9d..9c75b23e 100644--- a/apps/www/src/features/editor/views/GraphView/CustomNode/TextNode.tsx+++ b/apps/www/src/features/editor/views/GraphView/CustomNode/TextNode.tsx@@ -1,7 +1,6 @@import React from "react";import styled from "styled-components";import type { CustomNodeProps } from ".";-import useConfig from "../../../../../store/useConfig";import { isContentImage } from "../lib/utils/calculateNodeSize";import { TextRenderer } from "./TextRenderer";import * as Styled from "./styles";@@ -28,8 +27,7 @@ const StyledImage = styled.img`const Node = ({ node, x, y }: CustomNodeProps) => {const { text, width, height } = node;- const imagePreviewEnabled = useConfig(state => state.imagePreviewEnabled);- const isImage = imagePreviewEnabled && isContentImage(JSON.stringify(text[0].value));+ const isImage = isContentImage(JSON.stringify(text[0].value));const value = text[0].value;return (diff --git a/apps/www/src/features/editor/views/GraphView/OptionsMenu.tsx b/apps/www/src/features/editor/views/GraphView/OptionsMenu.tsxindex fc99858c..a56569e2 100644--- a/apps/www/src/features/editor/views/GraphView/OptionsMenu.tsx+++ b/apps/www/src/features/editor/views/GraphView/OptionsMenu.tsx@@ -32,10 +32,8 @@ const rotateLayout = (direction: LayoutDirection) => {export const OptionsMenu = () => {const toggleGestures = useConfig(state => state.toggleGestures);const toggleRulers = useConfig(state => state.toggleRulers);- const toggleImagePreview = useConfig(state => state.toggleImagePreview);const gesturesEnabled = useConfig(state => state.gesturesEnabled);const rulersEnabled = useConfig(state => state.rulersEnabled);- const imagePreviewEnabled = useConfig(state => state.imagePreviewEnabled);const setDirection = useGraph(state => state.setDirection);const direction = useGraph(state => state.direction);const setVisible = useModal(state => state.setVisible);@@ -145,15 +143,6 @@ export const OptionsMenu = () => {><Text size="xs">Zoom on Scroll</Text></Menu.Item>- <Menu.Item- leftSection={<BsCheck2 opacity={imagePreviewEnabled ? 100 : 0} />}- onClick={() => {- toggleImagePreview(!imagePreviewEnabled);- gaEvent("toggle_image_preview", { label: imagePreviewEnabled ? "on" : "off" });- }}- >- <Text size="xs">Image Link Preview</Text>- </Menu.Item></Menu.Dropdown></Menu></Menu.Dropdown>diff --git a/apps/www/src/features/editor/views/GraphView/index.tsx b/apps/www/src/features/editor/views/GraphView/index.tsxindex ec76508a..87768994 100644--- a/apps/www/src/features/editor/views/GraphView/index.tsx+++ b/apps/www/src/features/editor/views/GraphView/index.tsx@@ -1,7 +1,7 @@import React from "react";import { Box } from "@mantine/core";import styled from "styled-components";-import { JsonCrack } from "jsoncrack-react";+import { JSONCrack } from "jsoncrack-react";import type { NodeData } from "jsoncrack-react";import { useLongPress } from "use-long-press";import { SUPPORTED_LIMIT } from "../../../../constants/graph";@@ -34,7 +34,6 @@ export const GraphView = ({ isWidget = false }: GraphProps) => {const setSelectedNode = useGraph(state => state.setSelectedNode);const gesturesEnabled = useConfig(state => state.gesturesEnabled);const rulersEnabled = useConfig(state => state.rulersEnabled);- const imagePreviewEnabled = useConfig(state => state.imagePreviewEnabled);const darkmodeEnabled = useConfig(state => state.darkmodeEnabled);const json = useJson(state => state.json);const setVisible = useModal(state => state.setVisible);@@ -79,20 +78,19 @@ export const GraphView = ({ isWidget = false }: GraphProps) => {onClick={blurOnClick}{...bindLongPress()}>- <JsonCrack- key={[direction, gesturesEnabled, rulersEnabled, imagePreviewEnabled].join("-")}+ <JSONCrack+ key={[direction, gesturesEnabled, rulersEnabled].join("-")}json={json}theme={darkmodeEnabled ? "dark" : "light"}- direction={direction}+ layoutDirection={direction}showControls={false}showGrid={rulersEnabled}- zoomOnScroll={gesturesEnabled}- imagePreview={imagePreviewEnabled}- maxVisibleNodes={maxVisibleNodes}- fitViewOnLayout- onViewPortCreate={setViewPort}+ trackpadZoom={gesturesEnabled}+ maxRenderableNodes={maxVisibleNodes}+ centerOnLayout+ onViewportCreate={setViewPort}onNodeClick={handleNodeClick}- renderTooLarge={() => <NotSupported />}+ renderNodeLimitExceeded={() => <NotSupported />}/></StyledEditorWrapper></Box>diff --git a/apps/www/src/features/editor/views/GraphView/lib/utils/calculateNodeSize.ts b/apps/www/src/features/editor/views/GraphView/lib/utils/calculateNodeSize.tsindex 81f69e03..d4259f85 100644--- a/apps/www/src/features/editor/views/GraphView/lib/utils/calculateNodeSize.ts+++ b/apps/www/src/features/editor/views/GraphView/lib/utils/calculateNodeSize.ts@@ -1,5 +1,4 @@import { NODE_DIMENSIONS } from "../../../../../../constants/graph";-import useConfig from "../../../../../../store/useConfig";type Text = number | string | [string, string][];type Size = { width: number; height: number };@@ -51,8 +50,7 @@ const sizeCache = new Map<Text, Size>();setInterval(() => sizeCache.clear(), 120_000);export const calculateNodeSize = (text: Text, isParent = false) => {- const { imagePreviewEnabled } = useConfig.getState();- const isImage = isContentImage(text) && imagePreviewEnabled;+ const isImage = isContentImage(text);const cacheKey = [text, isParent].toString();diff --git a/apps/www/src/layout/JsonCrackLogo.tsx b/apps/www/src/layout/JSONCrackBrandLogo.tsxsimilarity index 100%rename from apps/www/src/layout/JsonCrackLogo.tsxrename to apps/www/src/layout/JSONCrackBrandLogo.tsxdiff --git a/apps/www/src/layout/PageLayout/Footer.tsx b/apps/www/src/layout/PageLayout/Footer.tsxindex d4ce1ba1..addb28ca 100644--- a/apps/www/src/layout/PageLayout/Footer.tsx+++ b/apps/www/src/layout/PageLayout/Footer.tsx@@ -3,7 +3,7 @@ import Link from "next/link";import { Anchor, Container, Divider, Flex, Stack, Text, ThemeIcon } from "@mantine/core";import { FaDiscord, FaGithub, FaLinkedin } from "react-icons/fa";import { FaXTwitter } from "react-icons/fa6";-import { JSONCrackLogo } from "../JsonCrackLogo";+import { JSONCrackLogo } from "../JSONCrackBrandLogo";export const Footer = () => {return (diff --git a/apps/www/src/layout/PageLayout/Navbar.tsx b/apps/www/src/layout/PageLayout/Navbar.tsxindex c521e831..a29c4e87 100644--- a/apps/www/src/layout/PageLayout/Navbar.tsx+++ b/apps/www/src/layout/PageLayout/Navbar.tsx@@ -3,7 +3,7 @@ import Link from "next/link";import { Button, Menu, type MenuItemProps, Text, Stack } from "@mantine/core";import styled from "styled-components";import { LuChevronDown } from "react-icons/lu";-import { JSONCrackLogo } from "../JsonCrackLogo";+import { JSONCrackLogo } from "../JSONCrackBrandLogo";const StyledNavbarWrapper = styled.div`z-index: 3;diff --git a/apps/www/src/pages/_app.tsx b/apps/www/src/pages/_app.tsxindex 7ae218ea..78435e6b 100644--- a/apps/www/src/pages/_app.tsx+++ b/apps/www/src/pages/_app.tsx@@ -68,7 +68,7 @@ const theme = createTheme({},});-function JsonCrack({ Component, pageProps }: AppProps) {+function JSONCrackApp({ Component, pageProps }: AppProps) {const { pathname } = useRouter();// Create a single smart manager that handles pathname logic internally@@ -121,4 +121,4 @@ function JsonCrack({ Component, pageProps }: AppProps) {);}-export default JsonCrack;+export default JSONCrackApp;diff --git a/apps/www/src/store/useConfig.ts b/apps/www/src/store/useConfig.tsindex bd16f487..78d85cc8 100644--- a/apps/www/src/store/useConfig.ts+++ b/apps/www/src/store/useConfig.ts@@ -3,7 +3,6 @@ import { persist } from "zustand/middleware";const initialStates = {darkmodeEnabled: true,- imagePreviewEnabled: true,liveTransformEnabled: true,gesturesEnabled: false,rulersEnabled: true,@@ -11,7 +10,6 @@ const initialStates = {export interface ConfigActions {toggleDarkMode: (value: boolean) => void;- toggleImagePreview: (value: boolean) => void;toggleLiveTransform: (value: boolean) => void;toggleGestures: (value: boolean) => void;toggleRulers: (value: boolean) => void;@@ -25,7 +23,6 @@ const useConfig = create(toggleGestures: gesturesEnabled => set({ gesturesEnabled }),toggleLiveTransform: liveTransformEnabled => set({ liveTransformEnabled }),toggleDarkMode: darkmodeEnabled => set({ darkmodeEnabled }),- toggleImagePreview: imagePreviewEnabled => set({ imagePreviewEnabled }),}),{name: "config",diff --git a/packages/jsoncrack-react/README.md b/packages/jsoncrack-react/README.mdindex f30966c9..85e465d5 100644--- a/packages/jsoncrack-react/README.md+++ b/packages/jsoncrack-react/README.md@@ -28,12 +28,12 @@ import "jsoncrack-react/style.css";## Quick Start```tsx-import { JsonCrack } from "jsoncrack-react";+import { JSONCrack } from "jsoncrack-react";export function Example() {return (<div style={{ height: 700 }}>- <JsonCrack+ <JSONCrackjson={{user: {id: 1,@@ -55,35 +55,34 @@ The wrapper must have an explicit height.| --- | --- | --- | --- || `json` | `string \| object \| unknown[]` | - | Input data to visualize || `theme` | `"dark" \| "light"` | `"dark"` | Canvas theme |-| `direction` | `"LEFT" \| "RIGHT" \| "DOWN" \| "UP"` | `"RIGHT"` | Layout direction |+| `layoutDirection` | `"LEFT" \| "RIGHT" \| "DOWN" \| "UP"` | `"RIGHT"` | Layout direction || `showControls` | `boolean` | `true` | Show built-in camera controls || `showGrid` | `boolean` | `true` | Show grid background |-| `zoomOnScroll` | `boolean` | `false` | Enables touch/trackpad gesture behavior |-| `imagePreview` | `boolean` | `true` | Render image URLs as image nodes |-| `fitViewOnLayout` | `boolean` | `true` | Auto-fit on first/major layout changes |-| `maxVisibleNodes` | `number` | `1500` | Node rendering safety limit |+| `trackpadZoom` | `boolean` | `false` | Enables two-finger trackpad gesture zoom behavior |+| `centerOnLayout` | `boolean` | `true` | Auto-center on first/major layout changes |+| `maxRenderableNodes` | `number` | `1500` | Node rendering safety limit || `className` | `string` | - | Wrapper class || `style` | `React.CSSProperties` | - | Wrapper inline style || `onNodeClick` | `(node: NodeData) => void` | - | Node click callback |-| `onGraphChange` | `(graph: GraphData) => void` | - | Parsed graph callback |+| `onParse` | `(graph: GraphData) => void` | - | Parsed graph callback || `onParseError` | `(error: Error) => void` | - | Parse error callback |-| `onViewPortCreate` | `(viewPort: ViewPort) => void` | - | Viewport ready callback |-| `renderTooLarge` | `(nodeCount: number, maxVisibleNodes: number) => React.ReactNode` | - | Custom fallback when node limit is exceeded |+| `onViewportCreate` | `(viewPort: ViewPort) => void` | - | Viewport ready callback |+| `renderNodeLimitExceeded` | `(nodeCount: number, maxRenderableNodes: number) => React.ReactNode` | - | Custom fallback when node limit is exceeded |## PerformanceThe component renders all nodes as SVG elements. For large inputs, rendering cost grows with the number of nodes.-- **Default limit:** `maxVisibleNodes` is set to `1500`. Graphs exceeding this render a fallback instead of the canvas.+- **Default limit:** `maxRenderableNodes` is set to `1500`. Graphs exceeding this render a fallback instead of the canvas.- **Recommended range:** Up to ~300–500 nodes for smooth interaction. Beyond that, panning and zooming may feel sluggish depending on the device.- **Reduce node count:** Flatten or trim your data before passing it in. Arrays of primitives become individual nodes, so large arrays expand the graph quickly.-- **Custom fallback:** Use `renderTooLarge` to show a message or alternative UI when the limit is hit.+- **Custom fallback:** Use `renderNodeLimitExceeded` to show a message or alternative UI when the limit is hit.```tsx-<JsonCrack+<JSONCrackjson={data}- maxVisibleNodes={300}- renderTooLarge={(count, max) => (+ maxRenderableNodes={300}+ renderNodeLimitExceeded={(count, max) => (<p>Too large to render ({count} nodes, limit is {max})</p>)}/>@@ -93,10 +92,10 @@ The component renders all nodes as SVG elements. For large inputs, rendering cos```tsximport { useRef } from "react";-import { JsonCrack, type JsonCrackRef } from "jsoncrack-react";+import { JSONCrack, type JSONCrackRef } from "jsoncrack-react";export function WithRef({ json }: { json: string }) {- const ref = useRef<JsonCrackRef>(null);+ const ref = useRef<JSONCrackRef>(null);return (<>@@ -104,14 +103,14 @@ export function WithRef({ json }: { json: string }) {<button onClick={() => ref.current?.zoomIn()}>+</button><button onClick={() => ref.current?.zoomOut()}>-</button><div style={{ height: 600 }}>- <JsonCrack ref={ref} json={json} />+ <JSONCrack ref={ref} json={json} /></div></>);}```-`JsonCrackRef` methods:+`JSONCrackRef` methods:- `zoomIn()`- `zoomOut()`@@ -126,15 +125,14 @@ If you only need parser output:```tsimport { parseGraph } from "jsoncrack-react";-const result = parseGraph('{"a":[1,2,3]}', { imagePreviewEnabled: true });+const result = parseGraph('{"a":[1,2,3]}');// result: { nodes, edges, errors }```## Exported Types-- `JsonCrackProps`-- `JsonCrackRef`-- `ParseGraphOptions`+- `JSONCrackProps`+- `JSONCrackRef`- `ParseGraphResult`- `CanvasThemeMode`- `LayoutDirection`diff --git a/packages/jsoncrack-react/src/JsonCrack.tsx b/packages/jsoncrack-react/src/JSONCrackComponent.tsxsimilarity index 81%rename from packages/jsoncrack-react/src/JsonCrack.tsxrename to packages/jsoncrack-react/src/JSONCrackComponent.tsxindex cc93e07a..6c6a2931 100644--- a/packages/jsoncrack-react/src/JsonCrack.tsx+++ b/packages/jsoncrack-react/src/JSONCrackComponent.tsx@@ -5,7 +5,7 @@ import type { ViewPort } from "react-zoomable-ui";import { Space } from "react-zoomable-ui";import { Canvas } from "reaflow";import type { ElkRoot } from "reaflow";-import styles from "./JsonCrack.module.css";+import styles from "./JSONCrackStyles.module.css";import { Controls } from "./components/Controls";import { CustomEdge } from "./components/CustomEdge";import { CustomNode } from "./components/CustomNode";@@ -21,7 +21,7 @@ const layoutOptions = {const objectJsonCache = new WeakMap<object, string>();-export interface JsonCrackRef {+export interface JSONCrackRef {zoomIn: () => void;zoomOut: () => void;setZoom: (zoomFactor: number) => void;@@ -29,26 +29,25 @@ export interface JsonCrackRef {focusFirstNode: () => void;}-export interface JsonCrackProps {+export interface JSONCrackProps {json: string | object | unknown[];theme?: CanvasThemeMode;- direction?: LayoutDirection;+ layoutDirection?: LayoutDirection;showControls?: boolean;showGrid?: boolean;- zoomOnScroll?: boolean;- imagePreview?: boolean;- fitViewOnLayout?: boolean;- maxVisibleNodes?: number;+ trackpadZoom?: boolean;+ centerOnLayout?: boolean;+ maxRenderableNodes?: number;className?: string;style?: React.CSSProperties;onNodeClick?: (node: NodeData) => void;- onGraphChange?: (graph: GraphData) => void;+ onParse?: (graph: GraphData) => void;onParseError?: (error: Error) => void;- onViewPortCreate?: (viewPort: ViewPort) => void;- renderTooLarge?: (nodeCount: number, maxVisibleNodes: number) => React.ReactNode;+ onViewportCreate?: (viewPort: ViewPort) => void;+ renderNodeLimitExceeded?: (nodeCount: number, maxRenderableNodes: number) => React.ReactNode;}-const toJsonText = (json: JsonCrackProps["json"]): string => {+const toJsonText = (json: JSONCrackProps["json"]): string => {if (typeof json === "string") return json;if (json && typeof json === "object") {@@ -63,25 +62,24 @@ const toJsonText = (json: JsonCrackProps["json"]): string => {return JSON.stringify(json, null, 2);};-export const JsonCrack = React.forwardRef<JsonCrackRef, JsonCrackProps>(+export const JSONCrack = React.forwardRef<JSONCrackRef, JSONCrackProps>(({json,theme = "dark",- direction = "RIGHT",+ layoutDirection = "RIGHT",showControls = true,showGrid = true,- zoomOnScroll = false,- imagePreview = true,- fitViewOnLayout = true,- maxVisibleNodes = 1500,+ trackpadZoom = false,+ centerOnLayout = true,+ maxRenderableNodes = 1500,className,style,onNodeClick,- onGraphChange,+ onParse,onParseError,- onViewPortCreate,- renderTooLarge,+ onViewportCreate,+ renderNodeLimitExceeded,},ref) => {@@ -97,26 +95,25 @@ export const JsonCrack = React.forwardRef<JsonCrackRef, JsonCrackProps>(const [paneHeight, setPaneHeight] = React.useState(2000);const hasAutoFittedRef = React.useRef(false);const previousLayoutAreaRef = React.useRef<number | null>(null);- const callbacksRef = React.useRef({ onGraphChange, onParseError });- const onViewPortCreateRef = React.useRef(onViewPortCreate);+ const callbacksRef = React.useRef({ onParse, onParseError });+ const onViewportCreateRef = React.useRef(onViewportCreate);const lastParsedInputRef = React.useRef<{jsonText: string;- imagePreview: boolean;- maxVisibleNodes: number;+ maxRenderableNodes: number;} | null>(null);React.useEffect(() => {- callbacksRef.current = { onGraphChange, onParseError };- }, [onGraphChange, onParseError]);+ callbacksRef.current = { onParse, onParseError };+ }, [onParse, onParseError]);React.useEffect(() => {- onViewPortCreateRef.current = onViewPortCreate;- }, [onViewPortCreate]);+ onViewportCreateRef.current = onViewportCreate;+ }, [onViewportCreate]);React.useEffect(() => {hasAutoFittedRef.current = false;previousLayoutAreaRef.current = null;- }, [direction]);+ }, [layoutDirection]);const centerView = React.useCallback(() => {const nextViewPort = viewPort;@@ -175,17 +172,14 @@ export const JsonCrack = React.forwardRef<JsonCrackRef, JsonCrackProps>(if (lastParsedInput &&lastParsedInput.jsonText === jsonText &&- lastParsedInput.imagePreview === imagePreview &&- lastParsedInput.maxVisibleNodes === maxVisibleNodes+ lastParsedInput.maxRenderableNodes === maxRenderableNodes) {return;}setLoading(true);- const graph = parseGraph(jsonText, {- imagePreviewEnabled: imagePreview,- });+ const graph = parseGraph(jsonText);if (graph.errors.length > 0) {callbacksRef.current.onParseError?.(@@ -195,15 +189,14 @@ export const JsonCrack = React.forwardRef<JsonCrackRef, JsonCrackProps>(setTotalNodes(graph.nodes.length);- if (graph.nodes.length > maxVisibleNodes) {+ if (graph.nodes.length > maxRenderableNodes) {setAboveSupportedLimit(true);setNodes([]);setEdges([]);setLoading(false);lastParsedInputRef.current = {jsonText,- imagePreview,- maxVisibleNodes,+ maxRenderableNodes,};return;}@@ -211,14 +204,13 @@ export const JsonCrack = React.forwardRef<JsonCrackRef, JsonCrackProps>(setAboveSupportedLimit(false);setNodes(graph.nodes);setEdges(graph.edges);- callbacksRef.current.onGraphChange?.({+ callbacksRef.current.onParse?.({nodes: graph.nodes,edges: graph.edges,});lastParsedInputRef.current = {jsonText,- imagePreview,- maxVisibleNodes,+ maxRenderableNodes,};if (graph.nodes.length === 0) {@@ -232,7 +224,7 @@ export const JsonCrack = React.forwardRef<JsonCrackRef, JsonCrackProps>(error instanceof Error ? error : new Error("Unable to parse data."));}- }, [imagePreview, json, maxVisibleNodes]);+ }, [json, maxRenderableNodes]);const edgeTargetById = React.useMemo(() => {const targetById = new Map<string, string>();@@ -266,7 +258,7 @@ export const JsonCrack = React.forwardRef<JsonCrackRef, JsonCrackProps>(previousLayoutArea !== null &&previousLayoutArea > 0 &&Math.abs((currentLayoutArea * 100) / previousLayoutArea - 100) > 70;- const shouldAutoFit = fitViewOnLayout && (isFirstAutoFit || hasLargeLayoutChange);+ const shouldAutoFit = centerOnLayout && (isFirstAutoFit || hasLargeLayoutChange);if (shouldAutoFit) {centerView();@@ -277,10 +269,10 @@ export const JsonCrack = React.forwardRef<JsonCrackRef, JsonCrackProps>(});}, 0);},- [centerView, fitViewOnLayout]+ [centerView, centerOnLayout]);- const tooLargeContent = renderTooLarge?.(totalNodes, maxVisibleNodes);+ const tooLargeContent = renderNodeLimitExceeded?.(totalNodes, maxRenderableNodes);const canvasClassName = [styles.canvasWrapper, showGrid ? styles.showGrid : "", className].filter(Boolean).join(" ");@@ -331,7 +323,7 @@ export const JsonCrack = React.forwardRef<JsonCrackRef, JsonCrackProps>(tooLargeContent) : (<div className={styles.tooLarge}>- {`This graph has ${totalNodes} nodes and exceeds the maxVisibleNodes limit (${maxVisibleNodes}).`}+ {`This graph has ${totalNodes} nodes and exceeds the maxRenderableNodes limit (${maxRenderableNodes}).`}</div>))}@@ -344,23 +336,17 @@ export const JsonCrack = React.forwardRef<JsonCrackRef, JsonCrackProps>(<SpaceonCreate={nextViewPort => {setViewPort(nextViewPort);- onViewPortCreateRef.current?.(nextViewPort);+ onViewportCreateRef.current?.(nextViewPort);}}onContextMenu={event => event.preventDefault()}- treatTwoFingerTrackPadGesturesLikeTouch={zoomOnScroll}+ treatTwoFingerTrackPadGesturesLikeTouch={trackpadZoom}pollForElementResizingclassName="jsoncrack-space"><CanvasclassName="jsoncrack-canvas"onLayoutChange={onLayoutChange}- node={nodeProps => (- <CustomNode- {...nodeProps}- imagePreviewEnabled={imagePreview}- onNodeClick={onNodeClick}- />- )}+ node={nodeProps => <CustomNode {...nodeProps} onNodeClick={onNodeClick} />}edge={edgeProps => (<CustomEdge{...edgeProps}@@ -376,9 +362,9 @@ export const JsonCrack = React.forwardRef<JsonCrackRef, JsonCrackProps>(maxWidth={paneWidth}height={paneHeight}width={paneWidth}- direction={direction}+ direction={layoutDirection}layoutOptions={layoutOptions}- key={direction}+ key={layoutDirection}pannable={false}zoomable={false}animated={false}@@ -393,4 +379,4 @@ export const JsonCrack = React.forwardRef<JsonCrackRef, JsonCrackProps>(});-JsonCrack.displayName = "JsonCrack";+JSONCrack.displayName = "JSONCrack";diff --git a/packages/jsoncrack-react/src/JsonCrack.module.css b/packages/jsoncrack-react/src/JSONCrackStyles.module.csssimilarity index 100%rename from packages/jsoncrack-react/src/JsonCrack.module.cssrename to packages/jsoncrack-react/src/JSONCrackStyles.module.cssdiff --git a/packages/jsoncrack-react/src/components/CustomNode.tsx b/packages/jsoncrack-react/src/components/CustomNode.tsxindex cf946ad9..02965bdc 100644--- a/packages/jsoncrack-react/src/components/CustomNode.tsx+++ b/packages/jsoncrack-react/src/components/CustomNode.tsx@@ -6,11 +6,10 @@ import { ObjectNode } from "./ObjectNode";import { TextNode } from "./TextNode";type CustomNodeProps = NodeProps<NodeData> & {- imagePreviewEnabled: boolean;onNodeClick?: (node: NodeData) => void;};-const CustomNodeBase = ({ imagePreviewEnabled, onNodeClick, ...nodeProps }: CustomNodeProps) => {+const CustomNodeBase = ({ onNodeClick, ...nodeProps }: CustomNodeProps) => {const handleNodeClick = React.useCallback((_: React.MouseEvent<SVGGElement, MouseEvent>, data: NodeData) => {onNodeClick?.(data);@@ -39,14 +38,7 @@ const CustomNodeBase = ({ imagePreviewEnabled, onNodeClick, ...nodeProps }: Cust{({ node, x, y }) => {const hasKey = nodeProps.properties.text[0]?.key;if (!hasKey) {- return (- <TextNode- node={nodeProps.properties as NodeData}- x={x}- y={y}- imagePreviewEnabled={imagePreviewEnabled}- />- );+ return <TextNode node={nodeProps.properties as NodeData} x={x} y={y} />;}return <ObjectNode node={node as NodeData} x={x} y={y} />;diff --git a/packages/jsoncrack-react/src/components/TextNode.tsx b/packages/jsoncrack-react/src/components/TextNode.tsxindex b59237f5..b544a705 100644--- a/packages/jsoncrack-react/src/components/TextNode.tsx+++ b/packages/jsoncrack-react/src/components/TextNode.tsx@@ -9,10 +9,9 @@ type TextNodeProps = {node: NodeData;x: number;y: number;- imagePreviewEnabled: boolean;};-const TextNodeBase = ({ node, x, y, imagePreviewEnabled }: TextNodeProps) => {+const TextNodeBase = ({ node, x, y }: TextNodeProps) => {const { text, width, height } = node;const firstRow = text[0];@@ -20,7 +19,7 @@ const TextNodeBase = ({ node, x, y, imagePreviewEnabled }: TextNodeProps) => {const value = firstRow.value;const normalizedValue = typeof value === "string" ? value : `${value}`;- const isImage = imagePreviewEnabled && isContentImage(normalizedValue);+ const isImage = isContentImage(normalizedValue);return (<foreignObject@@ -63,11 +62,7 @@ const TextNodeBase = ({ node, x, y, imagePreviewEnabled }: TextNodeProps) => {};const propsAreEqual = (prev: TextNodeProps, next: TextNodeProps) => {- return (- prev.imagePreviewEnabled === next.imagePreviewEnabled &&- prev.node.text === next.node.text &&- prev.node.width === next.node.width- );+ return prev.node.text === next.node.text && prev.node.width === next.node.width;};export const TextNode = React.memo(TextNodeBase, propsAreEqual);diff --git a/packages/jsoncrack-react/src/index.ts b/packages/jsoncrack-react/src/index.tsindex cf78600f..d2824ea1 100644--- a/packages/jsoncrack-react/src/index.ts+++ b/packages/jsoncrack-react/src/index.ts@@ -1,7 +1,7 @@-export { JsonCrack } from "./JsonCrack";+export { JSONCrack } from "./JSONCrackComponent";export { parseGraph } from "./parser";-export type { JsonCrackProps, JsonCrackRef } from "./JsonCrack";-export type { ParseGraphOptions, ParseGraphResult } from "./parser";+export type { JSONCrackProps, JSONCrackRef } from "./JSONCrackComponent";+export type { ParseGraphResult } from "./parser";export type {CanvasThemeMode,EdgeData,diff --git a/packages/jsoncrack-react/src/parser.ts b/packages/jsoncrack-react/src/parser.tsindex a41efb95..50af93b3 100644--- a/packages/jsoncrack-react/src/parser.ts+++ b/packages/jsoncrack-react/src/parser.ts@@ -2,15 +2,11 @@ import { getNodePath, parseTree, type Node, type ParseError } from "jsonc-parserimport type { EdgeData, GraphData, NodeData, NodeRow } from "./types";import { calculateNodeSize } from "./utils/calculateNodeSize";-export interface ParseGraphOptions {- imagePreviewEnabled?: boolean;-}-export interface ParseGraphResult extends GraphData {errors: ParseError[];}-export const parseGraph = (json: string, options: ParseGraphOptions = {}): ParseGraphResult => {+export const parseGraph = (json: string): ParseGraphResult => {const parseErrors: ParseError[] = [];const jsonTree = parseTree(json, parseErrors);@@ -44,11 +40,7 @@ export const parseGraph = (json: string, options: ParseGraphOptions = {}): Parseconst isRootArray = !node.parent || node.parent.type === "array";if (isArray && isRootArray) {- const { width, height } = calculateNodeSize(- `[${node.children?.length ?? "0"} items]`,- false,- options.imagePreviewEnabled ?? true- );+ const { width, height } = calculateNodeSize(`[${node.children?.length ?? "0"} items]`);nodes.push({id,@@ -170,11 +162,7 @@ export const parseGraph = (json: string, options: ParseGraphOptions = {}): Parseif (text.length === 0) {if (typeof node.value === "undefined") return undefined;- const { width, height } = calculateNodeSize(- node.value as string | number,- false,- options.imagePreviewEnabled ?? true- );+ const { width, height } = calculateNodeSize(node.value as string | number);nodes.push({id,@@ -207,11 +195,7 @@ export const parseGraph = (json: string, options: ParseGraphOptions = {}): ParsedisplayText = `${text[0].value}`;}- const { width, height } = calculateNodeSize(- displayText,- false,- options.imagePreviewEnabled ?? true- );+ const { width, height } = calculateNodeSize(displayText);nodes.push({id,diff --git a/packages/jsoncrack-react/src/theme.ts b/packages/jsoncrack-react/src/theme.tsindex 90cbf5d9..477b341a 100644--- a/packages/jsoncrack-react/src/theme.ts+++ b/packages/jsoncrack-react/src/theme.ts@@ -1,6 +1,6 @@import type { CanvasThemeMode } from "./types";-export interface JsonCrackTheme {+export interface JSONCrackTheme {NODE_COLORS: {TEXT: string;NODE_KEY: string;@@ -23,7 +23,7 @@ export interface JsonCrackTheme {GRID_COLOR_SECONDARY: string;}-export const themes: Record<CanvasThemeMode, JsonCrackTheme> = {+export const themes: Record<CanvasThemeMode, JSONCrackTheme> = {dark: {NODE_COLORS: {TEXT: "#DCE5E7",diff --git a/packages/jsoncrack-react/src/utils/calculateNodeSize.ts b/packages/jsoncrack-react/src/utils/calculateNodeSize.tsindex f8ab80a5..8ebe547f 100644--- a/packages/jsoncrack-react/src/utils/calculateNodeSize.ts+++ b/packages/jsoncrack-react/src/utils/calculateNodeSize.ts@@ -73,11 +73,11 @@ const maybeClearCache = () => {lastCacheClearAt = Date.now();};-export const calculateNodeSize = (text: Text, isParent = false, imagePreviewEnabled = true) => {+export const calculateNodeSize = (text: Text, isParent = false) => {maybeClearCache();- const isImage = isContentImage(text) && imagePreviewEnabled;- const cacheKey = `${JSON.stringify(text)}-${isParent}-${imagePreviewEnabled}`;+ const isImage = isContentImage(text);+ const cacheKey = `${JSON.stringify(text)}-${isParent}`;const cached = sizeCache.get(cacheKey);if (cached) return cached;