@octanejs/streamdown 0.1.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.
Files changed (69) hide show
  1. package/LICENSE +13 -0
  2. package/README.md +39 -0
  3. package/UPSTREAM.md +15 -0
  4. package/dist/client/chunks/chunk-6IDAODM4.js +4809 -0
  5. package/dist/client/chunks/highlighted-body-PYQZ7NZ4.js +69 -0
  6. package/dist/client/chunks/mermaid-I6WR5JDC.js +7 -0
  7. package/dist/client/cjk.js +104 -0
  8. package/dist/client/code.js +115 -0
  9. package/dist/client/index.js +57 -0
  10. package/dist/client/math.js +30 -0
  11. package/dist/client/mermaid.js +46 -0
  12. package/dist/server/chunks/chunk-55X6YY2C.js +4526 -0
  13. package/dist/server/chunks/highlighted-body-NLELYOBH.js +60 -0
  14. package/dist/server/chunks/mermaid-SICAYVAP.js +7 -0
  15. package/dist/server/cjk.js +104 -0
  16. package/dist/server/code.js +115 -0
  17. package/dist/server/index.js +57 -0
  18. package/dist/server/math.js +30 -0
  19. package/dist/server/mermaid.js +46 -0
  20. package/dist/styles.css +35 -0
  21. package/dist/types/cjk.d.ts +32 -0
  22. package/dist/types/code.d.ts +58 -0
  23. package/dist/types/hooks/use-deferred-render.d.ts +60 -0
  24. package/dist/types/index.d.ts +161 -0
  25. package/dist/types/lib/animate.d.ts +33 -0
  26. package/dist/types/lib/block-incomplete-context.d.ts +15 -0
  27. package/dist/types/lib/code-block/body.d.ts +12 -0
  28. package/dist/types/lib/code-block/container.d.ts +10 -0
  29. package/dist/types/lib/code-block/context.d.ts +7 -0
  30. package/dist/types/lib/code-block/copy-button.d.ts +10 -0
  31. package/dist/types/lib/code-block/download-button.d.ts +10 -0
  32. package/dist/types/lib/code-block/header.d.ts +6 -0
  33. package/dist/types/lib/code-block/highlighted-body.d.ts +12 -0
  34. package/dist/types/lib/code-block/index.d.ts +14 -0
  35. package/dist/types/lib/code-block/skeleton.d.ts +2 -0
  36. package/dist/types/lib/components.d.ts +3 -0
  37. package/dist/types/lib/detect-direction.d.ts +14 -0
  38. package/dist/types/lib/icon-context.d.ts +25 -0
  39. package/dist/types/lib/icons.d.ts +17 -0
  40. package/dist/types/lib/image.d.ts +6 -0
  41. package/dist/types/lib/incomplete-code-utils.d.ts +25 -0
  42. package/dist/types/lib/link-modal.d.ts +9 -0
  43. package/dist/types/lib/markdown.d.ts +33 -0
  44. package/dist/types/lib/mermaid/download-button.d.ts +13 -0
  45. package/dist/types/lib/mermaid/fullscreen-button.d.ts +11 -0
  46. package/dist/types/lib/mermaid/index.d.ts +11 -0
  47. package/dist/types/lib/mermaid/pan-zoom.d.ts +14 -0
  48. package/dist/types/lib/mermaid/utils.d.ts +7 -0
  49. package/dist/types/lib/parse-blocks.d.ts +2 -0
  50. package/dist/types/lib/plugin-context.d.ts +30 -0
  51. package/dist/types/lib/plugin-types.d.ts +151 -0
  52. package/dist/types/lib/prefix-context.d.ts +13 -0
  53. package/dist/types/lib/preprocess-custom-tags.d.ts +20 -0
  54. package/dist/types/lib/preprocess-literal-tag-content.d.ts +25 -0
  55. package/dist/types/lib/rehype/literal-tag-content.d.ts +13 -0
  56. package/dist/types/lib/remark/code-meta.d.ts +10 -0
  57. package/dist/types/lib/remark/escape-html.d.ts +4 -0
  58. package/dist/types/lib/scroll-lock.d.ts +3 -0
  59. package/dist/types/lib/table/copy-dropdown.d.ts +10 -0
  60. package/dist/types/lib/table/download-dropdown.d.ts +18 -0
  61. package/dist/types/lib/table/fullscreen-button.d.ts +10 -0
  62. package/dist/types/lib/table/index.d.ts +10 -0
  63. package/dist/types/lib/table/utils.d.ts +11 -0
  64. package/dist/types/lib/translations-context.d.ts +35 -0
  65. package/dist/types/lib/types.d.ts +17 -0
  66. package/dist/types/lib/utils.d.ts +19 -0
  67. package/dist/types/math.d.ts +44 -0
  68. package/dist/types/mermaid-plugin.d.ts +44 -0
  69. package/package.json +121 -0
