@iyulab/chat-components 0.4.0 → 0.5.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.
Files changed (265) hide show
  1. package/CHANGELOG.md +83 -52
  2. package/README.md +133 -16
  3. package/dist/_virtual/_@oxc-project_runtime@0.124.0/helpers/decorate.js +9 -0
  4. package/dist/_virtual/_@oxc-project_runtime@0.124.0/helpers/decorateMetadata.js +6 -0
  5. package/dist/_virtual/_glob-assets_raw/intent-prompt.md.1907474e.js +4 -0
  6. package/dist/_virtual/_glob-assets_raw/view-prompt.md.e0dbcffe.js +4 -0
  7. package/dist/components/blocks/UCodeBlock.d.ts +24 -2
  8. package/dist/components/blocks/UCodeBlock.js +65 -2
  9. package/dist/components/blocks/UCodeBlock.styles.js +4 -4
  10. package/dist/components/blocks/UFileBlock.d.ts +33 -0
  11. package/dist/components/blocks/UFileBlock.js +154 -0
  12. package/dist/components/blocks/{UFilesBlock.styles.js → UFileBlock.styles.js} +12 -90
  13. package/dist/components/blocks/UJsonBlock.d.ts +44 -2
  14. package/dist/components/blocks/UJsonBlock.js +128 -3
  15. package/dist/components/blocks/UJsonBlock.styles.js +4 -4
  16. package/dist/components/blocks/UMarkedBlock.d.ts +44 -2
  17. package/dist/components/blocks/UMarkedBlock.js +154 -4
  18. package/dist/components/blocks/UMarkedBlock.styles.js +4 -4
  19. package/dist/components/blocks/URefBlock.d.ts +16 -2
  20. package/dist/components/blocks/URefBlock.js +58 -3
  21. package/dist/components/blocks/URefBlock.styles.js +4 -4
  22. package/dist/components/blocks/UTableBlock.d.ts +47 -2
  23. package/dist/components/blocks/UTableBlock.js +197 -4
  24. package/dist/components/blocks/UTableBlock.styles.js +4 -5
  25. package/dist/components/blocks/UTextBlock.d.ts +36 -2
  26. package/dist/components/blocks/UTextBlock.js +94 -4
  27. package/dist/components/blocks/UTextBlock.styles.js +4 -4
  28. package/dist/components/blocks/UThinkBlock.d.ts +30 -2
  29. package/dist/components/blocks/UThinkBlock.js +86 -4
  30. package/dist/components/blocks/UThinkBlock.styles.js +4 -4
  31. package/dist/components/blocks/UToolBlock.d.ts +19 -2
  32. package/dist/components/blocks/UToolBlock.js +68 -3
  33. package/dist/components/blocks/UToolBlock.styles.js +4 -4
  34. package/dist/components/buttons/UAttachButton.d.ts +21 -2
  35. package/dist/components/buttons/UAttachButton.js +61 -3
  36. package/dist/components/buttons/UAttachButton.styles.js +4 -4
  37. package/dist/components/buttons/UCopyButton.d.ts +19 -2
  38. package/dist/components/buttons/UCopyButton.js +57 -3
  39. package/dist/components/buttons/UCopyButton.styles.js +4 -4
  40. package/dist/components/buttons/UVoteButton.d.ts +14 -3
  41. package/dist/components/buttons/UVoteButton.js +62 -3
  42. package/dist/components/buttons/UVoteButton.styles.js +4 -4
  43. package/dist/components/{actions/UQuestionAction.component.d.ts → intents/UQuestionIntent.d.ts} +6 -2
  44. package/dist/components/intents/UQuestionIntent.js +41 -0
  45. package/dist/components/{actions/UQuestionAction.styles.js → intents/UQuestionIntent.styles.js} +4 -6
  46. package/dist/components/message/UMessage.d.ts +18 -2
  47. package/dist/components/message/UMessage.js +47 -2
  48. package/dist/components/message/UMessage.styles.js +4 -4
  49. package/dist/components/prompt/UPrompt.d.ts +37 -2
  50. package/dist/components/prompt/UPrompt.js +139 -2
  51. package/dist/components/prompt/UPrompt.styles.js +15 -5
  52. package/dist/components/references/URefCard.d.ts +30 -2
  53. package/dist/components/references/URefCard.js +97 -2
  54. package/dist/components/references/URefCard.styles.js +4 -4
  55. package/dist/components/references/URefCardGroup.d.ts +25 -2
  56. package/dist/components/references/URefCardGroup.js +69 -4
  57. package/dist/components/references/URefCardGroup.styles.js +4 -4
  58. package/dist/components/references/URefTag.d.ts +12 -2
  59. package/dist/components/references/URefTag.js +37 -2
  60. package/dist/components/references/URefTag.styles.js +4 -4
  61. package/dist/components/{widgets/UChartWidget.component.d.ts → views/UChartView.d.ts} +7 -4
  62. package/dist/components/views/UChartView.js +167 -0
  63. package/dist/components/{widgets/UChartWidget.styles.js → views/UChartView.styles.js} +4 -4
  64. package/dist/components/{widgets/UImagesWidget.component.d.ts → views/UImagesView.d.ts} +7 -4
  65. package/dist/components/views/UImagesView.js +144 -0
  66. package/dist/components/{widgets/UImagesWidget.styles.js → views/UImagesView.styles.js} +6 -5
  67. package/dist/components/{widgets/UMapWidget.component.d.ts → views/UMapView.d.ts} +7 -3
  68. package/dist/components/views/UMapView.js +45 -0
  69. package/dist/components/{widgets/UMapWidget.styles.js → views/UMapView.styles.js} +4 -4
  70. package/dist/components/{widgets/UVideoWidget.component.d.ts → views/UVideoView.d.ts} +7 -3
  71. package/dist/components/views/UVideoView.js +81 -0
  72. package/dist/components/{widgets/UVideoWidget.styles.js → views/UVideoView.styles.js} +4 -4
  73. package/dist/components/{widgets/UWidget.component.d.ts → views/UView.d.ts} +8 -5
  74. package/dist/components/views/UView.js +113 -0
  75. package/dist/components/{widgets/UWidget.styles.js → views/UView.styles.js} +4 -4
  76. package/dist/events/AttachEvent.d.ts +9 -0
  77. package/dist/events/ChoiceEvent.d.ts +9 -0
  78. package/dist/events/SendEvent.d.ts +21 -0
  79. package/dist/events/StopEvent.d.ts +17 -0
  80. package/dist/index.d.ts +13 -16
  81. package/dist/index.js +28 -56
  82. package/dist/react/UAttachButton.d.ts +11 -0
  83. package/dist/react/UAttachButton.js +12 -0
  84. package/dist/react/UChartView.d.ts +9 -0
  85. package/dist/react/UChartView.js +10 -0
  86. package/dist/react/UCodeBlock.d.ts +9 -0
  87. package/dist/react/UCodeBlock.js +10 -0
  88. package/dist/react/UCopyButton.d.ts +9 -0
  89. package/dist/react/UCopyButton.js +10 -0
  90. package/dist/react/UFileBlock.d.ts +11 -0
  91. package/dist/react/UFileBlock.js +12 -0
  92. package/dist/react/UImagesView.d.ts +9 -0
  93. package/dist/react/UImagesView.js +10 -0
  94. package/dist/react/UJsonBlock.d.ts +9 -0
  95. package/dist/react/UJsonBlock.js +10 -0
  96. package/dist/react/UMapView.d.ts +9 -0
  97. package/dist/react/UMapView.js +10 -0
  98. package/dist/react/UMarkedBlock.d.ts +9 -0
  99. package/dist/react/UMarkedBlock.js +10 -0
  100. package/dist/react/UMessage.d.ts +9 -0
  101. package/dist/react/UMessage.js +10 -0
  102. package/dist/react/UPrompt.d.ts +13 -0
  103. package/dist/react/UPrompt.js +13 -0
  104. package/dist/react/UQuestionIntent.d.ts +11 -0
  105. package/dist/react/UQuestionIntent.js +12 -0
  106. package/dist/react/URefBlock.d.ts +9 -0
  107. package/dist/react/URefBlock.js +10 -0
  108. package/dist/react/URefCard.d.ts +9 -0
  109. package/dist/react/URefCard.js +10 -0
  110. package/dist/react/URefCardGroup.d.ts +9 -0
  111. package/dist/react/URefCardGroup.js +10 -0
  112. package/dist/react/URefTag.d.ts +9 -0
  113. package/dist/react/URefTag.js +10 -0
  114. package/dist/react/UTableBlock.d.ts +9 -0
  115. package/dist/react/UTableBlock.js +10 -0
  116. package/dist/react/UTextBlock.d.ts +9 -0
  117. package/dist/react/UTextBlock.js +10 -0
  118. package/dist/react/UThinkBlock.d.ts +9 -0
  119. package/dist/react/UThinkBlock.js +10 -0
  120. package/dist/react/UToolBlock.d.ts +9 -0
  121. package/dist/react/UToolBlock.js +10 -0
  122. package/dist/react/UVideoView.d.ts +9 -0
  123. package/dist/react/UVideoView.js +10 -0
  124. package/dist/react/UView.d.ts +9 -0
  125. package/dist/react/UView.js +10 -0
  126. package/dist/react/UVoteButton.d.ts +9 -0
  127. package/dist/react/UVoteButton.js +10 -0
  128. package/dist/react/index.d.ts +23 -0
  129. package/dist/react/index.js +23 -0
  130. package/dist/types/BlockItem.d.ts +21 -32
  131. package/dist/types/Intents.d.ts +26 -0
  132. package/dist/types/Intents.js +30 -0
  133. package/dist/types/{Widgets.d.ts → Views.d.ts} +8 -8
  134. package/dist/types/Views.js +150 -0
  135. package/dist/utilities/IntentPromptBuilder.d.ts +40 -0
  136. package/dist/utilities/IntentPromptBuilder.js +95 -0
  137. package/dist/utilities/ViewPromptBuilder.d.ts +28 -0
  138. package/dist/utilities/ViewPromptBuilder.js +76 -0
  139. package/dist/utilities/dom-agent/DOMAgent.d.ts +74 -0
  140. package/dist/utilities/dom-agent/DOMController.d.ts +78 -0
  141. package/dist/utilities/dom-agent/DOMPromptBuilder.d.ts +54 -0
  142. package/dist/utilities/dom-agent/DOMScanner.d.ts +83 -0
  143. package/dist/utilities/dom-agent/index.d.ts +9 -0
  144. package/dist/utilities/dom-agent/types.d.ts +209 -0
  145. package/package.json +33 -16
  146. package/skills/iyulab-chat-components/SKILL.md +107 -0
  147. package/skills/iyulab-chat-components/references/components/attach-button.md +69 -0
  148. package/skills/iyulab-chat-components/references/components/chart-view.md +65 -0
  149. package/skills/iyulab-chat-components/references/components/code-block.md +42 -0
  150. package/skills/iyulab-chat-components/references/components/copy-button.md +46 -0
  151. package/skills/iyulab-chat-components/references/components/file-block.md +64 -0
  152. package/skills/iyulab-chat-components/references/components/images-view.md +63 -0
  153. package/skills/iyulab-chat-components/references/components/json-block.md +41 -0
  154. package/skills/iyulab-chat-components/references/components/map-view.md +54 -0
  155. package/skills/iyulab-chat-components/references/components/marked-block.md +53 -0
  156. package/skills/iyulab-chat-components/references/components/message.md +60 -0
  157. package/skills/iyulab-chat-components/references/components/prompt.md +102 -0
  158. package/skills/iyulab-chat-components/references/components/question-intent.md +75 -0
  159. package/skills/iyulab-chat-components/references/components/ref-block.md +45 -0
  160. package/skills/iyulab-chat-components/references/components/ref-card-group.md +41 -0
  161. package/skills/iyulab-chat-components/references/components/ref-card.md +48 -0
  162. package/skills/iyulab-chat-components/references/components/ref-tag.md +40 -0
  163. package/skills/iyulab-chat-components/references/components/table-block.md +63 -0
  164. package/skills/iyulab-chat-components/references/components/text-block.md +59 -0
  165. package/skills/iyulab-chat-components/references/components/think-block.md +48 -0
  166. package/skills/iyulab-chat-components/references/components/tool-block.md +57 -0
  167. package/skills/iyulab-chat-components/references/components/video-view.md +55 -0
  168. package/skills/iyulab-chat-components/references/components/view.md +51 -0
  169. package/skills/iyulab-chat-components/references/components/vote-button.md +60 -0
  170. package/skills/iyulab-chat-components/references/types.md +115 -0
  171. package/skills/iyulab-chat-components/references/usage.md +254 -0
  172. package/skills/iyulab-chat-components/references/utilities/intent-prompt-builder.md +123 -0
  173. package/skills/iyulab-chat-components/references/utilities/view-prompt-builder.md +112 -0
  174. package/dist/assets/action-prompt.md.js +0 -3
  175. package/dist/assets/widget-prompt.md.js +0 -3
  176. package/dist/components/actions/UQuestionAction.component.js +0 -58
  177. package/dist/components/actions/UQuestionAction.d.ts +0 -7
  178. package/dist/components/actions/UQuestionAction.js +0 -5
  179. package/dist/components/blocks/UCodeBlock.component.d.ts +0 -25
  180. package/dist/components/blocks/UCodeBlock.component.js +0 -88
  181. package/dist/components/blocks/UFilesBlock.component.d.ts +0 -22
  182. package/dist/components/blocks/UFilesBlock.component.js +0 -192
  183. package/dist/components/blocks/UFilesBlock.d.ts +0 -7
  184. package/dist/components/blocks/UFilesBlock.js +0 -5
  185. package/dist/components/blocks/UJsonBlock.component.d.ts +0 -45
  186. package/dist/components/blocks/UJsonBlock.component.js +0 -140
  187. package/dist/components/blocks/UMarkedBlock.component.d.ts +0 -40
  188. package/dist/components/blocks/UMarkedBlock.component.js +0 -159
  189. package/dist/components/blocks/URefBlock.component.d.ts +0 -17
  190. package/dist/components/blocks/URefBlock.component.js +0 -73
  191. package/dist/components/blocks/UTableBlock.component.d.ts +0 -49
  192. package/dist/components/blocks/UTableBlock.component.js +0 -228
  193. package/dist/components/blocks/UTextBlock.component.d.ts +0 -37
  194. package/dist/components/blocks/UTextBlock.component.js +0 -123
  195. package/dist/components/blocks/UThinkBlock.component.d.ts +0 -23
  196. package/dist/components/blocks/UThinkBlock.component.js +0 -90
  197. package/dist/components/blocks/UToolBlock.component.d.ts +0 -20
  198. package/dist/components/blocks/UToolBlock.component.js +0 -80
  199. package/dist/components/buttons/UAttachButton.component.d.ts +0 -22
  200. package/dist/components/buttons/UAttachButton.component.js +0 -89
  201. package/dist/components/buttons/UCopyButton.component.d.ts +0 -20
  202. package/dist/components/buttons/UCopyButton.component.js +0 -81
  203. package/dist/components/buttons/UReportButton.component.d.ts +0 -9
  204. package/dist/components/buttons/UReportButton.component.js +0 -36
  205. package/dist/components/buttons/UReportButton.d.ts +0 -7
  206. package/dist/components/buttons/UReportButton.js +0 -5
  207. package/dist/components/buttons/UReportButton.styles.js +0 -14
  208. package/dist/components/buttons/URetryButton.component.d.ts +0 -11
  209. package/dist/components/buttons/URetryButton.component.js +0 -53
  210. package/dist/components/buttons/URetryButton.d.ts +0 -7
  211. package/dist/components/buttons/URetryButton.js +0 -5
  212. package/dist/components/buttons/URetryButton.styles.js +0 -26
  213. package/dist/components/buttons/UShareButton.component.d.ts +0 -9
  214. package/dist/components/buttons/UShareButton.component.js +0 -36
  215. package/dist/components/buttons/UShareButton.d.ts +0 -7
  216. package/dist/components/buttons/UShareButton.js +0 -5
  217. package/dist/components/buttons/UShareButton.styles.js +0 -14
  218. package/dist/components/buttons/UVoteButton.component.d.ts +0 -15
  219. package/dist/components/buttons/UVoteButton.component.js +0 -73
  220. package/dist/components/message/UMessage.component.d.ts +0 -19
  221. package/dist/components/message/UMessage.component.js +0 -56
  222. package/dist/components/prompt/UPrompt.component.d.ts +0 -25
  223. package/dist/components/prompt/UPrompt.component.js +0 -113
  224. package/dist/components/references/URefCard.component.d.ts +0 -27
  225. package/dist/components/references/URefCard.component.js +0 -109
  226. package/dist/components/references/URefCardGroup.component.d.ts +0 -26
  227. package/dist/components/references/URefCardGroup.component.js +0 -88
  228. package/dist/components/references/URefTag.component.d.ts +0 -13
  229. package/dist/components/references/URefTag.component.js +0 -54
  230. package/dist/components/widgets/UChartWidget.component.js +0 -180
  231. package/dist/components/widgets/UChartWidget.d.ts +0 -7
  232. package/dist/components/widgets/UChartWidget.js +0 -5
  233. package/dist/components/widgets/UImagesWidget.component.js +0 -164
  234. package/dist/components/widgets/UImagesWidget.d.ts +0 -7
  235. package/dist/components/widgets/UImagesWidget.js +0 -5
  236. package/dist/components/widgets/UMapWidget.component.js +0 -65
  237. package/dist/components/widgets/UMapWidget.d.ts +0 -7
  238. package/dist/components/widgets/UMapWidget.js +0 -5
  239. package/dist/components/widgets/UMapWidget.styles.d.ts +0 -1
  240. package/dist/components/widgets/UVideoWidget.component.js +0 -106
  241. package/dist/components/widgets/UVideoWidget.d.ts +0 -7
  242. package/dist/components/widgets/UVideoWidget.js +0 -5
  243. package/dist/components/widgets/UVideoWidget.styles.d.ts +0 -1
  244. package/dist/components/widgets/UWidget.component.js +0 -140
  245. package/dist/components/widgets/UWidget.d.ts +0 -7
  246. package/dist/components/widgets/UWidget.js +0 -5
  247. package/dist/components/widgets/UWidget.styles.d.ts +0 -1
  248. package/dist/events/UCancelEvent.d.ts +0 -6
  249. package/dist/events/USubmitEvent.d.ts +0 -6
  250. package/dist/types/Actions.d.ts +0 -24
  251. package/dist/types/Actions.js +0 -34
  252. package/dist/types/Widgets.js +0 -115
  253. package/dist/utilities/ActionPromptBuilder.d.ts +0 -40
  254. package/dist/utilities/ActionPromptBuilder.js +0 -93
  255. package/dist/utilities/WidgetPromptBuilder.d.ts +0 -28
  256. package/dist/utilities/WidgetPromptBuilder.js +0 -87
  257. package/dist/utilities/converters.d.ts +0 -9
  258. package/dist/utilities/converters.js +0 -19
  259. /package/dist/components/{actions/UQuestionAction.styles.d.ts → blocks/UFileBlock.styles.d.ts} +0 -0
  260. /package/dist/components/{blocks/UFilesBlock.styles.d.ts → intents/UQuestionIntent.styles.d.ts} +0 -0
  261. /package/dist/components/{buttons/UReportButton.styles.d.ts → views/UChartView.styles.d.ts} +0 -0
  262. /package/dist/components/{buttons/URetryButton.styles.d.ts → views/UImagesView.styles.d.ts} +0 -0
  263. /package/dist/components/{buttons/UShareButton.styles.d.ts → views/UMapView.styles.d.ts} +0 -0
  264. /package/dist/components/{widgets/UChartWidget.styles.d.ts → views/UVideoView.styles.d.ts} +0 -0
  265. /package/dist/components/{widgets/UImagesWidget.styles.d.ts → views/UView.styles.d.ts} +0 -0
