markstream-react 0.0.52 → 0.0.53
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 +43 -6
- package/dist/Tooltip-DSM4ImfZ.js +207 -0
- package/dist/codeBlockExtraProps-RaPzFq78.js +3 -0
- package/dist/index-D0DspXy9.js +85 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.px.css +1 -1
- package/dist/index.tailwind.css +1 -1
- package/dist/markstream-react.css +1 -1
- package/dist/next.d.ts +41 -18
- package/dist/next.js +1 -1
- package/dist/server.d.ts +28 -5
- package/dist/server.js +1 -1
- package/dist/tailwind.cjs +1 -1
- package/dist/tailwind.js +1 -1
- package/dist/types/components/HtmlInlineNode/HtmlInlineNode.d.ts +4 -1
- package/dist/types/components/NodeRenderer.d.ts +2 -1
- package/dist/types/customComponents.d.ts +20 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/next.d.ts +7 -3
- package/dist/types/renderers/renderNode.d.ts +1 -1
- package/dist/types/server-renderer/index.d.ts +6 -2
- package/dist/types/server.d.ts +2 -2
- package/dist/types/types.d.ts +8 -3
- package/dist/types/utils/customHtmlTag.d.ts +5 -4
- package/dist/types/utils/htmlToReact.d.ts +17 -6
- package/package.json +6 -6
- package/dist/Tooltip-Ux2h3oiV.js +0 -207
- package/dist/codeBlockExtraProps-NhTjbA1T.js +0 -3
- package/dist/index-DdaK6qko.js +0 -85
package/dist/tailwind.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const safeList = `use client react string cannot delete global call clearGlobalCustomComponents
|
|
1
|
+
const safeList = `use client react stream-markdown-parser string cannot delete global call clearGlobalCustomComponents checkbox-node checkbox checkbox-input note is-dark data-index-key headerId admonition-header admonition-icon admonition-title admonition-toggle aria-expanded aria-controls collapsed admonition-content aria-labelledby blockquote-node auto code_block next.type typeof window.requestIdleCallback [data-node-index] node-spacer dark virtualized data-custom-id node-slot data-node-index data-node-type fade-node typewriter-node node-placeholder typewriterCursorRef typewriter-cursor admonition math_block html_block image object [data-node-type="code_block"] [data-node-type="admonition"] [data-node-type="table"] [data-node-type="math_block"] [data-node-type="html_block"] [data-node-type="image"] performance [markstream-react][perf] mermaid theme name markdown-renderer boolean safe smooth footnote-reference handleScroll footnote-link cursor-pointer mark highlight-node footnote-node flex text-sm leading-relaxed border-t border-[var(--footnote-border,#eaecef)] pt-2 flex-1 emphasis-node dl definition-list indexKey mb-4 dt definition-term font-semibold ctx renderNode ?? definition dd definition-desc ml-4 dependency is not install it to enable hard-break emoji-node footnote-anchor hover:underline ↩︎ clsx heading-node html-block-node escape html-block html-block-node__placeholder html-block-node__placeholder-bar w-4/5 w-2/3 setHostEl shouldRender useDynamic reactNodes href xlink:href markstream-d2-root-svg number window.requestAnimationFrame instance.render instance missing render returned empty top d2-block my-4 rounded-lg border overflow-hidden shadow-sm border-gray-700/30 bg-gray-900 text-gray-100 border-gray-200 bg-white text-gray-900 d2-block-header justify-between items-center px-4 py-2.5 border-b border-gray-400/5 gap-x-2 font-medium font-mono gap-x-1 rounded-md p-0.5 bg-gray-700 bg-gray-100 mode-btn px-2 py-1 text-xs rounded !showSource is-active showSource d2-action-btn p-2 transition-colors hover:bg-[var(--vscode-editor-selectionBackground)] copying w-3 h-3 none currentColor round aria-pressed m9 bodyRef d2-block-body bodyStyle !hasPreview d2-source py-4 d2-code d2-error mt-2 d2-render d2-svg pb-3 style.visibility hidden line-info legacy off never background night moon black dracula mocha frappe macchiato palenight ocean poimandres monokai laserwave tokyo slack-dark rose-pine github-dark material-theme one-dark catppuccin-mocha catppuccin-frappe catppuccin-macchiato light latte dawn lotus plaintext diff important max-height visible height onDidUpdateDiff onDidContentSizeChange onDidLayoutChange window.MutationObserver childList record.type attributes class explicit fontSize lineHeight paddingBottom paddingTop tabSize on same helpers.cleanupEditor canonicalLanguage single window.cancelAnimationFrame clientX navigator.clipboard navigator.clipboard.writeText code-fallback-plain m-0 code-block-container is-rendering is-diff is-plain-text code-block-header space-x-2 icon-slot h-4 w-4 flex-shrink-0 truncate code-action-btn copied m14 evenodd code-block-body--collapsed code-block-body--expanded code-editor-layer code-height-placeholder aria-hidden code-editor-fallback-surface code-loading-placeholder loading-skeleton skeleton-line short sr-only polite status list-item pl-1.5 my-2 valueAttr children primary fallback failed is-loaded lazy eager async image-node__placeholder image-node__spinner image-node__placeholder-text image… placeholder image-node__error load ease-in-out infinite node.title link-loading inline-flex items-baseline gap-1.5 link-text-wrapper relative leading-[normal] link-text text link-loading-indicator link-node aria-label noopener noreferrer markstream-core inline-code inline text-[85%] px-1 py-0.5 bg-[hsl(var(--secondary))] whitespace-normal break-words max-w-full text-node-stream-delta text-node-stream-delta--a text-node-stream-delta--b insert-node list-node my-5 pl-[calc(13/8*1em)] list-decimal list-disc max-lg:my-[calc(4/3*1em)] max-lg:pl-[calc(14/9*1em)] list react-dom library text-red-500 p-4">Failed instanceof error.message error keydown transform ease center fullscreen touches text-gray-400 hover:bg-gray-700 hover:text-gray-200 text-gray-600 hover:bg-gray-200 hover:text-gray-700 source hasPreview preview pending bg-gray-800 bg-gray-50 px-2.5 bg-gray-600 text-gray-200 text-gray-700 text-gray-500 m16 isCollapsed opacity-50 cursor-not-allowed m7 whitespace-pre-wrap text-gray-300 baseCode absolute top-2 right-2 z-10 gap-2 backdrop-blur infographic-preview min-h-[360px] transition-all duration-100 block inset-0 cursor-grab isDragging containerRef w-full text-center justify-center min-h-full markstream-react fixed z-50 bg-black/70 p-4 closeModal dialog h-full max-h-full shadow-lg top-6 right-6 !isDragging cursor-grabbing hr-node thematic-break strikethrough-node vitesse-dark vitesse-light shiki shiki-fallback [MarkdownCodeBlockNode] dispose stream-markdown stream-markdown.createShikiStreamRenderer available stale ready requires with ignoring and using default language register configured retrying without code-block-content rendererTargetRef code-block-render containerClass vmr-container window.matchMedia ms-tooltip z-[9999] inline-block text-base py-2 px-3 shadow-md whitespace-nowrap pointer-events-none tooltip-element text-white border-gray-700 tooltip superscript-node unknown-node italic node strong-node paragraph-node paragraph child.type html_inline reference-node bg-[hsl(var(--muted))] px-1.5 mx-0.5 hover:bg-[hsl(var(--secondary))] event.key right text-right text-left pointermove pointerup pointercancel table-node-wrapper my-8 table-node table-node--loading aria-busy colgroup border-[var(--table-border,#cbd5e1)] p-[calc(4/7*1em)] table-node__resize-handle table-node__loading table-node__spinner subscript-node text-node text-node-center [mermaidWorkerClient] messageerror cleared worker inject via busy timed out canParse findPrefix in zoom loose strict viewBox gantt open-modal [data-mermaid-wrapper] mermaid-action-btn toggle-mode common.zoomIn common.zoomOut common.resetZoom transition-[height] duration-150 ease-out data-mermaid-wrapper mermaid-loading mermaid-spinner diagram… mermaid-block-header space-x-1 common.preview common.source common.export mermaid-error hasRenderedOnce mermaid-block modeContainerRef mermaid-modal-overlay mermaid-modal-panel mermaid-modal-header mermaid-modal-title mermaid-modal-close mermaid-modal-body modalContentRef mermaid-modal-content abort javascript typescript go python ruby shell powershell d2 plain cpp csharp objectivec objectivecpp yaml markdown rust kotlin node.type infographic d2lang langs text_special node.content heading list_item definition_list footnote footnote_reference footnote_anchor hardbreak inline_code emphasis strikethrough highlight insert subscript superscript checkbox_input emoji thematic_break math_inline reference vmr_container label_open label_close stream-monaco thinking htmlFor className data-ssr-fallback normalizedLanguage data-language no renderNodeProp classAttr node.cite value void rowIdx bodyRows.length isOpen thematic-break-node cssVars image-node__img code-block-node code-block markdown-code-block-node markdown-code-block mermaid-block-node d2-block-node infographic-block-node math-block overflow-x-auto min-h-[40px] $$ math-inline-wrapper math-inline data-reference-id customComponents html-inline server-renderer node-content [markstream-react] htmlPreviewSandbox contains both allow-scripts this only fully trusted content served an isolated en utf-8 viewport content="width=device-width initial-scale=1 html-preview-frame__backdrop--dark html-preview-frame--dark html-preview-frame__header html-preview-frame__title html-preview-frame__dot html-preview-frame__label html-preview-frame__close--dark html-preview-frame__iframe no-referrer about:blank document child key ref ms-html self_closing tag_open token.type tag_close parse dynamic template html-inline-node html-inline-node--loading role aria-describedby hunk !options.preserveBlankKind context removed added markstream-pre__diff-pane--inline original markstream-pre__diff-pane--original modified markstream-pre__diff-pane--modified markstream-pre--line-numbers markstream-pre--diff-preview markstream-pre--diff-inline showLineNumbers markstream-pre__diff-code line.empty markstream-pre__diff-line--empty markstream-pre__diff-rail markstream-pre__diff-number markstream-pre__diff-content markstream-pre__diff-content-inner mathRef math-inline--hidden math-inline__loading math-inline__spinner rendering math-rendering npm development process normalizedType [katexWorkerClient] init cache-hit timeout waiting slot sequencediagram classdiagram kind statediagram erdiagram flowchart graph globalThis.requestAnimationFrame globalThis.cancelAnimationFrame module did expected existingEnv.getWorkerUrl prototype constructor katex °C`;
|
|
2
2
|
module.exports = safeList;
|
|
3
3
|
module.exports.safeList = safeList;
|
|
4
4
|
module.exports.default = safeList;
|
package/dist/tailwind.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const safeList = `use client react string cannot delete global call clearGlobalCustomComponents
|
|
1
|
+
export const safeList = `use client react stream-markdown-parser string cannot delete global call clearGlobalCustomComponents checkbox-node checkbox checkbox-input note is-dark data-index-key headerId admonition-header admonition-icon admonition-title admonition-toggle aria-expanded aria-controls collapsed admonition-content aria-labelledby blockquote-node auto code_block next.type typeof window.requestIdleCallback [data-node-index] node-spacer dark virtualized data-custom-id node-slot data-node-index data-node-type fade-node typewriter-node node-placeholder typewriterCursorRef typewriter-cursor admonition math_block html_block image object [data-node-type="code_block"] [data-node-type="admonition"] [data-node-type="table"] [data-node-type="math_block"] [data-node-type="html_block"] [data-node-type="image"] performance [markstream-react][perf] mermaid theme name markdown-renderer boolean safe smooth footnote-reference handleScroll footnote-link cursor-pointer mark highlight-node footnote-node flex text-sm leading-relaxed border-t border-[var(--footnote-border,#eaecef)] pt-2 flex-1 emphasis-node dl definition-list indexKey mb-4 dt definition-term font-semibold ctx renderNode ?? definition dd definition-desc ml-4 dependency is not install it to enable hard-break emoji-node footnote-anchor hover:underline ↩︎ clsx heading-node html-block-node escape html-block html-block-node__placeholder html-block-node__placeholder-bar w-4/5 w-2/3 setHostEl shouldRender useDynamic reactNodes href xlink:href markstream-d2-root-svg number window.requestAnimationFrame instance.render instance missing render returned empty top d2-block my-4 rounded-lg border overflow-hidden shadow-sm border-gray-700/30 bg-gray-900 text-gray-100 border-gray-200 bg-white text-gray-900 d2-block-header justify-between items-center px-4 py-2.5 border-b border-gray-400/5 gap-x-2 font-medium font-mono gap-x-1 rounded-md p-0.5 bg-gray-700 bg-gray-100 mode-btn px-2 py-1 text-xs rounded !showSource is-active showSource d2-action-btn p-2 transition-colors hover:bg-[var(--vscode-editor-selectionBackground)] copying w-3 h-3 none currentColor round aria-pressed m9 bodyRef d2-block-body bodyStyle !hasPreview d2-source py-4 d2-code d2-error mt-2 d2-render d2-svg pb-3 style.visibility hidden line-info legacy off never background night moon black dracula mocha frappe macchiato palenight ocean poimandres monokai laserwave tokyo slack-dark rose-pine github-dark material-theme one-dark catppuccin-mocha catppuccin-frappe catppuccin-macchiato light latte dawn lotus plaintext diff important max-height visible height onDidUpdateDiff onDidContentSizeChange onDidLayoutChange window.MutationObserver childList record.type attributes class explicit fontSize lineHeight paddingBottom paddingTop tabSize on same helpers.cleanupEditor canonicalLanguage single window.cancelAnimationFrame clientX navigator.clipboard navigator.clipboard.writeText code-fallback-plain m-0 code-block-container is-rendering is-diff is-plain-text code-block-header space-x-2 icon-slot h-4 w-4 flex-shrink-0 truncate code-action-btn copied m14 evenodd code-block-body--collapsed code-block-body--expanded code-editor-layer code-height-placeholder aria-hidden code-editor-fallback-surface code-loading-placeholder loading-skeleton skeleton-line short sr-only polite status list-item pl-1.5 my-2 valueAttr children primary fallback failed is-loaded lazy eager async image-node__placeholder image-node__spinner image-node__placeholder-text image… placeholder image-node__error load ease-in-out infinite node.title link-loading inline-flex items-baseline gap-1.5 link-text-wrapper relative leading-[normal] link-text text link-loading-indicator link-node aria-label noopener noreferrer markstream-core inline-code inline text-[85%] px-1 py-0.5 bg-[hsl(var(--secondary))] whitespace-normal break-words max-w-full text-node-stream-delta text-node-stream-delta--a text-node-stream-delta--b insert-node list-node my-5 pl-[calc(13/8*1em)] list-decimal list-disc max-lg:my-[calc(4/3*1em)] max-lg:pl-[calc(14/9*1em)] list react-dom library text-red-500 p-4">Failed instanceof error.message error keydown transform ease center fullscreen touches text-gray-400 hover:bg-gray-700 hover:text-gray-200 text-gray-600 hover:bg-gray-200 hover:text-gray-700 source hasPreview preview pending bg-gray-800 bg-gray-50 px-2.5 bg-gray-600 text-gray-200 text-gray-700 text-gray-500 m16 isCollapsed opacity-50 cursor-not-allowed m7 whitespace-pre-wrap text-gray-300 baseCode absolute top-2 right-2 z-10 gap-2 backdrop-blur infographic-preview min-h-[360px] transition-all duration-100 block inset-0 cursor-grab isDragging containerRef w-full text-center justify-center min-h-full markstream-react fixed z-50 bg-black/70 p-4 closeModal dialog h-full max-h-full shadow-lg top-6 right-6 !isDragging cursor-grabbing hr-node thematic-break strikethrough-node vitesse-dark vitesse-light shiki shiki-fallback [MarkdownCodeBlockNode] dispose stream-markdown stream-markdown.createShikiStreamRenderer available stale ready requires with ignoring and using default language register configured retrying without code-block-content rendererTargetRef code-block-render containerClass vmr-container window.matchMedia ms-tooltip z-[9999] inline-block text-base py-2 px-3 shadow-md whitespace-nowrap pointer-events-none tooltip-element text-white border-gray-700 tooltip superscript-node unknown-node italic node strong-node paragraph-node paragraph child.type html_inline reference-node bg-[hsl(var(--muted))] px-1.5 mx-0.5 hover:bg-[hsl(var(--secondary))] event.key right text-right text-left pointermove pointerup pointercancel table-node-wrapper my-8 table-node table-node--loading aria-busy colgroup border-[var(--table-border,#cbd5e1)] p-[calc(4/7*1em)] table-node__resize-handle table-node__loading table-node__spinner subscript-node text-node text-node-center [mermaidWorkerClient] messageerror cleared worker inject via busy timed out canParse findPrefix in zoom loose strict viewBox gantt open-modal [data-mermaid-wrapper] mermaid-action-btn toggle-mode common.zoomIn common.zoomOut common.resetZoom transition-[height] duration-150 ease-out data-mermaid-wrapper mermaid-loading mermaid-spinner diagram… mermaid-block-header space-x-1 common.preview common.source common.export mermaid-error hasRenderedOnce mermaid-block modeContainerRef mermaid-modal-overlay mermaid-modal-panel mermaid-modal-header mermaid-modal-title mermaid-modal-close mermaid-modal-body modalContentRef mermaid-modal-content abort javascript typescript go python ruby shell powershell d2 plain cpp csharp objectivec objectivecpp yaml markdown rust kotlin node.type infographic d2lang langs text_special node.content heading list_item definition_list footnote footnote_reference footnote_anchor hardbreak inline_code emphasis strikethrough highlight insert subscript superscript checkbox_input emoji thematic_break math_inline reference vmr_container label_open label_close stream-monaco thinking htmlFor className data-ssr-fallback normalizedLanguage data-language no renderNodeProp classAttr node.cite value void rowIdx bodyRows.length isOpen thematic-break-node cssVars image-node__img code-block-node code-block markdown-code-block-node markdown-code-block mermaid-block-node d2-block-node infographic-block-node math-block overflow-x-auto min-h-[40px] $$ math-inline-wrapper math-inline data-reference-id customComponents html-inline server-renderer node-content [markstream-react] htmlPreviewSandbox contains both allow-scripts this only fully trusted content served an isolated en utf-8 viewport content="width=device-width initial-scale=1 html-preview-frame__backdrop--dark html-preview-frame--dark html-preview-frame__header html-preview-frame__title html-preview-frame__dot html-preview-frame__label html-preview-frame__close--dark html-preview-frame__iframe no-referrer about:blank document child key ref ms-html self_closing tag_open token.type tag_close parse dynamic template html-inline-node html-inline-node--loading role aria-describedby hunk !options.preserveBlankKind context removed added markstream-pre__diff-pane--inline original markstream-pre__diff-pane--original modified markstream-pre__diff-pane--modified markstream-pre--line-numbers markstream-pre--diff-preview markstream-pre--diff-inline showLineNumbers markstream-pre__diff-code line.empty markstream-pre__diff-line--empty markstream-pre__diff-rail markstream-pre__diff-number markstream-pre__diff-content markstream-pre__diff-content-inner mathRef math-inline--hidden math-inline__loading math-inline__spinner rendering math-rendering npm development process normalizedType [katexWorkerClient] init cache-hit timeout waiting slot sequencediagram classdiagram kind statediagram erdiagram flowchart graph globalThis.requestAnimationFrame globalThis.cancelAnimationFrame module did expected existingEnv.getWorkerUrl prototype constructor katex °C`;
|
|
2
2
|
export default safeList;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { HtmlPolicy } from 'stream-markdown-parser';
|
|
1
|
+
import { HtmlPolicy, ParsedNode } from 'stream-markdown-parser';
|
|
2
2
|
import { NodeComponentProps } from '../../types/node-component';
|
|
3
3
|
import { default as React } from 'react';
|
|
4
4
|
export declare function HtmlInlineNode(props: NodeComponentProps<{
|
|
5
5
|
type: 'html_inline';
|
|
6
6
|
content: string;
|
|
7
|
+
tag?: string;
|
|
8
|
+
attrs?: [string, string | null][] | null;
|
|
9
|
+
children?: ParsedNode[];
|
|
7
10
|
loading?: boolean;
|
|
8
11
|
autoClosed?: boolean;
|
|
9
12
|
}> & {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import { HtmlComponentMap, StreamingComponentMap } from '../customComponents';
|
|
1
2
|
import { NodeRendererProps } from '../types';
|
|
2
3
|
import { default as React } from 'react';
|
|
3
|
-
export declare
|
|
4
|
+
export declare function NodeRenderer<TStreamingComponents extends StreamingComponentMap = StreamingComponentMap, THtmlComponents extends Record<string, any> = HtmlComponentMap>(rawProps: NodeRendererProps<TStreamingComponents, THtmlComponents>): React.JSX.Element;
|
|
4
5
|
export default NodeRenderer;
|
|
@@ -1,9 +1,23 @@
|
|
|
1
|
-
import { ComponentType } from 'react';
|
|
1
|
+
import { ComponentType, PropsWithChildren } from 'react';
|
|
2
|
+
import { NodeComponentProps } from './types/node-component';
|
|
2
3
|
export type CustomComponentDisplayMode = 'inline' | 'block';
|
|
3
4
|
export type MarkstreamCustomComponent<P = never> = ComponentType<P> & {
|
|
4
5
|
markstreamDisplay?: CustomComponentDisplayMode;
|
|
5
6
|
};
|
|
6
7
|
export type CustomComponentMap = Record<string, MarkstreamCustomComponent>;
|
|
8
|
+
export type StreamingComponent<TNode = any> = ComponentType<NodeComponentProps<TNode>>;
|
|
9
|
+
export type StreamingComponentMap = Record<string, StreamingComponent<any>>;
|
|
10
|
+
export type HtmlComponent<P extends object = any> = ComponentType<PropsWithChildren<P>>;
|
|
11
|
+
export type HtmlComponentMap = Record<string, HtmlComponent<any>>;
|
|
12
|
+
type IsAny<T> = 0 extends (1 & T) ? true : false;
|
|
13
|
+
type ComponentProps<T> = T extends ComponentType<infer P> ? P : T extends (props: infer P) => any ? P : never;
|
|
14
|
+
export type StreamingComponentDefinitions<T extends Record<string, any>> = {
|
|
15
|
+
[K in keyof T]: ComponentProps<T[K]> extends infer P ? IsAny<P> extends true ? T[K] : P extends NodeComponentProps<any> ? NodeComponentProps<any> extends P ? T[K] : never : never : never;
|
|
16
|
+
};
|
|
17
|
+
type ParserComponentOnlyProp = Exclude<keyof NodeComponentProps<any>, 'children' | 'node'>;
|
|
18
|
+
export type HtmlComponentDefinitions<T extends Record<string, any>> = {
|
|
19
|
+
[K in keyof T]: ComponentProps<T[K]> extends infer P ? IsAny<P> extends true ? T[K] : Extract<keyof P, ParserComponentOnlyProp> extends never ? T[K] : never : never;
|
|
20
|
+
};
|
|
7
21
|
export declare function subscribeCustomComponents(listener: () => void): () => void;
|
|
8
22
|
export declare function getCustomComponentsRevision(): number;
|
|
9
23
|
export declare function setCustomComponents(id: string, mapping: CustomComponentMap): void;
|
|
@@ -15,3 +29,8 @@ export declare function getCustomComponentDisplay(component: ComponentType<never
|
|
|
15
29
|
export declare function withMarkstreamComponentDisplay<T extends ComponentType<never>>(component: T, display: CustomComponentDisplayMode): T & {
|
|
16
30
|
markstreamDisplay: CustomComponentDisplayMode;
|
|
17
31
|
};
|
|
32
|
+
export declare function defineStreamingComponents<const T extends Record<string, ComponentType<any>>>(components: T & StreamingComponentDefinitions<T>): T & StreamingComponentDefinitions<T>;
|
|
33
|
+
export declare function defineHtmlComponents<const T extends Record<string, ComponentType<any>>>(components: T & HtmlComponentDefinitions<T>): T & HtmlComponentDefinitions<T>;
|
|
34
|
+
export declare function normalizeComponentMap<T>(mapping?: Record<string, T>): Record<string, T>;
|
|
35
|
+
export declare function warnComponentMapConflicts(streamingComponents: StreamingComponentMap, htmlComponents: HtmlComponentMap, warnedTags: Set<string>): void;
|
|
36
|
+
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -51,8 +51,8 @@ export { ThematicBreakNode } from './components/ThematicBreakNode/ThematicBreakN
|
|
|
51
51
|
export { Tooltip } from './components/Tooltip/Tooltip';
|
|
52
52
|
export type { TooltipPlacement, TooltipProps } from './components/Tooltip/Tooltip';
|
|
53
53
|
export { VmrContainerNode } from './components/VmrContainerNode/VmrContainerNode';
|
|
54
|
-
export { clearGlobalCustomComponents, getCustomComponentDisplay, getCustomNodeComponents, removeCustomComponents, setCustomComponents, withMarkstreamComponentDisplay, } from './customComponents';
|
|
55
|
-
export type { CustomComponentDisplayMode, MarkstreamCustomComponent, } from './customComponents';
|
|
54
|
+
export { clearGlobalCustomComponents, defineHtmlComponents, defineStreamingComponents, getCustomComponentDisplay, getCustomNodeComponents, removeCustomComponents, setCustomComponents, withMarkstreamComponentDisplay, } from './customComponents';
|
|
55
|
+
export type { CustomComponentDisplayMode, HtmlComponent, HtmlComponentMap, MarkstreamCustomComponent, StreamingComponent, StreamingComponentMap, } from './customComponents';
|
|
56
56
|
export { useSmoothMarkdownStream } from './hooks/useSmoothMarkdownStream';
|
|
57
57
|
export type { SmoothMarkdownStreamOptions, SmoothMarkdownStreamSnapshot, } from './hooks/useSmoothMarkdownStream';
|
|
58
58
|
export * from './i18n/useSafeI18n';
|
package/dist/types/next.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { D2Loader, disableD2, enableD2, isD2Enabled, setD2Loader } from './components/D2BlockNode/d2';
|
|
2
2
|
import { default as React } from 'react';
|
|
3
|
-
import { clearGlobalCustomComponents, getCustomNodeComponents, removeCustomComponents, setCustomComponents } from './customComponents';
|
|
3
|
+
import { clearGlobalCustomComponents, defineHtmlComponents, defineStreamingComponents, getCustomNodeComponents, removeCustomComponents, setCustomComponents } from './customComponents';
|
|
4
4
|
export declare const AdmonitionNode: {
|
|
5
5
|
(props: import('./types/node-component').NodeComponentProps<{
|
|
6
6
|
type: "admonition";
|
|
@@ -120,6 +120,9 @@ export declare const HtmlInlineNode: {
|
|
|
120
120
|
(props: import('./types/node-component').NodeComponentProps<{
|
|
121
121
|
type: "html_inline";
|
|
122
122
|
content?: string;
|
|
123
|
+
tag?: string;
|
|
124
|
+
attrs?: [string, string | null][] | null;
|
|
125
|
+
children?: import('stream-markdown-parser').ParsedNode[];
|
|
123
126
|
}>): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
124
127
|
displayName: string;
|
|
125
128
|
};
|
|
@@ -190,7 +193,7 @@ export declare const MermaidBlockNode: {
|
|
|
190
193
|
displayName: string;
|
|
191
194
|
};
|
|
192
195
|
export declare const NodeRenderer: {
|
|
193
|
-
(props: import('./types').NodeRendererProps): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
196
|
+
(props: import('./types').NodeRendererProps<import('./customComponents').StreamingComponentMap, Record<string, any>>): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
194
197
|
displayName: string;
|
|
195
198
|
};
|
|
196
199
|
export declare const FallbackComponent: {
|
|
@@ -283,13 +286,14 @@ export declare const VmrContainerNode: {
|
|
|
283
286
|
export default NodeRenderer;
|
|
284
287
|
export type { D2Loader };
|
|
285
288
|
export { disableD2, enableD2, isD2Enabled, setD2Loader };
|
|
286
|
-
export { clearGlobalCustomComponents, getCustomNodeComponents, removeCustomComponents, setCustomComponents, };
|
|
289
|
+
export { clearGlobalCustomComponents, defineHtmlComponents, defineStreamingComponents, getCustomNodeComponents, removeCustomComponents, setCustomComponents, };
|
|
287
290
|
export type { HtmlPreviewFrameProps } from './components/CodeBlockNode/HtmlPreviewFrame';
|
|
288
291
|
export * from './components/D2BlockNode/d2';
|
|
289
292
|
export type { LinkNodeStyleProps } from './components/LinkNode/LinkNode';
|
|
290
293
|
export type { ListItemNodeProps } from './components/ListItemNode/ListItemNode';
|
|
291
294
|
export type { MarkdownCodeBlockNodeProps } from './components/MarkdownCodeBlockNode/MarkdownCodeBlockNode';
|
|
292
295
|
export type { TooltipPlacement, TooltipProps } from './components/Tooltip/Tooltip';
|
|
296
|
+
export type { CustomComponentDisplayMode, HtmlComponent, HtmlComponentMap, MarkstreamCustomComponent, StreamingComponent, StreamingComponentMap, } from './customComponents';
|
|
293
297
|
export * from './i18n/useSafeI18n';
|
|
294
298
|
export * from './renderers/renderNode';
|
|
295
299
|
export type { NodeRendererCodeBlockProps, NodeRendererProps } from './types';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ParsedNode } from 'stream-markdown-parser';
|
|
2
2
|
import { RenderContext } from '../types';
|
|
3
3
|
import { default as React } from 'react';
|
|
4
|
-
export declare function renderNode(node: ParsedNode, key: React.Key, ctx: RenderContext):
|
|
4
|
+
export declare function renderNode(node: ParsedNode, key: React.Key, ctx: RenderContext): any;
|
|
@@ -2,6 +2,7 @@ import { DefinitionItemNode as DefinitionItemNodeType, ListItemNode as ListItemN
|
|
|
2
2
|
import { HtmlPreviewFrameProps } from '../components/CodeBlockNode/HtmlPreviewFrame';
|
|
3
3
|
import { MarkdownCodeBlockNodeProps } from '../components/MarkdownCodeBlockNode/MarkdownCodeBlockNode';
|
|
4
4
|
import { TooltipProps } from '../components/Tooltip/Tooltip';
|
|
5
|
+
import { HtmlComponentMap, StreamingComponentMap } from '../customComponents';
|
|
5
6
|
import { NodeRendererProps, RenderContext } from '../types';
|
|
6
7
|
import { CodeBlockNodeProps, D2BlockNodeProps, ImageNodeProps, InfographicBlockNodeProps, LinkNodeProps, MathBlockNodeProps, MathInlineNodeProps, MermaidBlockNodeProps, PreCodeNodeProps } from '../types/component-props';
|
|
7
8
|
import { NodeComponentProps } from '../types/node-component';
|
|
@@ -151,6 +152,9 @@ export declare function HtmlBlockNode(props: NodeComponentProps<{
|
|
|
151
152
|
export declare function HtmlInlineNode(props: NodeComponentProps<{
|
|
152
153
|
type: 'html_inline';
|
|
153
154
|
content?: string;
|
|
155
|
+
tag?: string;
|
|
156
|
+
attrs?: [string, string | null][] | null;
|
|
157
|
+
children?: ParsedNode[];
|
|
154
158
|
}>): React.JSX.Element;
|
|
155
159
|
export declare function VmrContainerNode(props: NodeComponentProps<{
|
|
156
160
|
type: 'vmr_container';
|
|
@@ -163,7 +167,7 @@ export declare function HtmlPreviewFrame(_props: HtmlPreviewFrameProps): any;
|
|
|
163
167
|
export declare function FallbackComponent(props: NodeComponentProps<{
|
|
164
168
|
type: string;
|
|
165
169
|
}>): React.JSX.Element;
|
|
166
|
-
export declare function renderNode(node: ParsedNode, key: React.Key, ctx: RenderContext):
|
|
167
|
-
export declare function NodeRenderer(props: NodeRendererProps): React.JSX.Element;
|
|
170
|
+
export declare function renderNode(node: ParsedNode, key: React.Key, ctx: RenderContext): any;
|
|
171
|
+
export declare function NodeRenderer<TStreamingComponents extends StreamingComponentMap = StreamingComponentMap, THtmlComponents extends Record<string, any> = HtmlComponentMap>(props: NodeRendererProps<TStreamingComponents, THtmlComponents>): React.JSX.Element;
|
|
168
172
|
export { CodeBlockNode as ReactCodeBlockNode };
|
|
169
173
|
export default NodeRenderer;
|
package/dist/types/server.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ export type { LinkNodeStyleProps } from './components/LinkNode/LinkNode';
|
|
|
3
3
|
export type { ListItemNodeProps } from './components/ListItemNode/ListItemNode';
|
|
4
4
|
export type { MarkdownCodeBlockNodeProps } from './components/MarkdownCodeBlockNode/MarkdownCodeBlockNode';
|
|
5
5
|
export type { TooltipPlacement, TooltipProps } from './components/Tooltip/Tooltip';
|
|
6
|
-
export { clearGlobalCustomComponents, getCustomComponentDisplay, getCustomNodeComponents, removeCustomComponents, setCustomComponents, withMarkstreamComponentDisplay, } from './customComponents';
|
|
7
|
-
export type { CustomComponentDisplayMode, MarkstreamCustomComponent } from './customComponents';
|
|
6
|
+
export { clearGlobalCustomComponents, defineHtmlComponents, defineStreamingComponents, getCustomComponentDisplay, getCustomNodeComponents, removeCustomComponents, setCustomComponents, withMarkstreamComponentDisplay, } from './customComponents';
|
|
7
|
+
export type { CustomComponentDisplayMode, HtmlComponent, HtmlComponentMap, MarkstreamCustomComponent, StreamingComponent, StreamingComponentMap, } from './customComponents';
|
|
8
8
|
export { AdmonitionNode } from './server-renderer';
|
|
9
9
|
export { BlockquoteNode } from './server-renderer';
|
|
10
10
|
export { CheckboxNode } from './server-renderer';
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { default as React } from 'react';
|
|
1
|
+
import { default as React, ComponentType } from 'react';
|
|
2
2
|
import { BaseNode, HtmlPolicy, MarkdownIt, ParsedNode, ParseOptions } from 'stream-markdown-parser';
|
|
3
|
-
import { CustomComponentMap } from './customComponents';
|
|
3
|
+
import { CustomComponentMap, HtmlComponentDefinitions, HtmlComponentMap, StreamingComponentDefinitions, StreamingComponentMap } from './customComponents';
|
|
4
4
|
import { SmoothMarkdownStreamOptions } from './hooks/useSmoothMarkdownStream';
|
|
5
5
|
import { CodeBlockMonacoOptions, CodeBlockMonacoTheme, CodeBlockNodeProps, CodeBlockPreviewPayload, D2BlockNodeProps, InfographicBlockNodeProps, MermaidBlockNodeProps, ShikiCodeBlockProps } from './types/component-props';
|
|
6
6
|
type NodeRendererCodeBlockThemes = CodeBlockNodeProps['themes'] | ShikiCodeBlockProps['themes'];
|
|
7
7
|
export type NodeRendererCodeBlockProps = Partial<Omit<CodeBlockNodeProps, 'node' | 'themes'>> & Partial<Omit<ShikiCodeBlockProps, 'themes'>> & {
|
|
8
8
|
themes?: NodeRendererCodeBlockThemes;
|
|
9
9
|
} & Record<string, unknown>;
|
|
10
|
-
export interface NodeRendererProps {
|
|
10
|
+
export interface NodeRendererProps<TStreamingComponents extends Record<string, ComponentType<any>> = StreamingComponentMap, THtmlComponents extends Record<string, any> = HtmlComponentMap> {
|
|
11
11
|
content?: string;
|
|
12
12
|
nodes?: readonly BaseNode[] | null;
|
|
13
13
|
/**
|
|
@@ -17,6 +17,8 @@ export interface NodeRendererProps {
|
|
|
17
17
|
final?: boolean;
|
|
18
18
|
parseOptions?: ParseOptions;
|
|
19
19
|
customMarkdownIt?: (md: MarkdownIt) => MarkdownIt;
|
|
20
|
+
streamingComponents?: TStreamingComponents & StreamingComponentDefinitions<TStreamingComponents>;
|
|
21
|
+
htmlComponents?: THtmlComponents & HtmlComponentDefinitions<THtmlComponents>;
|
|
20
22
|
/** Log parse/render timing stats (dev only). */
|
|
21
23
|
debugPerformance?: boolean;
|
|
22
24
|
/**
|
|
@@ -86,6 +88,7 @@ export interface NodeRendererProps {
|
|
|
86
88
|
export interface RenderContext {
|
|
87
89
|
customId?: string;
|
|
88
90
|
isDark?: boolean;
|
|
91
|
+
final?: boolean;
|
|
89
92
|
indexKey?: string;
|
|
90
93
|
typewriter?: boolean;
|
|
91
94
|
/** Enable/disable fade animations. Default: true */
|
|
@@ -93,6 +96,8 @@ export interface RenderContext {
|
|
|
93
96
|
textStreamState?: Map<string, string>;
|
|
94
97
|
streamRenderVersion?: number;
|
|
95
98
|
customComponents?: CustomComponentMap;
|
|
99
|
+
streamingComponents?: StreamingComponentMap;
|
|
100
|
+
htmlComponents?: HtmlComponentMap;
|
|
96
101
|
customHtmlTags?: readonly string[];
|
|
97
102
|
htmlPolicy?: HtmlPolicy;
|
|
98
103
|
codeBlockProps?: NodeRendererCodeBlockProps;
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
+
import { ComponentType } from 'react';
|
|
1
2
|
import { ParsedNode } from 'stream-markdown-parser';
|
|
2
|
-
import { CustomComponentDisplayMode
|
|
3
|
+
import { CustomComponentDisplayMode } from '../customComponents';
|
|
3
4
|
export interface ResolvedCustomHtmlTag {
|
|
4
5
|
tag: string;
|
|
5
6
|
isWhitelisted: boolean;
|
|
6
|
-
component:
|
|
7
|
+
component: ComponentType<any> | null;
|
|
7
8
|
display: CustomComponentDisplayMode | undefined;
|
|
8
9
|
}
|
|
9
10
|
export declare function resolveCustomHtmlTag(node: Pick<ParsedNode, 'type'> & {
|
|
10
11
|
tag?: string | null;
|
|
11
12
|
content?: unknown;
|
|
12
|
-
}, customComponents:
|
|
13
|
+
}, customComponents: Record<string, ComponentType<any>>, customHtmlTags?: readonly string[]): ResolvedCustomHtmlTag | null;
|
|
13
14
|
export declare function isParagraphBreakingCustomHtmlNode(node: Pick<ParsedNode, 'type'> & {
|
|
14
15
|
tag?: string | null;
|
|
15
16
|
content?: unknown;
|
|
16
|
-
}, customComponents:
|
|
17
|
+
}, customComponents: Record<string, ComponentType<any>>, customHtmlTags?: readonly string[]): boolean;
|
|
@@ -1,10 +1,21 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { HtmlPolicy, sanitizeHtmlAttrs as sanitizeHtmlAttrsBase, tokenizeHtml as tokenizeHtmlBase } from 'stream-markdown-parser';
|
|
3
|
-
import {
|
|
1
|
+
import { ComponentType, ReactNode } from 'react';
|
|
2
|
+
import { HtmlPolicy, ParsedNode, sanitizeHtmlAttrs as sanitizeHtmlAttrsBase, tokenizeHtml as tokenizeHtmlBase } from 'stream-markdown-parser';
|
|
3
|
+
import { RenderContext, RenderNodeFn } from '../types';
|
|
4
4
|
export type { HtmlToken } from 'stream-markdown-parser';
|
|
5
|
+
type HtmlReactComponentMap = Record<string, ComponentType<any>>;
|
|
6
|
+
type HtmlReactPropComponentMap = Record<string, ComponentType<any>>;
|
|
7
|
+
type HtmlReactNodeComponentMap = Record<string, ComponentType<any>>;
|
|
8
|
+
interface HtmlToReactOptions {
|
|
9
|
+
ctx?: RenderContext;
|
|
10
|
+
keyPrefix?: string;
|
|
11
|
+
nodeComponents?: HtmlReactNodeComponentMap;
|
|
12
|
+
propComponents?: HtmlReactPropComponentMap;
|
|
13
|
+
renderNode?: RenderNodeFn;
|
|
14
|
+
sourceNode?: ParsedNode;
|
|
15
|
+
}
|
|
5
16
|
export declare function normalizeDomAttrs(attrs: Record<string, string>): Record<string, unknown>;
|
|
6
17
|
export declare const tokenizeHtml: typeof tokenizeHtmlBase;
|
|
7
18
|
export declare const sanitizeHtmlAttrs: typeof sanitizeHtmlAttrsBase;
|
|
8
|
-
export declare function isCustomHtmlComponent(tagName: string, customComponents:
|
|
9
|
-
export declare function hasCustomHtmlComponents(content: string, customComponents:
|
|
10
|
-
export declare function parseHtmlToReactNodes(content: string, customComponents:
|
|
19
|
+
export declare function isCustomHtmlComponent(tagName: string, customComponents: HtmlReactComponentMap): boolean;
|
|
20
|
+
export declare function hasCustomHtmlComponents(content: string, customComponents: HtmlReactComponentMap): boolean;
|
|
21
|
+
export declare function parseHtmlToReactNodes(content: string, customComponents: HtmlReactComponentMap, htmlPolicy?: HtmlPolicy, options?: HtmlToReactOptions): ReactNode[] | null;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markstream-react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.53",
|
|
5
5
|
"description": "React/Next.js streaming Markdown renderer for AI chat, LLM token streams, SSE/WebSocket output, incomplete Markdown, long documents, Mermaid, KaTeX, Shiki, Monaco, and custom React components.",
|
|
6
6
|
"author": "Simon He",
|
|
7
7
|
"license": "MIT",
|
|
@@ -114,14 +114,14 @@
|
|
|
114
114
|
"dependencies": {
|
|
115
115
|
"@floating-ui/dom": "^1.7.6",
|
|
116
116
|
"clsx": "^2.1.1",
|
|
117
|
-
"
|
|
118
|
-
"
|
|
117
|
+
"markstream-core": "1.0.3",
|
|
118
|
+
"stream-markdown-parser": "1.0.8"
|
|
119
119
|
},
|
|
120
120
|
"devDependencies": {
|
|
121
121
|
"@types/react": "^18.3.31",
|
|
122
122
|
"@types/react-dom": "^18.3.7",
|
|
123
123
|
"@vitejs/plugin-react-swc": "^3.11.0",
|
|
124
|
-
"autoprefixer": "^10.5.
|
|
124
|
+
"autoprefixer": "^10.5.1",
|
|
125
125
|
"rollup": "^3.30.0",
|
|
126
126
|
"rollup-plugin-dts": "^5.3.1",
|
|
127
127
|
"rollup-plugin-visualizer": "^6.0.11",
|
|
@@ -137,10 +137,10 @@
|
|
|
137
137
|
"build:dts": "rollup -c ./scripts/rollup.dts.config.mjs && node ./scripts/clean-dts.cjs",
|
|
138
138
|
"check:exports": "node ../../scripts/check-react-package-exports.mjs",
|
|
139
139
|
"preview": "vite preview",
|
|
140
|
-
"typecheck": "tsc --noEmit",
|
|
140
|
+
"typecheck": "tsc --noEmit && tsc -p ../../test/react-local-component-maps-types.tsconfig.json --noEmit",
|
|
141
141
|
"size:check": "node ../../scripts/check-package-size.mjs",
|
|
142
142
|
"check:core-published": "node ../../scripts/check-core-published.mjs --package-json package.json --core-package-json ../markstream-core/package.json",
|
|
143
143
|
"check:workspace-deps-published": "node ../../scripts/check-workspace-deps-published.mjs --package-json package.json",
|
|
144
|
-
"release": "pnpm run check:workspace-deps-published && bumpp --commit --no-tag --no-push && pnpm publish --access public && node ../../scripts/tag-package.mjs --package-json package.json --push"
|
|
144
|
+
"release": "pnpm run check:workspace-deps-published && bumpp --all --commit --no-tag --no-push --execute 'pnpm --workspace-root run docs:llms:generate' && pnpm publish --access public && node ../../scripts/tag-package.mjs --package-json package.json --push"
|
|
145
145
|
}
|
|
146
146
|
}
|