@iyulab/chat-components 0.6.0 → 0.7.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.
- package/CHANGELOG.md +40 -0
- package/README.md +15 -39
- package/dist/_virtual/{_@oxc-project_runtime@0.130.0/helpers → _@oxc-project_runtime@0.138.0/helpers/esm}/decorate.js +2 -2
- package/dist/_virtual/{_@oxc-project_runtime@0.130.0/helpers → _@oxc-project_runtime@0.138.0/helpers/esm}/decorateMetadata.js +2 -2
- package/dist/_virtual/_glob-assets_raw/alert-triangle-fill.svg.4cfc4305.js +4 -0
- package/dist/_virtual/_glob-assets_raw/arrows-sort.svg.dda43a85.js +4 -0
- package/dist/_virtual/_glob-assets_raw/code.svg.c69bc144.js +4 -0
- package/dist/_virtual/_glob-assets_raw/download.svg.bce82177.js +4 -0
- package/dist/_virtual/_glob-assets_raw/element-prompt.md.7047ffcc.js +4 -0
- package/dist/_virtual/_glob-assets_raw/external-link.svg.a9f7f02d.js +4 -0
- package/dist/_virtual/_glob-assets_raw/file-code.svg.0e706f93.js +4 -0
- package/dist/_virtual/_glob-assets_raw/file-music.svg.b9970203.js +4 -0
- package/dist/_virtual/_glob-assets_raw/file-spreadsheet.svg.8c03bdfa.js +4 -0
- package/dist/_virtual/_glob-assets_raw/file-text.svg.85bdd923.js +4 -0
- package/dist/_virtual/_glob-assets_raw/file-type-pdf.svg.bc12db6d.js +4 -0
- package/dist/_virtual/_glob-assets_raw/file-zip.svg.76dde660.js +4 -0
- package/dist/_virtual/_glob-assets_raw/file.svg.28f5d6f1.js +4 -0
- package/dist/_virtual/_glob-assets_raw/photo.svg.cc273cc1.js +4 -0
- package/dist/_virtual/_glob-assets_raw/player-stop-fill.svg.5378b752.js +4 -0
- package/dist/_virtual/_glob-assets_raw/send.svg.02326253.js +4 -0
- package/dist/_virtual/_glob-assets_raw/sort-ascending-letters.svg.14a3df67.js +4 -0
- package/dist/_virtual/_glob-assets_raw/sort-descending-letters.svg.3e03647c.js +4 -0
- package/dist/_virtual/_glob-assets_raw/video.svg.c183f03c.js +4 -0
- package/dist/_virtual/_glob-assets_raw/world.svg.cd9903c8.js +4 -0
- package/dist/components/UDataElement.d.ts +44 -0
- package/dist/components/UDataElement.js +76 -0
- package/dist/components/blocks/UCodeBlock.d.ts +0 -4
- package/dist/components/blocks/UCodeBlock.js +6 -12
- package/dist/components/{views/UView.d.ts → blocks/UElementBlock.d.ts} +18 -8
- package/dist/components/{views/UView.js → blocks/UElementBlock.js} +31 -21
- package/dist/components/{views/UView.styles.js → blocks/UElementBlock.styles.js} +1 -1
- package/dist/components/blocks/UFileBlock.d.ts +15 -5
- package/dist/components/blocks/UFileBlock.js +81 -68
- package/dist/components/blocks/UFileBlock.styles.js +86 -29
- package/dist/components/blocks/UMarkedBlock.d.ts +3 -1
- package/dist/components/blocks/UMarkedBlock.js +23 -18
- package/dist/components/blocks/URefBlock.js +2 -2
- package/dist/components/blocks/UTableBlock.d.ts +2 -2
- package/dist/components/blocks/UTableBlock.js +9 -8
- package/dist/components/blocks/UTableBlock.styles.js +1 -1
- package/dist/components/blocks/UTextBlock.d.ts +2 -0
- package/dist/components/blocks/UTextBlock.js +4 -5
- package/dist/components/message/UMessage.js +2 -2
- package/dist/components/prompt/UPrompt.d.ts +0 -5
- package/dist/components/prompt/UPrompt.js +18 -27
- package/dist/components/prompt/UPrompt.styles.js +9 -10
- package/dist/components/references/URefCard.d.ts +2 -2
- package/dist/components/references/URefCard.js +8 -7
- package/dist/components/references/URefCardGroup.js +2 -2
- package/dist/components/references/URefTag.js +5 -4
- package/dist/{components/views/UChartView.d.ts → components-extra/UChartBlock.d.ts} +4 -4
- package/dist/{components/views/UChartView.js → components-extra/UChartBlock.js} +22 -34
- package/dist/components-extra/UChartBlock.schema.d.ts +3 -0
- package/dist/components-extra/UChartBlock.schema.js +34 -0
- package/dist/{components/views/UChartView.styles.js → components-extra/UChartBlock.styles.js} +1 -1
- package/dist/{components/views/UImagesView.d.ts → components-extra/UImagesBlock.d.ts} +4 -4
- package/dist/{components/views/UImagesView.js → components-extra/UImagesBlock.js} +15 -15
- package/dist/components-extra/UImagesBlock.schema.d.ts +3 -0
- package/dist/components-extra/UImagesBlock.schema.js +31 -0
- package/dist/{components/views/UImagesView.styles.js → components-extra/UImagesBlock.styles.js} +5 -5
- package/dist/{components/views/UMapView.d.ts → components-extra/UMapBlock.d.ts} +4 -4
- package/dist/{components/views/UMapView.js → components-extra/UMapBlock.js} +18 -18
- package/dist/components-extra/UMapBlock.schema.d.ts +3 -0
- package/dist/components-extra/UMapBlock.schema.js +33 -0
- package/dist/{components/views/UMapView.styles.js → components-extra/UMapBlock.styles.js} +1 -1
- package/dist/{components/views/UVideoView.d.ts → components-extra/UVideoBlock.d.ts} +4 -4
- package/dist/{components/views/UVideoView.js → components-extra/UVideoBlock.js} +10 -10
- package/dist/components-extra/UVideoBlock.schema.d.ts +3 -0
- package/dist/components-extra/UVideoBlock.schema.js +28 -0
- package/dist/{components/views/UVideoView.styles.js → components-extra/UVideoBlock.styles.js} +1 -1
- package/dist/events/SendEvent.d.ts +0 -5
- package/dist/events/StopEvent.d.ts +0 -5
- package/dist/extra.d.ts +6 -0
- package/dist/extra.js +14 -0
- package/dist/index.d.ts +5 -17
- package/dist/index.js +6 -16
- package/dist/react/UCodeBlock.js +2 -2
- package/dist/react/UElementBlock.d.ts +9 -0
- package/dist/react/UElementBlock.js +10 -0
- package/dist/react/UFileBlock.js +2 -2
- package/dist/react/UImagesBlock.d.ts +9 -0
- package/dist/react/UImagesBlock.js +10 -0
- package/dist/react/UMapBlock.d.ts +9 -0
- package/dist/react/UMapBlock.js +10 -0
- package/dist/react/UMarkedBlock.js +2 -2
- package/dist/react/UMessage.js +2 -2
- package/dist/react/UPrompt.js +2 -2
- package/dist/react/URefBlock.js +2 -2
- package/dist/react/URefCard.js +2 -2
- package/dist/react/URefCardGroup.js +2 -2
- package/dist/react/URefTag.js +2 -2
- package/dist/react/UTableBlock.js +2 -2
- package/dist/react/UTextBlock.d.ts +1 -0
- package/dist/react/UTextBlock.js +5 -3
- package/dist/react/UVideoBlock.d.ts +9 -0
- package/dist/react/UVideoBlock.js +10 -0
- package/dist/react/index.d.ts +4 -11
- package/dist/react/index.js +4 -11
- package/dist/types/BlockItem.d.ts +1 -24
- package/dist/types/{JsonSchema.d.ts → Schema.d.ts} +13 -0
- package/dist/utilities/HtmlBuilder.d.ts +28 -0
- package/dist/utilities/HtmlBuilder.js +41 -0
- package/dist/utilities/PromptBuilder.d.ts +21 -0
- package/dist/utilities/PromptBuilder.js +60 -0
- package/dist/utilities/icons.d.ts +1 -0
- package/dist/utilities/icons.js +52 -0
- package/dist/utilities/sanitizers.d.ts +35 -0
- package/dist/utilities/sanitizers.js +75 -0
- package/package.json +13 -18
- package/skills/iyulab-chat-components/SKILL.md +18 -33
- package/skills/iyulab-chat-components/references/components/{chart-view.md → chart-block.md} +16 -12
- package/skills/iyulab-chat-components/references/components/code-block.md +1 -5
- package/skills/iyulab-chat-components/references/components/element-block.md +57 -0
- package/skills/iyulab-chat-components/references/components/file-block.md +22 -25
- package/skills/iyulab-chat-components/references/components/{images-view.md → images-block.md} +10 -10
- package/skills/iyulab-chat-components/references/components/{map-view.md → map-block.md} +9 -9
- package/skills/iyulab-chat-components/references/components/marked-block.md +5 -4
- package/skills/iyulab-chat-components/references/components/message.md +1 -2
- package/skills/iyulab-chat-components/references/components/prompt.md +12 -21
- package/skills/iyulab-chat-components/references/components/{video-view.md → video-block.md} +10 -10
- package/skills/iyulab-chat-components/references/extra-system.md +95 -0
- package/skills/iyulab-chat-components/references/types.md +17 -31
- package/skills/iyulab-chat-components/references/usage.md +13 -81
- package/skills/iyulab-chat-components/references/utilities/html-builder.md +35 -0
- package/skills/iyulab-chat-components/references/utilities/prompt-builder.md +73 -0
- package/dist/_virtual/_glob-assets_raw/intent-prompt.md.1907474e.js +0 -4
- package/dist/_virtual/_glob-assets_raw/view-prompt.md.e0dbcffe.js +0 -4
- package/dist/chart.d.ts +0 -1
- package/dist/chart.js +0 -2
- package/dist/components/blocks/UJsonBlock.d.ts +0 -49
- package/dist/components/blocks/UJsonBlock.js +0 -130
- package/dist/components/blocks/UJsonBlock.styles.js +0 -115
- package/dist/components/blocks/UThinkBlock.d.ts +0 -35
- package/dist/components/blocks/UThinkBlock.js +0 -87
- package/dist/components/blocks/UThinkBlock.styles.js +0 -74
- package/dist/components/blocks/UToolBlock.d.ts +0 -24
- package/dist/components/blocks/UToolBlock.js +0 -70
- package/dist/components/blocks/UToolBlock.styles.js +0 -66
- package/dist/components/buttons/UAttachButton.d.ts +0 -26
- package/dist/components/buttons/UAttachButton.js +0 -63
- package/dist/components/buttons/UAttachButton.styles.js +0 -14
- package/dist/components/buttons/UCopyButton.d.ts +0 -24
- package/dist/components/buttons/UCopyButton.js +0 -59
- package/dist/components/buttons/UCopyButton.styles.js +0 -18
- package/dist/components/buttons/UVoteButton.d.ts +0 -19
- package/dist/components/buttons/UVoteButton.js +0 -64
- package/dist/components/buttons/UVoteButton.styles.d.ts +0 -1
- package/dist/components/buttons/UVoteButton.styles.js +0 -19
- package/dist/components/intents/UQuestionIntent.d.ts +0 -22
- package/dist/components/intents/UQuestionIntent.js +0 -41
- package/dist/components/intents/UQuestionIntent.styles.d.ts +0 -1
- package/dist/components/intents/UQuestionIntent.styles.js +0 -43
- package/dist/components/views/UChartView.styles.d.ts +0 -1
- package/dist/components/views/UImagesView.styles.d.ts +0 -1
- package/dist/components/views/UMapView.styles.d.ts +0 -1
- package/dist/components/views/UVideoView.styles.d.ts +0 -1
- package/dist/components/views/UView.styles.d.ts +0 -1
- package/dist/events/AttachEvent.d.ts +0 -9
- package/dist/events/ChoiceEvent.d.ts +0 -9
- package/dist/react/UAttachButton.d.ts +0 -11
- package/dist/react/UAttachButton.js +0 -12
- package/dist/react/UCopyButton.d.ts +0 -9
- package/dist/react/UCopyButton.js +0 -10
- package/dist/react/UImagesView.d.ts +0 -9
- package/dist/react/UImagesView.js +0 -10
- package/dist/react/UJsonBlock.d.ts +0 -9
- package/dist/react/UJsonBlock.js +0 -10
- package/dist/react/UMapView.d.ts +0 -9
- package/dist/react/UMapView.js +0 -10
- package/dist/react/UQuestionIntent.d.ts +0 -11
- package/dist/react/UQuestionIntent.js +0 -12
- package/dist/react/UThinkBlock.d.ts +0 -9
- package/dist/react/UThinkBlock.js +0 -10
- package/dist/react/UToolBlock.d.ts +0 -9
- package/dist/react/UToolBlock.js +0 -10
- package/dist/react/UVideoView.d.ts +0 -9
- package/dist/react/UVideoView.js +0 -10
- package/dist/react/UView.d.ts +0 -9
- package/dist/react/UView.js +0 -10
- package/dist/react/UVoteButton.d.ts +0 -9
- package/dist/react/UVoteButton.js +0 -10
- package/dist/types/Intents.d.ts +0 -26
- package/dist/types/Intents.js +0 -30
- package/dist/types/JsonNode.d.ts +0 -20
- package/dist/types/Views.d.ts +0 -34
- package/dist/types/Views.js +0 -148
- package/dist/utilities/IntentPromptBuilder.d.ts +0 -40
- package/dist/utilities/IntentPromptBuilder.js +0 -95
- package/dist/utilities/ViewPromptBuilder.d.ts +0 -28
- package/dist/utilities/ViewPromptBuilder.js +0 -78
- package/dist/utilities/dom-agent/DOMAgent.d.ts +0 -74
- package/dist/utilities/dom-agent/DOMController.d.ts +0 -78
- package/dist/utilities/dom-agent/DOMPromptBuilder.d.ts +0 -54
- package/dist/utilities/dom-agent/DOMScanner.d.ts +0 -83
- package/dist/utilities/dom-agent/index.d.ts +0 -9
- package/dist/utilities/dom-agent/types.d.ts +0 -209
- package/skills/iyulab-chat-components/references/components/attach-button.md +0 -69
- package/skills/iyulab-chat-components/references/components/copy-button.md +0 -46
- package/skills/iyulab-chat-components/references/components/json-block.md +0 -41
- package/skills/iyulab-chat-components/references/components/question-intent.md +0 -75
- package/skills/iyulab-chat-components/references/components/think-block.md +0 -48
- package/skills/iyulab-chat-components/references/components/tool-block.md +0 -57
- package/skills/iyulab-chat-components/references/components/view.md +0 -51
- package/skills/iyulab-chat-components/references/components/vote-button.md +0 -60
- package/skills/iyulab-chat-components/references/utilities/intent-prompt-builder.md +0 -123
- package/skills/iyulab-chat-components/references/utilities/view-prompt-builder.md +0 -112
- /package/dist/components/{buttons/UCopyButton.styles.d.ts → blocks/UElementBlock.styles.d.ts} +0 -0
- /package/dist/{components/blocks/UJsonBlock.styles.d.ts → components-extra/UChartBlock.styles.d.ts} +0 -0
- /package/dist/{components/blocks/UThinkBlock.styles.d.ts → components-extra/UImagesBlock.styles.d.ts} +0 -0
- /package/dist/{components/blocks/UToolBlock.styles.d.ts → components-extra/UMapBlock.styles.d.ts} +0 -0
- /package/dist/{components/buttons/UAttachButton.styles.d.ts → components-extra/UVideoBlock.styles.d.ts} +0 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { createComponent } from '@lit/react';
|
|
3
|
+
import { UVideoBlock as UVideoBlockElement } from '../components-extra/UVideoBlock.js';
|
|
4
|
+
|
|
5
|
+
export const UVideoBlock = createComponent({
|
|
6
|
+
react: React,
|
|
7
|
+
tagName: 'u-video-block',
|
|
8
|
+
elementClass: UVideoBlockElement,
|
|
9
|
+
events: {},
|
|
10
|
+
});
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,22 +1,15 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export { UImagesView, UImagesViewProps } from './UImagesView';
|
|
1
|
+
export { UVideoBlock, UVideoBlockProps } from './UVideoBlock';
|
|
2
|
+
export { UMapBlock, UMapBlockProps } from './UMapBlock';
|
|
3
|
+
export { UImagesBlock, UImagesBlockProps } from './UImagesBlock';
|
|
5
4
|
export { URefTag, URefTagProps } from './URefTag';
|
|
6
5
|
export { URefCardGroup, URefCardGroupProps } from './URefCardGroup';
|
|
7
6
|
export { URefCard, URefCardProps } from './URefCard';
|
|
8
7
|
export { UPrompt, UPromptProps } from './UPrompt';
|
|
9
8
|
export { UMessage, UMessageProps } from './UMessage';
|
|
10
|
-
export { UQuestionIntent, UQuestionIntentProps } from './UQuestionIntent';
|
|
11
|
-
export { UVoteButton, UVoteButtonProps } from './UVoteButton';
|
|
12
|
-
export { UCopyButton, UCopyButtonProps } from './UCopyButton';
|
|
13
|
-
export { UAttachButton, UAttachButtonProps } from './UAttachButton';
|
|
14
|
-
export { UToolBlock, UToolBlockProps } from './UToolBlock';
|
|
15
|
-
export { UThinkBlock, UThinkBlockProps } from './UThinkBlock';
|
|
16
9
|
export { UTextBlock, UTextBlockProps } from './UTextBlock';
|
|
17
10
|
export { UTableBlock, UTableBlockProps } from './UTableBlock';
|
|
18
11
|
export { URefBlock, URefBlockProps } from './URefBlock';
|
|
19
12
|
export { UMarkedBlock, UMarkedBlockProps } from './UMarkedBlock';
|
|
20
|
-
export { UJsonBlock, UJsonBlockProps } from './UJsonBlock';
|
|
21
13
|
export { UFileBlock, UFileBlockProps } from './UFileBlock';
|
|
14
|
+
export { UElementBlock, UElementBlockProps } from './UElementBlock';
|
|
22
15
|
export { UCodeBlock, UCodeBlockProps } from './UCodeBlock';
|
package/dist/react/index.js
CHANGED
|
@@ -1,22 +1,15 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export { UImagesView } from './UImagesView.js';
|
|
1
|
+
export { UVideoBlock } from './UVideoBlock.js';
|
|
2
|
+
export { UMapBlock } from './UMapBlock.js';
|
|
3
|
+
export { UImagesBlock } from './UImagesBlock.js';
|
|
5
4
|
export { URefTag } from './URefTag.js';
|
|
6
5
|
export { URefCardGroup } from './URefCardGroup.js';
|
|
7
6
|
export { URefCard } from './URefCard.js';
|
|
8
7
|
export { UPrompt } from './UPrompt.js';
|
|
9
8
|
export { UMessage } from './UMessage.js';
|
|
10
|
-
export { UQuestionIntent } from './UQuestionIntent.js';
|
|
11
|
-
export { UVoteButton } from './UVoteButton.js';
|
|
12
|
-
export { UCopyButton } from './UCopyButton.js';
|
|
13
|
-
export { UAttachButton } from './UAttachButton.js';
|
|
14
|
-
export { UToolBlock } from './UToolBlock.js';
|
|
15
|
-
export { UThinkBlock } from './UThinkBlock.js';
|
|
16
9
|
export { UTextBlock } from './UTextBlock.js';
|
|
17
10
|
export { UTableBlock } from './UTableBlock.js';
|
|
18
11
|
export { URefBlock } from './URefBlock.js';
|
|
19
12
|
export { UMarkedBlock } from './UMarkedBlock.js';
|
|
20
|
-
export { UJsonBlock } from './UJsonBlock.js';
|
|
21
13
|
export { UFileBlock } from './UFileBlock.js';
|
|
14
|
+
export { UElementBlock } from './UElementBlock.js';
|
|
22
15
|
export { UCodeBlock } from './UCodeBlock.js';
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
import { ReferenceSource, ReferenceCitation } from './References';
|
|
2
|
-
import { JsonNode } from './JsonNode';
|
|
3
|
-
/** LLM 추론 텍스트 블록입니다. */
|
|
4
|
-
export interface ThinkingBlockItem {
|
|
5
|
-
type: "thinking";
|
|
6
|
-
/** 추론 중 로딩 상태 여부 */
|
|
7
|
-
loading?: boolean;
|
|
8
|
-
/** 추론 텍스트 내용 */
|
|
9
|
-
value?: string;
|
|
10
|
-
}
|
|
11
2
|
/** 일반 텍스트 블록입니다. */
|
|
12
3
|
export interface TextBlockItem {
|
|
13
4
|
type: "text";
|
|
@@ -25,8 +16,6 @@ export interface MarkdownBlockItem {
|
|
|
25
16
|
/** 파일 하나의 데이터 구조입니다. */
|
|
26
17
|
export interface FileBlockItem {
|
|
27
18
|
type: "file";
|
|
28
|
-
/** 파일 상태 */
|
|
29
|
-
status?: "idle" | "uploading" | "error";
|
|
30
19
|
/** 파일 이름 */
|
|
31
20
|
name?: string;
|
|
32
21
|
/** 파일 크기 (bytes) */
|
|
@@ -38,18 +27,6 @@ export interface FileBlockItem {
|
|
|
38
27
|
/** 실제 파일 데이터 (선택적, 필요에 따라 사용) */
|
|
39
28
|
data?: any;
|
|
40
29
|
}
|
|
41
|
-
/** 툴 사용 블록입니다. */
|
|
42
|
-
export interface ToolBlockItem {
|
|
43
|
-
type: "tool";
|
|
44
|
-
/** 툴 사용 중 로딩 상태 여부 */
|
|
45
|
-
loading?: boolean;
|
|
46
|
-
/** 도구 블록 제목 */
|
|
47
|
-
title?: string;
|
|
48
|
-
/** 도구 블록 입력값(json) */
|
|
49
|
-
input?: JsonNode;
|
|
50
|
-
/** 도구 블록 출력값(json) */
|
|
51
|
-
output?: JsonNode;
|
|
52
|
-
}
|
|
53
30
|
/** 출처 정보 */
|
|
54
31
|
export interface ReferenceBlockItem {
|
|
55
32
|
type: "reference";
|
|
@@ -59,4 +36,4 @@ export interface ReferenceBlockItem {
|
|
|
59
36
|
/**
|
|
60
37
|
* 타입별 메시지 컨텐츠 아이템
|
|
61
38
|
*/
|
|
62
|
-
export type BlockItem = (
|
|
39
|
+
export type BlockItem = (TextBlockItem | MarkdownBlockItem | FileBlockItem | ReferenceBlockItem);
|
|
@@ -57,3 +57,16 @@ export interface ObjectJsonSchema extends BaseJsonSchema {
|
|
|
57
57
|
additionalProperties?: boolean;
|
|
58
58
|
}
|
|
59
59
|
export type JsonSchema = BooleanJsonSchema | StringJsonSchema | NumberJsonSchema | ArrayJsonSchema | ObjectJsonSchema;
|
|
60
|
+
/**
|
|
61
|
+
* Element(부가 렌더링 블록)를 정의하는 구조체
|
|
62
|
+
*/
|
|
63
|
+
export interface ElementSchema {
|
|
64
|
+
/** 등록할 커스텀 엘리먼트 태그명 */
|
|
65
|
+
tag: string;
|
|
66
|
+
/** LLM용 설명 */
|
|
67
|
+
description: string;
|
|
68
|
+
/** LLM용 속성 스키마 */
|
|
69
|
+
properties?: Record<string, JsonSchema>;
|
|
70
|
+
/** 필수 속성 목록 */
|
|
71
|
+
required?: string[];
|
|
72
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 커스텀 엘리먼트 HTML 문자열을 생성하는 유틸리티입니다.
|
|
3
|
+
*/
|
|
4
|
+
export declare class HtmlBuilder {
|
|
5
|
+
/**
|
|
6
|
+
* 지정한 태그, 속성, 내용으로 커스텀 엘리먼트 HTML 문자열을 생성합니다.
|
|
7
|
+
*
|
|
8
|
+
* 속성 값 처리 규칙:
|
|
9
|
+
* - `null` / `undefined` → 해당 속성 생략
|
|
10
|
+
* - `false` (boolean) → 해당 속성 생략
|
|
11
|
+
* - `true` (boolean) → 값 없이 키만 출력 (예: `disabled`)
|
|
12
|
+
* - `object` → `JSON.stringify` 후 `escapeHtmlAttr`
|
|
13
|
+
* - `href` / `src` 키 → `escapeHtmlHref` 적용
|
|
14
|
+
* - 그 외 string → `escapeHtmlAttr` 적용
|
|
15
|
+
*
|
|
16
|
+
* `content`는 이미 안전한 HTML 문자열이라고 가정합니다 (내부 escape 없음).
|
|
17
|
+
*
|
|
18
|
+
* @param tag - 커스텀 엘리먼트 태그 이름 (예: `"u-ref-tag"`)
|
|
19
|
+
* @param attrs - 속성 객체
|
|
20
|
+
* @param content - 내부 HTML 문자열 (기본값: `""`)
|
|
21
|
+
* @returns 생성된 HTML 문자열
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* HtmlBuilder.build('u-ref-tag', { href: 'https://example.com', disabled: true }, 'Click');
|
|
25
|
+
* // → '<u-ref-tag href="https://example.com" disabled>Click</u-ref-tag>'
|
|
26
|
+
*/
|
|
27
|
+
static build(tag: string, attrs?: Record<string, string | boolean | object | null | undefined>, content?: string): string;
|
|
28
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { escapeHtmlAttr, escapeHtmlHref } from "./sanitizers.js";
|
|
2
|
+
//#region src/utilities/HtmlBuilder.ts
|
|
3
|
+
var URL_ATTR = /* @__PURE__ */ new Set(["href", "src"]);
|
|
4
|
+
/**
|
|
5
|
+
* 커스텀 엘리먼트 HTML 문자열을 생성하는 유틸리티입니다.
|
|
6
|
+
*/
|
|
7
|
+
var HtmlBuilder = class {
|
|
8
|
+
/**
|
|
9
|
+
* 지정한 태그, 속성, 내용으로 커스텀 엘리먼트 HTML 문자열을 생성합니다.
|
|
10
|
+
*
|
|
11
|
+
* 속성 값 처리 규칙:
|
|
12
|
+
* - `null` / `undefined` → 해당 속성 생략
|
|
13
|
+
* - `false` (boolean) → 해당 속성 생략
|
|
14
|
+
* - `true` (boolean) → 값 없이 키만 출력 (예: `disabled`)
|
|
15
|
+
* - `object` → `JSON.stringify` 후 `escapeHtmlAttr`
|
|
16
|
+
* - `href` / `src` 키 → `escapeHtmlHref` 적용
|
|
17
|
+
* - 그 외 string → `escapeHtmlAttr` 적용
|
|
18
|
+
*
|
|
19
|
+
* `content`는 이미 안전한 HTML 문자열이라고 가정합니다 (내부 escape 없음).
|
|
20
|
+
*
|
|
21
|
+
* @param tag - 커스텀 엘리먼트 태그 이름 (예: `"u-ref-tag"`)
|
|
22
|
+
* @param attrs - 속성 객체
|
|
23
|
+
* @param content - 내부 HTML 문자열 (기본값: `""`)
|
|
24
|
+
* @returns 생성된 HTML 문자열
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* HtmlBuilder.build('u-ref-tag', { href: 'https://example.com', disabled: true }, 'Click');
|
|
28
|
+
* // → '<u-ref-tag href="https://example.com" disabled>Click</u-ref-tag>'
|
|
29
|
+
*/
|
|
30
|
+
static build(tag, attrs = {}, content = "") {
|
|
31
|
+
const attrStr = Object.entries(attrs).flatMap(([k, v]) => {
|
|
32
|
+
if (v === void 0 || v == null || v === false) return [];
|
|
33
|
+
if (v === true) return [k];
|
|
34
|
+
const raw = typeof v === "object" ? JSON.stringify(v) : String(v);
|
|
35
|
+
return [`${k}="${URL_ATTR.has(k) ? escapeHtmlHref(raw) : escapeHtmlAttr(raw)}"`];
|
|
36
|
+
}).join(" ");
|
|
37
|
+
return attrStr ? `<${tag} ${attrStr}>${content}</${tag}>` : `<${tag}>${content}</${tag}>`;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
//#endregion
|
|
41
|
+
export { HtmlBuilder };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ElementSchema } from '../types/Schema.js';
|
|
2
|
+
/**
|
|
3
|
+
* Element(부가 렌더링 블록) 등록, LLM 인스트럭션 빌드, HTML 렌더링을 통합 제공하는 유틸리티
|
|
4
|
+
*/
|
|
5
|
+
export declare class ElementPromptBuilder {
|
|
6
|
+
private static _instance;
|
|
7
|
+
private elements;
|
|
8
|
+
/**
|
|
9
|
+
* 싱글톤 인스턴스를 반환합니다. 최초 호출 시 인스턴스가 생성됩니다.
|
|
10
|
+
*/
|
|
11
|
+
static get instance(): ElementPromptBuilder;
|
|
12
|
+
/**
|
|
13
|
+
* Element 정의를 등록합니다. 같은 태그가 이미 등록되어 있으면 에러를 던집니다.
|
|
14
|
+
* @throws {Error} 같은 태그가 이미 등록된 경우
|
|
15
|
+
*/
|
|
16
|
+
add(schema: ElementSchema): ElementPromptBuilder;
|
|
17
|
+
/**
|
|
18
|
+
* 등록된 Element들에 대한 LLM 인스트럭션 문자열을 생성합니다.
|
|
19
|
+
*/
|
|
20
|
+
build(): string;
|
|
21
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import element_prompt_md_default from "../_virtual/_glob-assets_raw/element-prompt.md.7047ffcc.js";
|
|
2
|
+
//#region src/utilities/PromptBuilder.ts
|
|
3
|
+
/**
|
|
4
|
+
* Element(부가 렌더링 블록) 등록, LLM 인스트럭션 빌드, HTML 렌더링을 통합 제공하는 유틸리티
|
|
5
|
+
*/
|
|
6
|
+
var ElementPromptBuilder = class ElementPromptBuilder {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.elements = /* @__PURE__ */ new Map();
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* 싱글톤 인스턴스를 반환합니다. 최초 호출 시 인스턴스가 생성됩니다.
|
|
12
|
+
*/
|
|
13
|
+
static get instance() {
|
|
14
|
+
if (!this._instance) this._instance = new ElementPromptBuilder();
|
|
15
|
+
return this._instance;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Element 정의를 등록합니다. 같은 태그가 이미 등록되어 있으면 에러를 던집니다.
|
|
19
|
+
* @throws {Error} 같은 태그가 이미 등록된 경우
|
|
20
|
+
*/
|
|
21
|
+
add(schema) {
|
|
22
|
+
if (this.elements.has(schema.tag)) throw new Error(`Element with tag "${schema.tag}" is already registered.`);
|
|
23
|
+
this.elements.set(schema.tag, schema);
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* 등록된 Element들에 대한 LLM 인스트럭션 문자열을 생성합니다.
|
|
28
|
+
*/
|
|
29
|
+
build() {
|
|
30
|
+
if (this.elements.size === 0) return "";
|
|
31
|
+
const docs = Array.from(this.elements.values()).map((def) => {
|
|
32
|
+
return [
|
|
33
|
+
`### ${def.tag}`,
|
|
34
|
+
"",
|
|
35
|
+
"**JSON Schema:**",
|
|
36
|
+
"```block-json",
|
|
37
|
+
JSON.stringify({
|
|
38
|
+
type: "object",
|
|
39
|
+
description: def.description,
|
|
40
|
+
properties: {
|
|
41
|
+
tag: {
|
|
42
|
+
type: "string",
|
|
43
|
+
enum: [def.tag]
|
|
44
|
+
},
|
|
45
|
+
properties: {
|
|
46
|
+
type: "object",
|
|
47
|
+
properties: def.properties || {},
|
|
48
|
+
required: def.required || []
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
required: ["tag"]
|
|
52
|
+
}, null, 2),
|
|
53
|
+
"```"
|
|
54
|
+
].join("\n");
|
|
55
|
+
}).join("\n\n---\n\n");
|
|
56
|
+
return element_prompt_md_default.replace("{{EXTRA_DOCS}}", docs);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
//#endregion
|
|
60
|
+
export { ElementPromptBuilder };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import alert_triangle_fill_svg_default from "../_virtual/_glob-assets_raw/alert-triangle-fill.svg.4cfc4305.js";
|
|
2
|
+
import arrows_sort_svg_default from "../_virtual/_glob-assets_raw/arrows-sort.svg.dda43a85.js";
|
|
3
|
+
import code_svg_default from "../_virtual/_glob-assets_raw/code.svg.c69bc144.js";
|
|
4
|
+
import download_svg_default from "../_virtual/_glob-assets_raw/download.svg.bce82177.js";
|
|
5
|
+
import external_link_svg_default from "../_virtual/_glob-assets_raw/external-link.svg.a9f7f02d.js";
|
|
6
|
+
import file_code_svg_default from "../_virtual/_glob-assets_raw/file-code.svg.0e706f93.js";
|
|
7
|
+
import file_music_svg_default from "../_virtual/_glob-assets_raw/file-music.svg.b9970203.js";
|
|
8
|
+
import file_spreadsheet_svg_default from "../_virtual/_glob-assets_raw/file-spreadsheet.svg.8c03bdfa.js";
|
|
9
|
+
import file_text_svg_default from "../_virtual/_glob-assets_raw/file-text.svg.85bdd923.js";
|
|
10
|
+
import file_type_pdf_svg_default from "../_virtual/_glob-assets_raw/file-type-pdf.svg.bc12db6d.js";
|
|
11
|
+
import file_zip_svg_default from "../_virtual/_glob-assets_raw/file-zip.svg.76dde660.js";
|
|
12
|
+
import file_svg_default from "../_virtual/_glob-assets_raw/file.svg.28f5d6f1.js";
|
|
13
|
+
import photo_svg_default from "../_virtual/_glob-assets_raw/photo.svg.cc273cc1.js";
|
|
14
|
+
import player_stop_fill_svg_default from "../_virtual/_glob-assets_raw/player-stop-fill.svg.5378b752.js";
|
|
15
|
+
import send_svg_default from "../_virtual/_glob-assets_raw/send.svg.02326253.js";
|
|
16
|
+
import sort_ascending_letters_svg_default from "../_virtual/_glob-assets_raw/sort-ascending-letters.svg.14a3df67.js";
|
|
17
|
+
import sort_descending_letters_svg_default from "../_virtual/_glob-assets_raw/sort-descending-letters.svg.3e03647c.js";
|
|
18
|
+
import video_svg_default from "../_virtual/_glob-assets_raw/video.svg.c183f03c.js";
|
|
19
|
+
import world_svg_default from "../_virtual/_glob-assets_raw/world.svg.cd9903c8.js";
|
|
20
|
+
import { IconRegistry } from "@iyulab/components/dist/utilities/icons.js";
|
|
21
|
+
//#region src/utilities/icons.ts
|
|
22
|
+
/**
|
|
23
|
+
* vite의 `import.meta.glob`을 사용하여 chat-components 전용 SVG 아이콘을 빌드 시점에 번들링합니다.
|
|
24
|
+
* 네트워크 요청 없이 즉시 조회 가능하며, 런타임 동안 불변입니다.
|
|
25
|
+
*/
|
|
26
|
+
var InternalChatIconBundle = new Map(Object.entries(/* #__PURE__ */ Object.assign({
|
|
27
|
+
"../assets/icons/alert-triangle-fill.svg": alert_triangle_fill_svg_default,
|
|
28
|
+
"../assets/icons/arrows-sort.svg": arrows_sort_svg_default,
|
|
29
|
+
"../assets/icons/code.svg": code_svg_default,
|
|
30
|
+
"../assets/icons/download.svg": download_svg_default,
|
|
31
|
+
"../assets/icons/external-link.svg": external_link_svg_default,
|
|
32
|
+
"../assets/icons/file-code.svg": file_code_svg_default,
|
|
33
|
+
"../assets/icons/file-music.svg": file_music_svg_default,
|
|
34
|
+
"../assets/icons/file-spreadsheet.svg": file_spreadsheet_svg_default,
|
|
35
|
+
"../assets/icons/file-text.svg": file_text_svg_default,
|
|
36
|
+
"../assets/icons/file-type-pdf.svg": file_type_pdf_svg_default,
|
|
37
|
+
"../assets/icons/file-zip.svg": file_zip_svg_default,
|
|
38
|
+
"../assets/icons/file.svg": file_svg_default,
|
|
39
|
+
"../assets/icons/photo.svg": photo_svg_default,
|
|
40
|
+
"../assets/icons/player-stop-fill.svg": player_stop_fill_svg_default,
|
|
41
|
+
"../assets/icons/send.svg": send_svg_default,
|
|
42
|
+
"../assets/icons/sort-ascending-letters.svg": sort_ascending_letters_svg_default,
|
|
43
|
+
"../assets/icons/sort-descending-letters.svg": sort_descending_letters_svg_default,
|
|
44
|
+
"../assets/icons/video.svg": video_svg_default,
|
|
45
|
+
"../assets/icons/world.svg": world_svg_default
|
|
46
|
+
})).map(([path, module]) => {
|
|
47
|
+
return [path.split("/").pop()?.replace(".svg", "") || "", module];
|
|
48
|
+
}).filter(([name]) => name !== ""));
|
|
49
|
+
IconRegistry.register("internal-chat", (name) => {
|
|
50
|
+
return InternalChatIconBundle.get(name);
|
|
51
|
+
});
|
|
52
|
+
//#endregion
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTML 출력 시 XSS 방지를 위한 escape 유틸
|
|
3
|
+
*
|
|
4
|
+
* 컨텍스트에 맞는 함수를 사용해야 합니다.
|
|
5
|
+
*
|
|
6
|
+
* - escapeHtmlText : HTML 텍스트 노드에 삽입할 때
|
|
7
|
+
* - escapeHtmlAttr : HTML attribute 값에 삽입할 때
|
|
8
|
+
* - escapeHtmlHref : href/src 같은 URL attribute에 삽입할 때
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Zero Width Space / LTR / RTL mark / BOM 등
|
|
12
|
+
* 화면에 표시되지 않는 유니코드 문자를 제거합니다.
|
|
13
|
+
*/
|
|
14
|
+
export declare function stripZeroWidth(value: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* HTML 텍스트 노드(context)에 삽입할 문자열을 escape합니다.
|
|
17
|
+
*
|
|
18
|
+
* 예:
|
|
19
|
+
* <script> → <script>
|
|
20
|
+
*/
|
|
21
|
+
export declare function escapeHtmlText(value: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* HTML attribute 값(context)에 삽입할 문자열을 escape합니다.
|
|
24
|
+
*
|
|
25
|
+
* 예:
|
|
26
|
+
* <div title="{value}">
|
|
27
|
+
*/
|
|
28
|
+
export declare function escapeHtmlAttr(value: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* href / src attribute용 문자열 처리
|
|
31
|
+
*
|
|
32
|
+
* 예:
|
|
33
|
+
* <a href="{value}">
|
|
34
|
+
*/
|
|
35
|
+
export declare function escapeHtmlHref(value: string): string;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
//#region src/utilities/sanitizers.ts
|
|
2
|
+
/**
|
|
3
|
+
* HTML 출력 시 XSS 방지를 위한 escape 유틸
|
|
4
|
+
*
|
|
5
|
+
* 컨텍스트에 맞는 함수를 사용해야 합니다.
|
|
6
|
+
*
|
|
7
|
+
* - escapeHtmlText : HTML 텍스트 노드에 삽입할 때
|
|
8
|
+
* - escapeHtmlAttr : HTML attribute 값에 삽입할 때
|
|
9
|
+
* - escapeHtmlHref : href/src 같은 URL attribute에 삽입할 때
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Zero Width Space / LTR / RTL mark / BOM 등
|
|
13
|
+
* 화면에 표시되지 않는 유니코드 문자를 제거합니다.
|
|
14
|
+
*/
|
|
15
|
+
function stripZeroWidth(value) {
|
|
16
|
+
const ZERO_WIDTH_REGEX = /[\u200B\u200C\u200D\u200E\u200F\uFEFF]/g;
|
|
17
|
+
return ZERO_WIDTH_REGEX.test(value) ? value.replace(ZERO_WIDTH_REGEX, "") : value;
|
|
18
|
+
}
|
|
19
|
+
/** HTML text context escape 대상 문자 */
|
|
20
|
+
var HTML_TEXT_ESCAPE_REGEX = /[&<>"']/g;
|
|
21
|
+
/** HTML text context escape용 문자 매핑 */
|
|
22
|
+
var HTML_TEXT_ESCAPE_MAP = {
|
|
23
|
+
"&": "&",
|
|
24
|
+
"<": "<",
|
|
25
|
+
">": ">",
|
|
26
|
+
"\"": """,
|
|
27
|
+
"'": "'"
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* HTML 텍스트 노드(context)에 삽입할 문자열을 escape합니다.
|
|
31
|
+
*
|
|
32
|
+
* 예:
|
|
33
|
+
* <script> → <script>
|
|
34
|
+
*/
|
|
35
|
+
function escapeHtmlText(value) {
|
|
36
|
+
return HTML_TEXT_ESCAPE_REGEX.test(value) ? value.replace(HTML_TEXT_ESCAPE_REGEX, (ch) => HTML_TEXT_ESCAPE_MAP[ch]) : value;
|
|
37
|
+
}
|
|
38
|
+
/** HTML attribute escape 대상 문자 */
|
|
39
|
+
var HTML_ATTR_ESCAPE_REGEX = /[&<>"]/g;
|
|
40
|
+
/** HTML attribute escape용 문자 매핑 */
|
|
41
|
+
var HTML_ATTR_ESCAPE_MAP = {
|
|
42
|
+
"&": "&",
|
|
43
|
+
"<": "<",
|
|
44
|
+
">": ">",
|
|
45
|
+
"\"": """
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* HTML attribute 값(context)에 삽입할 문자열을 escape합니다.
|
|
49
|
+
*
|
|
50
|
+
* 예:
|
|
51
|
+
* <div title="{value}">
|
|
52
|
+
*/
|
|
53
|
+
function escapeHtmlAttr(value) {
|
|
54
|
+
return HTML_ATTR_ESCAPE_REGEX.test(value) ? value.replace(HTML_ATTR_ESCAPE_REGEX, (ch) => HTML_ATTR_ESCAPE_MAP[ch]) : value;
|
|
55
|
+
}
|
|
56
|
+
/** protocol 우회 공격 방지를 위한 공백/제어문자 제거 */
|
|
57
|
+
var HREF_STRIP_CHARS_REGEX = /[\u0000-\u001F\u007F\s]+/g;
|
|
58
|
+
/** href/src에서 차단해야 하는 위험 protocol */
|
|
59
|
+
var HREF_UNSAFE_PROTOCOL_REGEX = /^(?:javascript|data|vbscript):/i;
|
|
60
|
+
/**
|
|
61
|
+
* href / src attribute용 문자열 처리
|
|
62
|
+
*
|
|
63
|
+
* 예:
|
|
64
|
+
* <a href="{value}">
|
|
65
|
+
*/
|
|
66
|
+
function escapeHtmlHref(value) {
|
|
67
|
+
let normalized = stripZeroWidth(value).trim();
|
|
68
|
+
if (HREF_STRIP_CHARS_REGEX.test(normalized)) normalized = normalized.replace(HREF_STRIP_CHARS_REGEX, "");
|
|
69
|
+
normalized = normalized.replace(/\\/g, "/");
|
|
70
|
+
if (normalized.startsWith("//")) return "#";
|
|
71
|
+
if (HREF_UNSAFE_PROTOCOL_REGEX.test(normalized)) return "#";
|
|
72
|
+
return escapeHtmlAttr(normalized);
|
|
73
|
+
}
|
|
74
|
+
//#endregion
|
|
75
|
+
export { escapeHtmlAttr, escapeHtmlHref, escapeHtmlText, stripZeroWidth };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iyulab/chat-components",
|
|
3
3
|
"description": "llm chat components for building chat interfaces",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.7.0",
|
|
5
5
|
"author": "iyulab",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"keywords": [
|
|
@@ -26,32 +26,27 @@
|
|
|
26
26
|
],
|
|
27
27
|
"type": "module",
|
|
28
28
|
"types": "./dist/index.d.ts",
|
|
29
|
-
"main": "./dist/index.js",
|
|
30
29
|
"exports": {
|
|
31
30
|
".": {
|
|
32
31
|
"types": "./dist/index.d.ts",
|
|
33
32
|
"import": "./dist/index.js"
|
|
34
33
|
},
|
|
35
|
-
"./
|
|
36
|
-
"types": "./dist/chart.d.ts",
|
|
37
|
-
"import": "./dist/chart.js"
|
|
38
|
-
},
|
|
34
|
+
"./extra": "./dist/extra.js",
|
|
39
35
|
"./dist/*": "./dist/*",
|
|
40
36
|
"./react": "./dist/react/index.js",
|
|
41
37
|
"./react/*": "./dist/react/*"
|
|
42
38
|
},
|
|
43
39
|
"scripts": {
|
|
44
|
-
"
|
|
40
|
+
"start": "vite",
|
|
45
41
|
"build": "eslint && vite build"
|
|
46
42
|
},
|
|
47
43
|
"dependencies": {
|
|
48
|
-
"@iyulab/components": "^1.0
|
|
44
|
+
"@iyulab/components": "^1.5.0",
|
|
49
45
|
"highlight.js": "^11.11.1",
|
|
50
|
-
"
|
|
51
|
-
"katex": "^0.16.0",
|
|
46
|
+
"katex": "^0.17.0",
|
|
52
47
|
"lit": "^3.3.3",
|
|
53
|
-
"marked": "^18.0.
|
|
54
|
-
"marked-katex-extension": "^5.1.
|
|
48
|
+
"marked": "^18.0.5",
|
|
49
|
+
"marked-katex-extension": "^5.1.10"
|
|
55
50
|
},
|
|
56
51
|
"peerDependencies": {
|
|
57
52
|
"@lit/react": ">=1.0.8",
|
|
@@ -71,16 +66,16 @@
|
|
|
71
66
|
},
|
|
72
67
|
"devDependencies": {
|
|
73
68
|
"@eslint/js": "^9.39.4",
|
|
74
|
-
"@types/node": "^
|
|
69
|
+
"@types/node": "^26.1.0",
|
|
75
70
|
"chart.js": "^4.5.1",
|
|
76
71
|
"eslint": "^9.39.4",
|
|
77
72
|
"eslint-plugin-lit": "^2.3.1",
|
|
78
73
|
"glob": "^13.0.6",
|
|
79
|
-
"globals": "^17.
|
|
80
|
-
"openai": "^6.
|
|
74
|
+
"globals": "^17.7.0",
|
|
75
|
+
"openai": "^6.45.0",
|
|
81
76
|
"typescript": "^5.9.3",
|
|
82
|
-
"typescript-eslint": "^8.
|
|
83
|
-
"vite": "^8.
|
|
84
|
-
"vite-plugin-dts": "^5.0.
|
|
77
|
+
"typescript-eslint": "^8.63.0",
|
|
78
|
+
"vite": "^8.1.3",
|
|
79
|
+
"vite-plugin-dts": "^5.0.3"
|
|
85
80
|
}
|
|
86
81
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: iyulab-chat-components
|
|
3
|
-
description: LLM chat UI component library. Covers all u-* custom elements for building chat interfaces — message rendering, chat input, markdown/code blocks,
|
|
3
|
+
description: LLM chat UI component library. Covers all u-* custom elements for building chat interfaces — message rendering, chat input, markdown/code/table/file blocks, reference citations, and the block-json Extra system (chart/images/map/video). Use when working with @iyulab/chat-components package.
|
|
4
4
|
license: MIT
|
|
5
5
|
metadata:
|
|
6
6
|
author: iyulab
|
|
7
|
-
version: "0.
|
|
7
|
+
version: "0.7.0"
|
|
8
8
|
---
|
|
9
9
|
|
|
10
10
|
# @iyulab/chat-components
|
|
@@ -43,21 +43,13 @@ import '@iyulab/chat-components/dist/components/prompt/UPrompt.js';
|
|
|
43
43
|
|
|
44
44
|
### Content Blocks
|
|
45
45
|
|
|
46
|
-
- [`u-marked-block`](./references/components/marked-block.md) — Renders markdown to HTML. KaTeX math, code highlighting, citation insertion,
|
|
46
|
+
- [`u-marked-block`](./references/components/marked-block.md) — Renders markdown to HTML. KaTeX math, code highlighting, citation insertion, `block-json` extra handling
|
|
47
47
|
- [`u-code-block`](./references/components/code-block.md) — Highlight.js code block with language label and clipboard copy
|
|
48
48
|
- [`u-text-block`](./references/components/text-block.md) — Plain text display or editable textarea
|
|
49
|
-
- [`u-
|
|
50
|
-
- [`u-tool-block`](./references/components/tool-block.md) — Tool call input/output display. Collapse/expand
|
|
51
|
-
- [`u-file-block`](./references/components/file-block.md) — File attachment card. Type icon, upload status, download, remove
|
|
49
|
+
- [`u-file-block`](./references/components/file-block.md) — File attachment card. Type icon or image/video thumbnail, click-to-preview, remove
|
|
52
50
|
- [`u-ref-block`](./references/components/ref-block.md) — Reference source group block. Collapse/expand, grid of ref cards
|
|
53
|
-
- [`u-json-block`](./references/components/json-block.md) — Visualizes JSON data as a collapsible tree
|
|
54
51
|
- [`u-table-block`](./references/components/table-block.md) — Markdown table renderer. Column sort, search filter, CSV/XLS download
|
|
55
|
-
|
|
56
|
-
### Action Buttons
|
|
57
|
-
|
|
58
|
-
- [`u-copy-button`](./references/components/copy-button.md) — Clipboard copy button; icon changes after copy
|
|
59
|
-
- [`u-vote-button`](./references/components/vote-button.md) — Thumbs-up / thumbs-down vote button pair
|
|
60
|
-
- [`u-attach-button`](./references/components/attach-button.md) — File picker button; fires `attach` event with selected files
|
|
52
|
+
- [`u-element-block`](./references/components/element-block.md) — Generic dynamic custom-element renderer, used internally to render `block-json` extras
|
|
61
53
|
|
|
62
54
|
### Reference Components
|
|
63
55
|
|
|
@@ -65,43 +57,36 @@ import '@iyulab/chat-components/dist/components/prompt/UPrompt.js';
|
|
|
65
57
|
- [`u-ref-card`](./references/components/ref-card.md) — Reference source card. web/document type, favicon, tags
|
|
66
58
|
- [`u-ref-card-group`](./references/components/ref-card-group.md) — Paginated group of reference cards
|
|
67
59
|
|
|
68
|
-
###
|
|
69
|
-
|
|
70
|
-
- [`u-question-intent`](./references/components/question-intent.md) — LLM-generated question with clickable choice buttons
|
|
60
|
+
### Extra Components (optional, `@iyulab/chat-components/extra`)
|
|
71
61
|
|
|
72
|
-
|
|
62
|
+
Not part of the core entrypoint — see [./references/extra-system.md](./references/extra-system.md) for setup.
|
|
73
63
|
|
|
74
|
-
- [`u-images-
|
|
75
|
-
- [`u-video-
|
|
76
|
-
- [`u-chart-
|
|
77
|
-
- [`u-map-
|
|
78
|
-
- [`u-view`](./references/components/view.md) — Dynamic custom element renderer (runtime for view-json blocks)
|
|
64
|
+
- [`u-images-block`](./references/components/images-block.md) — Image gallery (carousel + lightbox)
|
|
65
|
+
- [`u-video-block`](./references/components/video-block.md) — YouTube / Vimeo / direct video file player
|
|
66
|
+
- [`u-chart-block`](./references/components/chart-block.md) — Chart.js charts (bar, line, pie, etc.)
|
|
67
|
+
- [`u-map-block`](./references/components/map-block.md) — OpenStreetMap embed
|
|
79
68
|
|
|
80
69
|
---
|
|
81
70
|
|
|
82
71
|
## Utilities
|
|
83
72
|
|
|
84
|
-
- [`
|
|
85
|
-
- [`
|
|
73
|
+
- [`ElementPromptBuilder`](./references/utilities/prompt-builder.md) — Build LLM system prompt instructions for `block-json` extras/elements
|
|
74
|
+
- [`HtmlBuilder`](./references/utilities/html-builder.md) — Build custom-element HTML strings (used internally by `u-marked-block`)
|
|
86
75
|
|
|
87
76
|
---
|
|
88
77
|
|
|
89
78
|
## Types
|
|
90
79
|
|
|
91
|
-
- [`BlockItem`](./references/types.md) — Union type for message content blocks (text, markdown, file,
|
|
80
|
+
- [`BlockItem`](./references/types.md) — Union type for message content blocks (text, markdown, file, reference)
|
|
92
81
|
- `ReferenceSource` / `ReferenceCitation` — Citation source and inline citation position types
|
|
93
|
-
- `
|
|
94
|
-
- `ViewDefinition` / `PresetView` — View definition and preset bit flags
|
|
82
|
+
- `ElementSchema` / `JsonSchema` — Schema types for registering `block-json` extras/elements with `ElementPromptBuilder`
|
|
95
83
|
|
|
96
84
|
---
|
|
97
85
|
|
|
98
86
|
## Events
|
|
99
87
|
|
|
100
88
|
| Event | Source | Detail Type | Description |
|
|
101
|
-
|
|
102
|
-
| `send` | `u-prompt` | `
|
|
103
|
-
| `stop` | `u-prompt` | `
|
|
104
|
-
| `attach` | `u-attach-button` | `{ files: File[] }` | File selection completed |
|
|
105
|
-
| `choice` | `u-question-intent` | `{ value: string }` | Choice button clicked |
|
|
106
|
-
| `change` | `u-vote-button` | `Event` | Vote state changed |
|
|
89
|
+
|-------|--------|-------------|--------------|
|
|
90
|
+
| `send` | `u-prompt` | `SendEventDetail` (`{ value, files? }`) | Send button clicked or Enter pressed. Non-bubbling |
|
|
91
|
+
| `stop` | `u-prompt` | `StopEventDetail` (`{}`) | Stop button clicked while loading. Non-bubbling |
|
|
107
92
|
| `remove` | `u-file-block` | `RemoveEventDetail` | Remove button clicked |
|