@asgard-js/react 0.0.32 → 0.0.33-canary.1
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/dist/components/chatbot/chatbot-body/conversation-message-renderer.d.ts +1 -1
- package/dist/components/chatbot/chatbot.d.ts +1 -1
- package/dist/components/chatbot/chatbot.d.ts.map +1 -1
- package/dist/components/templates/button-template/button-template.d.ts +1 -1
- package/dist/components/templates/button-template/card.d.ts +1 -1
- package/dist/components/templates/carousel-template/carousel-template.d.ts +1 -1
- package/dist/components/templates/carousel-template/carousel-template.d.ts.map +1 -1
- package/dist/components/templates/chart-template/chart-template.d.ts +1 -1
- package/dist/components/templates/chart-template/chart-template.d.ts.map +1 -1
- package/dist/components/templates/hint-template/hint-template.d.ts +1 -1
- package/dist/components/templates/image-template/image-template.d.ts +1 -1
- package/dist/components/templates/image-template/image-template.d.ts.map +1 -1
- package/dist/components/templates/text-template/text-template.d.ts +1 -1
- package/dist/context/asgard-app-initialization-context.d.ts +1 -1
- package/dist/context/asgard-service-context.d.ts +1 -1
- package/dist/context/asgard-service-context.d.ts.map +1 -1
- package/dist/context/asgard-template-context.d.ts +3 -3
- package/dist/context/asgard-template-context.d.ts.map +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/use-asgard-service-client.d.ts +1 -1
- package/dist/hooks/use-channel.d.ts +4 -4
- package/dist/hooks/use-channel.d.ts.map +1 -1
- package/dist/hooks/use-react-markdown-renderer.d.ts.map +1 -0
- package/dist/index.js +15609 -15654
- package/dist/models/bot-provider.d.ts +1 -1
- package/dist/utils/deep-merge.d.ts +1 -1
- package/dist/utils/deep-merge.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/components/chatbot/chatbot-body/chatbot-body.tsx +2 -2
- package/src/components/chatbot/chatbot-container/chatbot-container.tsx +2 -2
- package/src/components/chatbot/chatbot-container/chatbot-full-screen-container.tsx +2 -2
- package/src/components/chatbot/chatbot-footer/chatbot-footer.tsx +3 -3
- package/src/components/chatbot/chatbot-footer/speech-input-button.tsx +2 -2
- package/src/components/chatbot/chatbot-header/chatbot-header.tsx +3 -3
- package/src/components/chatbot/chatbot.tsx +2 -2
- package/src/components/chatbot/profile-icon.tsx +1 -1
- package/src/components/templates/avatar/avatar.tsx +1 -1
- package/src/components/templates/button-template/button-template.tsx +2 -2
- package/src/components/templates/button-template/card.tsx +4 -4
- package/src/components/templates/carousel-template/carousel-template.tsx +4 -3
- package/src/components/templates/chart-template/chart-template.tsx +6 -7
- package/src/components/templates/hint-template/hint-template.tsx +2 -2
- package/src/components/templates/image-template/image-template.tsx +6 -6
- package/src/components/templates/quick-replies/quick-replies.tsx +2 -2
- package/src/components/templates/text-template/bot-typing-box.tsx +4 -4
- package/src/components/templates/text-template/bot-typing-placeholder.tsx +1 -1
- package/src/components/templates/text-template/text-template.tsx +3 -3
- package/src/components/templates/text-template/use-react-markdown-renderer.spec.tsx +8 -8
- package/src/components/templates/time/time.tsx +2 -2
- package/src/context/asgard-app-initialization-context.tsx +4 -4
- package/src/context/asgard-service-context.tsx +1 -1
- package/src/context/asgard-template-context.tsx +2 -2
- package/src/context/asgard-theme-context.tsx +3 -3
- package/src/hooks/index.ts +1 -1
- package/src/hooks/use-channel.ts +8 -8
- package/src/{components/templates/text-template → hooks}/use-react-markdown-renderer.tsx +13 -11
- package/src/utils/deep-merge.ts +7 -4
- package/tsconfig.lib.json +2 -1
- package/tsconfig.tsbuildinfo +1 -0
- package/dist/components/templates/text-template/use-react-markdown-renderer.d.ts.map +0 -1
- /package/dist/{components/templates/text-template → hooks}/use-react-markdown-renderer.d.ts +0 -0
|
@@ -12,9 +12,9 @@ import remarkMath from 'remark-math';
|
|
|
12
12
|
import rehypeHighlight from 'rehype-highlight';
|
|
13
13
|
import rehypeKatex from 'rehype-katex';
|
|
14
14
|
import 'katex/dist/katex.min.css';
|
|
15
|
-
import classes from '
|
|
16
|
-
import { useAsgardTemplateContext } from '
|
|
17
|
-
import { safeWindowOpen } from '
|
|
15
|
+
import classes from '../components/templates/text-template/text-template.module.scss';
|
|
16
|
+
import { useAsgardTemplateContext } from '../context/asgard-template-context';
|
|
17
|
+
import { safeWindowOpen } from '../utils/uri-validation';
|
|
18
18
|
|
|
19
19
|
interface MarkdownRenderResult {
|
|
20
20
|
htmlBlocks: ReactNode;
|
|
@@ -83,14 +83,14 @@ function isCompleteParagraph(raw: string): boolean {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
// Custom table renderer to maintain current styling
|
|
86
|
-
const TableRenderer = ({ children, ...props }:
|
|
86
|
+
const TableRenderer = ({ children, ...props }: React.ComponentProps<'table'>): ReactNode => (
|
|
87
87
|
<div className={classes.table_container}>
|
|
88
88
|
<table {...props}>{children}</table>
|
|
89
89
|
</div>
|
|
90
90
|
);
|
|
91
91
|
|
|
92
92
|
// Custom code renderer to maintain highlight.js classes exactly
|
|
93
|
-
const CodeRenderer = ({ children, className, ...props }:
|
|
93
|
+
const CodeRenderer = ({ children, className, ...props }: React.ComponentProps<'code'>): ReactNode => {
|
|
94
94
|
return (
|
|
95
95
|
<code className={`hljs ${className || ''}`} {...props}>
|
|
96
96
|
{children}
|
|
@@ -99,7 +99,7 @@ const CodeRenderer = ({ children, className, ...props }: any): ReactNode => {
|
|
|
99
99
|
};
|
|
100
100
|
|
|
101
101
|
// Custom link renderer to integrate defaultLinkTarget prop
|
|
102
|
-
const LinkRenderer = ({ children, href, ...props }:
|
|
102
|
+
const LinkRenderer = ({ children, href, ...props }: React.ComponentProps<'a'>): ReactNode => {
|
|
103
103
|
const { defaultLinkTarget } = useAsgardTemplateContext();
|
|
104
104
|
|
|
105
105
|
const handleClick = useCallback(
|
|
@@ -120,13 +120,13 @@ const LinkRenderer = ({ children, href, ...props }: any): ReactNode => {
|
|
|
120
120
|
};
|
|
121
121
|
|
|
122
122
|
// Custom math renderers for inline and block math expressions
|
|
123
|
-
const InlineMathRenderer = ({ children, ...props }:
|
|
123
|
+
const InlineMathRenderer = ({ children, ...props }: React.ComponentProps<'span'>): ReactNode => (
|
|
124
124
|
<span className="math math-inline" {...props}>
|
|
125
125
|
{children}
|
|
126
126
|
</span>
|
|
127
127
|
);
|
|
128
128
|
|
|
129
|
-
const BlockMathRenderer = ({ children, ...props }:
|
|
129
|
+
const BlockMathRenderer = ({ children, ...props }: React.ComponentProps<'div'>): ReactNode => (
|
|
130
130
|
<div className="math math-display" {...props}>
|
|
131
131
|
{children}
|
|
132
132
|
</div>
|
|
@@ -138,7 +138,7 @@ const components = {
|
|
|
138
138
|
code: CodeRenderer,
|
|
139
139
|
a: LinkRenderer,
|
|
140
140
|
math: InlineMathRenderer, // Inline math: $expression$
|
|
141
|
-
div: ({ className, ...props }:
|
|
141
|
+
div: ({ className, ...props }: React.ComponentProps<'div'>): ReactNode => {
|
|
142
142
|
// Block math: $$expression$$
|
|
143
143
|
// Check for KaTeX display math classes
|
|
144
144
|
if (
|
|
@@ -149,7 +149,9 @@ const components = {
|
|
|
149
149
|
<BlockMathRenderer
|
|
150
150
|
className={`math math-display ${className || ''}`}
|
|
151
151
|
{...props}
|
|
152
|
-
|
|
152
|
+
>
|
|
153
|
+
{props.children}
|
|
154
|
+
</BlockMathRenderer>
|
|
153
155
|
);
|
|
154
156
|
}
|
|
155
157
|
|
|
@@ -261,4 +263,4 @@ export function useMarkdownRenderer(
|
|
|
261
263
|
htmlBlocks,
|
|
262
264
|
lastTypingText: typingText,
|
|
263
265
|
};
|
|
264
|
-
}
|
|
266
|
+
}
|
package/src/utils/deep-merge.ts
CHANGED
|
@@ -2,21 +2,24 @@ export function isObject(item: unknown): item is Record<string, unknown> {
|
|
|
2
2
|
return item !== null && typeof item === 'object' && !Array.isArray(item);
|
|
3
3
|
}
|
|
4
4
|
|
|
5
|
-
export function deepMerge<T extends
|
|
5
|
+
export function deepMerge<T extends Record<string, unknown>, U extends Record<string, unknown>>(
|
|
6
6
|
target: T,
|
|
7
7
|
source: U
|
|
8
8
|
): T & U {
|
|
9
|
-
const output = { ...target } as
|
|
9
|
+
const output = { ...target } as T & U;
|
|
10
10
|
|
|
11
11
|
if (!source) return output;
|
|
12
12
|
|
|
13
13
|
for (const [key, value] of Object.entries(source)) {
|
|
14
14
|
if (!isObject(value)) {
|
|
15
|
-
output[key] = value;
|
|
15
|
+
(output as Record<string, unknown>)[key] = value;
|
|
16
16
|
continue;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
output[key] = deepMerge(
|
|
19
|
+
(output as Record<string, unknown>)[key] = deepMerge(
|
|
20
|
+
isObject((output as Record<string, unknown>)[key]) ? (output as Record<string, unknown>)[key] as Record<string, unknown> : {},
|
|
21
|
+
value as Record<string, unknown>
|
|
22
|
+
);
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
return output;
|
package/tsconfig.lib.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"fileNames":[],"fileInfos":[],"root":[],"options":{"allowJs":false,"allowSyntheticDefaultImports":true,"composite":true,"declaration":true,"declarationMap":true,"emitDeclarationOnly":true,"emitDecoratorMetadata":false,"esModuleInterop":true,"experimentalDecorators":false,"importHelpers":true,"module":99,"noEmitOnError":true,"noFallthroughCasesInSwitch":true,"noImplicitOverride":true,"noImplicitReturns":true,"noUnusedLocals":true,"removeComments":false,"rootDir":"../..","skipDefaultLibCheck":false,"skipLibCheck":true,"sourceMap":false,"strict":true,"target":99,"verbatimModuleSyntax":false},"version":"5.6.3"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-react-markdown-renderer.d.ts","sourceRoot":"","sources":["../../../../src/components/templates/text-template/use-react-markdown-renderer.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAMV,MAAM,OAAO,CAAC;AAMf,OAAO,0BAA0B,CAAC;AAKlC,UAAU,oBAAoB;IAC5B,UAAU,EAAE,SAAS,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;CACxB;AAQD,eAAO,MAAM,cAAc,MAAM,CAAC;AAGlC,wBAAgB,eAAe,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAI,CAQnE;AAuHD,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,MAAM,EACpB,KAAK,SAAM,GACV,oBAAoB,CAqGtB"}
|
|
File without changes
|