@@ -1,140 +0,0 @@
1
- import { html, nothing } from 'lit';
2
- import { property, state } from 'lit/decorators.js';
3
- import { UJsonElement } from '@iyulab/components/dist/components/UJsonElement.js';
4
- import { USkeleton } from '@iyulab/components/dist/components/skeleton/USkeleton.component.js';
5
- import { styles } from './UWidget.styles.js';
6
-
7
- var __defProp = Object.defineProperty;
8
- var __decorateClass = (decorators, target, key, kind) => {
9
- var result = void 0 ;
10
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
11
- if (decorator = decorators[i])
12
- result = (decorator(target, key, result) ) || result;
13
- if (result) __defProp(target, key, result);
14
- return result;
15
- };
16
- const DEFAULT_BLACKLIST = ["innerHTML", "outerHTML", "textContent", "innerText", "outerText", "srcdoc"];
17
- class UWidget extends UJsonElement {
18
- constructor() {
19
- super(...arguments);
20
- this.loading = false;
21
- this.blacklist = DEFAULT_BLACKLIST;
22
- this.element = null;
23
- }
24
- static {
25
- this.styles = [super.styles, styles];
26
- }
27
- static {
28
- this.dependencies = {
29
- "u-skeleton": USkeleton
30
- };
31
- }
32
- willUpdate(changedProperties) {
33
- super.willUpdate(changedProperties);
34
- if (changedProperties.has("tag")) {
35
- this.updateElement(this.tag);
36
- }
37
- if (changedProperties.has("properties") && this.element) {
38
- this.updateProperties(this.element, this.properties);
39
- }
40
- if (changedProperties.has("blacklist") && this.element && this.properties) {
41
- this.updateProperties(this.element, this.properties);
42
- }
43
- }
44
- render() {
45
- if (this.loading === true) {
46
- return html`
47
- <div class="sk-container">
48
- <div class="sk-card">
49
- <u-skeleton effect="shimmer" width="100%" height="5em" shape="default"></u-skeleton>
50
- <u-skeleton effect="shimmer" width="80%" height="0.8em" shape="rounded"></u-skeleton>
51
- <u-skeleton effect="shimmer" width="40%" height="0.75em" shape="rounded"></u-skeleton>
52
- </div>
53
- <div class="sk-doc">
54
- <u-skeleton effect="shimmer" width="40%" height="0.75em" shape="rounded"></u-skeleton>
55
- <u-skeleton effect="shimmer" width="80%" height="0.75em" shape="rounded"></u-skeleton>
56
- <u-skeleton effect="shimmer" width="60%" height="0.8em" shape="rounded"></u-skeleton>
57
- <u-skeleton effect="shimmer" width="100%" height="0.8em" shape="rounded"></u-skeleton>
58
- <u-skeleton effect="shimmer" width="80%" height="0.8em" shape="rounded"></u-skeleton>
59
- </div>
60
- </div>`;
61
- }
62
- if (this.element != null) {
63
- return this.element;
64
- }
65
- return nothing;
66
- }
67
- /**
68
- * `loading`이 `true`인 경우, 에러 UI로 대체하지 않습니다.
69
- */
70
- async error(error) {
71
- if (this.loading) return;
72
- await super.error(error);
73
- }
74
- /**
75
- * `tag` 프로퍼티에 등록된 커스텀 엘리먼트를 렌더링하는 컴포넌트입니다.
76
- * `tag`가 변경될 때마다 등록된 커스텀 엘리먼트를 새로 생성하여 렌더링합니다.
77
- * `tag`가 유효하지 않거나 등록된 커스텀 엘리먼트가 아닌 경우, 에러 처리합니다.
78
- */
79
- updateElement(tag) {
80
- tag = tag?.trim();
81
- if (!tag) {
82
- this.element = null;
83
- void super.error(new Error("Tag is required"));
84
- return;
85
- }
86
- if (!customElements.get(tag)) {
87
- this.element = null;
88
- void super.error(new Error(`Unknown tag: ${tag}`));
89
- return;
90
- }
91
- this.element = document.createElement(tag);
92
- }
93
- /**
94
- * `properties` 객체의 키가 렌더링된 엘리먼트의 프로퍼티 이름과 일치하면 자동으로 할당됩니다.
95
- * `properties` 객체에 위험한 프로퍼티가 포함되어 있는지 검증하여, 유효한 경우에만 할당합니다.
96
- * 할당 중 오류가 발생한 경우, 에러 처리합니다.
97
- */
98
- updateProperties(element, props) {
99
- if (this.validateProperties(props)) {
100
- try {
101
- Object.assign(element, props);
102
- } catch (error) {
103
- void super.error(error);
104
- }
105
- } else {
106
- void super.error(new Error(`Not allowed properties: ${JSON.stringify(props)}`));
107
- }
108
- }
109
- /**
110
- * `properties` 객체에 위험한 프로퍼티가 포함되어 있는지 검증합니다.
111
- * DOM 조작이나 이벤트 핸들러로 악용될 수 있는 프로퍼티를 최소한으로 차단합니다.
112
- */
113
- validateProperties(props) {
114
- if (typeof props !== "object" || props === null || Array.isArray(props)) {
115
- return false;
116
- }
117
- const obj = props;
118
- for (const key of Object.keys(obj)) {
119
- if (this.blacklist.includes(key)) return false;
120
- }
121
- return true;
122
- }
123
- }
124
- __decorateClass([
125
- property({ type: Boolean, reflect: true })
126
- ], UWidget.prototype, "loading");
127
- __decorateClass([
128
- property({ type: String })
129
- ], UWidget.prototype, "tag");
130
- __decorateClass([
131
- property({ type: Object })
132
- ], UWidget.prototype, "properties");
133
- __decorateClass([
134
- property({ type: Array })
135
- ], UWidget.prototype, "blacklist");
136
- __decorateClass([
137
- state()
138
- ], UWidget.prototype, "element");
139
-
140
- export { UWidget };
@@ -1,7 +0,0 @@
1
- import { UWidget } from './UWidget.component.js';
2
- declare global {
3
- interface HTMLElementTagNameMap {
4
- "u-widget": UWidget;
5
- }
6
- }
7
- export { UWidget };
@@ -1,5 +0,0 @@
1
- import { UWidget } from './UWidget.component.js';
2
-
3
- UWidget.define("u-widget");
4
-
5
- export { UWidget };
@@ -1 +0,0 @@
1
- export declare const styles: import('lit').CSSResult;
@@ -1,6 +0,0 @@
1
- export type UCancelEvent = CustomEvent<undefined>;
2
- declare global {
3
- interface HTMLElementEventMap {
4
- 'u-cancel': UCancelEvent;
5
- }
6
- }
@@ -1,6 +0,0 @@
1
- export type USubmitEvent = CustomEvent<string>;
2
- declare global {
3
- interface HTMLElementEventMap {
4
- 'u-submit': USubmitEvent;
5
- }
6
- }
@@ -1,24 +0,0 @@
1
- import { JsonSchema } from '../types/JsonSchema.js';
2
- /** LLM에서 action-json 블록으로 출력되는 구조입니다.*/
3
- export interface ActionSchema {
4
- type: string;
5
- properties?: Record<string, unknown>;
6
- }
7
- /** Action 정의 구조체 */
8
- export interface ActionDefinition {
9
- /** action 식별자 (action-json의 "type" 필드와 매칭) */
10
- type: string;
11
- /** LLM용 설명 */
12
- description: string;
13
- /** LLM용 속성 스키마 */
14
- properties?: Record<string, JsonSchema>;
15
- }
16
- /** 프리셋 Action 비트 플래그 */
17
- export declare enum PresetAction {
18
- Questions = 1,
19
- All = 1
20
- }
21
- /** 프리셋 Action 목록 (비트 플래그 순서대로) */
22
- export declare const PRESET_ACTION_LIST: readonly [PresetAction];
23
- /** 프리셋 Action 정의 매핑 */
24
- export declare const PRESET_ACTION_DEFINITIONS: Map<PresetAction, ActionDefinition>;
@@ -1,34 +0,0 @@
1
- var PresetAction = /* @__PURE__ */ ((PresetAction2) => {
2
- PresetAction2[PresetAction2["Questions"] = 1] = "Questions";
3
- PresetAction2[PresetAction2["All"] = 1 /* Questions */] = "All";
4
- return PresetAction2;
5
- })(PresetAction || {});
6
- const PRESET_ACTION_LIST = [
7
- 1 /* Questions */
8
- ];
9
- const PRESET_ACTION_DEFINITIONS = /* @__PURE__ */ new Map([
10
- [
11
- 1 /* Questions */,
12
- {
13
- type: "question",
14
- description: "Present a question to the user with clickable choices",
15
- properties: {
16
- question: {
17
- type: "string",
18
- description: 'Optional question text displayed above the choices (e.g. "What would you like to explore?")',
19
- examples: ["What would you like to do next?"]
20
- },
21
- choices: {
22
- type: "array",
23
- items: { type: "string" },
24
- minItems: 1,
25
- maxItems: 5,
26
- description: "Clickable choice buttons (1–5 items)",
27
- examples: [["What are the main differences?", "Can you show me an example?", "What should I learn next?"]]
28
- }
29
- }
30
- }
31
- ]
32
- ]);
33
-
34
- export { PRESET_ACTION_DEFINITIONS, PRESET_ACTION_LIST, PresetAction };
@@ -1,115 +0,0 @@
1
- import { UImagesWidget } from '../components/widgets/UImagesWidget.component.js';
2
- import { UVideoWidget } from '../components/widgets/UVideoWidget.component.js';
3
- import { UMapWidget } from '../components/widgets/UMapWidget.component.js';
4
- import { UChartWidget } from '../components/widgets/UChartWidget.component.js';
5
-
6
- var PresetWidget = /* @__PURE__ */ ((PresetWidget2) => {
7
- PresetWidget2[PresetWidget2["Images"] = 1] = "Images";
8
- PresetWidget2[PresetWidget2["Video"] = 2] = "Video";
9
- PresetWidget2[PresetWidget2["Map"] = 8] = "Map";
10
- PresetWidget2[PresetWidget2["Chart"] = 16] = "Chart";
11
- PresetWidget2[PresetWidget2["All"] = 27] = "All";
12
- return PresetWidget2;
13
- })(PresetWidget || {});
14
- const PRESET_WIDGET_LIST = [
15
- 1 /* Images */,
16
- 2 /* Video */,
17
- 8 /* Map */,
18
- 16 /* Chart */
19
- ];
20
- const PRESET_WIDGET_DEFINITIONS = /* @__PURE__ */ new Map([
21
- [
22
- 1 /* Images */,
23
- {
24
- element: UImagesWidget,
25
- tag: "u-images-widget",
26
- description: "Display multiple images in a scrollable gallery",
27
- properties: {
28
- items: {
29
- type: "array",
30
- items: {
31
- type: "object",
32
- properties: {
33
- src: { type: "string", description: "Image URL" },
34
- alt: { type: "string", description: "Alt text for accessibility" },
35
- caption: { type: "string", description: "Image caption" }
36
- },
37
- required: ["src"]
38
- },
39
- minItems: 1,
40
- description: "Array of image objects"
41
- }
42
- },
43
- required: ["items"]
44
- }
45
- ],
46
- [
47
- 2 /* Video */,
48
- {
49
- element: UVideoWidget,
50
- tag: "u-video-widget",
51
- description: "Embed video from YouTube, Vimeo, or Others. Provide a direct video file URL or a platform URL.",
52
- properties: {
53
- src: { type: "string", description: "Video URL (YouTube, Vimeo, or direct video file URL)" },
54
- poster: { type: "string", description: "Poster image URL" },
55
- ratio: {
56
- type: "string",
57
- enum: ["16:9", "4:3", "1:1"],
58
- default: "16:9",
59
- description: "Video aspect ratio"
60
- }
61
- },
62
- required: ["src"]
63
- }
64
- ],
65
- [
66
- 8 /* Map */,
67
- {
68
- element: UMapWidget,
69
- tag: "u-map-widget",
70
- description: "Display a map showing a single location",
71
- properties: {
72
- lat: { type: "number", description: "Latitude coordinate" },
73
- lng: { type: "number", description: "Longitude coordinate" },
74
- zoom: {
75
- type: "integer",
76
- minimum: 1,
77
- maximum: 20,
78
- default: 15,
79
- description: "Map zoom level"
80
- },
81
- label: { type: "string", description: "Location title" },
82
- description: { type: "string", description: "Location description" }
83
- },
84
- required: ["lat", "lng"]
85
- }
86
- ],
87
- [
88
- 16 /* Chart */,
89
- {
90
- element: UChartWidget,
91
- tag: "u-chart-widget",
92
- description: "Display charts using Chart.js v4 format. Use standard Chart.js configuration (type, data, options). The widget accepts the exact same structure as Chart.js - no conversion needed.",
93
- properties: {
94
- type: {
95
- type: "string",
96
- enum: ["bar", "line", "pie", "doughnut", "radar", "polarArea", "bubble", "scatter"],
97
- description: "Chart.js chart type"
98
- },
99
- data: {
100
- type: "object",
101
- description: "Chart.js data configuration",
102
- additionalProperties: true
103
- },
104
- options: {
105
- type: "object",
106
- description: "Chart.js options configuration (optional)",
107
- additionalProperties: true
108
- }
109
- },
110
- required: ["type", "data"]
111
- }
112
- ]
113
- ]);
114
-
115
- export { PRESET_WIDGET_DEFINITIONS, PRESET_WIDGET_LIST, PresetWidget };
@@ -1,40 +0,0 @@
1
- import { PresetAction, ActionDefinition, ActionSchema } from '../types/Actions.js';
2
- /**
3
- * Action 등록, LLM 인스트럭션 빌드, 텍스트 추출을 통합 제공하는 유틸리티
4
- *
5
- * @example
6
- * ActionPromptBuilder.use(PresetAction.All);
7
- * const prompt = ActionPromptBuilder.buildPrompt();
8
- * const [clean, templates] = ActionPromptBuilder.extractPrompt(llmText);
9
- */
10
- export declare class ActionPromptBuilder {
11
- private static _instance;
12
- private actions;
13
- /**
14
- * 싱글톤 인스턴스를 반환합니다. 최초 호출 시 인스턴스가 생성됩니다.
15
- */
16
- static get instance(): ActionPromptBuilder;
17
- /**
18
- * Action 정의를 등록합니다. 같은 type이 이미 등록되어 있으면 에러를 던집니다.
19
- * @throws {Error} 같은 type의 action이 이미 등록된 경우
20
- */
21
- add(definition: ActionDefinition): ActionPromptBuilder;
22
- /**
23
- * 미리 정의된 프리셋 Action을 등록합니다.
24
- * @example
25
- * ActionPromptBuilder.use(PresetAction.Questions);
26
- * ActionPromptBuilder.use(PresetAction.All);
27
- */
28
- use(flags: PresetAction): ActionPromptBuilder;
29
- /**
30
- * 등록된 action들에 대한 LLM 시스템 프롬프트 인스트럭션을 생성합니다.
31
- */
32
- build(): string;
33
- /**
34
- * LLM 응답 텍스트에서 `action-json` 코드블록을 추출합니다.
35
- *
36
- * @param value - LLM 응답 텍스트
37
- * @returns `[actions, rest]` — actions는 파싱된 JSON 객체 배열, rest는 블록이 제거된 나머지 텍스트
38
- */
39
- parse(value: string): [ActionSchema[], string];
40
- }
@@ -1,93 +0,0 @@
1
- import template from '../assets/action-prompt.md.js';
2
- import { PRESET_ACTION_LIST, PRESET_ACTION_DEFINITIONS } from '../types/Actions.js';
3
-
4
- class ActionPromptBuilder {
5
- constructor() {
6
- this.actions = /* @__PURE__ */ new Map();
7
- }
8
- /**
9
- * 싱글톤 인스턴스를 반환합니다. 최초 호출 시 인스턴스가 생성됩니다.
10
- */
11
- static get instance() {
12
- if (!this._instance) {
13
- this._instance = new ActionPromptBuilder();
14
- }
15
- return this._instance;
16
- }
17
- /**
18
- * Action 정의를 등록합니다. 같은 type이 이미 등록되어 있으면 에러를 던집니다.
19
- * @throws {Error} 같은 type의 action이 이미 등록된 경우
20
- */
21
- add(definition) {
22
- if (this.actions.has(definition.type)) {
23
- throw new Error(`Action with type "${definition.type}" is already registered.`);
24
- }
25
- this.actions.set(definition.type, definition);
26
- return this;
27
- }
28
- /**
29
- * 미리 정의된 프리셋 Action을 등록합니다.
30
- * @example
31
- * ActionPromptBuilder.use(PresetAction.Questions);
32
- * ActionPromptBuilder.use(PresetAction.All);
33
- */
34
- use(flags) {
35
- for (const flag of PRESET_ACTION_LIST) {
36
- if (flags & flag) {
37
- const definition = PRESET_ACTION_DEFINITIONS.get(flag);
38
- if (definition && !this.actions.has(definition.type)) {
39
- this.actions.set(definition.type, definition);
40
- }
41
- }
42
- }
43
- return this;
44
- }
45
- /**
46
- * 등록된 action들에 대한 LLM 시스템 프롬프트 인스트럭션을 생성합니다.
47
- */
48
- build() {
49
- if (this.actions.size === 0) return "";
50
- const defs = Array.from(this.actions.values());
51
- const actionList = defs.map((d) => `- \`${d.type}\`: ${d.description}`).join("\n");
52
- const actionDocs = defs.map((def) => {
53
- const lines = [
54
- `### ${def.type}`,
55
- "",
56
- def.description,
57
- "",
58
- `**Type:** \`${def.type}\``
59
- ];
60
- if (def.properties) {
61
- lines.push(
62
- "",
63
- "**Properties (JSON Schema):**",
64
- "```json",
65
- JSON.stringify({ type: "object", properties: def.properties }, null, 2),
66
- "```"
67
- );
68
- }
69
- return lines.join("\n");
70
- }).join("\n\n---\n\n");
71
- return template.replace("{{ACTION_LIST}}", actionList).replace("{{ACTION_DOCS}}", actionDocs);
72
- }
73
- /**
74
- * LLM 응답 텍스트에서 `action-json` 코드블록을 추출합니다.
75
- *
76
- * @param value - LLM 응답 텍스트
77
- * @returns `[actions, rest]` — actions는 파싱된 JSON 객체 배열, rest는 블록이 제거된 나머지 텍스트
78
- */
79
- parse(value) {
80
- const pattern = /```action-json\s*([\s\S]*?)```/g;
81
- const actions = [];
82
- const rest = value.replace(pattern, (_, json) => {
83
- try {
84
- actions.push(JSON.parse(json.trim()));
85
- } catch {
86
- }
87
- return "";
88
- }).trim();
89
- return [actions, rest];
90
- }
91
- }
92
-
93
- export { ActionPromptBuilder };
@@ -1,28 +0,0 @@
1
- import { PresetWidget, WidgetDefinition } from '../types/Widgets.js';
2
- /**
3
- * 위젯 등록, LLM 인스트럭션 빌드, HTML 렌더링을 통합 제공하는 유틸리티
4
- */
5
- export declare class WidgetPromptBuilder {
6
- private static _instance;
7
- private widgets;
8
- /**
9
- * 싱글톤 인스턴스를 반환합니다. 최초 호출 시 인스턴스가 생성됩니다.
10
- */
11
- static get instance(): WidgetPromptBuilder;
12
- /**
13
- * 위젯 정의를 등록합니다. 같은 이름의 위젯이 이미 등록되어 있으면 에러를 던집니다.
14
- * @throws {Error} 같은 이름의 위젯이 이미 등록된 경우 또는 같은 태그의 커스텀 요소가 다른 클래스에 의해 정의된 경우
15
- */
16
- add(definition: WidgetDefinition): WidgetPromptBuilder;
17
- /**
18
- * 미리 정의된 프리셋 위젯을 사용합니다.
19
- * @example
20
- * WidgetRegistry.use(Widget.Images | Widget.Chart);
21
- * WidgetRegistry.use(Widget.All);
22
- */
23
- use(flags: PresetWidget): WidgetPromptBuilder;
24
- /**
25
- * 등록된 위젯들에 대한 LLM 인스트럭션 문자열을 생성합니다.
26
- */
27
- build(): string;
28
- }
@@ -1,87 +0,0 @@
1
- import template from '../assets/widget-prompt.md.js';
2
- import { UElement } from '@iyulab/components/dist/components/UElement.js';
3
- import { PRESET_WIDGET_LIST, PRESET_WIDGET_DEFINITIONS } from '../types/Widgets.js';
4
-
5
- class WidgetPromptBuilder {
6
- constructor() {
7
- this.widgets = /* @__PURE__ */ new Map();
8
- }
9
- /**
10
- * 싱글톤 인스턴스를 반환합니다. 최초 호출 시 인스턴스가 생성됩니다.
11
- */
12
- static get instance() {
13
- if (!this._instance) {
14
- this._instance = new WidgetPromptBuilder();
15
- }
16
- return this._instance;
17
- }
18
- /**
19
- * 위젯 정의를 등록합니다. 같은 이름의 위젯이 이미 등록되어 있으면 에러를 던집니다.
20
- * @throws {Error} 같은 이름의 위젯이 이미 등록된 경우 또는 같은 태그의 커스텀 요소가 다른 클래스에 의해 정의된 경우
21
- */
22
- add(definition) {
23
- if (this.widgets.has(definition.tag)) {
24
- throw new Error(`Widget with tag "${definition.tag}" is already registered.`);
25
- }
26
- const constructor = customElements.get(definition.tag);
27
- if (constructor && constructor !== definition.element) {
28
- throw new Error(`Custom element with tag "${definition.tag}" is already defined to a different class.`);
29
- }
30
- if (definition.element.prototype instanceof UElement) {
31
- definition.element.define(definition.tag);
32
- } else {
33
- customElements.define(definition.tag, definition.element);
34
- }
35
- this.widgets.set(definition.tag, definition);
36
- return this;
37
- }
38
- /**
39
- * 미리 정의된 프리셋 위젯을 사용합니다.
40
- * @example
41
- * WidgetRegistry.use(Widget.Images | Widget.Chart);
42
- * WidgetRegistry.use(Widget.All);
43
- */
44
- use(flags) {
45
- for (const flag of PRESET_WIDGET_LIST) {
46
- if (flags & flag) {
47
- const definition = PRESET_WIDGET_DEFINITIONS.get(flag);
48
- if (definition) {
49
- this.add(definition);
50
- }
51
- }
52
- }
53
- return this;
54
- }
55
- /**
56
- * 등록된 위젯들에 대한 LLM 인스트럭션 문자열을 생성합니다.
57
- */
58
- build() {
59
- if (this.widgets.size === 0) return "";
60
- const widgets = Array.from(this.widgets.values());
61
- const widgetList = widgets.map((w) => `- \`${w.tag}\`: ${w.description}`).join("\n");
62
- const widgetDocs = widgets.map((w) => {
63
- const lines = [
64
- `### ${w.tag}`,
65
- "",
66
- `**Tag:** \`${w.tag}\``
67
- ];
68
- if (w.properties) {
69
- lines.push(
70
- "",
71
- "**Properties (JSON Schema):**",
72
- "```json",
73
- JSON.stringify({
74
- type: "object",
75
- properties: w.properties,
76
- ...w.required ? { required: w.required } : {}
77
- }, null, 2),
78
- "```"
79
- );
80
- }
81
- return lines.join("\n");
82
- }).join("\n\n---\n\n");
83
- return template.replace("{{WIDGET_LIST}}", widgetList).replace("{{WIDGET_DOCS}}", widgetDocs);
84
- }
85
- }
86
-
87
- export { WidgetPromptBuilder };
@@ -1,9 +0,0 @@
1
- import { JsonNode } from '../types/JsonNode';
2
- /**
3
- * 이 컨버터는 JsonNode 타입을 사용하여 JSON 데이터를 처리합니다.
4
- * 문자열 어트리뷰트로 전달된 JSON 문자열을 객체로 변환/직렬화합니다.
5
- */
6
- export declare const jsonAttrConverter: {
7
- fromAttribute: (value: string | null) => JsonNode;
8
- toAttribute: (value: JsonNode) => string;
9
- };
@@ -1,19 +0,0 @@
1
- const jsonAttrConverter = {
2
- fromAttribute: (value) => {
3
- if (!value || !value.trim()) return {};
4
- try {
5
- return JSON.parse(value);
6
- } catch {
7
- return {};
8
- }
9
- },
10
- toAttribute: (value) => {
11
- try {
12
- return JSON.stringify(value);
13
- } catch {
14
- return "{}";
15
- }
16
- }
17
- };
18
-
19
- export { jsonAttrConverter };