@dxos/react-ui-syntax-highlighter 0.16.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -151,8 +151,9 @@ var CopyOverlay = ({ source }) => /* @__PURE__ */ jsx("div", {
151
151
  })
152
152
  });
153
153
  /** The non-scrolling leaf: all scrolling is deferred to an enclosing viewport. */
154
- var SyntaxHighlighterLeaf = Util.composable(({ classNames, className, children, role, style, themeStyle, language: languageProp = "text", fallback = zeroWidthSpace, copyButton, ...nativeProps }, forwardedRef) => {
155
- const themeMode = Hooks.useThemeMode();
154
+ var SyntaxHighlighterLeaf = Util.composable(({ classNames, className, children, role, style, themeStyle, themeMode: themeModeProp, language: languageProp = "text", fallback = zeroWidthSpace, copyButton, ...nativeProps }, forwardedRef) => {
155
+ const appThemeMode = Hooks.useThemeMode();
156
+ const themeMode = themeModeProp ?? appThemeMode;
156
157
  const source = sourceOf(children, fallback);
157
158
  const language = source.length > MAX_HIGHLIGHTED_LENGTH ? "text" : languageProp;
158
159
  const prismTheme = themeStyle && typeof themeStyle === "object" && Object.keys(themeStyle).length > 0 ? themeStyle : themeMode === "dark" ? coldarkDark : coldarkCold;
@@ -388,6 +389,6 @@ var Syntax = {
388
389
  Code: SyntaxCode
389
390
  };
390
391
  //#endregion
391
- export { JsonHighlighter, Syntax, SyntaxHighlighter, createElement };
392
+ export { JsonHighlighter, Syntax, SyntaxHighlighter, createElement, renderRows };
392
393
 
393
394
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["createElement","dark","light"],"sources":["../../src/SyntaxHighlighter/renderer.ts","../../src/SyntaxHighlighter/SyntaxHighlighter.tsx","../../src/JsonHighlighter/JsonHighlighter.tsx","../../src/Syntax/SyntaxContext.ts","../../src/Syntax/Syntax.tsx"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport { type CSSProperties, type ReactNode, createElement } from 'react';\nimport { type SyntaxHighlighterProps } from 'react-syntax-highlighter';\n\ntype Renderer = NonNullable<SyntaxHighlighterProps['renderer']>;\ntype RendererProps = Parameters<Renderer>[0];\ntype Stylesheet = RendererProps['stylesheet'];\ntype RenderNode = RendererProps['rows'][number];\n\ntype StylesheetIndex = {\n /** Every class name any selector in the stylesheet mentions. */\n selectors: Set<string>;\n /** Merged stylesheet entries, keyed by a node's joined class names. */\n styles: Map<string, CSSProperties>;\n};\n\nconst indexes = new WeakMap<Stylesheet, StylesheetIndex>();\n\nconst indexOf = (stylesheet: Stylesheet): StylesheetIndex => {\n let index = indexes.get(stylesheet);\n if (!index) {\n const selectors = new Set<string>();\n for (const selector of Object.keys(stylesheet)) {\n for (const className of selector.split('.')) {\n selectors.add(className);\n }\n }\n index = { selectors, styles: new Map() };\n indexes.set(stylesheet, index);\n }\n\n return index;\n};\n\n/**\n * Every ordered selection of one to four class names, shortest first — the selector keys a\n * compound class list can match, in the precedence order `react-syntax-highlighter` applies them.\n */\nconst classNameCombinations = (classNames: string[]): string[] => {\n const pool = classNames.slice(0, 4);\n const combinations: string[] = [];\n const extend = (prefix: string[], remaining: number[], size: number) => {\n if (prefix.length === size) {\n combinations.push(prefix.join('.'));\n return;\n }\n for (const position of remaining) {\n extend(\n [...prefix, pool[position]],\n remaining.filter((other) => other !== position),\n size,\n );\n }\n };\n const positions = pool.map((_, position) => position);\n for (let size = 1; size <= pool.length; size++) {\n extend([], positions, size);\n }\n\n return combinations;\n};\n\nconst styleOf = (index: StylesheetIndex, stylesheet: Stylesheet, classNames: string[]): CSSProperties => {\n const key = classNames.join(' ');\n let style = index.styles.get(key);\n if (!style) {\n style = {};\n for (const selector of classNameCombinations(classNames.filter((className) => className !== 'token'))) {\n Object.assign(style, stylesheet[selector]);\n }\n index.styles.set(key, style);\n }\n\n return style;\n};\n\nconst renderNode = (node: RenderNode, stylesheet: Stylesheet, useInlineStyles: boolean, key: string): ReactNode => {\n if (node.type === 'text') {\n return node.value;\n }\n if (!node.tagName) {\n return undefined;\n }\n\n const properties = node.properties ?? { className: [] };\n const classNames: string[] = properties.className ?? [];\n let props: Record<string, unknown>;\n if (!useInlineStyles) {\n props = { ...properties, className: classNames.join(' ') };\n } else {\n const index = indexOf(stylesheet);\n const className = [\n ...(classNames.includes('token') ? ['token'] : []),\n ...classNames.filter((name) => !index.selectors.has(name)),\n ].join(' ');\n props = {\n ...properties,\n className: className || undefined,\n style: { ...properties.style, ...styleOf(index, stylesheet, classNames) },\n };\n }\n\n const children = (node.children ?? []).map((child, position) =>\n renderNode(child, stylesheet, useInlineStyles, `code-segment-1-${position}`),\n );\n return createElement(node.tagName, { key, ...props }, children);\n};\n\n/**\n * Drop-in for `react-syntax-highlighter`'s default row renderer, producing the same elements.\n * The stock renderer rebuilds the stylesheet's full selector list (a quadratic scan) for every\n * token node, which dominated the main thread whenever a highlighted block re-rendered.\n */\nexport const renderRows: Renderer = ({ rows, stylesheet, useInlineStyles }) =>\n rows.map((row, position) => renderNode(row, stylesheet, useInlineStyles, `code-segment-${position}`));\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { Children, type ReactNode, memo } from 'react';\nimport { type SyntaxHighlighterProps as NaturalSyntaxHighlighterProps } from 'react-syntax-highlighter';\nimport NativeSyntaxHighlighter from 'react-syntax-highlighter/dist/esm/prism-async-light';\nimport { coldarkDark as dark, coldarkCold as light } from 'react-syntax-highlighter/dist/esm/styles/prism';\n\nimport * as Hooks from '@dxos/react-ui/Hooks';\nimport * as ScrollArea from '@dxos/react-ui/ScrollArea';\nimport * as SystemButton from '@dxos/react-ui/SystemButton';\nimport * as Util from '@dxos/react-ui/Util';\nimport { mx } from '@dxos/ui-theme';\nimport { type AllowedAxis } from '@dxos/ui-types';\n\nimport { renderRows } from './renderer.ts';\n\nconst zeroWidthSpace = '\\u200b';\n\nconst languages = {\n js: 'javascript',\n ts: 'typescript',\n};\n\n/**\n * Above this, source is rendered unhighlighted. react-syntax-highlighter splices every line into a\n * single token array and wraps every token in an inline-styled element, so tokenizing grows\n * super-linearly in one synchronous render — a 3 MB payload takes about 30 s, and past roughly 123k\n * lines it throws. Plain text skips the tokenizer and keeps this component's own `pre`/`code` styles.\n */\nconst MAX_HIGHLIGHTED_LENGTH = 20_000;\n\nexport type SyntaxHighlighterProps = Pick<\n NaturalSyntaxHighlighterProps,\n | 'language'\n | 'renderer'\n | 'showLineNumbers'\n | 'showInlineLineNumbers'\n | 'startingLineNumber'\n | 'wrapLines'\n | 'wrapLongLines'\n | 'PreTag'\n> & {\n themeStyle?: NaturalSyntaxHighlighterProps['style'];\n fallback?: string;\n copyButton?: boolean;\n /**\n * The axes the built-in `ScrollArea` scrolls on (default: all). `false` renders the bare,\n * non-scrolling leaf for composition inside `Syntax.Viewport`.\n */\n scroll?: AllowedAxis | false;\n};\n\n/**\n * Highlighted source inside the family's themed `ScrollArea`, so a long line scrolls with the thin\n * scrollbar rather than the platform's. Pass `scroll={false}` to get the bare leaf.\n *\n * NOTE: Using `light-async` version directly from dist to avoid any chance of the heavy one being loaded.\n * The lightweight version will load specific language parsers asynchronously.\n *\n * https://github.com/react-syntax-highlighter/react-syntax-highlighter\n * https://react-syntax-highlighter.github.io/react-syntax-highlighter/demo/prism.html\n */\nexport const SyntaxHighlighter = Util.composable<HTMLDivElement, SyntaxHighlighterProps>(\n ({ scroll = 'all', copyButton, classNames, className, role, style, ...props }, forwardedRef) => {\n if (scroll === false) {\n return (\n <SyntaxHighlighterLeaf\n {...props}\n {...{ classNames, className, role, style }}\n copyButton={copyButton}\n ref={forwardedRef}\n />\n );\n }\n\n // The copy button sits on the scroll root so it stays put while the source scrolls under it.\n const source = sourceOf(props.children, props.fallback);\n return (\n <ScrollArea.Root\n role={role ?? 'none'}\n style={style}\n classNames={[className, classNames, copyButton && 'relative group']}\n orientation={scroll}\n ref={forwardedRef}\n >\n <ScrollArea.Viewport>\n <SyntaxHighlighterLeaf {...props} />\n </ScrollArea.Viewport>\n {copyButton && <CopyOverlay source={source} />}\n </ScrollArea.Root>\n );\n },\n);\n\nSyntaxHighlighter.displayName = 'SyntaxHighlighter';\n\nconst sourceOf = (children: ReactNode, fallback = zeroWidthSpace): string =>\n Children.toArray(children).join('') || fallback;\n\nconst CopyOverlay = ({ source }: { source: string }) => (\n <div className='pointer-events-none absolute top-1 right-1 z-10 opacity-0 group-hover:opacity-100 focus-within:opacity-100'>\n <SystemButton.Clipboard\n iconOnly\n value={source}\n variant='ghost'\n iconSize='md'\n classNames='pointer-events-auto aspect-square rounded-sm'\n />\n </div>\n);\n\n/** The non-scrolling leaf: all scrolling is deferred to an enclosing viewport. */\nconst SyntaxHighlighterLeaf = Util.composable<HTMLDivElement, Omit<SyntaxHighlighterProps, 'scroll'>>(\n (\n {\n classNames,\n className,\n children,\n role,\n style,\n themeStyle,\n language: languageProp = 'text',\n fallback = zeroWidthSpace,\n copyButton,\n ...nativeProps\n },\n forwardedRef,\n ) => {\n const themeMode = Hooks.useThemeMode();\n const source = sourceOf(children, fallback);\n const language = source.length > MAX_HIGHLIGHTED_LENGTH ? 'text' : languageProp;\n\n const hasCustomTheme = themeStyle && typeof themeStyle === 'object' && Object.keys(themeStyle).length > 0;\n const prismTheme = hasCustomTheme ? themeStyle : themeMode === 'dark' ? dark : light;\n\n return (\n <div\n {...Util.composableProps(\n { classNames, className, role, style },\n {\n role: 'none',\n classNames: mx('dx-expand overflow-visible p-1', copyButton && 'relative group'),\n },\n )}\n ref={forwardedRef}\n >\n <HighlightedSource\n language={languages[language as keyof typeof languages] || language}\n style={prismTheme}\n {...nativeProps}\n >\n {source}\n </HighlightedSource>\n\n {copyButton && <CopyOverlay source={source} />}\n </div>\n );\n },\n);\n\nSyntaxHighlighterLeaf.displayName = 'SyntaxHighlighterLeaf';\n\nconst customStyle: NaturalSyntaxHighlighterProps['customStyle'] = {\n background: 'unset',\n border: 'none',\n boxShadow: 'none',\n padding: 0,\n margin: 0,\n // This allows setting max-h-[6lh] on the Syntax.Code component.\n lineHeight: 'inherit',\n // Non-scrolling wrapper: defer all scrolling to an enclosing `Syntax.Viewport`.\n // The prism theme sets `overflow: auto` on the <pre>, which otherwise creates a\n // nested native horizontal scrollbar alongside the viewport's custom one.\n overflow: 'visible',\n};\n\nconst codeTagProps: NaturalSyntaxHighlighterProps['codeTagProps'] = {\n style: {\n lineHeight: 'inherit',\n // `block`, not the default `inline`: as an inline box every line is the union of the\n // <pre>'s strut and this element's own box, and the two carry different font stacks\n // (the prism theme's vs the app's), so lines advanced 16.5px under a 16px\n // line-height — enough that a `max-h-[Nlh]` cap showed N-1 lines and a sliver.\n display: 'block',\n },\n};\n\ntype HighlightedSourceProps = Omit<SyntaxHighlighterProps, 'themeStyle' | 'fallback' | 'copyButton' | 'scroll'> & {\n style: NaturalSyntaxHighlighterProps['style'];\n children: string;\n};\n\n/**\n * Memoized on primitive props because tokenizing and building the element tree is the expensive\n * part, and streaming parents (e.g. the assistant's tool panel) re-render with unchanged source.\n */\nconst HighlightedSource = memo(({ children, renderer, wrapLines, ...props }: HighlightedSourceProps) => (\n <NativeSyntaxHighlighter\n customStyle={customStyle}\n // Copied per render: the library writes `whiteSpace` into this style, which would leak across instances.\n codeTagProps={{ ...codeTagProps, style: { ...codeTagProps?.style } }}\n renderer={renderer ?? renderRows}\n // Any renderer makes the library default `wrapLines` to true; only a caller's own renderer should get that.\n wrapLines={wrapLines ?? (renderer ? undefined : false)}\n {...props}\n >\n {/* Non-empty fallback prevents collapse. */}\n {children}\n </NativeSyntaxHighlighter>\n));\n\nHighlightedSource.displayName = 'HighlightedSource';\n\nSyntaxHighlighter.displayName = 'SyntaxHighlighter';\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport React from 'react';\n\nimport * as Util from '@dxos/react-ui/Util';\nimport { type CreateReplacerProps, createReplacer, safeStringify } from '@dxos/util';\n\nimport { SyntaxHighlighter, type SyntaxHighlighterProps } from '../SyntaxHighlighter/index.ts';\n\nexport type JsonReplacer = CreateReplacerProps | ((key: string, value: any) => any);\n\nexport type JsonHighlighterProps = Omit<SyntaxHighlighterProps, 'children' | 'language'> & {\n data?: any;\n replacer?: JsonReplacer;\n /** Indentation passed to `JSON.stringify`. Default: `2` (pretty-printed). Pass `0` for single-line output. */\n indent?: number;\n testId?: string;\n};\n\nconst resolveReplacer = (replacer?: JsonReplacer) => {\n if (!replacer) {\n return undefined;\n }\n\n return typeof replacer === 'function' ? replacer : createReplacer(replacer);\n};\n\n/**\n * JSON in the family's themed `ScrollArea`: the shorthand for showing a value.\n *\n * Thin wrapper around `SyntaxHighlighter` that stringifies `data` with an optional replacer.\n * `replacer` accepts either `CreateReplacerProps` (declarative truncation) or a raw\n * `JSON.stringify`-compatible function (for bespoke serialization). `scroll` picks the axes\n * (default: all). Compose with the `Syntax.*` namespace only for filtering or a depth control.\n */\nexport const JsonHighlighter = Util.composable<HTMLDivElement, JsonHighlighterProps>(\n ({ data, replacer, indent = 2, testId, ...props }, forwardedRef) => {\n return (\n <SyntaxHighlighter {...props} language='json' data-testid={testId} ref={forwardedRef}>\n {safeStringify(data, resolveReplacer(replacer), indent)}\n </SyntaxHighlighter>\n );\n },\n);\n\nJsonHighlighter.displayName = 'JsonHighlighter';\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport { createContext } from '@dxos/react-hooks';\n\nimport { type SyntaxContextValue } from './Syntax.tsx';\n\n// Kept out of `Syntax.tsx`: react-refresh only fast-refreshes a module whose exports are all\n// components, so a context and its hook exported beside them force a full page reload on every edit.\n\nexport const SYNTAX_NAME = 'Syntax';\n\nexport const [SyntaxProvider, useSyntaxContext] = createContext<SyntaxContextValue>(SYNTAX_NAME);\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport { JSONPath } from 'jsonpath-plus';\nimport React, { type PropsWithChildren, forwardRef, useCallback, useMemo, useState } from 'react';\n\nimport * as Field from '@dxos/react-ui/Field';\nimport * as Input from '@dxos/react-ui/Input';\nimport * as ScrollArea from '@dxos/react-ui/ScrollArea';\nimport * as Util from '@dxos/react-ui/Util';\nimport { type ComposableProps } from '@dxos/ui-types';\n\nimport { JsonHighlighter, type JsonReplacer } from '../JsonHighlighter/index.ts';\nimport { SyntaxHighlighter } from '../SyntaxHighlighter/index.ts';\nimport { SyntaxProvider, useSyntaxContext } from './SyntaxContext.ts';\n\n//\n// Context\n//\n\nexport type SyntaxContextValue = {\n mode: 'text' | 'json';\n // Text mode.\n source?: string;\n language?: string;\n // JSON mode.\n data?: any;\n filteredData?: any;\n filterText: string;\n setFilterText: (text: string) => void;\n filterError: Error | null;\n replacer?: JsonReplacer;\n // Expansion depth (JSON mode); consumed by a `getReplacer` factory, edited via `Syntax.Depth`.\n depth: number;\n setDepth: (depth: number) => void;\n};\n\n//\n// Root\n//\n\nconst SYNTAX_ROOT_NAME = 'Syntax.Root';\n\ntype SyntaxRootProps = PropsWithChildren<{\n // Text mode.\n language?: string;\n source?: string;\n // JSON mode (presence of the `data` prop selects JSON mode; `undefined` is still JSON).\n data?: any;\n /**\n * `JSON.stringify` replacer applied to `data`. Use the function form to follow domain\n * references (e.g. ECHO refs) by returning a transformed value at the root call. Keeps\n * this package free of any domain-specific knowledge.\n */\n replacer?: JsonReplacer;\n /**\n * Depth-parametrized replacer, re-evaluated as the `Syntax.Depth` control changes. Takes\n * precedence over `replacer`. The consumer owns any domain knowledge (e.g. how depth maps to\n * ref resolution), so this package stays domain-free.\n */\n getReplacer?: (depth: number) => JsonReplacer | undefined;\n /** Initial expansion depth for `Syntax.Depth` / `getReplacer`. */\n defaultDepth?: number;\n /** Notified when the depth changes (via `Syntax.Depth`). */\n onDepthChange?: (depth: number) => void;\n}>;\n\n/**\n * Headless context provider. Selects JSON mode when the `data` prop is passed at all — even\n * `data={undefined}` — so loading states render an empty JSON view rather than flipping to\n * text mode (which would trip `Syntax.Filter`'s JSON-only guard). Mode is chosen by prop\n * presence, not value.\n */\nconst SyntaxRoot = (props: SyntaxRootProps) => {\n const { children, language, source, replacer, getReplacer, defaultDepth = 0, onDepthChange } = props;\n const isJson = 'data' in props;\n const data = props.data;\n const [filterText, setFilterText] = useState('');\n const [depth, setDepthState] = useState(defaultDepth);\n const setDepth = useCallback(\n (next: number) => {\n setDepthState(next);\n onDepthChange?.(next);\n },\n [onDepthChange],\n );\n\n // `getReplacer` (depth-parametrized) takes precedence over the static `replacer`.\n const effectiveReplacer = useMemo(\n () => (getReplacer ? getReplacer(depth) : replacer),\n [getReplacer, replacer, depth],\n );\n\n const { filteredData, filterError } = useMemo<{ filteredData: any; filterError: Error | null }>(() => {\n if (!isJson || !filterText.trim().length) {\n return { filteredData: data, filterError: null };\n }\n try {\n return { filteredData: JSONPath({ path: filterText, json: data }), filterError: null };\n } catch (err) {\n return { filteredData: data, filterError: err as Error };\n }\n }, [isJson, data, filterText]);\n\n return (\n <SyntaxProvider\n mode={isJson ? 'json' : 'text'}\n source={source}\n language={language}\n data={data}\n filteredData={filteredData}\n filterText={filterText}\n setFilterText={setFilterText}\n filterError={filterError}\n replacer={effectiveReplacer}\n depth={depth}\n setDepth={setDepth}\n >\n {children}\n </SyntaxProvider>\n );\n};\n\nSyntaxRoot.displayName = SYNTAX_ROOT_NAME;\n\n//\n// Content\n//\n\nconst SYNTAX_CONTENT_NAME = 'Syntax.Content';\n\ntype SyntaxContentProps = ComposableProps;\n\n/** Flex-column layout container for composite parts; unpadded so the host panel owns the frame. */\nconst SyntaxContent = Util.composable<HTMLDivElement, SyntaxContentProps>(({ children, ...props }, forwardedRef) => {\n return (\n <div {...Util.composableProps(props, { classNames: 'flex flex-col dx-expand overflow-hidden' })} ref={forwardedRef}>\n {children}\n </div>\n );\n});\n\nSyntaxContent.displayName = SYNTAX_CONTENT_NAME;\n\n//\n// Filter\n//\n\nconst SYNTAX_FILTER_NAME = 'Syntax.Filter';\n\ntype SyntaxFilterProps = ComposableProps<{\n placeholder?: string;\n}>;\n\n/** JSONPath filter input. Only meaningful when `Syntax.Root` is in JSON mode. */\nconst SyntaxFilter = forwardRef<HTMLInputElement, SyntaxFilterProps>(\n ({ classNames, placeholder = 'JSONPath (e.g., $.graph.nodes)' }, forwardedRef) => {\n const { mode, filterText, setFilterText, filterError } = useSyntaxContext(SYNTAX_FILTER_NAME);\n if (mode !== 'json') {\n throw new Error(`\\`${SYNTAX_FILTER_NAME}\\` requires \\`Syntax.Root\\` to be in JSON mode (pass \\`data\\`).`);\n }\n\n return (\n <Field.Root validationValence={filterError ? 'error' : 'success'}>\n <Input.Root\n classNames={['p-1 px-2 font-mono', filterError && 'border-rose-500', classNames]}\n variant='subdued'\n value={filterText}\n placeholder={placeholder}\n onChange={(event) => setFilterText(event.target.value)}\n ref={forwardedRef}\n />\n </Field.Root>\n );\n },\n);\n\nSyntaxFilter.displayName = SYNTAX_FILTER_NAME;\n\n//\n// Depth\n//\n\nconst SYNTAX_DEPTH_NAME = 'Syntax.Depth';\n\ntype SyntaxDepthProps = ComposableProps;\n\n/**\n * Numeric expansion-depth control bound to `Syntax.Root`'s depth state. Meaningful when the Root is\n * given a `getReplacer` that consumes depth (e.g. to resolve references N levels deep).\n */\nconst SyntaxDepth = forwardRef<HTMLInputElement, SyntaxDepthProps>(({ classNames }, forwardedRef) => {\n const { depth, setDepth } = useSyntaxContext(SYNTAX_DEPTH_NAME);\n return (\n <Field.Root>\n <Input.Number\n classNames={['font-mono', classNames]}\n min={0}\n step={1}\n aria-label='Depth'\n value={String(depth)}\n onValueChange={(_, valueAsNumber) => setDepth(Math.max(0, valueAsNumber || 0))}\n ref={forwardedRef}\n />\n </Field.Root>\n );\n});\n\nSyntaxDepth.displayName = SYNTAX_DEPTH_NAME;\n\n//\n// Viewport\n//\n\nconst SYNTAX_VIEWPORT_NAME = 'Syntax.Viewport';\n\ntype SyntaxViewportProps = ComposableProps;\n\n/** Optional scroll wrapper. Compose around `Syntax.Code` to make it scrollable. */\nconst SyntaxViewport = Util.composable<HTMLDivElement, SyntaxViewportProps>(({ children, ...props }, forwardedRef) => {\n return (\n <ScrollArea.Root {...Util.composableProps(props)} orientation='all' ref={forwardedRef}>\n <ScrollArea.Viewport>{children}</ScrollArea.Viewport>\n </ScrollArea.Root>\n );\n});\n\nSyntaxViewport.displayName = SYNTAX_VIEWPORT_NAME;\n\n//\n// Code\n//\n\nconst SYNTAX_CODE_NAME = 'Syntax.Code';\n\ntype SyntaxCodeProps = ComposableProps<{\n testId?: string;\n}>;\n\n/** Highlighted code leaf, unscrolled: `Syntax.Viewport` owns the scrolling. Reads source/data from `Syntax.Root`. */\nconst SyntaxCode = Util.composable<HTMLDivElement, SyntaxCodeProps>(({ testId, ...props }, forwardedRef) => {\n const merged = Util.composableProps(props, { classNames: 'text-sm' });\n\n const context = useSyntaxContext(SYNTAX_CODE_NAME);\n if (context.mode === 'json') {\n return (\n <JsonHighlighter\n {...merged}\n scroll={false}\n data={context.filteredData}\n replacer={context.replacer}\n testId={testId}\n ref={forwardedRef}\n />\n );\n }\n\n return (\n <SyntaxHighlighter {...merged} scroll={false} language={context.language} data-testid={testId} ref={forwardedRef}>\n {context.source ?? ''}\n </SyntaxHighlighter>\n );\n});\n\nSyntaxCode.displayName = SYNTAX_CODE_NAME;\n\n//\n// Syntax\n//\n\nexport const Syntax = {\n Root: SyntaxRoot,\n Content: SyntaxContent,\n Filter: SyntaxFilter,\n Depth: SyntaxDepth,\n Viewport: SyntaxViewport,\n Code: SyntaxCode,\n};\n\nexport type {\n SyntaxCodeProps,\n SyntaxContentProps,\n SyntaxDepthProps,\n SyntaxFilterProps,\n SyntaxRootProps,\n SyntaxViewportProps,\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAmBA,IAAM,0BAAU,IAAI,QAAqC;AAEzD,IAAM,WAAW,eAA4C;CAC3D,IAAI,QAAQ,QAAQ,IAAI,UAAU;CAClC,IAAI,CAAC,OAAO;EACV,MAAM,4BAAY,IAAI,IAAY;EAClC,KAAK,MAAM,YAAY,OAAO,KAAK,UAAU,GAC3C,KAAK,MAAM,aAAa,SAAS,MAAM,GAAG,GACxC,UAAU,IAAI,SAAS;EAG3B,QAAQ;GAAE;GAAW,wBAAQ,IAAI,IAAI;EAAE;EACvC,QAAQ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AAC,MAAM,QAAP;EACE,YAAY,CAAC,aAAa,UAAU;EACpC,KAAK;EACL,MAAM;EACN,cAAW;EACX,OAAO,OAAO,KAAK;EACnB,gBAAgB,GAAG,kBAAkB,SAAS,KAAK,IAAI,GAAG,iBAAiB,CAAC,CAAC;EAC7E,KAAK;CACN,CAAA,EACS,CAAA;AAEhB,CAAC;AAED,YAAY,cAAc;AAM1B,IAAM,uBAAuB;;AAK7B,IAAM,iBAAiB,KAAK,YAAiD,EAAE,UAAU,GAAG,SAAS,iBAAiB;CACpH,OACE,oBAAC,WAAW,MAAZ;EAAiB,GAAI,KAAK,gBAAgB,KAAK;EAAG,aAAY;EAAM,KAAK;EACvE,UAAA,oBAAC,WAAW,UAAZ,EAAsB,SAA8B,CAAA;CACrC,CAAA;AAErB,CAAC;AAED,eAAe,cAAc;AAM7B,IAAM,mBAAmB;;AAOzB,IAAM,aAAa,KAAK,YAA6C,EAAE,QAAQ,GAAG,SAAS,iBAAiB;CAC1G,MAAM,SAAS,KAAK,gBAAgB,OAAO,EAAE,YAAY,UAAU,CAAC;CAEpE,MAAM,UAAU,iBAAiB,gBAAgB;CACjD,IAAI,QAAQ,SAAS,QACnB,OACE,oBAAC,iBAAD;EACE,GAAI;EACJ,QAAQ;EACR,MAAM,QAAQ;EACd,UAAU,QAAQ;EACV;EACR,KAAK;CACN,CAAA;CAIL,OACE,oBAAC,mBAAD;EAAmB,GAAI;EAAQ,QAAQ;EAAO,UAAU,QAAQ;EAAU,eAAa;EAAQ,KAAK;EACjG,UAAA,QAAQ,UAAU;CACF,CAAA;AAEvB,CAAC;AAED,WAAW,cAAc;AAMzB,IAAa,SAAS;CACpB,MAAM;CACN,SAAS;CACT,QAAQ;CACR,OAAO;CACP,UAAU;CACV,MAAM;AACR"}
1
+ {"version":3,"file":"index.mjs","names":["createElement","dark","light"],"sources":["../../src/SyntaxHighlighter/renderer.ts","../../src/SyntaxHighlighter/SyntaxHighlighter.tsx","../../src/JsonHighlighter/JsonHighlighter.tsx","../../src/Syntax/SyntaxContext.ts","../../src/Syntax/Syntax.tsx"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport { type CSSProperties, type ReactNode, createElement } from 'react';\nimport { type SyntaxHighlighterProps } from 'react-syntax-highlighter';\n\ntype Renderer = NonNullable<SyntaxHighlighterProps['renderer']>;\ntype RendererProps = Parameters<Renderer>[0];\ntype Stylesheet = RendererProps['stylesheet'];\ntype RenderNode = RendererProps['rows'][number];\n\ntype StylesheetIndex = {\n /** Every class name any selector in the stylesheet mentions. */\n selectors: Set<string>;\n /** Merged stylesheet entries, keyed by a node's joined class names. */\n styles: Map<string, CSSProperties>;\n};\n\nconst indexes = new WeakMap<Stylesheet, StylesheetIndex>();\n\nconst indexOf = (stylesheet: Stylesheet): StylesheetIndex => {\n let index = indexes.get(stylesheet);\n if (!index) {\n const selectors = new Set<string>();\n for (const selector of Object.keys(stylesheet)) {\n for (const className of selector.split('.')) {\n selectors.add(className);\n }\n }\n index = { selectors, styles: new Map() };\n indexes.set(stylesheet, index);\n }\n\n return index;\n};\n\n/**\n * Every ordered selection of one to four class names, shortest first — the selector keys a\n * compound class list can match, in the precedence order `react-syntax-highlighter` applies them.\n */\nconst classNameCombinations = (classNames: string[]): string[] => {\n const pool = classNames.slice(0, 4);\n const combinations: string[] = [];\n const extend = (prefix: string[], remaining: number[], size: number) => {\n if (prefix.length === size) {\n combinations.push(prefix.join('.'));\n return;\n }\n for (const position of remaining) {\n extend(\n [...prefix, pool[position]],\n remaining.filter((other) => other !== position),\n size,\n );\n }\n };\n const positions = pool.map((_, position) => position);\n for (let size = 1; size <= pool.length; size++) {\n extend([], positions, size);\n }\n\n return combinations;\n};\n\nconst styleOf = (index: StylesheetIndex, stylesheet: Stylesheet, classNames: string[]): CSSProperties => {\n const key = classNames.join(' ');\n let style = index.styles.get(key);\n if (!style) {\n style = {};\n for (const selector of classNameCombinations(classNames.filter((className) => className !== 'token'))) {\n Object.assign(style, stylesheet[selector]);\n }\n index.styles.set(key, style);\n }\n\n return style;\n};\n\nconst renderNode = (node: RenderNode, stylesheet: Stylesheet, useInlineStyles: boolean, key: string): ReactNode => {\n if (node.type === 'text') {\n return node.value;\n }\n if (!node.tagName) {\n return undefined;\n }\n\n const properties = node.properties ?? { className: [] };\n const classNames: string[] = properties.className ?? [];\n let props: Record<string, unknown>;\n if (!useInlineStyles) {\n props = { ...properties, className: classNames.join(' ') };\n } else {\n const index = indexOf(stylesheet);\n const className = [\n ...(classNames.includes('token') ? ['token'] : []),\n ...classNames.filter((name) => !index.selectors.has(name)),\n ].join(' ');\n props = {\n ...properties,\n className: className || undefined,\n style: { ...properties.style, ...styleOf(index, stylesheet, classNames) },\n };\n }\n\n const children = (node.children ?? []).map((child, position) =>\n renderNode(child, stylesheet, useInlineStyles, `code-segment-1-${position}`),\n );\n return createElement(node.tagName, { key, ...props }, children);\n};\n\n/**\n * Drop-in for `react-syntax-highlighter`'s default row renderer, producing the same elements.\n * The stock renderer rebuilds the stylesheet's full selector list (a quadratic scan) for every\n * token node, which dominated the main thread whenever a highlighted block re-rendered.\n */\nexport const renderRows: Renderer = ({ rows, stylesheet, useInlineStyles }) =>\n rows.map((row, position) => renderNode(row, stylesheet, useInlineStyles, `code-segment-${position}`));\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { Children, type ReactNode, memo } from 'react';\nimport { type SyntaxHighlighterProps as NaturalSyntaxHighlighterProps } from 'react-syntax-highlighter';\nimport NativeSyntaxHighlighter from 'react-syntax-highlighter/dist/esm/prism-async-light';\nimport { coldarkDark as dark, coldarkCold as light } from 'react-syntax-highlighter/dist/esm/styles/prism';\n\nimport * as Hooks from '@dxos/react-ui/Hooks';\nimport * as ScrollArea from '@dxos/react-ui/ScrollArea';\nimport * as SystemButton from '@dxos/react-ui/SystemButton';\nimport * as Util from '@dxos/react-ui/Util';\nimport { mx } from '@dxos/ui-theme';\nimport { type AllowedAxis, type ThemeMode } from '@dxos/ui-types';\n\nimport { renderRows } from './renderer.ts';\n\nconst zeroWidthSpace = '\\u200b';\n\nconst languages = {\n js: 'javascript',\n ts: 'typescript',\n};\n\n/**\n * Above this, source is rendered unhighlighted. react-syntax-highlighter splices every line into a\n * single token array and wraps every token in an inline-styled element, so tokenizing grows\n * super-linearly in one synchronous render — a 3 MB payload takes about 30 s, and past roughly 123k\n * lines it throws. Plain text skips the tokenizer and keeps this component's own `pre`/`code` styles.\n */\nconst MAX_HIGHLIGHTED_LENGTH = 20_000;\n\nexport type SyntaxHighlighterProps = Pick<\n NaturalSyntaxHighlighterProps,\n | 'language'\n | 'renderer'\n | 'showLineNumbers'\n | 'showInlineLineNumbers'\n | 'startingLineNumber'\n | 'wrapLines'\n | 'wrapLongLines'\n | 'PreTag'\n> & {\n themeStyle?: NaturalSyntaxHighlighterProps['style'];\n /** Picks the built-in light or dark style regardless of the app's mode (default: the app's mode). */\n themeMode?: ThemeMode;\n fallback?: string;\n copyButton?: boolean;\n /**\n * The axes the built-in `ScrollArea` scrolls on (default: all). `false` renders the bare,\n * non-scrolling leaf for composition inside `Syntax.Viewport`.\n */\n scroll?: AllowedAxis | false;\n};\n\n/**\n * Highlighted source inside the family's themed `ScrollArea`, so a long line scrolls with the thin\n * scrollbar rather than the platform's. Pass `scroll={false}` to get the bare leaf.\n *\n * NOTE: Using `light-async` version directly from dist to avoid any chance of the heavy one being loaded.\n * The lightweight version will load specific language parsers asynchronously.\n *\n * https://github.com/react-syntax-highlighter/react-syntax-highlighter\n * https://react-syntax-highlighter.github.io/react-syntax-highlighter/demo/prism.html\n */\nexport const SyntaxHighlighter = Util.composable<HTMLDivElement, SyntaxHighlighterProps>(\n ({ scroll = 'all', copyButton, classNames, className, role, style, ...props }, forwardedRef) => {\n if (scroll === false) {\n return (\n <SyntaxHighlighterLeaf\n {...props}\n {...{ classNames, className, role, style }}\n copyButton={copyButton}\n ref={forwardedRef}\n />\n );\n }\n\n // The copy button sits on the scroll root so it stays put while the source scrolls under it.\n const source = sourceOf(props.children, props.fallback);\n return (\n <ScrollArea.Root\n role={role ?? 'none'}\n style={style}\n classNames={[className, classNames, copyButton && 'relative group']}\n orientation={scroll}\n ref={forwardedRef}\n >\n <ScrollArea.Viewport>\n <SyntaxHighlighterLeaf {...props} />\n </ScrollArea.Viewport>\n {copyButton && <CopyOverlay source={source} />}\n </ScrollArea.Root>\n );\n },\n);\n\nSyntaxHighlighter.displayName = 'SyntaxHighlighter';\n\nconst sourceOf = (children: ReactNode, fallback = zeroWidthSpace): string =>\n Children.toArray(children).join('') || fallback;\n\nconst CopyOverlay = ({ source }: { source: string }) => (\n <div className='pointer-events-none absolute top-1 right-1 z-10 opacity-0 group-hover:opacity-100 focus-within:opacity-100'>\n <SystemButton.Clipboard\n iconOnly\n value={source}\n variant='ghost'\n iconSize='md'\n classNames='pointer-events-auto aspect-square rounded-sm'\n />\n </div>\n);\n\n/** The non-scrolling leaf: all scrolling is deferred to an enclosing viewport. */\nconst SyntaxHighlighterLeaf = Util.composable<HTMLDivElement, Omit<SyntaxHighlighterProps, 'scroll'>>(\n (\n {\n classNames,\n className,\n children,\n role,\n style,\n themeStyle,\n themeMode: themeModeProp,\n language: languageProp = 'text',\n fallback = zeroWidthSpace,\n copyButton,\n ...nativeProps\n },\n forwardedRef,\n ) => {\n const appThemeMode = Hooks.useThemeMode();\n const themeMode = themeModeProp ?? appThemeMode;\n const source = sourceOf(children, fallback);\n const language = source.length > MAX_HIGHLIGHTED_LENGTH ? 'text' : languageProp;\n\n const hasCustomTheme = themeStyle && typeof themeStyle === 'object' && Object.keys(themeStyle).length > 0;\n const prismTheme = hasCustomTheme ? themeStyle : themeMode === 'dark' ? dark : light;\n\n return (\n <div\n {...Util.composableProps(\n { classNames, className, role, style },\n {\n role: 'none',\n classNames: mx('dx-expand overflow-visible p-1', copyButton && 'relative group'),\n },\n )}\n ref={forwardedRef}\n >\n <HighlightedSource\n language={languages[language as keyof typeof languages] || language}\n style={prismTheme}\n {...nativeProps}\n >\n {source}\n </HighlightedSource>\n\n {copyButton && <CopyOverlay source={source} />}\n </div>\n );\n },\n);\n\nSyntaxHighlighterLeaf.displayName = 'SyntaxHighlighterLeaf';\n\nconst customStyle: NaturalSyntaxHighlighterProps['customStyle'] = {\n background: 'unset',\n border: 'none',\n boxShadow: 'none',\n padding: 0,\n margin: 0,\n // This allows setting max-h-[6lh] on the Syntax.Code component.\n lineHeight: 'inherit',\n // Non-scrolling wrapper: defer all scrolling to an enclosing `Syntax.Viewport`.\n // The prism theme sets `overflow: auto` on the <pre>, which otherwise creates a\n // nested native horizontal scrollbar alongside the viewport's custom one.\n overflow: 'visible',\n};\n\nconst codeTagProps: NaturalSyntaxHighlighterProps['codeTagProps'] = {\n style: {\n lineHeight: 'inherit',\n // `block`, not the default `inline`: as an inline box every line is the union of the\n // <pre>'s strut and this element's own box, and the two carry different font stacks\n // (the prism theme's vs the app's), so lines advanced 16.5px under a 16px\n // line-height — enough that a `max-h-[Nlh]` cap showed N-1 lines and a sliver.\n display: 'block',\n },\n};\n\ntype HighlightedSourceProps = Omit<SyntaxHighlighterProps, 'themeStyle' | 'fallback' | 'copyButton' | 'scroll'> & {\n style: NaturalSyntaxHighlighterProps['style'];\n children: string;\n};\n\n/**\n * Memoized on primitive props because tokenizing and building the element tree is the expensive\n * part, and streaming parents (e.g. the assistant's tool panel) re-render with unchanged source.\n */\nconst HighlightedSource = memo(({ children, renderer, wrapLines, ...props }: HighlightedSourceProps) => (\n <NativeSyntaxHighlighter\n customStyle={customStyle}\n // Copied per render: the library writes `whiteSpace` into this style, which would leak across instances.\n codeTagProps={{ ...codeTagProps, style: { ...codeTagProps?.style } }}\n renderer={renderer ?? renderRows}\n // Any renderer makes the library default `wrapLines` to true; only a caller's own renderer should get that.\n wrapLines={wrapLines ?? (renderer ? undefined : false)}\n {...props}\n >\n {/* Non-empty fallback prevents collapse. */}\n {children}\n </NativeSyntaxHighlighter>\n));\n\nHighlightedSource.displayName = 'HighlightedSource';\n\nSyntaxHighlighter.displayName = 'SyntaxHighlighter';\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport React from 'react';\n\nimport * as Util from '@dxos/react-ui/Util';\nimport { type CreateReplacerProps, createReplacer, safeStringify } from '@dxos/util';\n\nimport { SyntaxHighlighter, type SyntaxHighlighterProps } from '../SyntaxHighlighter/index.ts';\n\nexport type JsonReplacer = CreateReplacerProps | ((key: string, value: any) => any);\n\nexport type JsonHighlighterProps = Omit<SyntaxHighlighterProps, 'children' | 'language'> & {\n data?: any;\n replacer?: JsonReplacer;\n /** Indentation passed to `JSON.stringify`. Default: `2` (pretty-printed). Pass `0` for single-line output. */\n indent?: number;\n testId?: string;\n};\n\nconst resolveReplacer = (replacer?: JsonReplacer) => {\n if (!replacer) {\n return undefined;\n }\n\n return typeof replacer === 'function' ? replacer : createReplacer(replacer);\n};\n\n/**\n * JSON in the family's themed `ScrollArea`: the shorthand for showing a value.\n *\n * Thin wrapper around `SyntaxHighlighter` that stringifies `data` with an optional replacer.\n * `replacer` accepts either `CreateReplacerProps` (declarative truncation) or a raw\n * `JSON.stringify`-compatible function (for bespoke serialization). `scroll` picks the axes\n * (default: all). Compose with the `Syntax.*` namespace only for filtering or a depth control.\n */\nexport const JsonHighlighter = Util.composable<HTMLDivElement, JsonHighlighterProps>(\n ({ data, replacer, indent = 2, testId, ...props }, forwardedRef) => {\n return (\n <SyntaxHighlighter {...props} language='json' data-testid={testId} ref={forwardedRef}>\n {safeStringify(data, resolveReplacer(replacer), indent)}\n </SyntaxHighlighter>\n );\n },\n);\n\nJsonHighlighter.displayName = 'JsonHighlighter';\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport { createContext } from '@dxos/react-hooks';\n\nimport { type SyntaxContextValue } from './Syntax.tsx';\n\n// Kept out of `Syntax.tsx`: react-refresh only fast-refreshes a module whose exports are all\n// components, so a context and its hook exported beside them force a full page reload on every edit.\n\nexport const SYNTAX_NAME = 'Syntax';\n\nexport const [SyntaxProvider, useSyntaxContext] = createContext<SyntaxContextValue>(SYNTAX_NAME);\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport { JSONPath } from 'jsonpath-plus';\nimport React, { type PropsWithChildren, forwardRef, useCallback, useMemo, useState } from 'react';\n\nimport * as Field from '@dxos/react-ui/Field';\nimport * as Input from '@dxos/react-ui/Input';\nimport * as ScrollArea from '@dxos/react-ui/ScrollArea';\nimport * as Util from '@dxos/react-ui/Util';\nimport { type ComposableProps } from '@dxos/ui-types';\n\nimport { JsonHighlighter, type JsonReplacer } from '../JsonHighlighter/index.ts';\nimport { SyntaxHighlighter } from '../SyntaxHighlighter/index.ts';\nimport { SyntaxProvider, useSyntaxContext } from './SyntaxContext.ts';\n\n//\n// Context\n//\n\nexport type SyntaxContextValue = {\n mode: 'text' | 'json';\n // Text mode.\n source?: string;\n language?: string;\n // JSON mode.\n data?: any;\n filteredData?: any;\n filterText: string;\n setFilterText: (text: string) => void;\n filterError: Error | null;\n replacer?: JsonReplacer;\n // Expansion depth (JSON mode); consumed by a `getReplacer` factory, edited via `Syntax.Depth`.\n depth: number;\n setDepth: (depth: number) => void;\n};\n\n//\n// Root\n//\n\nconst SYNTAX_ROOT_NAME = 'Syntax.Root';\n\ntype SyntaxRootProps = PropsWithChildren<{\n // Text mode.\n language?: string;\n source?: string;\n // JSON mode (presence of the `data` prop selects JSON mode; `undefined` is still JSON).\n data?: any;\n /**\n * `JSON.stringify` replacer applied to `data`. Use the function form to follow domain\n * references (e.g. ECHO refs) by returning a transformed value at the root call. Keeps\n * this package free of any domain-specific knowledge.\n */\n replacer?: JsonReplacer;\n /**\n * Depth-parametrized replacer, re-evaluated as the `Syntax.Depth` control changes. Takes\n * precedence over `replacer`. The consumer owns any domain knowledge (e.g. how depth maps to\n * ref resolution), so this package stays domain-free.\n */\n getReplacer?: (depth: number) => JsonReplacer | undefined;\n /** Initial expansion depth for `Syntax.Depth` / `getReplacer`. */\n defaultDepth?: number;\n /** Notified when the depth changes (via `Syntax.Depth`). */\n onDepthChange?: (depth: number) => void;\n}>;\n\n/**\n * Headless context provider. Selects JSON mode when the `data` prop is passed at all — even\n * `data={undefined}` — so loading states render an empty JSON view rather than flipping to\n * text mode (which would trip `Syntax.Filter`'s JSON-only guard). Mode is chosen by prop\n * presence, not value.\n */\nconst SyntaxRoot = (props: SyntaxRootProps) => {\n const { children, language, source, replacer, getReplacer, defaultDepth = 0, onDepthChange } = props;\n const isJson = 'data' in props;\n const data = props.data;\n const [filterText, setFilterText] = useState('');\n const [depth, setDepthState] = useState(defaultDepth);\n const setDepth = useCallback(\n (next: number) => {\n setDepthState(next);\n onDepthChange?.(next);\n },\n [onDepthChange],\n );\n\n // `getReplacer` (depth-parametrized) takes precedence over the static `replacer`.\n const effectiveReplacer = useMemo(\n () => (getReplacer ? getReplacer(depth) : replacer),\n [getReplacer, replacer, depth],\n );\n\n const { filteredData, filterError } = useMemo<{ filteredData: any; filterError: Error | null }>(() => {\n if (!isJson || !filterText.trim().length) {\n return { filteredData: data, filterError: null };\n }\n try {\n return { filteredData: JSONPath({ path: filterText, json: data }), filterError: null };\n } catch (err) {\n return { filteredData: data, filterError: err as Error };\n }\n }, [isJson, data, filterText]);\n\n return (\n <SyntaxProvider\n mode={isJson ? 'json' : 'text'}\n source={source}\n language={language}\n data={data}\n filteredData={filteredData}\n filterText={filterText}\n setFilterText={setFilterText}\n filterError={filterError}\n replacer={effectiveReplacer}\n depth={depth}\n setDepth={setDepth}\n >\n {children}\n </SyntaxProvider>\n );\n};\n\nSyntaxRoot.displayName = SYNTAX_ROOT_NAME;\n\n//\n// Content\n//\n\nconst SYNTAX_CONTENT_NAME = 'Syntax.Content';\n\ntype SyntaxContentProps = ComposableProps;\n\n/** Flex-column layout container for composite parts; unpadded so the host panel owns the frame. */\nconst SyntaxContent = Util.composable<HTMLDivElement, SyntaxContentProps>(({ children, ...props }, forwardedRef) => {\n return (\n <div {...Util.composableProps(props, { classNames: 'flex flex-col dx-expand overflow-hidden' })} ref={forwardedRef}>\n {children}\n </div>\n );\n});\n\nSyntaxContent.displayName = SYNTAX_CONTENT_NAME;\n\n//\n// Filter\n//\n\nconst SYNTAX_FILTER_NAME = 'Syntax.Filter';\n\ntype SyntaxFilterProps = ComposableProps<{\n placeholder?: string;\n}>;\n\n/** JSONPath filter input. Only meaningful when `Syntax.Root` is in JSON mode. */\nconst SyntaxFilter = forwardRef<HTMLInputElement, SyntaxFilterProps>(\n ({ classNames, placeholder = 'JSONPath (e.g., $.graph.nodes)' }, forwardedRef) => {\n const { mode, filterText, setFilterText, filterError } = useSyntaxContext(SYNTAX_FILTER_NAME);\n if (mode !== 'json') {\n throw new Error(`\\`${SYNTAX_FILTER_NAME}\\` requires \\`Syntax.Root\\` to be in JSON mode (pass \\`data\\`).`);\n }\n\n return (\n <Field.Root validationValence={filterError ? 'error' : 'success'}>\n <Input.Root\n classNames={['p-1 px-2 font-mono', filterError && 'border-rose-500', classNames]}\n variant='subdued'\n value={filterText}\n placeholder={placeholder}\n onChange={(event) => setFilterText(event.target.value)}\n ref={forwardedRef}\n />\n </Field.Root>\n );\n },\n);\n\nSyntaxFilter.displayName = SYNTAX_FILTER_NAME;\n\n//\n// Depth\n//\n\nconst SYNTAX_DEPTH_NAME = 'Syntax.Depth';\n\ntype SyntaxDepthProps = ComposableProps;\n\n/**\n * Numeric expansion-depth control bound to `Syntax.Root`'s depth state. Meaningful when the Root is\n * given a `getReplacer` that consumes depth (e.g. to resolve references N levels deep).\n */\nconst SyntaxDepth = forwardRef<HTMLInputElement, SyntaxDepthProps>(({ classNames }, forwardedRef) => {\n const { depth, setDepth } = useSyntaxContext(SYNTAX_DEPTH_NAME);\n return (\n <Field.Root>\n <Input.Number\n classNames={['font-mono', classNames]}\n min={0}\n step={1}\n aria-label='Depth'\n value={String(depth)}\n onValueChange={(_, valueAsNumber) => setDepth(Math.max(0, valueAsNumber || 0))}\n ref={forwardedRef}\n />\n </Field.Root>\n );\n});\n\nSyntaxDepth.displayName = SYNTAX_DEPTH_NAME;\n\n//\n// Viewport\n//\n\nconst SYNTAX_VIEWPORT_NAME = 'Syntax.Viewport';\n\ntype SyntaxViewportProps = ComposableProps;\n\n/** Optional scroll wrapper. Compose around `Syntax.Code` to make it scrollable. */\nconst SyntaxViewport = Util.composable<HTMLDivElement, SyntaxViewportProps>(({ children, ...props }, forwardedRef) => {\n return (\n <ScrollArea.Root {...Util.composableProps(props)} orientation='all' ref={forwardedRef}>\n <ScrollArea.Viewport>{children}</ScrollArea.Viewport>\n </ScrollArea.Root>\n );\n});\n\nSyntaxViewport.displayName = SYNTAX_VIEWPORT_NAME;\n\n//\n// Code\n//\n\nconst SYNTAX_CODE_NAME = 'Syntax.Code';\n\ntype SyntaxCodeProps = ComposableProps<{\n testId?: string;\n}>;\n\n/** Highlighted code leaf, unscrolled: `Syntax.Viewport` owns the scrolling. Reads source/data from `Syntax.Root`. */\nconst SyntaxCode = Util.composable<HTMLDivElement, SyntaxCodeProps>(({ testId, ...props }, forwardedRef) => {\n const merged = Util.composableProps(props, { classNames: 'text-sm' });\n\n const context = useSyntaxContext(SYNTAX_CODE_NAME);\n if (context.mode === 'json') {\n return (\n <JsonHighlighter\n {...merged}\n scroll={false}\n data={context.filteredData}\n replacer={context.replacer}\n testId={testId}\n ref={forwardedRef}\n />\n );\n }\n\n return (\n <SyntaxHighlighter {...merged} scroll={false} language={context.language} data-testid={testId} ref={forwardedRef}>\n {context.source ?? ''}\n </SyntaxHighlighter>\n );\n});\n\nSyntaxCode.displayName = SYNTAX_CODE_NAME;\n\n//\n// Syntax\n//\n\nexport const Syntax = {\n Root: SyntaxRoot,\n Content: SyntaxContent,\n Filter: SyntaxFilter,\n Depth: SyntaxDepth,\n Viewport: SyntaxViewport,\n Code: SyntaxCode,\n};\n\nexport type {\n SyntaxCodeProps,\n SyntaxContentProps,\n SyntaxDepthProps,\n SyntaxFilterProps,\n SyntaxRootProps,\n SyntaxViewportProps,\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAmBA,IAAM,0BAAU,IAAI,QAAqC;AAEzD,IAAM,WAAW,eAA4C;CAC3D,IAAI,QA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,UAAA,QAAQ,UAAU;CACF,CAAA;AAEvB,CAAC;AAED,WAAW,cAAc;AAMzB,IAAa,SAAS;CACpB,MAAM;CACN,SAAS;CACT,QAAQ;CACR,OAAO;CACP,UAAU;CACV,MAAM;AACR"}
@@ -1,8 +1,10 @@
1
1
  import React from 'react';
2
2
  import { type SyntaxHighlighterProps as NaturalSyntaxHighlighterProps } from 'react-syntax-highlighter';
3
- import { type AllowedAxis } from '@dxos/ui-types';
3
+ import { type AllowedAxis, type ThemeMode } from '@dxos/ui-types';
4
4
  export type SyntaxHighlighterProps = Pick<NaturalSyntaxHighlighterProps, 'language' | 'renderer' | 'showLineNumbers' | 'showInlineLineNumbers' | 'startingLineNumber' | 'wrapLines' | 'wrapLongLines' | 'PreTag'> & {
5
5
  themeStyle?: NaturalSyntaxHighlighterProps['style'];
6
+ /** Picks the built-in light or dark style regardless of the app's mode (default: the app's mode). */
7
+ themeMode?: ThemeMode;
6
8
  fallback?: string;
7
9
  copyButton?: boolean;
8
10
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"SyntaxHighlighter.d.ts","sourceRoot":"","sources":["../../../../src/SyntaxHighlighter/SyntaxHighlighter.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAC9D,OAAO,EAAE,KAAK,sBAAsB,IAAI,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AASxG,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAmBlD,MAAM,MAAM,sBAAsB,GAAG,IAAI,CACvC,6BAA6B,EAC3B,UAAU,GACV,UAAU,GACV,iBAAiB,GACjB,uBAAuB,GACvB,oBAAoB,GACpB,WAAW,GACX,eAAe,GACf,QAAQ,CACX,GAAG;IACF,UAAU,CAAC,EAAE,6BAA6B,CAAC,OAAO,CAAC,CAAC;IACpD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,MAAM,CAAC,EAAE,WAAW,GAAG,KAAK,CAAC;CAC9B,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB;;6GA8B7B,CAAC"}
1
+ {"version":3,"file":"SyntaxHighlighter.d.ts","sourceRoot":"","sources":["../../../../src/SyntaxHighlighter/SyntaxHighlighter.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAC9D,OAAO,EAAE,KAAK,sBAAsB,IAAI,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AASxG,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAmBlE,MAAM,MAAM,sBAAsB,GAAG,IAAI,CACvC,6BAA6B,EAC3B,UAAU,GACV,UAAU,GACV,iBAAiB,GACjB,uBAAuB,GACvB,oBAAoB,GACpB,WAAW,GACX,eAAe,GACf,QAAQ,CACX,GAAG;IACF,UAAU,CAAC,EAAE,6BAA6B,CAAC,OAAO,CAAC,CAAC;IACpD,qGAAqG;IACrG,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,MAAM,CAAC,EAAE,WAAW,GAAG,KAAK,CAAC;CAC9B,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB;;6GA8B7B,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import createElement from 'react-syntax-highlighter/dist/esm/create-element';
2
2
  export { createElement };
3
+ export * from './renderer.ts';
3
4
  export * from './SyntaxHighlighter.tsx';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/SyntaxHighlighter/index.ts"],"names":[],"mappings":"AAKA,OAAO,aAAa,MAAM,kDAAkD,CAAC;AAE7E,OAAO,EAAE,aAAa,EAAE,CAAC;AAEzB,cAAc,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/SyntaxHighlighter/index.ts"],"names":[],"mappings":"AAKA,OAAO,aAAa,MAAM,kDAAkD,CAAC;AAE7E,OAAO,EAAE,aAAa,EAAE,CAAC;AAEzB,cAAc,eAAe,CAAC;AAC9B,cAAc,yBAAyB,CAAC"}