@stackone/malachite 2.91.0 → 2.93.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.
- package/COMPONENTS.md +2 -2
- package/dist/components/Accordion.js +52 -49
- package/dist/components/Accordion.js.map +1 -1
- package/dist/components/Chat/ChatReasoning.js +40 -0
- package/dist/components/Chat/ChatReasoning.js.map +1 -0
- package/dist/components/Chat/ChatToolCall.js +57 -43
- package/dist/components/Chat/ChatToolCall.js.map +1 -1
- package/dist/components/Chat/index.js +12 -10
- package/dist/components/Chat/index.js.map +1 -1
- package/dist/components/Chat/stickToBottom.js +23 -17
- package/dist/components/Chat/stickToBottom.js.map +1 -1
- package/dist/components/CodeBlock.js +49 -48
- package/dist/components/CodeBlock.js.map +1 -1
- package/dist/components/CodeBlockHighlighter.js +22 -22
- package/dist/components/CodeBlockHighlighter.js.map +1 -1
- package/dist/components/FilterSearch.js +318 -282
- package/dist/components/FilterSearch.js.map +1 -1
- package/dist/components/Modal.js +58 -59
- package/dist/components/Modal.js.map +1 -1
- package/dist/components/SidePanel.js +47 -48
- package/dist/components/SidePanel.js.map +1 -1
- package/dist/components/Typography/MarkdownBlock.js +136 -103
- package/dist/components/Typography/MarkdownBlock.js.map +1 -1
- package/dist/components/afterNextPaint.js +11 -0
- package/dist/components/afterNextPaint.js.map +1 -0
- package/dist/components/codeBlockStyles.js +6 -5
- package/dist/components/codeBlockStyles.js.map +1 -1
- package/dist/components/filterSearchModel.js +32 -31
- package/dist/components/filterSearchModel.js.map +1 -1
- package/dist/components/frameStyles.js +6 -5
- package/dist/components/frameStyles.js.map +1 -1
- package/dist/index.d.ts +29 -7
- package/dist/tailwind.css.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatToolCall.js","sources":["../../../src/components/Chat/ChatToolCall.tsx"],"sourcesContent":["import React from 'react';\nimport Accordion from '../Accordion';\nimport CodeBlock from '../CodeBlock';\nimport CheckIcon from '../CustomIcons/CheckIcon';\nimport RejectIcon from '../CustomIcons/RejectIcon';\nimport Tag from '../Tag';\nimport type { TagType } from '../Tag';\nimport Typography from '../Typography';\n\nexport type ChatToolCallStatus = 'running' | 'completed' | 'error';\n\nexport interface ChatToolCallProps {\n /** The tool the assistant called, e.g. `update_policy_draft`. */\n name: string;\n status?: ChatToolCallStatus;\n /**\n * The provider's id for this call. Shown once the card is expanded, not on the collapsed\n * row: it is a long opaque string nobody reads at a glance, and beside the tool name it\n * was taking two lines of the transcript to say nothing a reader wanted.\n */\n callId?: string;\n /** Arguments the assistant sent. */\n input?: object;\n /** What the call returned. Absent while it is still running. */\n output?: object;\n defaultExpanded?: boolean;\n className?: string;\n}\n\nconst STATUS_LABELS: Record<ChatToolCallStatus, string> = {\n running: 'Running',\n completed: 'Completed',\n error: 'Failed',\n};\n\nconst STATUS_TAG_TYPES: Record<ChatToolCallStatus, TagType> = {\n running: 'warning',\n completed: 'success',\n error: 'error',\n};\n\n/** Only a settled call carries a mark; a running one would be claiming an outcome. */\nconst STATUS_ICONS: Partial<Record<ChatToolCallStatus, React.ReactNode>> = {\n completed: <CheckIcon size={11} />,\n error: <RejectIcon size={11} />,\n};\n\n/**\n * One tool call in a transcript, collapsed by default: what the assistant did is worth a\n * line, and the arguments behind it are worth a click.\n *\n * The status sits in `trailing` rather than in the header, so it stays outside the toggle\n * button — a tag nested inside a button is invalid, and it reads as its own thing.\n */\nconst ChatToolCall: React.FC<ChatToolCallProps> = ({\n name,\n status = 'completed',\n callId,\n input,\n output,\n defaultExpanded = false,\n className,\n}) => (\n <Accordion\n variant=\"sunken\"\n defaultExpanded={defaultExpanded}\n className={className}\n header={\n <span className=\"min-w-0 text-left\">\n <Typography.Text size=\"small\" fontWeight=\"semi-bold\">\n {name}\n </Typography.Text>\n </span>\n }\n trailing={\n <Tag\n
|
|
1
|
+
{"version":3,"file":"ChatToolCall.js","sources":["../../../src/components/Chat/ChatToolCall.tsx"],"sourcesContent":["import React from 'react';\nimport Accordion from '../Accordion';\nimport CodeBlock from '../CodeBlock';\nimport CheckIcon from '../CustomIcons/CheckIcon';\nimport DisabledIcon from '../CustomIcons/DisabledIcon';\nimport RejectIcon from '../CustomIcons/RejectIcon';\nimport Tag from '../Tag';\nimport type { TagType } from '../Tag';\nimport Typography from '../Typography';\n\n/** `blocked` is a call something refused to let run, which is not the call having failed. */\nexport type ChatToolCallStatus = 'running' | 'completed' | 'error' | 'blocked';\n\nexport interface ChatToolCallProps {\n /** The tool the assistant called, e.g. `update_policy_draft`. */\n name: string;\n status?: ChatToolCallStatus;\n /**\n * The provider's id for this call. Shown once the card is expanded, not on the collapsed\n * row: it is a long opaque string nobody reads at a glance, and beside the tool name it\n * was taking two lines of the transcript to say nothing a reader wanted.\n */\n callId?: string;\n /** Arguments the assistant sent. A string is shown as it is, for a payload that is not JSON. */\n input?: object | string;\n /** What the call returned. Absent while it is still running. */\n output?: object | string;\n /** Sits before the status on the row, outside the toggle, e.g. a risk indicator. */\n adornment?: React.ReactNode;\n /** Anything else the expanded card should carry, below the payloads. Unmounts on close. */\n children?: React.ReactNode;\n defaultExpanded?: boolean;\n className?: string;\n}\n\nconst STATUS_LABELS: Record<ChatToolCallStatus, string> = {\n running: 'Running',\n completed: 'Completed',\n error: 'Failed',\n blocked: 'Blocked',\n};\n\nconst STATUS_TAG_TYPES: Record<ChatToolCallStatus, TagType> = {\n running: 'warning',\n completed: 'success',\n error: 'error',\n blocked: 'error',\n};\n\n/** Only a settled call carries a mark; a running one would be claiming an outcome. */\nconst STATUS_ICONS: Partial<Record<ChatToolCallStatus, React.ReactNode>> = {\n completed: <CheckIcon size={11} />,\n error: <RejectIcon size={11} />,\n blocked: <DisabledIcon size={11} />,\n};\n\nconst Payload: React.FC<{ label: string; value?: object | string }> = ({ label, value }) => {\n if (value === undefined || value === '') {\n return null;\n }\n\n return (\n <div className=\"flex min-w-0 flex-col gap-1\">\n <Typography.SecondaryText size=\"xsmall\">{label}</Typography.SecondaryText>\n {typeof value === 'string' ? (\n <CodeBlock code={value} wrapLines showLineNumbers={false} aria-label={label} />\n ) : (\n <CodeBlock json={value} collapsed={2} aria-label={label} />\n )}\n </div>\n );\n};\n\n/**\n * One tool call in a transcript, collapsed by default: what the assistant did is worth a\n * line, and the arguments behind it are worth a click.\n *\n * The status sits in `trailing` rather than in the header, so it stays outside the toggle\n * button — a tag nested inside a button is invalid, and it reads as its own thing.\n *\n * `animate={false}` so the body only mounts once opened: a result can be tens of KB of JSON,\n * and a streamed turn renders every call again on each update.\n */\nconst ChatToolCall: React.FC<ChatToolCallProps> = ({\n name,\n status = 'completed',\n callId,\n input,\n output,\n adornment,\n children,\n defaultExpanded = false,\n className,\n}) => (\n <Accordion\n variant=\"sunken\"\n animate={false}\n defaultExpanded={defaultExpanded}\n className={className}\n header={\n <span className=\"min-w-0 text-left [overflow-wrap:anywhere]\">\n <Typography.Text size=\"small\" fontWeight=\"semi-bold\">\n {name}\n </Typography.Text>\n </span>\n }\n trailing={\n <span className=\"flex items-center gap-2\">\n {adornment}\n <Tag\n value={STATUS_LABELS[status]}\n type={STATUS_TAG_TYPES[status]}\n fontSize=\"xsmall\"\n textTransform=\"none\"\n icon={STATUS_ICONS[status]}\n iconPosition=\"left\"\n />\n </span>\n }\n >\n <div className=\"flex flex-col gap-2 p-2\">\n {callId === undefined ? null : (\n <Typography.SecondaryText size=\"xsmall\">Call ID: {callId}</Typography.SecondaryText>\n )}\n <Payload label=\"Parameters\" value={input} />\n <Payload label=\"Result\" value={output} />\n {children}\n </div>\n </Accordion>\n);\n\nexport default ChatToolCall;\nexport { ChatToolCall };\n"],"names":["STATUS_LABELS","STATUS_TAG_TYPES","STATUS_ICONS","jsx","CheckIcon","RejectIcon","DisabledIcon","Payload","label","value","jsxs","Typography","CodeBlock","ChatToolCall","name","status","callId","input","output","adornment","children","defaultExpanded","className","Accordion","Tag"],"mappings":";;;;;;;;AAmCA,MAAMA,IAAoD;AAAA,EACtD,SAAS;AAAA,EACT,WAAW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K,WAAU,2BACX,UAAA;AAAA,MAAAS;AAAA,MACD,gBAAAhB;AAAA,QAACqB;AAAA,QAAA;AAAA,UACG,OAAOxB,EAAce,CAAM;AAAA,UAC3B,MAAMd,EAAiBc,CAAM;AAAA,UAC7B,UAAS;AAAA,UACT,eAAc;AAAA,UACd,MAAMb,EAAaa,CAAM;AAAA,UACzB,cAAa;AAAA,QAAA;AAAA,MAAA;AAAA,IACjB,GACJ;AAAA,IAGJ,UAAA,gBAAAL,EAAC,OAAA,EAAI,WAAU,2BACV,UAAA;AAAA,MAAAM,MAAW,SAAY,OACpB,gBAAAN,EAACC,EAAW,eAAX,EAAyB,MAAK,UAAS,UAAA;AAAA,QAAA;AAAA,QAAUK;AAAA,MAAA,GAAO;AAAA,MAE7D,gBAAAb,EAACI,GAAA,EAAQ,OAAM,cAAa,OAAOU,GAAO;AAAA,MAC1C,gBAAAd,EAACI,GAAA,EAAQ,OAAM,UAAS,OAAOW,GAAQ;AAAA,MACtCE;AAAA,IAAA,EAAA,CACL;AAAA,EAAA;AACJ;"}
|
|
@@ -2,26 +2,28 @@ import { ChatComposer as t } from "./ChatComposer.js";
|
|
|
2
2
|
import { ChatComposerChip as r } from "./ChatComposerChip.js";
|
|
3
3
|
import { ChatContext as e } from "./ChatContext.js";
|
|
4
4
|
import { ChatContextMeter as m } from "./ChatContextMeter.js";
|
|
5
|
-
import { ChatHeader as
|
|
6
|
-
import { ChatMessage as
|
|
5
|
+
import { ChatHeader as a } from "./ChatHeader.js";
|
|
6
|
+
import { ChatMessage as C } from "./ChatMessage.js";
|
|
7
7
|
import { ChatModelPicker as i } from "./ChatModelPicker.js";
|
|
8
|
-
import h from "./
|
|
9
|
-
import
|
|
8
|
+
import { ChatReasoning as h } from "./ChatReasoning.js";
|
|
9
|
+
import p from "./ChatRoot.js";
|
|
10
|
+
import { ChatSuggestion as n } from "./ChatSuggestion.js";
|
|
10
11
|
import { ChatThinking as f } from "./ChatThinking.js";
|
|
11
12
|
import { ChatThread as s } from "./ChatThread.js";
|
|
12
|
-
import { ChatToolCall as
|
|
13
|
-
const o =
|
|
14
|
-
o.Header =
|
|
13
|
+
import { ChatToolCall as g } from "./ChatToolCall.js";
|
|
14
|
+
const o = p;
|
|
15
|
+
o.Header = a;
|
|
15
16
|
o.Thread = s;
|
|
16
|
-
o.Message =
|
|
17
|
-
o.ToolCall =
|
|
17
|
+
o.Message = C;
|
|
18
|
+
o.ToolCall = g;
|
|
18
19
|
o.Thinking = f;
|
|
20
|
+
o.Reasoning = h;
|
|
19
21
|
o.Composer = t;
|
|
20
22
|
o.ComposerChip = r;
|
|
21
23
|
o.Context = e;
|
|
22
24
|
o.ContextMeter = m;
|
|
23
25
|
o.ModelPicker = i;
|
|
24
|
-
o.Suggestion =
|
|
26
|
+
o.Suggestion = n;
|
|
25
27
|
export {
|
|
26
28
|
o as Chat,
|
|
27
29
|
o as default
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/Chat/index.tsx"],"sourcesContent":["import React from 'react';\nimport { default as ChatComposer, type ChatComposerProps } from './ChatComposer';\nimport { default as ChatComposerChip, type ChatComposerChipProps } from './ChatComposerChip';\nimport { default as ChatContext, type ChatContextProps } from './ChatContext';\nimport { default as ChatContextMeter, type ChatContextMeterProps } from './ChatContextMeter';\nimport { default as ChatHeader, type ChatHeaderProps } from './ChatHeader';\nimport { default as ChatMessage, type ChatMessageProps } from './ChatMessage';\nimport { default as ChatModelPicker, type ChatModelPickerProps } from './ChatModelPicker';\nimport { type ChatProps, default as ChatRoot } from './ChatRoot';\nimport { default as ChatSuggestion, type ChatSuggestionProps } from './ChatSuggestion';\nimport { default as ChatThinking, type ChatThinkingProps } from './ChatThinking';\nimport { default as ChatThread, type ChatThreadProps } from './ChatThread';\nimport { default as ChatToolCall, type ChatToolCallProps } from './ChatToolCall';\n\nexport type {\n ChatFeedback,\n ChatMessageStatus,\n ChatMessageUsage,\n ChatMessageVariant,\n ChatRole,\n} from './ChatMessage';\nexport type { ChatToolCallStatus } from './ChatToolCall';\nexport type { ChatModelOption, ChatModelSubOption } from './ChatModelPicker';\nexport type { ChatContextItem } from './ChatContext';\nexport type {\n ChatComposerChipProps,\n ChatComposerProps,\n ChatContextMeterProps,\n ChatContextProps,\n ChatHeaderProps,\n ChatMessageProps,\n ChatModelPickerProps,\n ChatProps,\n ChatSuggestionProps,\n ChatThinkingProps,\n ChatThreadProps,\n ChatToolCallProps,\n};\n\ninterface ChatComponent extends React.FC<ChatProps> {\n Header: React.FC<ChatHeaderProps>;\n Thread: React.FC<ChatThreadProps>;\n Message: React.FC<ChatMessageProps>;\n ToolCall: React.FC<ChatToolCallProps>;\n Thinking: React.FC<ChatThinkingProps>;\n Composer: React.FC<ChatComposerProps>;\n ComposerChip: React.FC<ChatComposerChipProps>;\n Context: React.FC<ChatContextProps>;\n ContextMeter: React.FC<ChatContextMeterProps>;\n ModelPicker: React.FC<ChatModelPickerProps>;\n Suggestion: React.FC<ChatSuggestionProps>;\n}\n\nconst Chat = ChatRoot as ChatComponent;\n\nChat.Header = ChatHeader;\nChat.Thread = ChatThread;\nChat.Message = ChatMessage;\nChat.ToolCall = ChatToolCall;\nChat.Thinking = ChatThinking;\nChat.Composer = ChatComposer;\nChat.ComposerChip = ChatComposerChip;\nChat.Context = ChatContext;\nChat.ContextMeter = ChatContextMeter;\nChat.ModelPicker = ChatModelPicker;\nChat.Suggestion = ChatSuggestion;\n\nexport default Chat;\nexport { Chat };\n"],"names":["Chat","ChatRoot","ChatHeader","ChatThread","ChatMessage","ChatToolCall","ChatThinking","ChatComposer","ChatComposerChip","ChatContext","ChatContextMeter","ChatModelPicker","ChatSuggestion"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/Chat/index.tsx"],"sourcesContent":["import React from 'react';\nimport { default as ChatComposer, type ChatComposerProps } from './ChatComposer';\nimport { default as ChatComposerChip, type ChatComposerChipProps } from './ChatComposerChip';\nimport { default as ChatContext, type ChatContextProps } from './ChatContext';\nimport { default as ChatContextMeter, type ChatContextMeterProps } from './ChatContextMeter';\nimport { default as ChatHeader, type ChatHeaderProps } from './ChatHeader';\nimport { default as ChatMessage, type ChatMessageProps } from './ChatMessage';\nimport { default as ChatModelPicker, type ChatModelPickerProps } from './ChatModelPicker';\nimport { default as ChatReasoning, type ChatReasoningProps } from './ChatReasoning';\nimport { type ChatProps, default as ChatRoot } from './ChatRoot';\nimport { default as ChatSuggestion, type ChatSuggestionProps } from './ChatSuggestion';\nimport { default as ChatThinking, type ChatThinkingProps } from './ChatThinking';\nimport { default as ChatThread, type ChatThreadProps } from './ChatThread';\nimport { default as ChatToolCall, type ChatToolCallProps } from './ChatToolCall';\n\nexport type {\n ChatFeedback,\n ChatMessageStatus,\n ChatMessageUsage,\n ChatMessageVariant,\n ChatRole,\n} from './ChatMessage';\nexport type { ChatToolCallStatus } from './ChatToolCall';\nexport type { ChatModelOption, ChatModelSubOption } from './ChatModelPicker';\nexport type { ChatContextItem } from './ChatContext';\nexport type {\n ChatComposerChipProps,\n ChatComposerProps,\n ChatContextMeterProps,\n ChatContextProps,\n ChatHeaderProps,\n ChatMessageProps,\n ChatModelPickerProps,\n ChatProps,\n ChatReasoningProps,\n ChatSuggestionProps,\n ChatThinkingProps,\n ChatThreadProps,\n ChatToolCallProps,\n};\n\ninterface ChatComponent extends React.FC<ChatProps> {\n Header: React.FC<ChatHeaderProps>;\n Thread: React.FC<ChatThreadProps>;\n Message: React.FC<ChatMessageProps>;\n ToolCall: React.FC<ChatToolCallProps>;\n Thinking: React.FC<ChatThinkingProps>;\n Reasoning: React.FC<ChatReasoningProps>;\n Composer: React.FC<ChatComposerProps>;\n ComposerChip: React.FC<ChatComposerChipProps>;\n Context: React.FC<ChatContextProps>;\n ContextMeter: React.FC<ChatContextMeterProps>;\n ModelPicker: React.FC<ChatModelPickerProps>;\n Suggestion: React.FC<ChatSuggestionProps>;\n}\n\nconst Chat = ChatRoot as ChatComponent;\n\nChat.Header = ChatHeader;\nChat.Thread = ChatThread;\nChat.Message = ChatMessage;\nChat.ToolCall = ChatToolCall;\nChat.Thinking = ChatThinking;\nChat.Reasoning = ChatReasoning;\nChat.Composer = ChatComposer;\nChat.ComposerChip = ChatComposerChip;\nChat.Context = ChatContext;\nChat.ContextMeter = ChatContextMeter;\nChat.ModelPicker = ChatModelPicker;\nChat.Suggestion = ChatSuggestion;\n\nexport default Chat;\nexport { Chat };\n"],"names":["Chat","ChatRoot","ChatHeader","ChatThread","ChatMessage","ChatToolCall","ChatThinking","ChatReasoning","ChatComposer","ChatComposerChip","ChatContext","ChatContextMeter","ChatModelPicker","ChatSuggestion"],"mappings":";;;;;;;;;;;;;AAwDA,MAAMA,IAAOC;AAEbD,EAAK,SAASE;AACdF,EAAK,SAASG;AACdH,EAAK,UAAUI;AACfJ,EAAK,WAAWK;AAChBL,EAAK,WAAWM;AAChBN,EAAK,YAAYO;AACjBP,EAAK,WAAWQ;AAChBR,EAAK,eAAeS;AACpBT,EAAK,UAAUU;AACfV,EAAK,eAAeW;AACpBX,EAAK,cAAcY;AACnBZ,EAAK,aAAaa;"}
|
|
@@ -1,29 +1,35 @@
|
|
|
1
|
-
import { useRef as
|
|
2
|
-
const
|
|
3
|
-
const t =
|
|
1
|
+
import { useRef as c, useState as p, useCallback as h, useEffect as v } from "react";
|
|
2
|
+
const R = 32, T = (t) => t.scrollHeight - t.scrollTop - t.clientHeight <= R, E = () => {
|
|
3
|
+
const t = c(null), l = c(null), [a, u] = p(!0), s = c(!0), r = c(!1), m = h(() => {
|
|
4
4
|
const e = t.current;
|
|
5
5
|
if (!e)
|
|
6
6
|
return;
|
|
7
|
-
typeof window.matchMedia == "function" && !window.matchMedia("(prefers-reduced-motion: reduce)").matches && typeof e.scrollTo == "function" ? e.scrollTo({ top: e.scrollHeight, behavior: "smooth" }) : e.scrollTop = e.scrollHeight,
|
|
7
|
+
typeof window.matchMedia == "function" && !window.matchMedia("(prefers-reduced-motion: reduce)").matches && typeof e.scrollTo == "function" ? e.scrollTo({ top: e.scrollHeight, behavior: "smooth" }) : e.scrollTop = e.scrollHeight, s.current = !0, u(!0);
|
|
8
8
|
}, []);
|
|
9
|
-
return
|
|
10
|
-
const e = t.current,
|
|
11
|
-
if (!e || !
|
|
9
|
+
return v(() => {
|
|
10
|
+
const e = t.current, o = l.current;
|
|
11
|
+
if (!e || !o)
|
|
12
12
|
return;
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
|
|
13
|
+
const i = () => {
|
|
14
|
+
const d = T(e);
|
|
15
|
+
s.current = d, u(d);
|
|
16
|
+
}, f = () => {
|
|
17
|
+
r.current = !0, requestAnimationFrame(
|
|
18
|
+
() => requestAnimationFrame(() => {
|
|
19
|
+
r.current = !1;
|
|
20
|
+
})
|
|
21
|
+
);
|
|
16
22
|
};
|
|
17
|
-
e.addEventListener("scroll",
|
|
18
|
-
const
|
|
19
|
-
|
|
23
|
+
e.addEventListener("scroll", i, { passive: !0 }), o.addEventListener("click", f);
|
|
24
|
+
const n = typeof ResizeObserver > "u" ? void 0 : new ResizeObserver(() => {
|
|
25
|
+
r.current ? (r.current = !1, i()) : s.current && (e.scrollTop = e.scrollHeight);
|
|
20
26
|
});
|
|
21
|
-
return
|
|
22
|
-
e.removeEventListener("scroll",
|
|
27
|
+
return n == null || n.observe(o), () => {
|
|
28
|
+
e.removeEventListener("scroll", i), o.removeEventListener("click", f), n == null || n.disconnect();
|
|
23
29
|
};
|
|
24
|
-
}, []), { scrollRef: t, contentRef:
|
|
30
|
+
}, []), { scrollRef: t, contentRef: l, pinned: a, scrollToBottom: m };
|
|
25
31
|
};
|
|
26
32
|
export {
|
|
27
|
-
|
|
33
|
+
E as useStickToBottom
|
|
28
34
|
};
|
|
29
35
|
//# sourceMappingURL=stickToBottom.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stickToBottom.js","sources":["../../../src/components/Chat/stickToBottom.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\n\n/** How far from the bottom still counts as pinned, in px. */\nconst PINNED_SLACK = 32;\n\nconst isPinned = (node: HTMLElement): boolean =>\n node.scrollHeight - node.scrollTop - node.clientHeight <= PINNED_SLACK;\n\n/**\n * Keeps a scroll container pinned to its newest content while the reader is at the bottom,\n * and reports when they have scrolled away.\n *\n * `contentRef` goes on the growing child rather than the container: a streaming reply changes\n * the content's height, never the container's, so an observer on the container never fires.\n */\nexport const useStickToBottom = () => {\n const scrollRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement>(null);\n const [pinned, setPinned] = useState(true);\n\n // Whether the reader was pinned BEFORE the content grew. By the time the observer runs,\n // the container is no longer at the bottom, so the live DOM cannot answer this.\n const pinnedRef = useRef(true);\n\n const scrollToBottom = useCallback(() => {\n const node = scrollRef.current;\n\n if (!node) {\n return;\n }\n\n // Eased, because arriving instantly at the bottom reads as a glitch rather than as\n // travel. `scrollTo` is asked for smooth only when the reader has not opted out of\n // motion — matchMedia rather than CSS, since this is a scroll and not a style.\n const smooth =\n typeof window.matchMedia === 'function' &&\n !window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n\n if (smooth && typeof node.scrollTo === 'function') {\n node.scrollTo({ top: node.scrollHeight, behavior: 'smooth' });\n } else {\n node.scrollTop = node.scrollHeight;\n }\n\n // Pinned because this just pinned it, rather than waiting to be told: Chrome can\n // coalesce the scroll event a programmatic scroll produces, which would leave the\n // jump-to-latest affordance on screen at the latest message.\n pinnedRef.current = true;\n setPinned(true);\n }, []);\n\n useEffect(() => {\n const node = scrollRef.current;\n const content = contentRef.current;\n\n if (!node || !content) {\n return;\n }\n\n const readPinned = () => {\n const next = isPinned(node);\n pinnedRef.current = next;\n setPinned(next);\n };\n\n node.addEventListener('scroll', readPinned, { passive: true });\n\n // jsdom has no ResizeObserver, and a thread that cannot follow its content is still\n // a working transcript — so pinning degrades rather than throwing on mount.\n const observer =\n typeof ResizeObserver === 'undefined'\n ? undefined\n : new ResizeObserver(() => {\n if (pinnedRef.current) {\n node.scrollTop = node.scrollHeight;\n }\n });\n observer?.observe(content);\n\n return () => {\n node.removeEventListener('scroll', readPinned);\n observer?.disconnect();\n };\n }, []);\n\n return { scrollRef, contentRef, pinned, scrollToBottom };\n};\n"],"names":["PINNED_SLACK","isPinned","node","useStickToBottom","scrollRef","useRef","contentRef","pinned","setPinned","useState","pinnedRef","scrollToBottom","useCallback","useEffect","content","readPinned","next","observer"],"mappings":";AAGA,MAAMA,IAAe,IAEfC,IAAW,CAACC,MACdA,EAAK,eAAeA,EAAK,YAAYA,EAAK,gBAAgBF,GASjDG,IAAmB,MAAM;AAClC,QAAMC,IAAYC,EAAuB,IAAI,GACvCC,IAAaD,EAAuB,IAAI,GACxC,CAACE,GAAQC,CAAS,IAAIC,EAAS,EAAI,GAInCC,IAAYL,EAAO,EAAI,
|
|
1
|
+
{"version":3,"file":"stickToBottom.js","sources":["../../../src/components/Chat/stickToBottom.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\n\n/** How far from the bottom still counts as pinned, in px. */\nconst PINNED_SLACK = 32;\n\nconst isPinned = (node: HTMLElement): boolean =>\n node.scrollHeight - node.scrollTop - node.clientHeight <= PINNED_SLACK;\n\n/**\n * Keeps a scroll container pinned to its newest content while the reader is at the bottom,\n * and reports when they have scrolled away.\n *\n * `contentRef` goes on the growing child rather than the container: a streaming reply changes\n * the content's height, never the container's, so an observer on the container never fires.\n */\nexport const useStickToBottom = () => {\n const scrollRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement>(null);\n const [pinned, setPinned] = useState(true);\n\n // Whether the reader was pinned BEFORE the content grew. By the time the observer runs,\n // the container is no longer at the bottom, so the live DOM cannot answer this.\n const pinnedRef = useRef(true);\n\n // The reader just clicked in the transcript. Any growth that causes is theirs, a tool call or\n // a JSON node or a <details> opening, so following it would carry what they clicked out of view.\n const clickedRef = useRef(false);\n\n const scrollToBottom = useCallback(() => {\n const node = scrollRef.current;\n\n if (!node) {\n return;\n }\n\n // Eased, because arriving instantly at the bottom reads as a glitch rather than as\n // travel. `scrollTo` is asked for smooth only when the reader has not opted out of\n // motion — matchMedia rather than CSS, since this is a scroll and not a style.\n const smooth =\n typeof window.matchMedia === 'function' &&\n !window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n\n if (smooth && typeof node.scrollTo === 'function') {\n node.scrollTo({ top: node.scrollHeight, behavior: 'smooth' });\n } else {\n node.scrollTop = node.scrollHeight;\n }\n\n // Pinned because this just pinned it, rather than waiting to be told: Chrome can\n // coalesce the scroll event a programmatic scroll produces, which would leave the\n // jump-to-latest affordance on screen at the latest message.\n pinnedRef.current = true;\n setPinned(true);\n }, []);\n\n useEffect(() => {\n const node = scrollRef.current;\n const content = contentRef.current;\n\n if (!node || !content) {\n return;\n }\n\n const readPinned = () => {\n const next = isPinned(node);\n pinnedRef.current = next;\n setPinned(next);\n };\n\n const noteClick = () => {\n clickedRef.current = true;\n // Two frames: the first callback runs before that frame's resize observers do. So a\n // click that never grew the content cannot swallow later growth.\n requestAnimationFrame(() =>\n requestAnimationFrame(() => {\n clickedRef.current = false;\n }),\n );\n };\n\n node.addEventListener('scroll', readPinned, { passive: true });\n content.addEventListener('click', noteClick);\n\n // jsdom has no ResizeObserver, and a thread that cannot follow its content is still\n // a working transcript — so pinning degrades rather than throwing on mount.\n const observer =\n typeof ResizeObserver === 'undefined'\n ? undefined\n : new ResizeObserver(() => {\n if (clickedRef.current) {\n clickedRef.current = false;\n readPinned();\n } else if (pinnedRef.current) {\n node.scrollTop = node.scrollHeight;\n }\n });\n observer?.observe(content);\n\n return () => {\n node.removeEventListener('scroll', readPinned);\n content.removeEventListener('click', noteClick);\n observer?.disconnect();\n };\n }, []);\n\n return { scrollRef, contentRef, pinned, scrollToBottom };\n};\n"],"names":["PINNED_SLACK","isPinned","node","useStickToBottom","scrollRef","useRef","contentRef","pinned","setPinned","useState","pinnedRef","clickedRef","scrollToBottom","useCallback","useEffect","content","readPinned","next","noteClick","observer"],"mappings":";AA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,IAE9B,CAAC;AACX,WAAAiB,KAAA,QAAAA,EAAU,QAAQJ,IAEX,MAAM;AACT,MAAAb,EAAK,oBAAoB,UAAUc,CAAU,GAC7CD,EAAQ,oBAAoB,SAASG,CAAS,GAC9CC,KAAA,QAAAA,EAAU;AAAA,IACd;AAAA,EACJ,GAAG,CAAA,CAAE,GAEE,EAAE,WAAAf,GAAW,YAAAE,GAAY,QAAAC,GAAQ,gBAAAK,EAAA;AAC5C;"}
|
|
@@ -1,67 +1,68 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as p, jsx as o, Fragment as U } from "react/jsx-runtime";
|
|
2
2
|
import h from "@uiw/react-json-view";
|
|
3
3
|
import x from "react";
|
|
4
4
|
import B from "./CustomIcons/CheckmarkIcon.js";
|
|
5
5
|
import E from "./CustomIcons/CopyIcon.js";
|
|
6
6
|
import { diffHunks as G } from "./codeBlockDiff.js";
|
|
7
7
|
import { CodeLine as M } from "./codeBlockLine.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
8
|
+
import { rowsWrapperStyle as H } from "./codeBlockStyles.js";
|
|
9
|
+
import { FOCUS_RING_INSET as P, FOCUS_RING as q } from "./focusRing.js";
|
|
10
|
+
import { useClipboardCopy as J } from "./useClipboardCopy.js";
|
|
11
|
+
const w = (e, a) => (c, { type: r }) => r === "value" ? /* @__PURE__ */ o("span", { ...c, style: { ...c.style, color: `var(--w-rjv-type-${a}-color)` }, children: e }) : null, T = x.lazy(() => import("./CodeBlockHighlighter.js")), V = {
|
|
11
12
|
added: "var(--malachite-codeblock-diff-added-background)",
|
|
12
13
|
removed: "var(--malachite-codeblock-diff-removed-background)",
|
|
13
14
|
context: void 0
|
|
14
|
-
},
|
|
15
|
+
}, W = {
|
|
15
16
|
added: "+",
|
|
16
17
|
removed: "-",
|
|
17
18
|
context: void 0
|
|
18
|
-
},
|
|
19
|
+
}, Q = {
|
|
19
20
|
added: "var(--malachite-codeblock-diff-assistant-background)",
|
|
20
21
|
removed: "var(--malachite-codeblock-diff-assistant-removed-background)",
|
|
21
22
|
context: void 0
|
|
22
|
-
},
|
|
23
|
+
}, X = {
|
|
23
24
|
added: "✦",
|
|
24
25
|
// U+2212 minus sign, not a hyphen: the mock is explicit about which glyph.
|
|
25
26
|
removed: "−",
|
|
26
27
|
context: "·"
|
|
27
|
-
},
|
|
28
|
+
}, Y = {
|
|
28
29
|
added: "var(--malachite-codeblock-diff-assistant-foreground)",
|
|
29
30
|
removed: "var(--malachite-codeblock-diff-removed-foreground)",
|
|
30
31
|
context: "var(--malachite-codeblock-diff-context-foreground)"
|
|
31
|
-
},
|
|
32
|
+
}, Z = (e) => `⋯ ${e} unchanged ${e === 1 ? "line" : "lines"}`, L = (e, a, c) => {
|
|
32
33
|
const r = c === "assistant";
|
|
33
34
|
return {
|
|
34
|
-
background: r ?
|
|
35
|
-
marker: r ?
|
|
36
|
-
markerColor: r ?
|
|
35
|
+
background: r ? Q[e.type] : V[e.type],
|
|
36
|
+
marker: r ? X[e.type] : W[e.type],
|
|
37
|
+
markerColor: r ? Y[e.type] : void 0,
|
|
37
38
|
// Reserved on unchanged rows too, so the code column does not step in and out.
|
|
38
39
|
reserveMarker: !0,
|
|
39
40
|
// Context rows read as de-emphasised, not just unmarked, in the assistant palette.
|
|
40
41
|
textColor: r && e.type === "context" ? "var(--malachite-codeblock-diff-context-text)" : void 0,
|
|
41
42
|
strikethrough: r && e.type === "removed",
|
|
42
|
-
separatorAbove: e.skippedAbove === void 0 ? void 0 :
|
|
43
|
+
separatorAbove: e.skippedAbove === void 0 ? void 0 : Z(e.skippedAbove),
|
|
43
44
|
// A removed line has no number in the after-text, so it keeps the one it had before.
|
|
44
45
|
lineNumber: a ? e.afterNumber ?? e.beforeNumber : void 0
|
|
45
46
|
};
|
|
46
|
-
},
|
|
47
|
+
}, be = ({
|
|
47
48
|
code: e,
|
|
48
49
|
json: a,
|
|
49
50
|
showLineNumbers: c = !0,
|
|
50
51
|
className: r = "",
|
|
51
52
|
style: N = {},
|
|
52
53
|
height: S,
|
|
53
|
-
enableCopy:
|
|
54
|
-
wrapLines:
|
|
55
|
-
language:
|
|
54
|
+
enableCopy: f = !0,
|
|
55
|
+
wrapLines: s = !1,
|
|
56
|
+
language: b,
|
|
56
57
|
collapsed: D = !1,
|
|
57
|
-
diff:
|
|
58
|
+
diff: t,
|
|
58
59
|
"aria-label": A,
|
|
59
60
|
"aria-labelledby": F
|
|
60
61
|
}) => {
|
|
61
|
-
const
|
|
62
|
-
`)) ?? "",
|
|
63
|
-
if (
|
|
64
|
-
return
|
|
62
|
+
const l = t ? G(t.before, t.after, t.context) : null, m = (l == null ? void 0 : l.map((n) => n.text).join(`
|
|
63
|
+
`)) ?? "", u = (() => {
|
|
64
|
+
if (l)
|
|
65
|
+
return m;
|
|
65
66
|
if (e)
|
|
66
67
|
return e;
|
|
67
68
|
if (a !== void 0)
|
|
@@ -70,16 +71,16 @@ const w = (e, a) => (c, { type: r }) => r === "value" ? /* @__PURE__ */ o("span"
|
|
|
70
71
|
} catch {
|
|
71
72
|
return;
|
|
72
73
|
}
|
|
73
|
-
})(), { outcome: O, copy: $ } =
|
|
74
|
+
})(), { outcome: O, copy: $ } = J(u), I = O === "copied", _ = f && u !== void 0 && /* @__PURE__ */ p(U, { children: [
|
|
74
75
|
/* @__PURE__ */ o(
|
|
75
76
|
"button",
|
|
76
77
|
{
|
|
77
78
|
type: "button",
|
|
78
79
|
"aria-label": "Copy",
|
|
79
80
|
onClick: () => {
|
|
80
|
-
|
|
81
|
+
u !== void 0 && $(u);
|
|
81
82
|
},
|
|
82
|
-
className: `absolute top-2 right-2 z-10 flex items-center justify-center rounded-md border border-solid border-[var(--malachite-codeblock-border)] bg-[var(--malachite-codeblock-background)] p-1.5 transition-colors hover:bg-[var(--malachite-codeblock-border)] ${
|
|
83
|
+
className: `absolute top-2 right-2 z-10 flex items-center justify-center rounded-md border border-solid border-[var(--malachite-codeblock-border)] bg-[var(--malachite-codeblock-background)] p-1.5 transition-colors hover:bg-[var(--malachite-codeblock-border)] ${q}`,
|
|
83
84
|
style: { color: "var(--malachite-codeblock-line-number)" },
|
|
84
85
|
children: I ? /* @__PURE__ */ o(B, { size: 14 }) : /* @__PURE__ */ o(E, { size: 14 })
|
|
85
86
|
}
|
|
@@ -90,10 +91,10 @@ const w = (e, a) => (c, { type: r }) => r === "value" ? /* @__PURE__ */ o("span"
|
|
|
90
91
|
"aria-label": F ? A : A ?? "Code",
|
|
91
92
|
"aria-labelledby": F,
|
|
92
93
|
tabIndex: 0,
|
|
93
|
-
className: `box-border h-full overflow-auto ${
|
|
94
|
+
className: `box-border h-full overflow-auto ${P}`
|
|
94
95
|
};
|
|
95
|
-
if (a && !
|
|
96
|
-
return /* @__PURE__ */
|
|
96
|
+
if (a && !l)
|
|
97
|
+
return /* @__PURE__ */ p(
|
|
97
98
|
"div",
|
|
98
99
|
{
|
|
99
100
|
className: `relative border border-solid rounded-lg overflow-hidden ${r}`,
|
|
@@ -105,7 +106,7 @@ const w = (e, a) => (c, { type: r }) => r === "value" ? /* @__PURE__ */ o("span"
|
|
|
105
106
|
},
|
|
106
107
|
children: [
|
|
107
108
|
_,
|
|
108
|
-
/* @__PURE__ */ o("div", { ...i, children: /* @__PURE__ */
|
|
109
|
+
/* @__PURE__ */ o("div", { ...i, children: /* @__PURE__ */ p(
|
|
109
110
|
h,
|
|
110
111
|
{
|
|
111
112
|
value: a,
|
|
@@ -144,7 +145,7 @@ const w = (e, a) => (c, { type: r }) => r === "value" ? /* @__PURE__ */ o("span"
|
|
|
144
145
|
"--w-rjv-type-undefined-color": "var(--malachite-codeblock-keyword)"
|
|
145
146
|
},
|
|
146
147
|
displayDataTypes: !1,
|
|
147
|
-
enableClipboard:
|
|
148
|
+
enableClipboard: f,
|
|
148
149
|
collapsed: D,
|
|
149
150
|
displayObjectSize: !1,
|
|
150
151
|
children: [
|
|
@@ -157,7 +158,7 @@ const w = (e, a) => (c, { type: r }) => r === "value" ? /* @__PURE__ */ o("span"
|
|
|
157
158
|
]
|
|
158
159
|
}
|
|
159
160
|
);
|
|
160
|
-
const y =
|
|
161
|
+
const y = f && (!!e || !!l), g = (n, d) => {
|
|
161
162
|
const C = n.split(`
|
|
162
163
|
`);
|
|
163
164
|
return /* @__PURE__ */ o(
|
|
@@ -166,15 +167,15 @@ const w = (e, a) => (c, { type: r }) => r === "value" ? /* @__PURE__ */ o("span"
|
|
|
166
167
|
...i,
|
|
167
168
|
className: `${i.className} p-4 text-left`,
|
|
168
169
|
style: { paddingRight: y ? 44 : void 0 },
|
|
169
|
-
children: /* @__PURE__ */ o("div", { style:
|
|
170
|
-
const
|
|
170
|
+
children: /* @__PURE__ */ o("div", { style: H(s), children: C.map((v, j) => {
|
|
171
|
+
const k = d == null ? void 0 : d(j);
|
|
171
172
|
return /* @__PURE__ */ o(
|
|
172
173
|
M,
|
|
173
174
|
{
|
|
174
175
|
line: v,
|
|
175
|
-
lineNumber: (
|
|
176
|
-
wrap:
|
|
177
|
-
decoration:
|
|
176
|
+
lineNumber: (k == null ? void 0 : k.lineNumber) ?? (c ? j + 1 : void 0),
|
|
177
|
+
wrap: s,
|
|
178
|
+
decoration: k,
|
|
178
179
|
children: v
|
|
179
180
|
},
|
|
180
181
|
j
|
|
@@ -194,32 +195,32 @@ const w = (e, a) => (c, { type: r }) => r === "value" ? /* @__PURE__ */ o("span"
|
|
|
194
195
|
);
|
|
195
196
|
const d = (C) => {
|
|
196
197
|
const v = n[C];
|
|
197
|
-
return v ?
|
|
198
|
+
return v ? L(v, c, t == null ? void 0 : t.origin) : void 0;
|
|
198
199
|
};
|
|
199
|
-
return
|
|
200
|
+
return b ? /* @__PURE__ */ o(x.Suspense, { fallback: g(m, d), children: /* @__PURE__ */ o(
|
|
200
201
|
T,
|
|
201
202
|
{
|
|
202
|
-
code:
|
|
203
|
-
language:
|
|
203
|
+
code: m,
|
|
204
|
+
language: b,
|
|
204
205
|
showLineNumbers: c,
|
|
205
|
-
wrapLines:
|
|
206
|
+
wrapLines: s,
|
|
206
207
|
copyClearance: y,
|
|
207
208
|
decorate: d,
|
|
208
209
|
viewportProps: i
|
|
209
210
|
}
|
|
210
|
-
) }) : g(
|
|
211
|
-
}, K = () => e ?
|
|
211
|
+
) }) : g(m, d);
|
|
212
|
+
}, K = () => e ? b ? /* @__PURE__ */ o(x.Suspense, { fallback: R(), children: /* @__PURE__ */ o(
|
|
212
213
|
T,
|
|
213
214
|
{
|
|
214
215
|
code: e,
|
|
215
|
-
language:
|
|
216
|
+
language: b,
|
|
216
217
|
showLineNumbers: c,
|
|
217
|
-
wrapLines:
|
|
218
|
+
wrapLines: s,
|
|
218
219
|
copyClearance: y,
|
|
219
220
|
viewportProps: i
|
|
220
221
|
}
|
|
221
222
|
) }) : R() : null;
|
|
222
|
-
return /* @__PURE__ */
|
|
223
|
+
return /* @__PURE__ */ p(
|
|
223
224
|
"div",
|
|
224
225
|
{
|
|
225
226
|
className: `relative border border-solid rounded-lg overflow-hidden ${r}`,
|
|
@@ -231,12 +232,12 @@ const w = (e, a) => (c, { type: r }) => r === "value" ? /* @__PURE__ */ o("span"
|
|
|
231
232
|
},
|
|
232
233
|
children: [
|
|
233
234
|
_,
|
|
234
|
-
|
|
235
|
+
l ? z(l) : K()
|
|
235
236
|
]
|
|
236
237
|
}
|
|
237
238
|
);
|
|
238
239
|
};
|
|
239
240
|
export {
|
|
240
|
-
|
|
241
|
+
be as default
|
|
241
242
|
};
|
|
242
243
|
//# sourceMappingURL=CodeBlock.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlock.js","sources":["../../src/components/CodeBlock.tsx"],"sourcesContent":["import JsonView from '@uiw/react-json-view';\nimport React from 'react';\nimport CheckmarkIcon from './CustomIcons/CheckmarkIcon';\nimport CopyIcon from './CustomIcons/CopyIcon';\nimport { type DiffDisplayRow, type DiffRowType, diffHunks } from './codeBlockDiff';\nimport { CodeLine, type CodeLineDecoration } from './codeBlockLine';\nimport { FOCUS_RING, FOCUS_RING_INSET } from './focusRing';\nimport { useClipboardCopy } from './useClipboardCopy';\n\n/**\n * The value side of a JSON literal that has no value of its own to print, in its type's\n * colour. These read as keywords, as `true` and `false` do: the comment grey is under AA\n * contrast on the light background.\n */\nconst renderLiteral =\n (text: string, type: 'null' | 'undefined' | 'nan') =>\n (props: React.HTMLAttributes<HTMLSpanElement>, { type: part }: { type: 'type' | 'value' }) =>\n part === 'value' ? (\n <span {...props} style={{ ...props.style, color: `var(--w-rjv-type-${type}-color)` }}>\n {text}\n </span>\n ) : null;\n\nconst CodeBlockHighlighter = React.lazy(() => import('./CodeBlockHighlighter'));\n\nexport interface CodeBlockProps {\n /** The code content to display */\n code?: string;\n /** JSON object to display as formatted JSON */\n json?: object;\n /** Show line numbers */\n showLineNumbers?: boolean;\n /** Custom class name */\n className?: string;\n /** Custom styles */\n style?: React.CSSProperties;\n /** Height of the code block */\n height?: string | number;\n /** Enable copy functionality */\n enableCopy?: boolean;\n /** Wrap long lines instead of scrolling horizontally */\n wrapLines?: boolean;\n /**\n * Highlight the code with this language's grammar. `cedar` is a grammar this library\n * ships itself (`prismCedar.ts`), since Prism and refractor carry none; widen the union\n * as further grammars are registered in CodeBlockHighlighter.\n */\n language?: 'yaml' | 'cedar';\n /** How much of a `json` tree starts collapsed: `true` all of it, a number below that depth. */\n collapsed?: boolean | number;\n /**\n * Renders the change between two texts rather than one text, and takes precedence over\n * `code` and `json`. Only the changed lines are shown, with `context` unchanged ones either\n * side, so a small edit to a long document reads as a few hunks instead of the whole thing.\n */\n diff?: {\n before: string;\n after: string;\n /** Unchanged lines kept either side of each change. Three by convention. */\n context?: number;\n /**\n * Swaps the `+`/`-` gutter and tinted rows for the palette a mock specified for\n * AI-authored changes: star, minus-sign and middle-dot markers, and a struck-through\n * removal. Omit to keep the neutral markers; there is no default consumer for the\n * assistant look yet.\n */\n origin?: 'assistant';\n };\n /** Names the scrollable region. Defaults to \"Code\". */\n 'aria-label'?: string;\n /** Names the scrollable region by a visible label instead of `aria-label`. */\n 'aria-labelledby'?: string;\n}\n\nconst DIFF_BACKGROUNDS: Record<DiffRowType, string | undefined> = {\n added: 'var(--malachite-codeblock-diff-added-background)',\n removed: 'var(--malachite-codeblock-diff-removed-background)',\n context: undefined,\n};\n\nconst DIFF_MARKERS: Record<DiffRowType, string | undefined> = {\n added: '+',\n removed: '-',\n context: undefined,\n};\n\n// The assistant palette also marks context rows, which the neutral one leaves bare.\nconst ASSISTANT_DIFF_BACKGROUNDS: Record<DiffRowType, string | undefined> = {\n added: 'var(--malachite-codeblock-diff-assistant-background)',\n removed: 'var(--malachite-codeblock-diff-assistant-removed-background)',\n context: undefined,\n};\n\nconst ASSISTANT_DIFF_MARKERS: Record<DiffRowType, string> = {\n added: '\\u2726',\n // U+2212 minus sign, not a hyphen: the mock is explicit about which glyph.\n removed: '\\u2212',\n context: '\\u00b7',\n};\n\nconst ASSISTANT_DIFF_MARKER_COLORS: Record<DiffRowType, string> = {\n added: 'var(--malachite-codeblock-diff-assistant-foreground)',\n removed: 'var(--malachite-codeblock-diff-removed-foreground)',\n context: 'var(--malachite-codeblock-diff-context-foreground)',\n};\n\nconst unchangedRun = (count: number): string =>\n `\\u22ef ${count} unchanged ${count === 1 ? 'line' : 'lines'}`;\n\nconst diffDecoration = (\n row: DiffDisplayRow,\n showLineNumbers: boolean,\n origin?: 'assistant',\n): CodeLineDecoration => {\n const assistant = origin === 'assistant';\n\n return {\n background: assistant ? ASSISTANT_DIFF_BACKGROUNDS[row.type] : DIFF_BACKGROUNDS[row.type],\n marker: assistant ? ASSISTANT_DIFF_MARKERS[row.type] : DIFF_MARKERS[row.type],\n markerColor: assistant ? ASSISTANT_DIFF_MARKER_COLORS[row.type] : undefined,\n // Reserved on unchanged rows too, so the code column does not step in and out.\n reserveMarker: true,\n // Context rows read as de-emphasised, not just unmarked, in the assistant palette.\n textColor:\n assistant && row.type === 'context'\n ? 'var(--malachite-codeblock-diff-context-text)'\n : undefined,\n strikethrough: assistant && row.type === 'removed',\n separatorAbove: row.skippedAbove === undefined ? undefined : unchangedRun(row.skippedAbove),\n // A removed line has no number in the after-text, so it keeps the one it had before.\n lineNumber: showLineNumbers ? (row.afterNumber ?? row.beforeNumber) : undefined,\n };\n};\n\nconst CodeBlock: React.FC<CodeBlockProps> = ({\n code,\n json,\n showLineNumbers = true,\n className = '',\n style = {},\n height,\n enableCopy = true,\n wrapLines = false,\n language,\n collapsed = false,\n diff,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n}) => {\n const diffRows = diff ? diffHunks(diff.before, diff.after, diff.context) : null;\n const diffText = diffRows?.map((row) => row.text).join('\\n') ?? '';\n\n /**\n * What the button puts on the clipboard, in the same form the block is showing. A JSON\n * block is pretty-printed rather than handed over minified: the reader is copying what\n * they can see. `undefined` means there is nothing to copy and no button to offer.\n */\n const copyText = (): string | undefined => {\n if (diffRows) {\n return diffText;\n }\n\n // An empty block has nothing to copy, so it offers no button — `!== undefined` would\n // hand back the empty string and put a dead control on it.\n if (code) {\n return code;\n }\n\n if (json !== undefined) {\n try {\n return JSON.stringify(json, null, 2);\n } catch {\n // A cycle or a BigInt: no honest text to copy, so offer no button.\n return undefined;\n }\n }\n\n return undefined;\n };\n\n const textToCopy = copyText();\n\n const { outcome: copyOutcome, copy } = useClipboardCopy(textToCopy);\n const copied = copyOutcome === 'copied';\n\n const handleCopy = () => {\n if (textToCopy !== undefined) {\n void copy(textToCopy);\n }\n };\n\n // Declared once and rendered by both the JSON branch and the code branch below, so the\n // two tabs of one document do not disagree about whether it can be copied.\n const copyButton = enableCopy && textToCopy !== undefined && (\n <>\n <button\n type=\"button\"\n aria-label=\"Copy\"\n onClick={handleCopy}\n className={`absolute top-2 right-2 z-10 flex items-center justify-center rounded-md border border-solid border-[var(--malachite-codeblock-border)] bg-[var(--malachite-codeblock-background)] p-1.5 transition-colors hover:bg-[var(--malachite-codeblock-border)] ${FOCUS_RING}`}\n style={{ color: 'var(--malachite-codeblock-line-number)' }}\n >\n {copied ? <CheckmarkIcon size={14} /> : <CopyIcon size={14} />}\n </button>\n {/* Not role=\"status\": one per block would collide with a page's own status queries. */}\n <span aria-live=\"polite\" className=\"sr-only\">\n {copied ? 'Copied to clipboard' : ''}\n </span>\n </>\n );\n\n // Tabbable so a keyboard can scroll it: Safari never focuses a scroll container on its own.\n const viewportProps = {\n role: 'region',\n 'aria-label': ariaLabelledBy ? ariaLabel : (ariaLabel ?? 'Code'),\n 'aria-labelledby': ariaLabelledBy,\n tabIndex: 0,\n className: `box-border h-full overflow-auto ${FOCUS_RING_INSET}`,\n } satisfies React.HTMLAttributes<HTMLElement>;\n\n // If JSON is provided, use JsonView component\n if (json && !diffRows) {\n return (\n <div\n className={`relative border border-solid rounded-lg overflow-hidden ${className}`}\n style={{\n backgroundColor: 'var(--malachite-codeblock-background)',\n borderColor: 'var(--malachite-codeblock-border)',\n height,\n ...style,\n }}\n >\n {copyButton}\n {/* The frame clips at `height`; this scrolls inside it, so the copy button stays put. */}\n <div {...viewportProps}>\n <JsonView\n value={json}\n style={\n {\n backgroundColor: 'var(--malachite-codeblock-background)',\n color: 'var(--malachite-codeblock-foreground)',\n fontSize: '14px',\n fontFamily: 'var(--malachite-font-mono, monospace)',\n padding: '16px',\n lineHeight: '1.5',\n textAlign: 'left',\n '--w-rjv-color': 'var(--malachite-codeblock-foreground)',\n '--w-rjv-key-string': 'var(--malachite-codeblock-keyword)',\n '--w-rjv-background-color': 'var(--malachite-codeblock-background)',\n '--w-rjv-line-color': 'var(--malachite-codeblock-border)',\n '--w-rjv-arrow-color': 'var(--malachite-codeblock-line-number)',\n '--w-rjv-edit-color': 'var(--malachite-codeblock-keyword)',\n '--w-rjv-info-color': 'var(--malachite-codeblock-line-number)',\n '--w-rjv-update-color': 'var(--malachite-codeblock-keyword)',\n '--w-rjv-copied-color': 'var(--malachite-codeblock-string)',\n '--w-rjv-copied-success-color': 'var(--malachite-codeblock-string)',\n '--w-rjv-curlybraces-color':\n 'var(--malachite-codeblock-foreground)',\n '--w-rjv-colon-color': 'var(--malachite-codeblock-foreground)',\n '--w-rjv-brackets-color': 'var(--malachite-codeblock-foreground)',\n '--w-rjv-quotes-color': 'var(--malachite-codeblock-string)',\n '--w-rjv-quotes-string-color': 'var(--malachite-codeblock-string)',\n '--w-rjv-type-string-color': 'var(--malachite-codeblock-string)',\n '--w-rjv-type-int-color': 'var(--malachite-codeblock-number)',\n '--w-rjv-type-float-color': 'var(--malachite-codeblock-number)',\n '--w-rjv-type-bigint-color': 'var(--malachite-codeblock-number)',\n '--w-rjv-type-boolean-color': 'var(--malachite-codeblock-keyword)',\n '--w-rjv-type-date-color': 'var(--malachite-codeblock-string)',\n '--w-rjv-type-url-color': 'var(--malachite-codeblock-keyword)',\n '--w-rjv-type-null-color': 'var(--malachite-codeblock-keyword)',\n '--w-rjv-type-nan-color': 'var(--malachite-codeblock-keyword)',\n '--w-rjv-type-undefined-color':\n 'var(--malachite-codeblock-keyword)',\n } as React.CSSProperties\n }\n displayDataTypes={false}\n enableClipboard={enableCopy}\n collapsed={collapsed}\n displayObjectSize={false}\n >\n {/* The library draws these three only as their type label, which\n `displayDataTypes` turns off, so without a value of their own a\n `null` reads as a key with nothing after it. */}\n <JsonView.Null render={renderLiteral('null', 'null')} />\n <JsonView.Undefined render={renderLiteral('undefined', 'undefined')} />\n <JsonView.Nan render={renderLiteral('NaN', 'nan')} />\n </JsonView>\n </div>\n </div>\n );\n }\n\n // Reserve clearance so a wide first line never sits under the floating copy button.\n const copyClearance = enableCopy && (!!code || !!diffRows);\n\n const renderPlainLines = (\n text: string,\n decorate?: (index: number) => CodeLineDecoration | undefined,\n ) => {\n const lines = text.split('\\n');\n\n return (\n <div\n {...viewportProps}\n className={`${viewportProps.className} p-4 text-left`}\n style={{ paddingRight: copyClearance ? 44 : undefined }}\n >\n {/* As wide as the widest line, floored at the view, so rows filling it end level. */}\n <div style={{ width: 'max-content', minWidth: '100%' }}>\n {lines.map((line, index) => {\n const decoration = decorate?.(index);\n\n return (\n <CodeLine\n key={index}\n line={line}\n lineNumber={\n decoration?.lineNumber ??\n (showLineNumbers ? index + 1 : undefined)\n }\n wrap={wrapLines}\n decoration={decoration}\n >\n {line}\n </CodeLine>\n );\n })}\n </div>\n </div>\n );\n };\n\n const renderPlainCode = () => (code ? renderPlainLines(code) : null);\n\n const renderDiff = (rows: DiffDisplayRow[]) => {\n if (rows.length === 0) {\n return (\n <div\n className=\"p-4 text-left\"\n style={{ color: 'var(--malachite-codeblock-comment)' }}\n >\n No changes\n </div>\n );\n }\n\n const decorate = (index: number) => {\n const row = rows[index];\n\n return row ? diffDecoration(row, showLineNumbers, diff?.origin) : undefined;\n };\n\n if (language) {\n return (\n <React.Suspense fallback={renderPlainLines(diffText, decorate)}>\n {/*\n * The whole merged text goes to the highlighter in one piece, so a hunk\n * is tokenised in the company of its neighbours rather than on its own.\n * Prism still cannot see the lines the hunks left out, so a construct\n * spanning an omitted run can highlight oddly — the reason `context`\n * defaults to a few lines rather than none.\n */}\n <CodeBlockHighlighter\n code={diffText}\n language={language}\n showLineNumbers={showLineNumbers}\n wrapLines={wrapLines}\n copyClearance={copyClearance}\n decorate={decorate}\n viewportProps={viewportProps}\n />\n </React.Suspense>\n );\n }\n\n return renderPlainLines(diffText, decorate);\n };\n\n // For code strings, create a simple syntax-highlighted view\n const renderCodeContent = () => {\n if (!code) {\n return null;\n }\n\n if (language) {\n return (\n <React.Suspense fallback={renderPlainCode()}>\n <CodeBlockHighlighter\n code={code}\n language={language}\n showLineNumbers={showLineNumbers}\n wrapLines={wrapLines}\n copyClearance={copyClearance}\n viewportProps={viewportProps}\n />\n </React.Suspense>\n );\n }\n\n return renderPlainCode();\n };\n\n return (\n <div\n className={`relative border border-solid rounded-lg overflow-hidden ${className}`}\n style={{\n backgroundColor: 'var(--malachite-codeblock-background)',\n borderColor: 'var(--malachite-codeblock-border)',\n height,\n ...style,\n }}\n >\n {copyButton}\n {diffRows ? renderDiff(diffRows) : renderCodeContent()}\n </div>\n );\n};\n\nexport default CodeBlock;\n"],"names":["renderLiteral","text","type","props","part","jsx","CodeBlockHighlighter","React","DIFF_BACKGROUNDS","DIFF_MARKERS","ASSISTANT_DIFF_BACKGROUNDS","ASSISTANT_DIFF_MARKERS","ASSISTANT_DIFF_MARKER_COLORS","unchangedRun","count","diffDecoration","row","showLineNumbers","origin","assistant","CodeBlock","code","json","className","style","height","enableCopy","wrapLines","language","collapsed","diff","ariaLabel","ariaLabelledBy","diffRows","diffHunks","diffText","textToCopy","copyOutcome","copy","useClipboardCopy","copied","copyButton","jsxs","Fragment","FOCUS_RING","CheckmarkIcon","CopyIcon","viewportProps","FOCUS_RING_INSET","JsonView","copyClearance","renderPlainLines","decorate","lines","line","index","decoration","CodeLine","renderPlainCode","renderDiff","rows","renderCodeContent"],"mappings":";;;;;;;;;AAcA,MAAMA,IACF,CAACC,GAAcC,MACf,CAACC,GAA8C,EAAE,MAAMC,EAAA,MACnDA,MAAS,UACL,gBAAAC,EAAC,QAAA,EAAM,GAAGF,GAAO,OAAO,EAAE,GAAGA,EAAM,OAAO,OAAO,oBAAoBD,CAAI,UAAA,GACpE,UAAAD,EAAA,CACL,IACA,MAENK,IAAuBC,EAAM,KAAK,MAAM,OAAO,2BAAwB,CAAC,GAmDxEC,IAA4D;AAAA,EAC9D,OAAO;AAAA,EACP,SAAS;AAAA,EACT,SAAS;AACb,GAEMC,IAAwD;AAAA,EAC1D,OAAO;AAAA,EACP,SAAS;AAAA,EACT,SAAS;AACb,GAGMC,IAAsE;AAAA,EACxE,OAAO;AAAA,EACP,SAAS;AAAA,EACT,SAAS;AACb,GAEMC,IAAsD;AAAA,EACxD,OAAO;AAAA;AAAA,EAEP,SAAS;AAAA,EACT,SAAS;AACb,GAEMC,IAA4D;AAAA,EAC9D,OAAO;AAAA,EACP,SAAS;AAAA,EACT,SAAS;AACb,GAEMC,IAAe,CAACC,MAClB,KAAUA,CAAK,cAAcA,MAAU,IAAI,SAAS,OAAO,IAEzDC,IAAiB,CACnBC,GACAC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AAAA,MAAA;AAAA,IAAA,GAER,IAIDI,EAAiBhB,GAAUiB,CAAQ;AAAA,EAC9C,GAGMS,IAAoB,MACjBxC,IAIDO,sBAEKrB,EAAM,UAAN,EAAe,UAAUmD,KACtB,UAAA,gBAAArD;AAAA,IAACC;AAAA,IAAA;AAAA,MACG,MAAAe;AAAA,MACA,UAAAO;AAAA,MACA,iBAAAX;AAAA,MACA,WAAAU;AAAA,MACA,eAAAuB;AAAA,MACA,eAAAH;AAAA,IAAA;AAAA,EAAA,GAER,IAIDW,EAAA,IAlBI;AAqBf,SACI,gBAAAhB;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,WAAW,2DAA2DnB,CAAS;AAAA,MAC/E,OAAO;AAAA,QACH,iBAAiB;AAAA,QACjB,aAAa;AAAA,QACb,QAAAE;AAAA,QACA,GAAGD;AAAA,MAAA;AAAA,MAGN,UAAA;AAAA,QAAAiB;AAAA,QACAR,IAAW0B,EAAW1B,CAAQ,IAAI4B,EAAA;AAAA,MAAkB;AAAA,IAAA;AAAA,EAAA;AAGjE;"}
|
|
1
|
+
{"version":3,"file":"CodeBlock.js","sources":["../../src/components/CodeBlock.tsx"],"sourcesContent":["import JsonView from '@uiw/react-json-view';\nimport React from 'react';\nimport CheckmarkIcon from './CustomIcons/CheckmarkIcon';\nimport CopyIcon from './CustomIcons/CopyIcon';\nimport { type DiffDisplayRow, type DiffRowType, diffHunks } from './codeBlockDiff';\nimport { CodeLine, type CodeLineDecoration } from './codeBlockLine';\nimport { rowsWrapperStyle } from './codeBlockStyles';\nimport { FOCUS_RING, FOCUS_RING_INSET } from './focusRing';\nimport { useClipboardCopy } from './useClipboardCopy';\n\n/**\n * The value side of a JSON literal that has no value of its own to print, in its type's\n * colour. These read as keywords, as `true` and `false` do: the comment grey is under AA\n * contrast on the light background.\n */\nconst renderLiteral =\n (text: string, type: 'null' | 'undefined' | 'nan') =>\n (props: React.HTMLAttributes<HTMLSpanElement>, { type: part }: { type: 'type' | 'value' }) =>\n part === 'value' ? (\n <span {...props} style={{ ...props.style, color: `var(--w-rjv-type-${type}-color)` }}>\n {text}\n </span>\n ) : null;\n\nconst CodeBlockHighlighter = React.lazy(() => import('./CodeBlockHighlighter'));\n\nexport interface CodeBlockProps {\n /** The code content to display */\n code?: string;\n /** JSON object to display as formatted JSON */\n json?: object;\n /** Show line numbers */\n showLineNumbers?: boolean;\n /** Custom class name */\n className?: string;\n /** Custom styles */\n style?: React.CSSProperties;\n /** Height of the code block */\n height?: string | number;\n /** Enable copy functionality */\n enableCopy?: boolean;\n /** Wrap long lines instead of scrolling horizontally */\n wrapLines?: boolean;\n /**\n * Highlight the code with this language's grammar. `cedar` is a grammar this library\n * ships itself (`prismCedar.ts`), since Prism and refractor carry none; widen the union\n * as further grammars are registered in CodeBlockHighlighter.\n */\n language?: 'yaml' | 'cedar';\n /** How much of a `json` tree starts collapsed: `true` all of it, a number below that depth. */\n collapsed?: boolean | number;\n /**\n * Renders the change between two texts rather than one text, and takes precedence over\n * `code` and `json`. Only the changed lines are shown, with `context` unchanged ones either\n * side, so a small edit to a long document reads as a few hunks instead of the whole thing.\n */\n diff?: {\n before: string;\n after: string;\n /** Unchanged lines kept either side of each change. Three by convention. */\n context?: number;\n /**\n * Swaps the `+`/`-` gutter and tinted rows for the palette a mock specified for\n * AI-authored changes: star, minus-sign and middle-dot markers, and a struck-through\n * removal. Omit to keep the neutral markers; there is no default consumer for the\n * assistant look yet.\n */\n origin?: 'assistant';\n };\n /** Names the scrollable region. Defaults to \"Code\". */\n 'aria-label'?: string;\n /** Names the scrollable region by a visible label instead of `aria-label`. */\n 'aria-labelledby'?: string;\n}\n\nconst DIFF_BACKGROUNDS: Record<DiffRowType, string | undefined> = {\n added: 'var(--malachite-codeblock-diff-added-background)',\n removed: 'var(--malachite-codeblock-diff-removed-background)',\n context: undefined,\n};\n\nconst DIFF_MARKERS: Record<DiffRowType, string | undefined> = {\n added: '+',\n removed: '-',\n context: undefined,\n};\n\n// The assistant palette also marks context rows, which the neutral one leaves bare.\nconst ASSISTANT_DIFF_BACKGROUNDS: Record<DiffRowType, string | undefined> = {\n added: 'var(--malachite-codeblock-diff-assistant-background)',\n removed: 'var(--malachite-codeblock-diff-assistant-removed-background)',\n context: undefined,\n};\n\nconst ASSISTANT_DIFF_MARKERS: Record<DiffRowType, string> = {\n added: '\\u2726',\n // U+2212 minus sign, not a hyphen: the mock is explicit about which glyph.\n removed: '\\u2212',\n context: '\\u00b7',\n};\n\nconst ASSISTANT_DIFF_MARKER_COLORS: Record<DiffRowType, string> = {\n added: 'var(--malachite-codeblock-diff-assistant-foreground)',\n removed: 'var(--malachite-codeblock-diff-removed-foreground)',\n context: 'var(--malachite-codeblock-diff-context-foreground)',\n};\n\nconst unchangedRun = (count: number): string =>\n `\\u22ef ${count} unchanged ${count === 1 ? 'line' : 'lines'}`;\n\nconst diffDecoration = (\n row: DiffDisplayRow,\n showLineNumbers: boolean,\n origin?: 'assistant',\n): CodeLineDecoration => {\n const assistant = origin === 'assistant';\n\n return {\n background: assistant ? ASSISTANT_DIFF_BACKGROUNDS[row.type] : DIFF_BACKGROUNDS[row.type],\n marker: assistant ? ASSISTANT_DIFF_MARKERS[row.type] : DIFF_MARKERS[row.type],\n markerColor: assistant ? ASSISTANT_DIFF_MARKER_COLORS[row.type] : undefined,\n // Reserved on unchanged rows too, so the code column does not step in and out.\n reserveMarker: true,\n // Context rows read as de-emphasised, not just unmarked, in the assistant palette.\n textColor:\n assistant && row.type === 'context'\n ? 'var(--malachite-codeblock-diff-context-text)'\n : undefined,\n strikethrough: assistant && row.type === 'removed',\n separatorAbove: row.skippedAbove === undefined ? undefined : unchangedRun(row.skippedAbove),\n // A removed line has no number in the after-text, so it keeps the one it had before.\n lineNumber: showLineNumbers ? (row.afterNumber ?? row.beforeNumber) : undefined,\n };\n};\n\nconst CodeBlock: React.FC<CodeBlockProps> = ({\n code,\n json,\n showLineNumbers = true,\n className = '',\n style = {},\n height,\n enableCopy = true,\n wrapLines = false,\n language,\n collapsed = false,\n diff,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n}) => {\n const diffRows = diff ? diffHunks(diff.before, diff.after, diff.context) : null;\n const diffText = diffRows?.map((row) => row.text).join('\\n') ?? '';\n\n /**\n * What the button puts on the clipboard, in the same form the block is showing. A JSON\n * block is pretty-printed rather than handed over minified: the reader is copying what\n * they can see. `undefined` means there is nothing to copy and no button to offer.\n */\n const copyText = (): string | undefined => {\n if (diffRows) {\n return diffText;\n }\n\n // An empty block has nothing to copy, so it offers no button — `!== undefined` would\n // hand back the empty string and put a dead control on it.\n if (code) {\n return code;\n }\n\n if (json !== undefined) {\n try {\n return JSON.stringify(json, null, 2);\n } catch {\n // A cycle or a BigInt: no honest text to copy, so offer no button.\n return undefined;\n }\n }\n\n return undefined;\n };\n\n const textToCopy = copyText();\n\n const { outcome: copyOutcome, copy } = useClipboardCopy(textToCopy);\n const copied = copyOutcome === 'copied';\n\n const handleCopy = () => {\n if (textToCopy !== undefined) {\n void copy(textToCopy);\n }\n };\n\n // Declared once and rendered by both the JSON branch and the code branch below, so the\n // two tabs of one document do not disagree about whether it can be copied.\n const copyButton = enableCopy && textToCopy !== undefined && (\n <>\n <button\n type=\"button\"\n aria-label=\"Copy\"\n onClick={handleCopy}\n className={`absolute top-2 right-2 z-10 flex items-center justify-center rounded-md border border-solid border-[var(--malachite-codeblock-border)] bg-[var(--malachite-codeblock-background)] p-1.5 transition-colors hover:bg-[var(--malachite-codeblock-border)] ${FOCUS_RING}`}\n style={{ color: 'var(--malachite-codeblock-line-number)' }}\n >\n {copied ? <CheckmarkIcon size={14} /> : <CopyIcon size={14} />}\n </button>\n {/* Not role=\"status\": one per block would collide with a page's own status queries. */}\n <span aria-live=\"polite\" className=\"sr-only\">\n {copied ? 'Copied to clipboard' : ''}\n </span>\n </>\n );\n\n // Tabbable so a keyboard can scroll it: Safari never focuses a scroll container on its own.\n const viewportProps = {\n role: 'region',\n 'aria-label': ariaLabelledBy ? ariaLabel : (ariaLabel ?? 'Code'),\n 'aria-labelledby': ariaLabelledBy,\n tabIndex: 0,\n className: `box-border h-full overflow-auto ${FOCUS_RING_INSET}`,\n } satisfies React.HTMLAttributes<HTMLElement>;\n\n // If JSON is provided, use JsonView component\n if (json && !diffRows) {\n return (\n <div\n className={`relative border border-solid rounded-lg overflow-hidden ${className}`}\n style={{\n backgroundColor: 'var(--malachite-codeblock-background)',\n borderColor: 'var(--malachite-codeblock-border)',\n height,\n ...style,\n }}\n >\n {copyButton}\n {/* The frame clips at `height`; this scrolls inside it, so the copy button stays put. */}\n <div {...viewportProps}>\n <JsonView\n value={json}\n style={\n {\n backgroundColor: 'var(--malachite-codeblock-background)',\n color: 'var(--malachite-codeblock-foreground)',\n fontSize: '14px',\n fontFamily: 'var(--malachite-font-mono, monospace)',\n padding: '16px',\n lineHeight: '1.5',\n textAlign: 'left',\n '--w-rjv-color': 'var(--malachite-codeblock-foreground)',\n '--w-rjv-key-string': 'var(--malachite-codeblock-keyword)',\n '--w-rjv-background-color': 'var(--malachite-codeblock-background)',\n '--w-rjv-line-color': 'var(--malachite-codeblock-border)',\n '--w-rjv-arrow-color': 'var(--malachite-codeblock-line-number)',\n '--w-rjv-edit-color': 'var(--malachite-codeblock-keyword)',\n '--w-rjv-info-color': 'var(--malachite-codeblock-line-number)',\n '--w-rjv-update-color': 'var(--malachite-codeblock-keyword)',\n '--w-rjv-copied-color': 'var(--malachite-codeblock-string)',\n '--w-rjv-copied-success-color': 'var(--malachite-codeblock-string)',\n '--w-rjv-curlybraces-color':\n 'var(--malachite-codeblock-foreground)',\n '--w-rjv-colon-color': 'var(--malachite-codeblock-foreground)',\n '--w-rjv-brackets-color': 'var(--malachite-codeblock-foreground)',\n '--w-rjv-quotes-color': 'var(--malachite-codeblock-string)',\n '--w-rjv-quotes-string-color': 'var(--malachite-codeblock-string)',\n '--w-rjv-type-string-color': 'var(--malachite-codeblock-string)',\n '--w-rjv-type-int-color': 'var(--malachite-codeblock-number)',\n '--w-rjv-type-float-color': 'var(--malachite-codeblock-number)',\n '--w-rjv-type-bigint-color': 'var(--malachite-codeblock-number)',\n '--w-rjv-type-boolean-color': 'var(--malachite-codeblock-keyword)',\n '--w-rjv-type-date-color': 'var(--malachite-codeblock-string)',\n '--w-rjv-type-url-color': 'var(--malachite-codeblock-keyword)',\n '--w-rjv-type-null-color': 'var(--malachite-codeblock-keyword)',\n '--w-rjv-type-nan-color': 'var(--malachite-codeblock-keyword)',\n '--w-rjv-type-undefined-color':\n 'var(--malachite-codeblock-keyword)',\n } as React.CSSProperties\n }\n displayDataTypes={false}\n enableClipboard={enableCopy}\n collapsed={collapsed}\n displayObjectSize={false}\n >\n {/* The library draws these three only as their type label, which\n `displayDataTypes` turns off, so without a value of their own a\n `null` reads as a key with nothing after it. */}\n <JsonView.Null render={renderLiteral('null', 'null')} />\n <JsonView.Undefined render={renderLiteral('undefined', 'undefined')} />\n <JsonView.Nan render={renderLiteral('NaN', 'nan')} />\n </JsonView>\n </div>\n </div>\n );\n }\n\n // Reserve clearance so a wide first line never sits under the floating copy button.\n const copyClearance = enableCopy && (!!code || !!diffRows);\n\n const renderPlainLines = (\n text: string,\n decorate?: (index: number) => CodeLineDecoration | undefined,\n ) => {\n const lines = text.split('\\n');\n\n return (\n <div\n {...viewportProps}\n className={`${viewportProps.className} p-4 text-left`}\n style={{ paddingRight: copyClearance ? 44 : undefined }}\n >\n <div style={rowsWrapperStyle(wrapLines)}>\n {lines.map((line, index) => {\n const decoration = decorate?.(index);\n\n return (\n <CodeLine\n key={index}\n line={line}\n lineNumber={\n decoration?.lineNumber ??\n (showLineNumbers ? index + 1 : undefined)\n }\n wrap={wrapLines}\n decoration={decoration}\n >\n {line}\n </CodeLine>\n );\n })}\n </div>\n </div>\n );\n };\n\n const renderPlainCode = () => (code ? renderPlainLines(code) : null);\n\n const renderDiff = (rows: DiffDisplayRow[]) => {\n if (rows.length === 0) {\n return (\n <div\n className=\"p-4 text-left\"\n style={{ color: 'var(--malachite-codeblock-comment)' }}\n >\n No changes\n </div>\n );\n }\n\n const decorate = (index: number) => {\n const row = rows[index];\n\n return row ? diffDecoration(row, showLineNumbers, diff?.origin) : undefined;\n };\n\n if (language) {\n return (\n <React.Suspense fallback={renderPlainLines(diffText, decorate)}>\n {/*\n * The whole merged text goes to the highlighter in one piece, so a hunk\n * is tokenised in the company of its neighbours rather than on its own.\n * Prism still cannot see the lines the hunks left out, so a construct\n * spanning an omitted run can highlight oddly — the reason `context`\n * defaults to a few lines rather than none.\n */}\n <CodeBlockHighlighter\n code={diffText}\n language={language}\n showLineNumbers={showLineNumbers}\n wrapLines={wrapLines}\n copyClearance={copyClearance}\n decorate={decorate}\n viewportProps={viewportProps}\n />\n </React.Suspense>\n );\n }\n\n return renderPlainLines(diffText, decorate);\n };\n\n // For code strings, create a simple syntax-highlighted view\n const renderCodeContent = () => {\n if (!code) {\n return null;\n }\n\n if (language) {\n return (\n <React.Suspense fallback={renderPlainCode()}>\n <CodeBlockHighlighter\n code={code}\n language={language}\n showLineNumbers={showLineNumbers}\n wrapLines={wrapLines}\n copyClearance={copyClearance}\n viewportProps={viewportProps}\n />\n </React.Suspense>\n );\n }\n\n return renderPlainCode();\n };\n\n return (\n <div\n className={`relative border border-solid rounded-lg overflow-hidden ${className}`}\n style={{\n backgroundColor: 'var(--malachite-codeblock-background)',\n borderColor: 'var(--malachite-codeblock-border)',\n height,\n ...style,\n }}\n >\n {copyButton}\n {diffRows ? renderDiff(diffRows) : renderCodeContent()}\n </div>\n );\n};\n\nexport default CodeBlock;\n"],"names":["renderLiteral","text","type","props","part","jsx","CodeBlockHighlighter","React","DIFF_BACKGROUNDS","DIFF_MARKERS","ASSISTANT_DIFF_BACKGROUNDS","ASSISTANT_DIFF_MARKERS","ASSISTANT_DIFF_MARKER_COLORS","unchangedRun","count","diffDecoration","row","showLineNumbers","origin","assistant","CodeBlock","code","json","className","style","height","enableCopy","wrapLines","language","collapsed","diff","ariaLabel","ariaLabelledBy","diffRows","diffHunks","diffText","textToCopy","copyOutcome","copy","useClipboardCopy","copied","copyButton","jsxs","Fragment","FOCUS_RING","CheckmarkIcon","CopyIcon","viewportProps","FOCUS_RING_INSET","JsonView","copyClearance","renderPlainLines","decorate","lines","rowsWrapperStyle","line","index","decoration","CodeLine","renderPlainCode","renderDiff","rows","renderCodeContent"],"mappings":";;;;;;;;;;AAeA,MAAMA,IACF,CAACC,GAAcC,MACf,CAACC,GAA8C,EAAE,MAAMC,EAAA,MACnDA,MAAS,UACL,gBAAAC,EAAC,QAAA,EAAM,GAAGF,GAAO,OAAO,EAAE,GAAGA,EAAM,OAAO,OAAO,oBAAoBD,CAAI,UAAA,GACpE,UAAAD,EAAA,CACL,IACA,MAENK,IAAuBC,EAAM,KAAK,MAAM,OAAO,2BAAwB,CAAC,GAmDxEC,IAA4D;AAAA,EAC9D,OAAO;AAAA,EACP,SAAS;AAAA,EACT,SAAS;AACb,GAEMC,IAAwD;AAAA,EAC1D,OAAO;AAAA,EACP,SAAS;AAAA,EACT,SAAS;AACb,GAGMC,IAAsE;AAAA,EACxE,OAAO;AAAA,EACP,SAAS;AAAA,EACT,SAAS;AACb,GAEMC,IAAsD;AAAA,EACxD,OAAO;AAAA;AAAA,EAEP,SAAS;AAAA,EACT,SAAS;AACb,GAEMC,IAA4D;AAAA,EAC9D,OAAO;AAAA,EACP,SAAS;AAAA,EACT,SAAS;AACb,GAEMC,IAAe,CAACC,MAClB,KAAUA,CAAK,cAAcA,MAAU,IAAI,SAAS,OAAO,IAEzDC,IAAiB,CACnBC,GACAC,GACAC,MACqB;AACrB,QAAMC,IAAYD,MAAW;AAE7B,SAAO;AAAA,IACH,YAAYC,IAAYT,EAA2BM,EAAI,IAAI,IAAIR,EAAiBQ,EAAI,IAAI;AAAA,IACxF,QAAQG,IAAYR,EAAuBK,EAAI,IAAI,IAAIP,EAAaO,EAAI,IAAI;AAAA,IAC5E,aAAaG,IAAYP,EAA6BI,EAAI,IAAI,IAAI;AAAA;AAAA,IAElE,eAAe;AAAA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