@seclai/react 0.0.16 → 0.0.18
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/README.md +138 -13
- package/dist/chunk-OFKVHNZ6.js +117 -0
- package/dist/chunk-VRNPDCWI.js +134 -0
- package/dist/extensions-D2MHwNt1.d.ts +49 -0
- package/dist/html.d.ts +22 -0
- package/dist/html.js +11 -0
- package/dist/index.d.ts +39 -10
- package/dist/index.js +584 -258
- package/dist/math.d.ts +22 -0
- package/dist/math.js +106 -0
- package/dist/mermaid.d.ts +30 -0
- package/dist/mermaid.js +126 -0
- package/dist/styles.css +175 -5
- package/package.json +49 -12
- package/dist/index.cjs +0 -1456
- package/dist/index.d.cts +0 -474
package/dist/math.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { M as MarkdownExtension } from './extensions-D2MHwNt1.js';
|
|
2
|
+
import 'react';
|
|
3
|
+
import 'react-markdown';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Maths in `MarkdownContent`, rendered with KaTeX: `$…$` and `\(…\)` inline,
|
|
7
|
+
* `$$…$$` and `\[…\]` as a block, and ```` ```math ```` fences. Maths renders
|
|
8
|
+
* once its closing delimiter arrives, and invalid maths shows as its source.
|
|
9
|
+
*
|
|
10
|
+
* Needs `katex` and `remark-math` installed, and KaTeX's stylesheet:
|
|
11
|
+
*
|
|
12
|
+
* ```tsx
|
|
13
|
+
* import { SeclaiMarkdownProvider } from "@seclai/react";
|
|
14
|
+
* import { math } from "@seclai/react/math";
|
|
15
|
+
* import "katex/dist/katex.min.css";
|
|
16
|
+
*
|
|
17
|
+
* <SeclaiMarkdownProvider extensions={[math()]}>…</SeclaiMarkdownProvider>
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
declare function math(): MarkdownExtension;
|
|
21
|
+
|
|
22
|
+
export { math };
|
package/dist/math.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
replaceOutsideCode
|
|
4
|
+
} from "./chunk-OFKVHNZ6.js";
|
|
5
|
+
import {
|
|
6
|
+
isClosedFence,
|
|
7
|
+
remarkOpenFencesAsCode
|
|
8
|
+
} from "./chunk-VRNPDCWI.js";
|
|
9
|
+
|
|
10
|
+
// src/math.tsx
|
|
11
|
+
import katex from "katex";
|
|
12
|
+
import { useMemo } from "react";
|
|
13
|
+
import remarkMath from "remark-math";
|
|
14
|
+
import { jsx } from "react/jsx-runtime";
|
|
15
|
+
var DISPLAY = /\\\[[\s\S]*?\\\]/g;
|
|
16
|
+
var INLINE = /\\\([\s\S]*?\\\)/g;
|
|
17
|
+
var LINE_END = /[ \t]*(?:\n|$)/y;
|
|
18
|
+
function normalizeMathDelimiters(markdown) {
|
|
19
|
+
if (!markdown.includes("\\[") && !markdown.includes("\\(")) return markdown;
|
|
20
|
+
const display = replaceOutsideCode(markdown, DISPLAY, (match, offset, text2) => {
|
|
21
|
+
const inner = match.slice(2, -2);
|
|
22
|
+
LINE_END.lastIndex = offset + match.length;
|
|
23
|
+
const ownLines = (offset === 0 || text2[offset - 1] === "\n") && LINE_END.test(text2);
|
|
24
|
+
return ownLines ? `$$
|
|
25
|
+
${inner.trim()}
|
|
26
|
+
$$` : `$$${inner}$$`;
|
|
27
|
+
});
|
|
28
|
+
return replaceOutsideCode(display, INLINE, (match) => `$${match.slice(2, -2)}$`);
|
|
29
|
+
}
|
|
30
|
+
function remarkOpenMathAsCode() {
|
|
31
|
+
return (tree, file) => {
|
|
32
|
+
const source = String(file.value);
|
|
33
|
+
const walk = (parent) => {
|
|
34
|
+
parent.children.forEach((child, index) => {
|
|
35
|
+
const node = child;
|
|
36
|
+
if (node.type === "math" && !isClosedFence(node, source)) {
|
|
37
|
+
parent.children[index] = { type: "code", lang: null, meta: null, value: node.value, position: node.position };
|
|
38
|
+
} else if ("children" in node) {
|
|
39
|
+
walk(node);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
walk(tree);
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
var text = (node) => node.children.map((child) => child.type === "text" ? child.value : child.type === "element" ? text(child) : "").join("");
|
|
47
|
+
function rehypeMathElements() {
|
|
48
|
+
const isMath = (node) => node?.type === "element" && node.tagName === "code" && Array.isArray(node.properties.className) && node.properties.className.includes("language-math");
|
|
49
|
+
const walk = (parent) => {
|
|
50
|
+
parent.children.forEach((child, index) => {
|
|
51
|
+
if (child.type !== "element") return;
|
|
52
|
+
const code = child.tagName === "pre" ? child.children.find(isMath) : isMath(child) ? child : void 0;
|
|
53
|
+
if (!code) return walk(child);
|
|
54
|
+
parent.children[index] = {
|
|
55
|
+
type: "element",
|
|
56
|
+
tagName: "seclai-math",
|
|
57
|
+
properties: { dataDisplay: child.tagName === "pre" ? "block" : "inline" },
|
|
58
|
+
children: [{ type: "text", value: text(code).replace(/\n$/, "") }]
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
return (tree) => walk(tree);
|
|
63
|
+
}
|
|
64
|
+
var cache = /* @__PURE__ */ new Map();
|
|
65
|
+
function renderMath(source, display) {
|
|
66
|
+
const key = `${display ? "block" : "inline"}\0${source}`;
|
|
67
|
+
let html = cache.get(key);
|
|
68
|
+
if (html === void 0) {
|
|
69
|
+
try {
|
|
70
|
+
html = katex.renderToString(source, {
|
|
71
|
+
displayMode: display,
|
|
72
|
+
throwOnError: true,
|
|
73
|
+
// No `\href`, `\url`, `\includegraphics` or `\html…` commands from the reply.
|
|
74
|
+
trust: false,
|
|
75
|
+
strict: "ignore"
|
|
76
|
+
});
|
|
77
|
+
} catch {
|
|
78
|
+
html = null;
|
|
79
|
+
}
|
|
80
|
+
if (cache.size >= 500) cache.delete(cache.keys().next().value);
|
|
81
|
+
cache.set(key, html);
|
|
82
|
+
}
|
|
83
|
+
return html;
|
|
84
|
+
}
|
|
85
|
+
function MathElement({ node }) {
|
|
86
|
+
const source = node ? text(node) : "";
|
|
87
|
+
const display = node?.properties.dataDisplay === "block";
|
|
88
|
+
const html = useMemo(() => renderMath(source, display), [source, display]);
|
|
89
|
+
if (html === null) {
|
|
90
|
+
return display ? /* @__PURE__ */ jsx("pre", { children: /* @__PURE__ */ jsx("code", { children: source }) }) : /* @__PURE__ */ jsx("code", { children: source });
|
|
91
|
+
}
|
|
92
|
+
const Tag = display ? "div" : "span";
|
|
93
|
+
return /* @__PURE__ */ jsx(Tag, { className: "seclai-markdown-math", dangerouslySetInnerHTML: { __html: html } });
|
|
94
|
+
}
|
|
95
|
+
var extension;
|
|
96
|
+
function math() {
|
|
97
|
+
return extension ??= {
|
|
98
|
+
remarkPlugins: [remarkMath, remarkOpenMathAsCode, remarkOpenFencesAsCode(["math"])],
|
|
99
|
+
rehypePlugins: [rehypeMathElements],
|
|
100
|
+
components: { "seclai-math": MathElement },
|
|
101
|
+
transform: normalizeMathDelimiters
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
export {
|
|
105
|
+
math
|
|
106
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { M as MarkdownExtension } from './extensions-D2MHwNt1.js';
|
|
2
|
+
import 'react';
|
|
3
|
+
import 'react-markdown';
|
|
4
|
+
|
|
5
|
+
interface MermaidOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Mermaid's theme, such as `"dark"` for a dark page. Defaults to `"default"`,
|
|
8
|
+
* on a white background. Mermaid has one configuration per page, so the first
|
|
9
|
+
* diagram's theme applies to all of them.
|
|
10
|
+
*/
|
|
11
|
+
theme?: "default" | "base" | "dark" | "forest" | "neutral";
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Mermaid diagrams in `MarkdownContent`, from ```` ```mermaid ```` code blocks.
|
|
15
|
+
* A diagram is drawn once its closing fence arrives; until then, and if it has
|
|
16
|
+
* a syntax error, its source shows as code. Mermaid runs with
|
|
17
|
+
* `securityLevel: "strict"`.
|
|
18
|
+
*
|
|
19
|
+
* Needs `mermaid` installed:
|
|
20
|
+
*
|
|
21
|
+
* ```tsx
|
|
22
|
+
* import { SeclaiMarkdownProvider } from "@seclai/react";
|
|
23
|
+
* import { mermaid } from "@seclai/react/mermaid";
|
|
24
|
+
*
|
|
25
|
+
* <SeclaiMarkdownProvider extensions={[mermaid()]}>…</SeclaiMarkdownProvider>
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
declare function mermaid(options?: MermaidOptions): MarkdownExtension;
|
|
29
|
+
|
|
30
|
+
export { type MermaidOptions, mermaid };
|
package/dist/mermaid.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
remarkOpenFencesAsCode
|
|
4
|
+
} from "./chunk-VRNPDCWI.js";
|
|
5
|
+
|
|
6
|
+
// src/mermaid.tsx
|
|
7
|
+
import { useEffect, useState } from "react";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
var loading;
|
|
10
|
+
function loadMermaid(theme) {
|
|
11
|
+
return loading ??= import("mermaid").then(({ default: mermaid2 }) => {
|
|
12
|
+
mermaid2.initialize({
|
|
13
|
+
startOnLoad: false,
|
|
14
|
+
// Labels are sanitized and click handlers are off.
|
|
15
|
+
securityLevel: "strict",
|
|
16
|
+
// A syntax error throws, rather than drawing Mermaid's error diagram.
|
|
17
|
+
suppressErrorRendering: true,
|
|
18
|
+
theme,
|
|
19
|
+
// Labels may hold some HTML. Like images elsewhere in a reply, none of it
|
|
20
|
+
// may load anything: no images, and no styles, which could hold `url(…)`.
|
|
21
|
+
dompurifyConfig: {
|
|
22
|
+
FORBID_TAGS: ["style", "img", "image", "picture", "source", "video", "audio", "svg", "link"],
|
|
23
|
+
FORBID_ATTR: ["style", "src", "srcset", "background", "poster"]
|
|
24
|
+
},
|
|
25
|
+
// Settings a diagram can't change with an `%%{init: …}%%` directive:
|
|
26
|
+
// Mermaid's own list, plus the ones it copies into the diagram's CSS as
|
|
27
|
+
// they are, which could load outside URLs with `url(…)` or restyle the
|
|
28
|
+
// page, and the label sanitizing above.
|
|
29
|
+
secure: [
|
|
30
|
+
"secure",
|
|
31
|
+
"securityLevel",
|
|
32
|
+
"startOnLoad",
|
|
33
|
+
"maxTextSize",
|
|
34
|
+
"suppressErrorRendering",
|
|
35
|
+
"maxEdges",
|
|
36
|
+
"themeCSS",
|
|
37
|
+
"fontFamily",
|
|
38
|
+
"altFontFamily",
|
|
39
|
+
"dompurifyConfig"
|
|
40
|
+
]
|
|
41
|
+
});
|
|
42
|
+
return mermaid2;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
var queue = Promise.resolve();
|
|
46
|
+
var nextId = 0;
|
|
47
|
+
var rendered = /* @__PURE__ */ new Map();
|
|
48
|
+
function renderDiagram(source, theme) {
|
|
49
|
+
const key = `${theme}\0${source}`;
|
|
50
|
+
const done = rendered.get(key);
|
|
51
|
+
if (done !== void 0) return Promise.resolve(done);
|
|
52
|
+
const result = queue.then(async () => {
|
|
53
|
+
let svg = null;
|
|
54
|
+
try {
|
|
55
|
+
const mermaid2 = await loadMermaid(theme);
|
|
56
|
+
if (await mermaid2.parse(source, { suppressErrors: true })) {
|
|
57
|
+
svg = (await mermaid2.render(`seclai-mermaid-${nextId++}`, source)).svg;
|
|
58
|
+
}
|
|
59
|
+
} catch {
|
|
60
|
+
svg = null;
|
|
61
|
+
}
|
|
62
|
+
if (rendered.size >= 100) rendered.delete(rendered.keys().next().value);
|
|
63
|
+
rendered.set(key, svg);
|
|
64
|
+
return svg;
|
|
65
|
+
});
|
|
66
|
+
queue = result;
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
var text = (node) => node.children.map((child) => child.type === "text" ? child.value : child.type === "element" ? text(child) : "").join("");
|
|
70
|
+
function rehypeMermaidElements() {
|
|
71
|
+
const isMermaid = (node) => node.type === "element" && node.tagName === "code" && Array.isArray(node.properties.className) && node.properties.className.includes("language-mermaid");
|
|
72
|
+
const walk = (parent) => {
|
|
73
|
+
parent.children.forEach((child, index) => {
|
|
74
|
+
if (child.type !== "element") return;
|
|
75
|
+
const code = child.tagName === "pre" ? child.children.find(isMermaid) : void 0;
|
|
76
|
+
if (!code) return walk(child);
|
|
77
|
+
parent.children[index] = {
|
|
78
|
+
type: "element",
|
|
79
|
+
tagName: "seclai-mermaid",
|
|
80
|
+
properties: {},
|
|
81
|
+
children: [{ type: "text", value: text(code).replace(/\n$/, "") }]
|
|
82
|
+
};
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
return (tree) => walk(tree);
|
|
86
|
+
}
|
|
87
|
+
function diagramComponent(theme) {
|
|
88
|
+
return function MermaidDiagram({ node }) {
|
|
89
|
+
const source = node ? text(node) : "";
|
|
90
|
+
const key = `${theme}\0${source}`;
|
|
91
|
+
const [svg, setSvg] = useState(() => rendered.get(key) ?? null);
|
|
92
|
+
const [drawn, setDrawn] = useState(() => rendered.get(key) !== void 0 ? key : null);
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
let current = true;
|
|
95
|
+
renderDiagram(source, theme).then((result) => {
|
|
96
|
+
if (!current) return;
|
|
97
|
+
setSvg(result);
|
|
98
|
+
setDrawn(key);
|
|
99
|
+
});
|
|
100
|
+
return () => {
|
|
101
|
+
current = false;
|
|
102
|
+
};
|
|
103
|
+
}, [source, key]);
|
|
104
|
+
if (drawn !== key || svg === null) {
|
|
105
|
+
return /* @__PURE__ */ jsx("pre", { className: "seclai-markdown-mermaid-source", children: /* @__PURE__ */ jsx("code", { className: "language-mermaid", children: source }) });
|
|
106
|
+
}
|
|
107
|
+
return /* @__PURE__ */ jsx("div", { className: "seclai-markdown-mermaid", "data-theme": theme, dangerouslySetInnerHTML: { __html: svg } });
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
var extensions = /* @__PURE__ */ new Map();
|
|
111
|
+
function mermaid(options = {}) {
|
|
112
|
+
const theme = options.theme ?? "default";
|
|
113
|
+
let extension = extensions.get(theme);
|
|
114
|
+
if (!extension) {
|
|
115
|
+
extension = {
|
|
116
|
+
remarkPlugins: [remarkOpenFencesAsCode(["mermaid"])],
|
|
117
|
+
rehypePlugins: [rehypeMermaidElements],
|
|
118
|
+
components: { "seclai-mermaid": diagramComponent(theme) }
|
|
119
|
+
};
|
|
120
|
+
extensions.set(theme, extension);
|
|
121
|
+
}
|
|
122
|
+
return extension;
|
|
123
|
+
}
|
|
124
|
+
export {
|
|
125
|
+
mermaid
|
|
126
|
+
};
|
package/dist/styles.css
CHANGED
|
@@ -427,24 +427,136 @@
|
|
|
427
427
|
inset: -8px;
|
|
428
428
|
}
|
|
429
429
|
|
|
430
|
-
/*
|
|
430
|
+
/*
|
|
431
|
+
* Agent output (Markdown). The list numbers are badges, below. Also themable with:
|
|
432
|
+
* --seclai-code-font the monospace font for code (ui-monospace and fallbacks)
|
|
433
|
+
* --seclai-code-surface the background of code blocks and inline code
|
|
434
|
+
*/
|
|
431
435
|
.seclai-markdown {
|
|
432
436
|
overflow-wrap: anywhere;
|
|
433
437
|
}
|
|
434
438
|
|
|
439
|
+
/* Blocks at any depth: no margins of their own, only space between siblings. */
|
|
440
|
+
.seclai-markdown :where(p, ul, ol, pre, blockquote, table, h1, h2, h3, h4, h5, h6, hr, details, dl, figure) {
|
|
441
|
+
margin-block: 0;
|
|
442
|
+
}
|
|
443
|
+
|
|
435
444
|
.seclai-markdown > * {
|
|
436
445
|
margin: 0;
|
|
437
446
|
}
|
|
438
447
|
|
|
439
|
-
.seclai-markdown > * +
|
|
448
|
+
.seclai-markdown > * + *,
|
|
449
|
+
.seclai-markdown :where(blockquote, ul > li, ol > li > div, td, th, details, section) > * + * {
|
|
440
450
|
margin-block-start: 0.75em;
|
|
441
451
|
}
|
|
442
452
|
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
453
|
+
.seclai-markdown :where(h1, h2, h3, h4, h5, h6) {
|
|
454
|
+
font-weight: 600;
|
|
455
|
+
line-height: 1.3;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
.seclai-markdown h1 {
|
|
459
|
+
font-size: 1.5em;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
.seclai-markdown h2 {
|
|
463
|
+
font-size: 1.3em;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
.seclai-markdown h3 {
|
|
467
|
+
font-size: 1.15em;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
.seclai-markdown :where(h4, h5, h6) {
|
|
471
|
+
font-size: 1em;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/* A heading after other content gets more room above it. */
|
|
475
|
+
.seclai-markdown * + :where(h1, h2, h3, h4, h5, h6) {
|
|
476
|
+
margin-block-start: 1.25em;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
.seclai-markdown a {
|
|
480
|
+
color: var(--seclai-accent);
|
|
481
|
+
text-underline-offset: 0.16em;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
@media (hover: hover) {
|
|
485
|
+
.seclai-markdown a:hover {
|
|
486
|
+
color: var(--seclai-accent-hover);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
/* Code */
|
|
491
|
+
.seclai-markdown :where(code, kbd, samp) {
|
|
492
|
+
font-family: var(--seclai-code-font, ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace);
|
|
493
|
+
font-size: 0.875em;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
.seclai-markdown :not(pre) > code {
|
|
497
|
+
padding: 0.1em 0.35em;
|
|
498
|
+
background: var(--seclai-code-surface, var(--seclai-surface-hover));
|
|
499
|
+
border-radius: 4px;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
.seclai-markdown pre {
|
|
503
|
+
padding: 12px 16px;
|
|
504
|
+
overflow-x: auto;
|
|
505
|
+
line-height: 1.5;
|
|
506
|
+
background: var(--seclai-code-surface, var(--seclai-surface-hover));
|
|
507
|
+
border-radius: var(--seclai-radius);
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
/* Code blocks keep their lines and scroll sideways rather than wrap. */
|
|
511
|
+
.seclai-markdown pre code {
|
|
512
|
+
font-size: 0.8125em;
|
|
513
|
+
white-space: pre;
|
|
514
|
+
overflow-wrap: normal;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
.seclai-markdown kbd {
|
|
518
|
+
padding: 0.1em 0.4em;
|
|
519
|
+
border: 1px solid var(--seclai-border);
|
|
520
|
+
border-block-end-width: 2px;
|
|
521
|
+
border-radius: 4px;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
.seclai-markdown blockquote {
|
|
525
|
+
padding-inline-start: 12px;
|
|
526
|
+
color: var(--seclai-muted);
|
|
527
|
+
border-inline-start: 3px solid var(--seclai-border);
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
/* Tables scroll sideways rather than squeezing their columns. */
|
|
531
|
+
.seclai-markdown-table {
|
|
532
|
+
max-width: 100%;
|
|
533
|
+
overflow-x: auto;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
.seclai-markdown table {
|
|
537
|
+
font-size: 0.9375em;
|
|
538
|
+
overflow-wrap: normal;
|
|
539
|
+
border-collapse: collapse;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
.seclai-markdown :where(th, td) {
|
|
543
|
+
min-width: 4em;
|
|
544
|
+
padding: 6px 12px;
|
|
545
|
+
text-align: start;
|
|
546
|
+
vertical-align: top;
|
|
547
|
+
border: 1px solid var(--seclai-border);
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
.seclai-markdown th {
|
|
551
|
+
font-weight: 600;
|
|
552
|
+
background: var(--seclai-surface);
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
.seclai-markdown tbody tr:nth-child(even) {
|
|
556
|
+
background: var(--seclai-surface);
|
|
446
557
|
}
|
|
447
558
|
|
|
559
|
+
/* Lists */
|
|
448
560
|
.seclai-markdown ul {
|
|
449
561
|
padding-inline-start: 1.25em;
|
|
450
562
|
list-style: disc;
|
|
@@ -469,6 +581,7 @@
|
|
|
469
581
|
}
|
|
470
582
|
|
|
471
583
|
.seclai-markdown ol > li > :last-child {
|
|
584
|
+
flex: 1;
|
|
472
585
|
min-width: 0;
|
|
473
586
|
}
|
|
474
587
|
|
|
@@ -487,12 +600,69 @@
|
|
|
487
600
|
list-style: square;
|
|
488
601
|
}
|
|
489
602
|
|
|
603
|
+
/* Task lists: the checkbox takes the bullet's place. */
|
|
604
|
+
.seclai-markdown ul.contains-task-list {
|
|
605
|
+
padding-inline-start: 0;
|
|
606
|
+
list-style: none;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
.seclai-markdown .task-list-item input {
|
|
610
|
+
margin: 0 0.4em 0 0;
|
|
611
|
+
vertical-align: -0.1em;
|
|
612
|
+
accent-color: var(--seclai-accent);
|
|
613
|
+
}
|
|
614
|
+
|
|
490
615
|
.seclai-markdown hr {
|
|
491
616
|
height: 0;
|
|
492
617
|
border: 0;
|
|
493
618
|
border-block-start: 1px solid var(--seclai-border);
|
|
494
619
|
}
|
|
495
620
|
|
|
621
|
+
.seclai-markdown svg {
|
|
622
|
+
max-width: 100%;
|
|
623
|
+
height: auto;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
/* Footnotes */
|
|
627
|
+
.seclai-markdown section.footnotes {
|
|
628
|
+
padding-block-start: 0.75em;
|
|
629
|
+
font-size: 0.875em;
|
|
630
|
+
color: var(--seclai-muted);
|
|
631
|
+
border-block-start: 1px solid var(--seclai-border);
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
.seclai-markdown .sr-only {
|
|
635
|
+
position: absolute;
|
|
636
|
+
width: 1px;
|
|
637
|
+
height: 1px;
|
|
638
|
+
margin: -1px;
|
|
639
|
+
padding: 0;
|
|
640
|
+
overflow: hidden;
|
|
641
|
+
clip: rect(0, 0, 0, 0);
|
|
642
|
+
white-space: nowrap;
|
|
643
|
+
border: 0;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
/* Maths (`@seclai/react/math`) and diagrams (`@seclai/react/mermaid`) */
|
|
647
|
+
div.seclai-markdown-math {
|
|
648
|
+
max-width: 100%;
|
|
649
|
+
overflow-x: auto;
|
|
650
|
+
overflow-y: hidden;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
.seclai-markdown-mermaid {
|
|
654
|
+
max-width: 100%;
|
|
655
|
+
overflow-x: auto;
|
|
656
|
+
padding: 12px;
|
|
657
|
+
text-align: center;
|
|
658
|
+
border-radius: var(--seclai-radius);
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
/* Mermaid's light themes draw dark text, so they keep a white background on a dark page. */
|
|
662
|
+
.seclai-markdown-mermaid:not([data-theme="dark"]) {
|
|
663
|
+
background: #ffffff;
|
|
664
|
+
}
|
|
665
|
+
|
|
496
666
|
.seclai-media {
|
|
497
667
|
display: flex;
|
|
498
668
|
flex-direction: column;
|
package/package.json
CHANGED
|
@@ -1,22 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seclai/react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.18",
|
|
4
4
|
"description": "React components and hooks for running Seclai agents: run form, chat, and streaming output.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"main": "./dist/index.
|
|
8
|
-
"module": "./dist/index.js",
|
|
7
|
+
"main": "./dist/index.js",
|
|
9
8
|
"types": "./dist/index.d.ts",
|
|
10
9
|
"exports": {
|
|
11
10
|
".": {
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./html": {
|
|
15
|
+
"types": "./dist/html.d.ts",
|
|
16
|
+
"default": "./dist/html.js"
|
|
17
|
+
},
|
|
18
|
+
"./math": {
|
|
19
|
+
"types": "./dist/math.d.ts",
|
|
20
|
+
"default": "./dist/math.js"
|
|
21
|
+
},
|
|
22
|
+
"./mermaid": {
|
|
23
|
+
"types": "./dist/mermaid.d.ts",
|
|
24
|
+
"default": "./dist/mermaid.js"
|
|
20
25
|
},
|
|
21
26
|
"./styles.css": "./dist/styles.css",
|
|
22
27
|
"./package.json": "./package.json"
|
|
@@ -40,19 +45,51 @@
|
|
|
40
45
|
"typecheck": "tsc --noEmit",
|
|
41
46
|
"test": "vitest run"
|
|
42
47
|
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"mdast-util-gfm-footnote": "^2.1.0",
|
|
50
|
+
"mdast-util-gfm-strikethrough": "^2.0.1",
|
|
51
|
+
"mdast-util-gfm-table": "^2.0.1",
|
|
52
|
+
"mdast-util-gfm-task-list-item": "^2.0.1",
|
|
53
|
+
"micromark-extension-gfm": "^3.0.0",
|
|
54
|
+
"react-markdown": "^10.1.0",
|
|
55
|
+
"rehype-raw": "^7.0.0",
|
|
56
|
+
"rehype-sanitize": "^6.0.0"
|
|
57
|
+
},
|
|
43
58
|
"peerDependencies": {
|
|
59
|
+
"katex": ">=0.18.2",
|
|
60
|
+
"mermaid": "^11.16.1 || ^12.0.0",
|
|
44
61
|
"react": ">=18",
|
|
45
|
-
"react-dom": ">=18"
|
|
62
|
+
"react-dom": ">=18",
|
|
63
|
+
"remark-math": "^6.0.0"
|
|
64
|
+
},
|
|
65
|
+
"peerDependenciesMeta": {
|
|
66
|
+
"katex": {
|
|
67
|
+
"optional": true
|
|
68
|
+
},
|
|
69
|
+
"mermaid": {
|
|
70
|
+
"optional": true
|
|
71
|
+
},
|
|
72
|
+
"remark-math": {
|
|
73
|
+
"optional": true
|
|
74
|
+
}
|
|
46
75
|
},
|
|
47
76
|
"devDependencies": {
|
|
48
77
|
"@testing-library/dom": "^10.4.0",
|
|
49
78
|
"@testing-library/react": "^16.3.0",
|
|
50
79
|
"@testing-library/user-event": "^14.6.1",
|
|
80
|
+
"@types/hast": "^3.0.5",
|
|
81
|
+
"@types/mdast": "^4.0.4",
|
|
51
82
|
"@types/react": "^19.0.0",
|
|
52
83
|
"@types/react-dom": "^19.0.0",
|
|
84
|
+
"esbuild": "^0.27.7",
|
|
53
85
|
"jsdom": "^26.1.0",
|
|
86
|
+
"katex": "^0.19.1",
|
|
87
|
+
"mdast-util-from-markdown": "^2.1.0",
|
|
88
|
+
"mermaid": "^12.3.0",
|
|
54
89
|
"react": "^19.0.0",
|
|
55
90
|
"react-dom": "^19.0.0",
|
|
91
|
+
"remark-gfm": "^4.0.1",
|
|
92
|
+
"remark-math": "^6.0.0",
|
|
56
93
|
"tsup": "^8.5.0",
|
|
57
94
|
"typescript": "^5.9.3",
|
|
58
95
|
"vitest": "^3.2.4"
|