@asgard-js/react 0.0.33-canary.0 → 0.0.33-canary.2
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.d.ts.map +1 -1
- package/dist/context/asgard-service-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-react-markdown-renderer.d.ts.map +1 -0
- package/dist/index.js +15607 -15656
- package/package.json +4 -4
- 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 +3 -3
- package/src/components/templates/carousel-template/carousel-template.tsx +2 -2
- package/src/components/templates/chart-template/chart-template.tsx +2 -2
- package/src/components/templates/hint-template/hint-template.tsx +2 -2
- package/src/components/templates/image-template/image-template.tsx +3 -3
- 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 +1 -1
- 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-theme-context.tsx +2 -2
- package/src/hooks/index.ts +1 -1
- package/src/{components/templates/text-template → hooks}/use-react-markdown-renderer.tsx +4 -4
- 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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asgard-js/react",
|
|
3
|
-
"version": "0.0.33-canary.
|
|
3
|
+
"version": "0.0.33-canary.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -32,13 +32,13 @@
|
|
|
32
32
|
"highlight.js": "^11.11.1",
|
|
33
33
|
"katex": "^0.16.22",
|
|
34
34
|
"react-markdown": "^10.1.0",
|
|
35
|
-
"react-vega": "^7.
|
|
35
|
+
"react-vega": "^7.7.1",
|
|
36
36
|
"rehype-highlight": "^7.0.2",
|
|
37
37
|
"rehype-katex": "^7.0.1",
|
|
38
38
|
"remark-gfm": "^4.0.1",
|
|
39
39
|
"remark-math": "^6.0.0",
|
|
40
40
|
"vega": "^6.1.2",
|
|
41
|
-
"vega-embed": "
|
|
41
|
+
"vega-embed": "6.5.1",
|
|
42
42
|
"vega-lite": "^6.1.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"vitest": "^1.6.0"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"@asgard-js/core": "^0.0.33-canary.
|
|
57
|
+
"@asgard-js/core": "^0.0.33-canary.2",
|
|
58
58
|
"react": "^18.0.0",
|
|
59
59
|
"react-dom": "^18.0.0"
|
|
60
60
|
},
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ReactNode, useEffect, useMemo } from 'react';
|
|
2
|
-
import { useAsgardContext } from '
|
|
2
|
+
import { useAsgardContext } from '../../../context/asgard-service-context';
|
|
3
3
|
import styles from './chatbot-body.module.scss';
|
|
4
4
|
import { ConversationMessageRenderer } from './conversation-message-renderer';
|
|
5
5
|
import { BotTypingPlaceholder } from '../../templates';
|
|
6
|
-
import { useAsgardThemeContext } from '
|
|
6
|
+
import { useAsgardThemeContext } from '../../../context/asgard-theme-context';
|
|
7
7
|
import clsx from 'clsx';
|
|
8
8
|
|
|
9
9
|
export function ChatbotBody(): ReactNode {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { PropsWithChildren, ReactNode, useRef, CSSProperties } from 'react';
|
|
2
|
-
import { useUpdateVh } from '
|
|
2
|
+
import { useUpdateVh } from '../../../hooks';
|
|
3
3
|
import { ChatbotFullScreenContainer } from './chatbot-full-screen-container';
|
|
4
4
|
import classes from './chatbot-container.module.scss';
|
|
5
|
-
import { useAsgardThemeContext } from '
|
|
5
|
+
import { useAsgardThemeContext } from '../../../context/asgard-theme-context';
|
|
6
6
|
import clsx from 'clsx';
|
|
7
7
|
|
|
8
8
|
interface ChatbotContainerProps extends PropsWithChildren {
|
|
@@ -5,9 +5,9 @@ import {
|
|
|
5
5
|
useOnScreenKeyboardScrollFix,
|
|
6
6
|
usePreventOverScrolling,
|
|
7
7
|
useViewportSize,
|
|
8
|
-
} from '
|
|
8
|
+
} from '../../../hooks';
|
|
9
9
|
import classes from './chatbot-container.module.scss';
|
|
10
|
-
import { useAsgardThemeContext } from '
|
|
10
|
+
import { useAsgardThemeContext } from '../../../context/asgard-theme-context';
|
|
11
11
|
|
|
12
12
|
export function ChatbotFullScreenContainer(
|
|
13
13
|
props: PropsWithChildren
|
|
@@ -8,12 +8,12 @@ import {
|
|
|
8
8
|
useRef,
|
|
9
9
|
useState,
|
|
10
10
|
} from 'react';
|
|
11
|
-
import { useAsgardContext } from '
|
|
11
|
+
import { useAsgardContext } from '../../../context/asgard-service-context';
|
|
12
12
|
import styles from './chatbot-footer.module.scss';
|
|
13
|
-
import SendSvg from '
|
|
13
|
+
import SendSvg from '../../../icons/send.svg?react';
|
|
14
14
|
import { SpeechInputButton } from './speech-input-button';
|
|
15
15
|
import clsx from 'clsx';
|
|
16
|
-
import { useAsgardThemeContext } from '
|
|
16
|
+
import { useAsgardThemeContext } from '../../../context/asgard-theme-context';
|
|
17
17
|
|
|
18
18
|
export function ChatbotFooter(): ReactNode {
|
|
19
19
|
const { sendMessage, isConnecting } = useAsgardContext();
|
|
@@ -10,8 +10,8 @@ import {
|
|
|
10
10
|
useState,
|
|
11
11
|
CSSProperties,
|
|
12
12
|
} from 'react';
|
|
13
|
-
import MicSvg from '
|
|
14
|
-
import StopSvg from '
|
|
13
|
+
import MicSvg from '../../../icons/mic.svg?react';
|
|
14
|
+
import StopSvg from '../../../icons/stop.svg?react';
|
|
15
15
|
|
|
16
16
|
interface SpeechInputButtonProps {
|
|
17
17
|
setValue: Dispatch<SetStateAction<string>>;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { MouseEventHandler, ReactNode, useCallback, useMemo } from 'react';
|
|
2
2
|
import styles from './chatbot-header.module.scss';
|
|
3
3
|
import { ProfileIcon } from '../profile-icon';
|
|
4
|
-
import RefreshSvg from '
|
|
5
|
-
import CloseSvg from '
|
|
4
|
+
import RefreshSvg from '../../../icons/refresh.svg?react';
|
|
5
|
+
import CloseSvg from '../../../icons/close.svg?react';
|
|
6
6
|
import {
|
|
7
7
|
useAsgardAppInitializationContext,
|
|
8
8
|
useAsgardThemeContext,
|
|
9
9
|
useAsgardContext,
|
|
10
|
-
} from '
|
|
10
|
+
} from '../../../context/';
|
|
11
11
|
import clsx from 'clsx';
|
|
12
12
|
|
|
13
13
|
interface ChatbotHeaderProps {
|
|
@@ -3,7 +3,7 @@ import { ClientConfig, ConversationMessage } from '@asgard-js/core';
|
|
|
3
3
|
import {
|
|
4
4
|
AsgardThemeContextProvider,
|
|
5
5
|
AsgardThemeContextValue,
|
|
6
|
-
} from '
|
|
6
|
+
} from '../../context/asgard-theme-context';
|
|
7
7
|
import {
|
|
8
8
|
AsgardServiceContextProvider,
|
|
9
9
|
AsgardServiceContextValue,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
AsgardTemplateContextValue,
|
|
12
12
|
AsgardAppInitializationContextProvider,
|
|
13
13
|
AsgardServiceContextProviderProps,
|
|
14
|
-
} from '
|
|
14
|
+
} from '../../context';
|
|
15
15
|
import { ChatbotHeader } from './chatbot-header';
|
|
16
16
|
import { ChatbotBody } from './chatbot-body';
|
|
17
17
|
import { ChatbotFooter } from './chatbot-footer';
|
|
@@ -3,8 +3,8 @@ import { ReactNode } from 'react';
|
|
|
3
3
|
import { TemplateBox, TemplateBoxContent } from '../template-box';
|
|
4
4
|
import { Avatar } from '../avatar';
|
|
5
5
|
import { Card } from './card';
|
|
6
|
-
import { useAsgardContext } from '
|
|
7
|
-
import { useAsgardThemeContext } from '
|
|
6
|
+
import { useAsgardContext } from '../../../context/asgard-service-context';
|
|
7
|
+
import { useAsgardThemeContext } from '../../../context/asgard-theme-context';
|
|
8
8
|
|
|
9
9
|
interface ButtonTemplateProps {
|
|
10
10
|
message: ConversationBotMessage;
|
|
@@ -11,9 +11,9 @@ import {
|
|
|
11
11
|
ButtonMessageTemplate,
|
|
12
12
|
CarouselMessageTemplate,
|
|
13
13
|
} from '@asgard-js/core';
|
|
14
|
-
import { useAsgardContext } from '
|
|
15
|
-
import { useAsgardTemplateContext } from '
|
|
16
|
-
import { safeWindowOpen } from '
|
|
14
|
+
import { useAsgardContext } from '../../../context/asgard-service-context';
|
|
15
|
+
import { useAsgardTemplateContext } from '../../../context/asgard-template-context';
|
|
16
|
+
import { safeWindowOpen } from '../../../utils/uri-validation';
|
|
17
17
|
import clsx from 'clsx';
|
|
18
18
|
|
|
19
19
|
interface CardProps {
|
|
@@ -9,8 +9,8 @@ import {
|
|
|
9
9
|
ButtonMessageTemplate,
|
|
10
10
|
} from '@asgard-js/core';
|
|
11
11
|
import { Time } from '../time';
|
|
12
|
-
import { useAsgardContext } from '
|
|
13
|
-
import { useAsgardThemeContext } from '
|
|
12
|
+
import { useAsgardContext } from '../../../context/asgard-service-context';
|
|
13
|
+
import { useAsgardThemeContext } from '../../../context/asgard-theme-context';
|
|
14
14
|
|
|
15
15
|
interface CarouselTemplateProps {
|
|
16
16
|
message: ConversationBotMessage;
|
|
@@ -3,11 +3,11 @@ import { TemplateBox, TemplateBoxContent } from '../template-box';
|
|
|
3
3
|
import { Avatar } from '../avatar';
|
|
4
4
|
import { ConversationBotMessage, ChartMessageTemplate } from '@asgard-js/core';
|
|
5
5
|
import { Time } from '../time';
|
|
6
|
-
import { useAsgardContext } from '
|
|
6
|
+
import { useAsgardContext } from '../../../context/asgard-service-context';
|
|
7
7
|
import { VegaLite, VisualizationSpec } from 'react-vega';
|
|
8
8
|
import clsx from 'clsx';
|
|
9
9
|
import classes from './chart-template.module.scss';
|
|
10
|
-
import { useAsgardThemeContext } from '
|
|
10
|
+
import { useAsgardThemeContext } from '../../../context/asgard-theme-context';
|
|
11
11
|
|
|
12
12
|
interface ChartTemplateProps {
|
|
13
13
|
message: ConversationBotMessage;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { ReactNode, useCallback } from 'react';
|
|
2
2
|
import classes from './hint-template.module.scss';
|
|
3
|
-
import { formatTime } from '
|
|
3
|
+
import { formatTime } from '../../../utils';
|
|
4
4
|
import {
|
|
5
5
|
ConversationErrorMessage,
|
|
6
6
|
ConversationMessage,
|
|
7
7
|
MessageTemplateType,
|
|
8
8
|
} from '@asgard-js/core';
|
|
9
|
-
import { useAsgardTemplateContext, useAsgardThemeContext } from '
|
|
9
|
+
import { useAsgardTemplateContext, useAsgardThemeContext } from '../../../context';
|
|
10
10
|
import clsx from 'clsx';
|
|
11
11
|
|
|
12
12
|
interface HintTemplateProps {
|
|
@@ -3,9 +3,9 @@ import { TemplateBox, TemplateBoxContent } from '../template-box';
|
|
|
3
3
|
import { Avatar } from '../avatar';
|
|
4
4
|
import styles from './image-template.module.scss';
|
|
5
5
|
import { ConversationBotMessage, ImageMessageTemplate } from '@asgard-js/core';
|
|
6
|
-
import { useAsgardContext } from '
|
|
7
|
-
import { useAsgardThemeContext } from '
|
|
8
|
-
import CloseSvg from '
|
|
6
|
+
import { useAsgardContext } from '../../../context/asgard-service-context';
|
|
7
|
+
import { useAsgardThemeContext } from '../../../context/asgard-theme-context';
|
|
8
|
+
import CloseSvg from '../../../icons/close.svg?react';
|
|
9
9
|
|
|
10
10
|
interface ImageTemplateProps {
|
|
11
11
|
message: ConversationBotMessage;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReactNode, useCallback } from 'react';
|
|
2
2
|
import styles from './quick-replies.module.scss';
|
|
3
|
-
import { useAsgardContext } from '
|
|
4
|
-
import { useAsgardThemeContext } from '
|
|
3
|
+
import { useAsgardContext } from '../../../context/asgard-service-context';
|
|
4
|
+
import { useAsgardThemeContext } from '../../../context/asgard-theme-context';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
|
|
7
7
|
interface QuickRepliesProps {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { CSSProperties, ReactNode, useCallback, useMemo, useRef } from 'react';
|
|
2
|
-
import { useAsgardContext } from '
|
|
2
|
+
import { useAsgardContext } from '../../../context/asgard-service-context';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
import { TemplateBox, TemplateBoxContent } from '../template-box';
|
|
5
5
|
import { Avatar } from '../avatar';
|
|
6
|
-
import { useDebounce, useResizeObserver } from '
|
|
6
|
+
import { useDebounce, useResizeObserver } from '../../../hooks';
|
|
7
7
|
import classes from './text-template.module.scss';
|
|
8
|
-
import { useAsgardThemeContext } from '
|
|
9
|
-
import { useMarkdownRenderer } from '
|
|
8
|
+
import { useAsgardThemeContext } from '../../../context/asgard-theme-context';
|
|
9
|
+
import { useMarkdownRenderer } from '../../../hooks/use-react-markdown-renderer';
|
|
10
10
|
interface BotTypingBoxProps {
|
|
11
11
|
isTyping: boolean;
|
|
12
12
|
typingText: string | null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode, useMemo } from 'react';
|
|
2
2
|
import { BotTypingBox } from './bot-typing-box';
|
|
3
|
-
import { useAsgardContext } from '
|
|
3
|
+
import { useAsgardContext } from '../../../context/asgard-service-context';
|
|
4
4
|
|
|
5
5
|
interface BotTypingPlaceholderProps {
|
|
6
6
|
placeholder: string;
|
|
@@ -5,9 +5,9 @@ import { TemplateBox, TemplateBoxContent } from '../template-box';
|
|
|
5
5
|
import classes from './text-template.module.scss';
|
|
6
6
|
import { Avatar } from '../avatar';
|
|
7
7
|
import { Time } from '../time';
|
|
8
|
-
import { useAsgardContext } from '
|
|
9
|
-
import { useAsgardThemeContext } from '
|
|
10
|
-
import { useMarkdownRenderer } from '
|
|
8
|
+
import { useAsgardContext } from '../../../context/asgard-service-context';
|
|
9
|
+
import { useAsgardThemeContext } from '../../../context/asgard-theme-context';
|
|
10
|
+
import { useMarkdownRenderer } from '../../../hooks/use-react-markdown-renderer';
|
|
11
11
|
|
|
12
12
|
interface TextTemplateProps {
|
|
13
13
|
message: ConversationMessage;
|
|
@@ -2,7 +2,7 @@ import { describe, it, expect, vi } from 'vitest';
|
|
|
2
2
|
import { renderHook } from '@testing-library/react';
|
|
3
3
|
import { render, screen, fireEvent } from '@testing-library/react';
|
|
4
4
|
import '@testing-library/jest-dom';
|
|
5
|
-
import { useMarkdownRenderer, manageCacheSize, MAX_CACHE_SIZE } from '
|
|
5
|
+
import { useMarkdownRenderer, manageCacheSize, MAX_CACHE_SIZE } from '../../../hooks/use-react-markdown-renderer';
|
|
6
6
|
import { AsgardTemplateContextProvider } from '../../../context/asgard-template-context';
|
|
7
7
|
|
|
8
8
|
describe('useMarkdownRenderer - Simple Tests', () => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ReactNode, useMemo } from 'react';
|
|
2
|
-
import { formatTime } from '
|
|
2
|
+
import { formatTime } from '../../../utils';
|
|
3
3
|
import styles from './time.module.scss';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
|
-
import { useAsgardThemeContext } from '
|
|
5
|
+
import { useAsgardThemeContext } from '../../../context/asgard-theme-context';
|
|
6
6
|
|
|
7
7
|
interface TimeProps {
|
|
8
8
|
time?: Date;
|
|
@@ -7,10 +7,10 @@ import React, {
|
|
|
7
7
|
ReactNode,
|
|
8
8
|
} from 'react';
|
|
9
9
|
import { ClientConfig } from '@asgard-js/core';
|
|
10
|
-
import { getBotProviderModels } from '
|
|
11
|
-
import { useDeepCompareMemo } from '
|
|
12
|
-
import { deepMerge } from '
|
|
13
|
-
import { extractRefs } from '
|
|
10
|
+
import { getBotProviderModels } from '../models/bot-provider';
|
|
11
|
+
import { useDeepCompareMemo } from '../hooks';
|
|
12
|
+
import { deepMerge } from '../utils/deep-merge';
|
|
13
|
+
import { extractRefs } from '../utils/extractors';
|
|
14
14
|
|
|
15
15
|
type AsyncInitializers = {
|
|
16
16
|
[key: string]: () => Promise<unknown>;
|
|
@@ -7,11 +7,11 @@ import {
|
|
|
7
7
|
useMemo,
|
|
8
8
|
useCallback,
|
|
9
9
|
} from 'react';
|
|
10
|
-
import { deepMerge } from '
|
|
10
|
+
import { deepMerge } from '../utils/deep-merge';
|
|
11
11
|
import {
|
|
12
12
|
useAsgardAppInitializationContext,
|
|
13
13
|
Annotations,
|
|
14
|
-
} from '
|
|
14
|
+
} from './asgard-app-initialization-context';
|
|
15
15
|
|
|
16
16
|
export interface AsgardThemeContextValue {
|
|
17
17
|
chatbot: Pick<
|
package/src/hooks/index.ts
CHANGED
|
@@ -8,4 +8,4 @@ export * from './use-prevent-over-scrolling';
|
|
|
8
8
|
export * from './use-update-vh';
|
|
9
9
|
export * from './use-resize-observer';
|
|
10
10
|
export * from './use-deep-compare-memo';
|
|
11
|
-
export * from '
|
|
11
|
+
export * from './use-react-markdown-renderer';
|
|
@@ -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;
|
|
@@ -263,4 +263,4 @@ export function useMarkdownRenderer(
|
|
|
263
263
|
htmlBlocks,
|
|
264
264
|
lastTypingText: typingText,
|
|
265
265
|
};
|
|
266
|
-
}
|
|
266
|
+
}
|
|
@@ -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;AAyHD,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,MAAM,EACpB,KAAK,SAAM,GACV,oBAAoB,CAqGtB"}
|
|
File without changes
|