@@ -0,0 +1,60 @@
1
+ // octane-no-slot: this package already contains compiler-assigned hook slots.
2
+ import {
3
+ CodeBlockBody,
4
+ StreamdownContext,
5
+ useCodePlugin
6
+ } from "./chunk-55X6YY2C.js";
7
+
8
+ // src/lib/code-block/highlighted-body.tsrx
9
+ import {
10
+ createElement as _$createElement,
11
+ createScopedValue as _$createScopedValue,
12
+ useContext,
13
+ useEffect,
14
+ useMemo,
15
+ useRef,
16
+ useState
17
+ } from "octane/server";
18
+ var HighlightedCodeBlockBody = ({
19
+ code,
20
+ language,
21
+ raw,
22
+ className,
23
+ startLine,
24
+ lineNumbers,
25
+ ...rest
26
+ }) => {
27
+ const { shikiTheme } = useContext(StreamdownContext);
28
+ const codePlugin = useCodePlugin();
29
+ const request = useMemo(() => ({ code, language, plugin: codePlugin, themes: shikiTheme }), [code, language, codePlugin, shikiTheme]);
30
+ const [highlight, setHighlight] = useState({ request, result: raw });
31
+ const requestRef = useRef(request);
32
+ requestRef.current = request;
33
+ const result = highlight.request === request ? highlight.result : raw;
34
+ useEffect(
35
+ () => {
36
+ const commit = (nextResult) => {
37
+ if (requestRef.current !== request) return;
38
+ setHighlight({ request, result: nextResult });
39
+ };
40
+ if (!request.plugin) {
41
+ commit(raw);
42
+ return;
43
+ }
44
+ const cachedResult = request.plugin.highlight(
45
+ {
46
+ code: request.code,
47
+ language: request.language,
48
+ themes: request.themes
49
+ },
50
+ commit
51
+ );
52
+ if (cachedResult) commit(cachedResult);
53
+ },
54
+ [request, raw]
55
+ );
56
+ return _$createScopedValue(() => _$createElement(CodeBlockBody, { className, language, lineNumbers, result, startLine, ...rest }));
57
+ };
58
+ export {
59
+ HighlightedCodeBlockBody
60
+ };
@@ -0,0 +1,7 @@
1
+ // octane-no-slot: this package already contains compiler-assigned hook slots.
2
+ import {
3
+ Mermaid
4
+ } from "./chunk-55X6YY2C.js";
5
+ export {
6
+ Mermaid
7
+ };
@@ -0,0 +1,104 @@
1
+ // octane-no-slot: this package already contains compiler-assigned hook slots.
2
+ "use client";
3
+
4
+ // src/cjk.ts
5
+ import remarkCjkFriendly from "remark-cjk-friendly";
6
+ import remarkCjkFriendlyGfmStrikethrough from "remark-cjk-friendly-gfm-strikethrough";
7
+ import { visit } from "unist-util-visit";
8
+ var CJK_AUTOLINK_BOUNDARY_CHARS = /* @__PURE__ */ new Set([
9
+ "\u3002",
10
+ "\uFF0E",
11
+ "\uFF0C",
12
+ "\u3001",
13
+ "\uFF1F",
14
+ "\uFF01",
15
+ "\uFF1A",
16
+ "\uFF1B",
17
+ "\uFF08",
18
+ "\uFF09",
19
+ "\u3010",
20
+ "\u3011",
21
+ "\u300C",
22
+ "\u300D",
23
+ "\u300E",
24
+ "\u300F",
25
+ "\u3008",
26
+ "\u3009",
27
+ "\u300A",
28
+ "\u300B"
29
+ ]);
30
+ var AUTOLINK_PREFIX_PATTERN = /^(https?:\/\/|mailto:|www\.)/i;
31
+ var isAutolinkLiteral = (node) => {
32
+ if (node.children.length !== 1) {
33
+ return false;
34
+ }
35
+ const child = node.children[0];
36
+ return child.type === "text" && child.value === node.url;
37
+ };
38
+ var findCjkBoundaryIndex = (url) => {
39
+ let index = 0;
40
+ for (const char of url) {
41
+ if (CJK_AUTOLINK_BOUNDARY_CHARS.has(char)) {
42
+ return index;
43
+ }
44
+ index += char.length;
45
+ }
46
+ return null;
47
+ };
48
+ var buildAutolink = (url, source) => ({
49
+ ...source,
50
+ url,
51
+ children: [
52
+ {
53
+ type: "text",
54
+ value: url
55
+ }
56
+ ]
57
+ });
58
+ var buildTrailingText = (value) => ({
59
+ type: "text",
60
+ value
61
+ });
62
+ var remarkCjkAutolinkBoundary = () => (tree) => {
63
+ visit(tree, "link", (node, index, parent) => {
64
+ if (!parent || typeof index !== "number") {
65
+ return;
66
+ }
67
+ if (!isAutolinkLiteral(node)) {
68
+ return;
69
+ }
70
+ if (!AUTOLINK_PREFIX_PATTERN.test(node.url)) {
71
+ return;
72
+ }
73
+ const boundaryIndex = findCjkBoundaryIndex(node.url);
74
+ if (boundaryIndex === null || boundaryIndex === 0) {
75
+ return;
76
+ }
77
+ const trimmedUrl = node.url.slice(0, boundaryIndex);
78
+ const trailing = node.url.slice(boundaryIndex);
79
+ const trimmedLink = buildAutolink(trimmedUrl, node);
80
+ const trailingText = buildTrailingText(trailing);
81
+ parent.children.splice(index, 1, trimmedLink, trailingText);
82
+ return index + 1;
83
+ });
84
+ };
85
+ function createCjkPlugin() {
86
+ const remarkPluginsBefore = [remarkCjkFriendly];
87
+ const remarkPluginsAfter = [
88
+ remarkCjkAutolinkBoundary,
89
+ remarkCjkFriendlyGfmStrikethrough
90
+ ];
91
+ const remarkPlugins = [...remarkPluginsBefore, ...remarkPluginsAfter];
92
+ return {
93
+ name: "cjk",
94
+ type: "cjk",
95
+ remarkPluginsBefore,
96
+ remarkPluginsAfter,
97
+ remarkPlugins
98
+ };
99
+ }
100
+ var cjk = createCjkPlugin();
101
+ export {
102
+ cjk,
103
+ createCjkPlugin
104
+ };
@@ -0,0 +1,115 @@
1
+ // octane-no-slot: this package already contains compiler-assigned hook slots.
2
+ "use client";
3
+
4
+ // src/code.ts
5
+ import {
6
+ bundledLanguages,
7
+ bundledLanguagesInfo,
8
+ createHighlighter
9
+ } from "shiki";
10
+ import { createJavaScriptRegexEngine } from "shiki/engine/javascript";
11
+ var jsEngine = createJavaScriptRegexEngine({ forgiving: true });
12
+ var languageAliases = Object.fromEntries(
13
+ bundledLanguagesInfo.flatMap(
14
+ (info) => (info.aliases ?? []).map((alias) => [alias, info.id])
15
+ )
16
+ );
17
+ var languageNames = new Set(Object.keys(bundledLanguages));
18
+ var normalizeLanguage = (language) => {
19
+ const trimmed = language.trim();
20
+ const lower = trimmed.toLowerCase();
21
+ const alias = languageAliases[lower];
22
+ if (alias) {
23
+ return alias;
24
+ }
25
+ if (languageNames.has(lower)) {
26
+ return lower;
27
+ }
28
+ return lower;
29
+ };
30
+ var highlighterCache = /* @__PURE__ */ new Map();
31
+ var tokensCache = /* @__PURE__ */ new Map();
32
+ var subscribers = /* @__PURE__ */ new Map();
33
+ var getThemeName = (theme) => typeof theme === "string" ? theme : theme.name ?? "custom";
34
+ var getHighlighterCacheKey = (language, themes) => `${language}-${getThemeName(themes[0])}-${getThemeName(themes[1])}`;
35
+ var getTokensCacheKey = (code2, language, themeNames) => {
36
+ const start = code2.slice(0, 100);
37
+ const end = code2.length > 100 ? code2.slice(-100) : "";
38
+ return `${language}:${themeNames[0]}:${themeNames[1]}:${code2.length}:${start}:${end}`;
39
+ };
40
+ var getHighlighter = (language, themes) => {
41
+ const cacheKey = getHighlighterCacheKey(language, themes);
42
+ if (highlighterCache.has(cacheKey)) {
43
+ return highlighterCache.get(cacheKey);
44
+ }
45
+ const highlighterPromise = createHighlighter({
46
+ themes,
47
+ langs: [language],
48
+ engine: jsEngine
49
+ });
50
+ highlighterCache.set(cacheKey, highlighterPromise);
51
+ return highlighterPromise;
52
+ };
53
+ function createCodePlugin(options = {}) {
54
+ const defaultThemes = options.themes ?? ["github-light", "github-dark"];
55
+ return {
56
+ name: "shiki",
57
+ type: "code-highlighter",
58
+ supportsLanguage(language) {
59
+ const resolvedLanguage = normalizeLanguage(language);
60
+ return languageNames.has(resolvedLanguage);
61
+ },
62
+ getSupportedLanguages() {
63
+ return Array.from(languageNames);
64
+ },
65
+ getThemes() {
66
+ return defaultThemes;
67
+ },
68
+ highlight({ code: code2, language, themes }, callback) {
69
+ const resolvedLanguage = normalizeLanguage(language);
70
+ const themeNames = [getThemeName(themes[0]), getThemeName(themes[1])];
71
+ const tokensCacheKey = getTokensCacheKey(code2, resolvedLanguage, themeNames);
72
+ if (tokensCache.has(tokensCacheKey)) {
73
+ return tokensCache.get(tokensCacheKey);
74
+ }
75
+ if (callback) {
76
+ if (!subscribers.has(tokensCacheKey)) {
77
+ subscribers.set(tokensCacheKey, /* @__PURE__ */ new Set());
78
+ }
79
+ const subs = subscribers.get(tokensCacheKey);
80
+ subs.add(callback);
81
+ }
82
+ const safeLanguage = languageNames.has(
83
+ resolvedLanguage
84
+ ) ? resolvedLanguage : "text";
85
+ getHighlighter(safeLanguage, themes).then((highlighter) => {
86
+ const availableLangs = highlighter.getLoadedLanguages();
87
+ const langToUse = availableLangs.includes(resolvedLanguage) ? resolvedLanguage : "text";
88
+ const result = highlighter.codeToTokens(code2, {
89
+ lang: langToUse,
90
+ themes: {
91
+ light: themeNames[0],
92
+ dark: themeNames[1]
93
+ }
94
+ });
95
+ tokensCache.set(tokensCacheKey, result);
96
+ const subs = subscribers.get(tokensCacheKey);
97
+ if (subs) {
98
+ for (const sub of subs) {
99
+ sub(result);
100
+ }
101
+ subscribers.delete(tokensCacheKey);
102
+ }
103
+ }).catch((error) => {
104
+ console.error("[Streamdown Code] Failed to highlight code:", error);
105
+ subscribers.delete(tokensCacheKey);
106
+ });
107
+ return null;
108
+ }
109
+ };
110
+ }
111
+ var code = createCodePlugin();
112
+ export {
113
+ code,
114
+ createCodePlugin
115
+ };
@@ -0,0 +1,57 @@
1
+ // octane-no-slot: this package already contains compiler-assigned hook slots.
2
+ import {
3
+ Block,
4
+ CodeBlock,
5
+ CodeBlockContainer,
6
+ CodeBlockCopyButton,
7
+ CodeBlockDownloadButton,
8
+ CodeBlockHeader,
9
+ CodeBlockSkeleton,
10
+ Streamdown,
11
+ StreamdownContext,
12
+ TableCopyDropdown,
13
+ TableDownloadButton,
14
+ TableDownloadDropdown,
15
+ createAnimatePlugin,
16
+ defaultRehypePlugins,
17
+ defaultRemarkPlugins,
18
+ defaultTranslations,
19
+ defaultUrlTransform,
20
+ detectTextDirection,
21
+ escapeMarkdownTableCell,
22
+ extractTableDataFromElement,
23
+ normalizeHtmlIndentation,
24
+ parseMarkdownIntoBlocks,
25
+ tableDataToCSV,
26
+ tableDataToMarkdown,
27
+ tableDataToTSV,
28
+ useIsCodeFenceIncomplete
29
+ } from "./chunks/chunk-55X6YY2C.js";
30
+ export {
31
+ Block,
32
+ CodeBlock,
33
+ CodeBlockContainer,
34
+ CodeBlockCopyButton,
35
+ CodeBlockDownloadButton,
36
+ CodeBlockHeader,
37
+ CodeBlockSkeleton,
38
+ Streamdown,
39
+ StreamdownContext,
40
+ TableCopyDropdown,
41
+ TableDownloadButton,
42
+ TableDownloadDropdown,
43
+ createAnimatePlugin,
44
+ defaultRehypePlugins,
45
+ defaultRemarkPlugins,
46
+ defaultTranslations,
47
+ defaultUrlTransform,
48
+ detectTextDirection,
49
+ escapeMarkdownTableCell,
50
+ extractTableDataFromElement,
51
+ normalizeHtmlIndentation,
52
+ parseMarkdownIntoBlocks,
53
+ tableDataToCSV,
54
+ tableDataToMarkdown,
55
+ tableDataToTSV,
56
+ useIsCodeFenceIncomplete
57
+ };
@@ -0,0 +1,30 @@
1
+ // octane-no-slot: this package already contains compiler-assigned hook slots.
2
+ "use client";
3
+
4
+ // src/math.ts
5
+ import rehypeKatex from "rehype-katex";
6
+ import remarkMath from "remark-math";
7
+ function createMathPlugin(options = {}) {
8
+ const remarkMathPlugin = [
9
+ remarkMath,
10
+ { singleDollarTextMath: options.singleDollarTextMath ?? false }
11
+ ];
12
+ const rehypeKatexPlugin = [
13
+ rehypeKatex,
14
+ { errorColor: options.errorColor ?? "var(--color-muted-foreground)" }
15
+ ];
16
+ return {
17
+ name: "katex",
18
+ type: "math",
19
+ remarkPlugin: remarkMathPlugin,
20
+ rehypePlugin: rehypeKatexPlugin,
21
+ getStyles() {
22
+ return "katex/dist/katex.min.css";
23
+ }
24
+ };
25
+ }
26
+ var math = createMathPlugin();
27
+ export {
28
+ createMathPlugin,
29
+ math
30
+ };
@@ -0,0 +1,46 @@
1
+ // octane-no-slot: this package already contains compiler-assigned hook slots.
2
+ "use client";
3
+
4
+ // src/mermaid-plugin.ts
5
+ import mermaidLib from "mermaid";
6
+ var defaultConfig = {
7
+ startOnLoad: false,
8
+ theme: "default",
9
+ securityLevel: "strict",
10
+ fontFamily: "monospace",
11
+ suppressErrorRendering: true
12
+ };
13
+ function createMermaidPlugin(options = {}) {
14
+ let initialized = false;
15
+ let currentConfig = { ...defaultConfig, ...options.config };
16
+ const mermaidInstance = {
17
+ initialize(config) {
18
+ currentConfig = { ...defaultConfig, ...options.config, ...config };
19
+ mermaidLib.initialize(currentConfig);
20
+ initialized = true;
21
+ },
22
+ async render(id, source) {
23
+ if (!initialized) {
24
+ mermaidLib.initialize(currentConfig);
25
+ initialized = true;
26
+ }
27
+ return await mermaidLib.render(id, source);
28
+ }
29
+ };
30
+ return {
31
+ name: "mermaid",
32
+ type: "diagram",
33
+ language: "mermaid",
34
+ getMermaid(config) {
35
+ if (config) {
36
+ mermaidInstance.initialize(config);
37
+ }
38
+ return mermaidInstance;
39
+ }
40
+ };
41
+ }
42
+ var mermaid = createMermaidPlugin();
43
+ export {
44
+ createMermaidPlugin,
45
+ mermaid
46
+ };
@@ -0,0 +1,35 @@
1
+ @keyframes sd-fadeIn {
2
+ from {
3
+ opacity: 0;
4
+ }
5
+ to {
6
+ opacity: 1;
7
+ }
8
+ }
9
+
10
+ @keyframes sd-blurIn {
11
+ from {
12
+ opacity: 0;
13
+ filter: blur(4px);
14
+ }
15
+ to {
16
+ opacity: 1;
17
+ filter: blur(0);
18
+ }
19
+ }
20
+
21
+ @keyframes sd-slideUp {
22
+ from {
23
+ opacity: 0;
24
+ transform: translateY(4px);
25
+ }
26
+ to {
27
+ opacity: 1;
28
+ transform: translateY(0);
29
+ }
30
+ }
31
+
32
+ [data-sd-animate] {
33
+ animation: var(--sd-animation, sd-fadeIn) var(--sd-duration, 150ms) var(--sd-easing, ease)
34
+ var(--sd-delay, 0ms) both;
35
+ }
@@ -0,0 +1,32 @@
1
+ // Generated by scripts/generate-tsrx-types.mjs for the built package.
2
+ import type { Pluggable } from 'unified';
3
+ /**
4
+ * Plugin for CJK text handling
5
+ */
6
+ export interface CjkPlugin {
7
+ name: 'cjk';
8
+ /**
9
+ * @deprecated Use remarkPluginsBefore and remarkPluginsAfter instead
10
+ * All remark plugins (for backwards compatibility)
11
+ */
12
+ remarkPlugins: Pluggable[];
13
+ /**
14
+ * Remark plugins that must run AFTER remarkGfm
15
+ * (e.g., autolink boundary splitting, strikethrough enhancements)
16
+ */
17
+ remarkPluginsAfter: Pluggable[];
18
+ /**
19
+ * Remark plugins that must run BEFORE remarkGfm
20
+ * (e.g., remark-cjk-friendly which modifies emphasis handling)
21
+ */
22
+ remarkPluginsBefore: Pluggable[];
23
+ type: 'cjk';
24
+ }
25
+ /**
26
+ * Create a CJK plugin
27
+ */
28
+ export declare function createCjkPlugin(): CjkPlugin;
29
+ /**
30
+ * Pre-configured CJK plugin with default settings
31
+ */
32
+ export declare const cjk: CjkPlugin;
@@ -0,0 +1,58 @@
1
+ // Generated by scripts/generate-tsrx-types.mjs for the built package.
2
+ import { type BundledLanguage, type BundledTheme, type ThemeRegistrationAny, type TokensResult } from 'shiki';
3
+ export type ThemeInput = BundledTheme | ThemeRegistrationAny;
4
+ /**
5
+ * Result from code highlighting
6
+ */
7
+ export type HighlightResult = TokensResult;
8
+ /**
9
+ * Options for highlighting code
10
+ */
11
+ export interface HighlightOptions {
12
+ code: string;
13
+ language: BundledLanguage;
14
+ themes: [ThemeInput, ThemeInput];
15
+ }
16
+ /**
17
+ * Plugin for code syntax highlighting (Shiki)
18
+ */
19
+ export interface CodeHighlighterPlugin {
20
+ /**
21
+ * Get list of supported languages
22
+ */
23
+ getSupportedLanguages: () => BundledLanguage[];
24
+ /**
25
+ * Get the configured themes
26
+ */
27
+ getThemes: () => [ThemeInput, ThemeInput];
28
+ /**
29
+ * Highlight code and return tokens
30
+ * Returns null if highlighting not ready yet (async loading)
31
+ * Use callback for async result
32
+ */
33
+ highlight: (options: HighlightOptions, callback?: (result: HighlightResult) => void) => HighlightResult | null;
34
+ name: 'shiki';
35
+ /**
36
+ * Check if language is supported
37
+ */
38
+ supportsLanguage: (language: BundledLanguage) => boolean;
39
+ type: 'code-highlighter';
40
+ }
41
+ /**
42
+ * Options for creating a code plugin
43
+ */
44
+ export interface CodePluginOptions {
45
+ /**
46
+ * Default themes for syntax highlighting [light, dark]
47
+ * @default ["github-light", "github-dark"]
48
+ */
49
+ themes?: [ThemeInput, ThemeInput];
50
+ }
51
+ /**
52
+ * Create a code plugin with optional configuration
53
+ */
54
+ export declare function createCodePlugin(options?: CodePluginOptions): CodeHighlighterPlugin;
55
+ /**
56
+ * Pre-configured code plugin with default settings
57
+ */
58
+ export declare const code: CodeHighlighterPlugin;
@@ -0,0 +1,60 @@
1
+ // Generated by scripts/generate-tsrx-types.mjs for the built package.
2
+ /**
3
+ * Default debounce delay in milliseconds before checking if element is still in view
4
+ */
5
+ export declare const DEFERRED_RENDER_DEBOUNCE_DELAY = 300;
6
+ /**
7
+ * Default root margin for Intersection Observer
8
+ * Starts rendering when element is 200px away from viewport
9
+ */
10
+ export declare const DEFERRED_RENDER_ROOT_MARGIN = "300px";
11
+ /**
12
+ * Default timeout for requestIdleCallback in milliseconds
13
+ */
14
+ export declare const DEFERRED_RENDER_IDLE_TIMEOUT = 500;
15
+ export interface UseDeferredRenderOptions {
16
+ /**
17
+ * Debounce delay in milliseconds before checking if still in view
18
+ * @default DEFERRED_RENDER_DEBOUNCE_DELAY
19
+ */
20
+ debounceDelay?: number;
21
+ /**
22
+ * Timeout for requestIdleCallback in milliseconds
23
+ * @default DEFERRED_RENDER_IDLE_TIMEOUT
24
+ */
25
+ idleTimeout?: number;
26
+ /**
27
+ * If true, render immediately without waiting for intersection
28
+ * @default false
29
+ */
30
+ immediate?: boolean;
31
+ /**
32
+ * Root margin for Intersection Observer (e.g., '200px' to start rendering 200px before entering viewport)
33
+ * @default DEFERRED_RENDER_ROOT_MARGIN
34
+ */
35
+ rootMargin?: string;
36
+ }
37
+ /**
38
+ * Hook for deferred rendering components when they enter the viewport.
39
+ * Uses Intersection Observer + debounce + requestIdleCallback for optimal performance.
40
+ *
41
+ * @param options Configuration options
42
+ * @returns Object containing `shouldRender` flag and `containerRef` to attach to the element
43
+ *
44
+ * @example
45
+ * ```tsx
46
+ * const { shouldRender, containerRef } = useDeferredRender({ immediate: false })
47
+ *
48
+ * return (
49
+ * <div ref={containerRef}>
50
+ * {shouldRender && <ExpensiveComponent />}
51
+ * </div>
52
+ * )
53
+ * ```
54
+ */
55
+ export declare function useDeferredRender(options?: UseDeferredRenderOptions): {
56
+ shouldRender: boolean;
57
+ containerRef: {
58
+ current: HTMLDivElement | null;
59
+ };
60
+ };