@openviking/react 0.1.3 → 0.1.5

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 (209) hide show
  1. package/LICENSE.arco-design +21 -0
  2. package/README.md +27 -15
  3. package/dist/0~0.js +19 -0
  4. package/dist/28~0.js +15 -0
  5. package/dist/2~0.js +2270 -29
  6. package/dist/2~0.js.LICENSE.txt +23 -0
  7. package/dist/3c~0.js +2208 -0
  8. package/dist/3~0.js +1207 -1982
  9. package/dist/4~0.js +18 -0
  10. package/dist/9~0.js +43 -0
  11. package/dist/{1~0.js → ae~0.js} +11 -26
  12. package/dist/ark-message-list-view~0.js +530 -119
  13. package/dist/a~0.js +1300 -14
  14. package/dist/c7~0.js +38 -2
  15. package/dist/ck~0.js +23 -0
  16. package/dist/client/provider.d.ts +15 -9
  17. package/dist/client/types.d.ts +5 -5
  18. package/dist/client.js +2 -1
  19. package/dist/components/agent-connect/agent-connect-code-block.d.ts +14 -0
  20. package/dist/components/agent-connect/agent-connect-copy.d.ts +22 -33
  21. package/dist/components/agent-connect/agent-connect-design.d.ts +1936 -168
  22. package/dist/components/agent-connect/agent-connect-installer.d.ts +1 -0
  23. package/dist/components/agent-connect/agent-connect-instructions-view.d.ts +4 -6
  24. package/dist/components/agent-connect/agent-connect-instructions.d.ts +148 -0
  25. package/dist/components/agent-connect/agent-connect-markdown.d.ts +8 -2
  26. package/dist/components/agent-connect/agent-connect-mask.d.ts +10 -0
  27. package/dist/components/agent-connect/agent-connect.d.ts +1 -1
  28. package/dist/components/agent-connect/locales/en-US.d.ts +23 -0
  29. package/dist/components/agent-connect/locales/zh-CN.d.ts +3 -0
  30. package/dist/components/agent-connect/style.css +129 -3
  31. package/dist/components/agent-connect/types.d.ts +7 -4
  32. package/dist/components/agent-connect/use-agent-connect-copy.d.ts +6 -0
  33. package/dist/components/directory-tour/directory-tour.d.ts +3 -0
  34. package/dist/components/directory-tour/index.d.ts +3 -0
  35. package/dist/components/directory-tour/locales/en-US.d.ts +3 -0
  36. package/dist/components/directory-tour/locales/zh-CN.d.ts +3 -0
  37. package/dist/components/directory-tour/steps.d.ts +5 -0
  38. package/dist/components/directory-tour/style.css +237 -0
  39. package/dist/components/directory-tour/style.js +0 -0
  40. package/dist/components/directory-tour/types.d.ts +43 -0
  41. package/dist/components/directory-tour/use-tour-anchor.d.ts +5 -0
  42. package/dist/components/directory-tour/use-tour-position.d.ts +12 -0
  43. package/dist/components/directory-tour.js +40 -0
  44. package/dist/components/file-browser-entries/file-browser-entries.d.ts +5 -5
  45. package/dist/components/file-browser-entries/labels.d.ts +3 -0
  46. package/dist/components/file-browser-entries/locales/en-US.d.ts +6 -0
  47. package/dist/components/file-browser-entries/locales/zh-CN.d.ts +6 -0
  48. package/dist/components/file-browser-entries/style.css +866 -2
  49. package/dist/components/file-browser-entries/types.d.ts +34 -16
  50. package/dist/components/file-preview/file-preview-adapters.d.ts +2 -1
  51. package/dist/components/file-preview/file-preview-body.d.ts +2 -1
  52. package/dist/components/file-preview/file-preview-breadcrumb-menu.d.ts +2 -1
  53. package/dist/components/file-preview/file-preview-breadcrumb.d.ts +2 -1
  54. package/dist/components/file-preview/file-preview-directory.d.ts +2 -1
  55. package/dist/components/file-preview/file-preview-handle-adapters.d.ts +2 -1
  56. package/dist/components/file-preview/file-preview-header.d.ts +6 -2
  57. package/dist/components/file-preview/file-preview-image-frame.d.ts +5 -0
  58. package/dist/components/file-preview/file-preview-labels.d.ts +2 -14
  59. package/dist/components/file-preview/file-preview-level-tabs.d.ts +7 -0
  60. package/dist/components/file-preview/file-preview-markdown-images.d.ts +13 -0
  61. package/dist/components/file-preview/file-preview-panels.d.ts +5 -2
  62. package/dist/components/file-preview/file-preview-viewer.d.ts +2 -1
  63. package/dist/components/file-preview/file-preview.d.ts +0 -1
  64. package/dist/components/file-preview/index.d.ts +2 -1
  65. package/dist/components/file-preview/locales/en-US.d.ts +16 -0
  66. package/dist/components/file-preview/locales/zh-CN.d.ts +16 -0
  67. package/dist/components/file-preview/style.css +160 -2
  68. package/dist/components/file-preview/types.d.ts +34 -10
  69. package/dist/components/file-preview/use-file-preview-levels.d.ts +7 -0
  70. package/dist/components/file-preview/use-file-preview-view-state.d.ts +15 -0
  71. package/dist/components/file-preview.js +1 -1
  72. package/dist/components/file-tree/file-tree-info-labels.d.ts +0 -15
  73. package/dist/components/file-tree/file-tree-labels.d.ts +4 -0
  74. package/dist/components/file-tree/file-tree-row-shared.d.ts +2 -12
  75. package/dist/components/file-tree/file-tree-toolbar.d.ts +11 -0
  76. package/dist/components/file-tree/locales/en-US.d.ts +69 -0
  77. package/dist/components/file-tree/locales/zh-CN.d.ts +69 -0
  78. package/dist/components/file-tree/style.css +143 -15
  79. package/dist/components/file-tree/types.d.ts +38 -10
  80. package/dist/components/file-tree/use-file-tree-actions.d.ts +4 -1
  81. package/dist/components/scope-switcher/labels.d.ts +3 -0
  82. package/dist/components/scope-switcher/locales/en-US.d.ts +8 -0
  83. package/dist/components/scope-switcher/locales/zh-CN.d.ts +8 -0
  84. package/dist/components/scope-switcher/scope-panel.d.ts +1 -1
  85. package/dist/components/scope-switcher/scope-switcher.d.ts +2 -2
  86. package/dist/components/scope-switcher/style.css +14 -2
  87. package/dist/components/scope-switcher/types.d.ts +12 -6
  88. package/dist/components/style.css +10030 -6763
  89. package/dist/components/tui/locales/en-US.d.ts +35 -0
  90. package/dist/components/tui/locales/zh-CN.d.ts +35 -0
  91. package/dist/components/tui/style.css +310 -18
  92. package/dist/components/tui/tui-copy-button.d.ts +1 -1
  93. package/dist/components/tui/tui-empty.d.ts +25 -0
  94. package/dist/components/tui/tui-labels.d.ts +2 -2
  95. package/dist/components/tui/tui.d.ts +1 -1
  96. package/dist/components/tui/types.d.ts +35 -12
  97. package/dist/components/tui.js +1 -1
  98. package/dist/components/viking-bot/ark-adapter.d.ts +2 -0
  99. package/dist/components/viking-bot/ark-message-body.d.ts +1 -7
  100. package/dist/components/viking-bot/ark-message-list-view.d.ts +4 -1
  101. package/dist/components/viking-bot/ark-message-row.d.ts +3 -1
  102. package/dist/components/viking-bot/bot-popover.d.ts +9 -0
  103. package/dist/components/viking-bot/capabilities.d.ts +49 -0
  104. package/dist/components/viking-bot/composer-attachments.d.ts +13 -0
  105. package/dist/components/viking-bot/composer-controls.d.ts +10 -0
  106. package/dist/components/viking-bot/composer-footer.d.ts +17 -0
  107. package/dist/components/viking-bot/composer-references.d.ts +20 -0
  108. package/dist/components/viking-bot/composer-text.d.ts +10 -0
  109. package/dist/components/viking-bot/index.d.ts +3 -1
  110. package/dist/components/viking-bot/interaction/ask-human-fields.d.ts +1 -1
  111. package/dist/components/viking-bot/interaction/labels.d.ts +2 -1
  112. package/dist/components/viking-bot/interaction/locales/en-US.d.ts +17 -0
  113. package/dist/components/viking-bot/interaction/locales/zh-CN.d.ts +17 -0
  114. package/dist/components/viking-bot/interaction/types.d.ts +8 -3
  115. package/dist/components/viking-bot/interaction/viking-bot-interaction.d.ts +1 -1
  116. package/dist/components/viking-bot/labels.d.ts +2 -0
  117. package/dist/components/viking-bot/locales/en-US.d.ts +40 -0
  118. package/dist/components/viking-bot/locales/zh-CN.d.ts +40 -0
  119. package/dist/components/viking-bot/markdown-links.d.ts +27 -0
  120. package/dist/components/viking-bot/message-activity.d.ts +7 -0
  121. package/dist/components/viking-bot/message-code-block.d.ts +8 -0
  122. package/dist/components/viking-bot/message-footer.d.ts +8 -0
  123. package/dist/components/viking-bot/message-markdown.d.ts +9 -0
  124. package/dist/components/viking-bot/model.d.ts +37 -3
  125. package/dist/components/viking-bot/quick-input-tracker.d.ts +16 -0
  126. package/dist/components/viking-bot/quick-inputs.d.ts +6 -0
  127. package/dist/components/viking-bot/reference-picker.d.ts +16 -0
  128. package/dist/components/viking-bot/session-actions.d.ts +11 -0
  129. package/dist/components/viking-bot/style.css +1486 -48
  130. package/dist/components/viking-bot/tool-activity.d.ts +9 -0
  131. package/dist/components/viking-bot/tool-result-links.d.ts +6 -0
  132. package/dist/components/viking-bot/types.d.ts +20 -8
  133. package/dist/components/viking-bot/use-quick-input.d.ts +17 -0
  134. package/dist/components/viking-bot/viking-bot.d.ts +1 -6
  135. package/dist/components/viking-bot/welcome.d.ts +8 -0
  136. package/dist/components/viking-bot.js +1 -1
  137. package/dist/c~0.js +550 -69
  138. package/dist/e~0.js +335 -0
  139. package/dist/file-preview-viewer~0.js +90 -8
  140. package/dist/f~0.js +49 -51
  141. package/dist/h~0.js +5 -1
  142. package/dist/icons/console-icons.d.ts +12 -0
  143. package/dist/icons/index.d.ts +2 -0
  144. package/dist/icons/viking-bot-icons.d.ts +6 -0
  145. package/dist/icons.js +1 -0
  146. package/dist/index.d.ts +2 -0
  147. package/dist/index.js +2 -1
  148. package/dist/k~0.js +1 -0
  149. package/dist/lg~0.js +155 -0
  150. package/dist/lk~0.js +40 -8
  151. package/dist/l~0.js +170 -181
  152. package/dist/modules/console/command-messages.d.ts +19 -0
  153. package/dist/modules/console/command-parser.d.ts +15 -0
  154. package/dist/modules/console/command-specs.d.ts +15 -0
  155. package/dist/modules/console/commands.d.ts +6 -0
  156. package/dist/modules/console/console-history.d.ts +10 -0
  157. package/dist/modules/console/console-toolbar.d.ts +18 -0
  158. package/dist/modules/console/console.d.ts +1 -3
  159. package/dist/modules/console/controller.d.ts +17 -0
  160. package/dist/modules/console/index.d.ts +2 -0
  161. package/dist/modules/console/labels.d.ts +61 -0
  162. package/dist/modules/console/locales/en-US.d.ts +49 -0
  163. package/dist/modules/console/locales/zh-CN.d.ts +3 -0
  164. package/dist/modules/console/localize-records.d.ts +11 -0
  165. package/dist/modules/console/results.d.ts +2 -0
  166. package/dist/modules/console/style.css +10905 -15
  167. package/dist/modules/console/types.d.ts +59 -80
  168. package/dist/modules/console/use-console.d.ts +3 -0
  169. package/dist/modules/console.js +1 -1
  170. package/dist/modules/file-browser/file-browser-detail.d.ts +2 -1
  171. package/dist/modules/file-browser/file-browser-labels.d.ts +11 -12
  172. package/dist/modules/file-browser/file-browser-toolbar.d.ts +3 -4
  173. package/dist/modules/file-browser/file-browser-tree-pane.d.ts +7 -5
  174. package/dist/modules/file-browser/file-browser.d.ts +1 -1
  175. package/dist/modules/file-browser/fs-read-directory.d.ts +2 -6
  176. package/dist/modules/file-browser/locales/en-US.d.ts +25 -0
  177. package/dist/modules/file-browser/locales/zh-CN.d.ts +25 -0
  178. package/dist/modules/file-browser/style.css +1695 -126
  179. package/dist/modules/file-browser/types.d.ts +38 -29
  180. package/dist/modules/file-browser/use-file-browser.d.ts +6 -1
  181. package/dist/modules/file-browser/use-fs-preview.d.ts +15 -1
  182. package/dist/modules/scope-cascade/labels.d.ts +6 -0
  183. package/dist/modules/scope-cascade/locales/en-US.d.ts +6 -0
  184. package/dist/modules/scope-cascade/locales/zh-CN.d.ts +3 -0
  185. package/dist/modules/scope-cascade/scope-cascade.d.ts +2 -2
  186. package/dist/modules/scope-cascade/style.css +14 -2
  187. package/dist/modules/scope-cascade/types.d.ts +3 -0
  188. package/dist/modules/style.css +15938 -3455
  189. package/dist/nx~0.js +15 -0
  190. package/dist/n~0.js +240 -83
  191. package/dist/o~0.js +10 -7
  192. package/dist/p~0.js +27 -0
  193. package/dist/rslib-runtime~0.js +42 -0
  194. package/dist/r~0.js +152 -0
  195. package/dist/shared/components/drawer/drawer.d.ts +13 -0
  196. package/dist/shared/components/drawer/index.d.ts +1 -0
  197. package/dist/shared/components/overlay/use-overlay-position.d.ts +2 -2
  198. package/dist/shared/components/tooltip/use-portal-theme.d.ts +3 -0
  199. package/dist/shared/locale-context.d.ts +8 -0
  200. package/dist/shared/locale.d.ts +6 -0
  201. package/dist/style.css +26339 -10577
  202. package/dist/u~0.js +397 -152
  203. package/dist/viking-bot-composer~0.js +436 -77
  204. package/dist/viking-bot-interaction~0.js +13 -11
  205. package/package.json +15 -4
  206. package/dist/30~0.js +0 -1332
  207. package/dist/components/tui/tui-labels-zh.d.ts +0 -2
  208. package/dist/modules/file-browser/tree-info-copy.d.ts +0 -15
  209. package/dist/modules/file-browser/tree-info-copy.zh-CN.d.ts +0 -15
package/dist/e~0.js ADDED
@@ -0,0 +1,335 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useId, useRef, useState } from "react";
3
+ import { createPortal } from "react-dom";
4
+ import { useLocale } from "./28~0.js";
5
+ import { resolveLocale } from "./nx~0.js";
6
+ function useTourAnchor(target, locateTarget, timeout, attempt) {
7
+ const [state, setState] = useState({
8
+ anchor: null,
9
+ failed: false
10
+ });
11
+ useEffect(()=>{
12
+ const controller = new AbortController();
13
+ setState({
14
+ anchor: null,
15
+ failed: false
16
+ });
17
+ const timer = window.setTimeout(()=>{
18
+ controller.abort();
19
+ setState({
20
+ anchor: null,
21
+ failed: true
22
+ });
23
+ }, timeout);
24
+ Promise.resolve().then(()=>locateTarget?.(target, controller.signal) ?? null).then((anchor)=>{
25
+ if (controller.signal.aborted) return;
26
+ window.clearTimeout(timer);
27
+ if (anchor?.isConnected) {
28
+ anchor.scrollIntoView({
29
+ block: 'nearest',
30
+ inline: 'nearest'
31
+ });
32
+ setState({
33
+ anchor,
34
+ failed: false
35
+ });
36
+ } else setState({
37
+ anchor: null,
38
+ failed: true
39
+ });
40
+ }, ()=>{
41
+ if (controller.signal.aborted) return;
42
+ window.clearTimeout(timer);
43
+ setState({
44
+ anchor: null,
45
+ failed: true
46
+ });
47
+ });
48
+ return ()=>{
49
+ controller.abort();
50
+ window.clearTimeout(timer);
51
+ };
52
+ }, [
53
+ target,
54
+ locateTarget,
55
+ timeout,
56
+ attempt
57
+ ]);
58
+ return state;
59
+ }
60
+ function useTourPosition(anchor, surface, placement) {
61
+ const [position, setPosition] = useState();
62
+ useEffect(()=>{
63
+ if (!surface) return;
64
+ surface.showPopover?.();
65
+ const update = ()=>{
66
+ const a = anchor?.getBoundingClientRect();
67
+ const box = surface.getBoundingClientRect();
68
+ const width = window.innerWidth;
69
+ const height = window.innerHeight;
70
+ const margin = 8;
71
+ let left = (width - box.width) / 2;
72
+ let top = (height - box.height) / 2;
73
+ const missing = Boolean(anchor && !anchor.isConnected);
74
+ let visible = !anchor || missing;
75
+ if (anchor && a && !missing) {
76
+ let clip = {
77
+ left: 0,
78
+ top: 0,
79
+ right: width,
80
+ bottom: height
81
+ };
82
+ for(let parent = anchor.parentElement; parent; parent = parent.parentElement){
83
+ const css = window.getComputedStyle(parent);
84
+ const rect = parent.getBoundingClientRect();
85
+ if (/(auto|scroll|hidden|clip)/.test(css.overflowX)) clip = {
86
+ ...clip,
87
+ left: Math.max(clip.left, rect.left),
88
+ right: Math.min(clip.right, rect.right)
89
+ };
90
+ if (/(auto|scroll|hidden|clip)/.test(css.overflowY)) clip = {
91
+ ...clip,
92
+ top: Math.max(clip.top, rect.top),
93
+ bottom: Math.min(clip.bottom, rect.bottom)
94
+ };
95
+ }
96
+ visible = anchor.isConnected && a.width > 0 && a.height > 0 && a.top < clip.bottom && a.bottom > clip.top && a.left < clip.right && a.right > clip.left;
97
+ const right = a.right + 6;
98
+ const leftSide = a.left - box.width - 6;
99
+ left = 'right' === placement ? right + box.width <= width - margin || leftSide < margin ? right : leftSide : leftSide >= margin || right + box.width > width - margin ? leftSide : right;
100
+ top = a.top - 16;
101
+ const css = window.getComputedStyle(anchor);
102
+ for(let i = 0; i < css.length; i++){
103
+ const name = css[i];
104
+ if (name?.startsWith('--ov-ui-')) surface.style.setProperty(name, css.getPropertyValue(name));
105
+ }
106
+ }
107
+ const next = {
108
+ left: Math.max(margin, Math.min(left, width - box.width - margin)),
109
+ top: Math.max(margin, Math.min(top, height - box.height - margin)),
110
+ targetTop: a?.top ?? 0,
111
+ targetLeft: a?.left ?? 0,
112
+ targetWidth: a?.width ?? 0,
113
+ targetHeight: a?.height ?? 0,
114
+ visible,
115
+ missing
116
+ };
117
+ setPosition((old)=>old && Object.keys(next).every((key)=>old[key] === next[key]) ? old : next);
118
+ };
119
+ update();
120
+ const resize = new ResizeObserver(update);
121
+ resize.observe(surface);
122
+ for(let node = anchor; node; node = node.parentElement)resize.observe(node);
123
+ const mutation = new MutationObserver(update);
124
+ mutation.observe(document.body, {
125
+ childList: true,
126
+ subtree: true
127
+ });
128
+ window.addEventListener('scroll', update, true);
129
+ window.addEventListener('resize', update);
130
+ window.visualViewport?.addEventListener('resize', update);
131
+ window.visualViewport?.addEventListener('scroll', update);
132
+ return ()=>{
133
+ resize.disconnect();
134
+ mutation.disconnect();
135
+ window.removeEventListener('scroll', update, true);
136
+ window.removeEventListener('resize', update);
137
+ window.visualViewport?.removeEventListener('resize', update);
138
+ window.visualViewport?.removeEventListener('scroll', update);
139
+ if (surface.isConnected) surface.hidePopover?.();
140
+ };
141
+ }, [
142
+ anchor,
143
+ surface,
144
+ placement
145
+ ]);
146
+ return position;
147
+ }
148
+ const messages = {
149
+ close: 'Close guide',
150
+ next: 'Next',
151
+ done: 'Got it',
152
+ locating: 'Locating directory…',
153
+ unavailable: 'This directory is unavailable. Retry or skip this step.',
154
+ retry: 'Retry',
155
+ skip: 'Skip',
156
+ progress: (current, total)=>`${current}/${total}`
157
+ };
158
+ const en_US = messages;
159
+ const zh_CN_messages = {
160
+ close: '关闭引导',
161
+ next: '下一步',
162
+ done: '知道了',
163
+ locating: '正在定位目录…',
164
+ unavailable: '此目录暂不可用,请重试或跳过这一步。',
165
+ retry: '重试',
166
+ skip: '跳过',
167
+ progress: (current, total)=>`${current}/${total}`
168
+ };
169
+ const zh_CN = zh_CN_messages;
170
+ function DirectoryTour(props) {
171
+ if (!props.open || 0 === props.steps.length) return null;
172
+ return /*#__PURE__*/ jsx(TourSession, {
173
+ ...props
174
+ });
175
+ }
176
+ function TourSession(props) {
177
+ const [index, setIndex] = useState(props.defaultStep ?? 0);
178
+ const skipped = useRef(new Set());
179
+ const current = props.currentStep ?? index;
180
+ const step = props.steps[current];
181
+ if (!step) return null;
182
+ const advance = (skip)=>{
183
+ if (skip) skipped.current.add(step.id);
184
+ if (current === props.steps.length - 1) props.onComplete?.({
185
+ skippedStepIds: [
186
+ ...skipped.current
187
+ ]
188
+ });
189
+ else {
190
+ if (void 0 === props.currentStep) setIndex(current + 1);
191
+ props.onStepChange?.(current + 1);
192
+ }
193
+ };
194
+ return /*#__PURE__*/ jsx(TourStep, {
195
+ ...props,
196
+ step: step,
197
+ index: current,
198
+ advance: advance
199
+ }, step.id);
200
+ }
201
+ function TourStep({ step, index, advance, steps, locateTarget, locateTimeout = 10000, placement = 'right', onClose, labels, locale: localeProp, className, style }) {
202
+ const locale = useLocale(localeProp);
203
+ const text = resolveLocale({
204
+ 'en-US': en_US,
205
+ 'zh-CN': zh_CN
206
+ }, locale, labels);
207
+ const [attempt, retry] = useState(0);
208
+ const [surface, setSurface] = useState(null);
209
+ const { anchor, failed } = useTourAnchor(step.target, locateTarget, locateTimeout, attempt);
210
+ const position = useTourPosition(anchor, surface, placement);
211
+ const titleId = useId();
212
+ const bodyId = useId();
213
+ useEffect(()=>{
214
+ const close = (event)=>{
215
+ if ('Escape' === event.key) {
216
+ event.preventDefault();
217
+ onClose?.();
218
+ }
219
+ };
220
+ document.addEventListener('keydown', close);
221
+ return ()=>document.removeEventListener('keydown', close);
222
+ }, [
223
+ onClose
224
+ ]);
225
+ useEffect(()=>{
226
+ const previous = document.activeElement;
227
+ return ()=>{
228
+ if (previous instanceof HTMLElement && previous.isConnected) previous.focus({
229
+ preventScroll: true
230
+ });
231
+ };
232
+ }, []);
233
+ const visible = position?.visible;
234
+ useEffect(()=>{
235
+ if (surface && visible) surface.focus({
236
+ preventScroll: true
237
+ });
238
+ }, [
239
+ surface,
240
+ visible
241
+ ]);
242
+ if ("u" < typeof document) return null;
243
+ const unavailable = failed || position?.missing;
244
+ const locating = !anchor && !failed;
245
+ return /*#__PURE__*/ createPortal(/*#__PURE__*/ jsxs("div", {
246
+ ref: setSurface,
247
+ popover: "manual",
248
+ role: "dialog",
249
+ "aria-modal": "false",
250
+ "aria-labelledby": titleId,
251
+ "aria-describedby": bodyId,
252
+ "aria-busy": locating,
253
+ tabIndex: -1,
254
+ className: [
255
+ 'ov-directory-tour',
256
+ className
257
+ ].filter(Boolean).join(' '),
258
+ style: {
259
+ ...style,
260
+ top: position?.top ?? 0,
261
+ left: position?.left ?? 0,
262
+ visibility: position?.visible ? 'visible' : 'hidden'
263
+ },
264
+ children: [
265
+ anchor && !unavailable && position?.visible && /*#__PURE__*/ jsx("div", {
266
+ className: "ov-directory-tour__highlight",
267
+ "aria-hidden": "true",
268
+ style: {
269
+ top: position.targetTop,
270
+ left: position.targetLeft,
271
+ width: position.targetWidth,
272
+ height: position.targetHeight
273
+ }
274
+ }),
275
+ /*#__PURE__*/ jsxs("div", {
276
+ className: "ov-directory-tour__card",
277
+ children: [
278
+ onClose && /*#__PURE__*/ jsx("button", {
279
+ className: "ov-directory-tour__close",
280
+ type: "button",
281
+ "aria-label": text.close,
282
+ onClick: onClose,
283
+ children: "\xd7"
284
+ }),
285
+ !locating && !unavailable && step.illustration && /*#__PURE__*/ jsx("div", {
286
+ className: "ov-directory-tour__illustration",
287
+ children: step.illustration
288
+ }),
289
+ /*#__PURE__*/ jsx("h2", {
290
+ id: titleId,
291
+ className: "ov-directory-tour__title",
292
+ children: step.title
293
+ }),
294
+ /*#__PURE__*/ jsx("div", {
295
+ id: bodyId,
296
+ className: "ov-directory-tour__description",
297
+ role: unavailable ? 'alert' : void 0,
298
+ children: unavailable ? text.unavailable : locating ? text.locating : step.description
299
+ }),
300
+ /*#__PURE__*/ jsxs("footer", {
301
+ className: "ov-directory-tour__actions",
302
+ children: [
303
+ /*#__PURE__*/ jsx("span", {
304
+ className: "ov-directory-tour__progress",
305
+ "aria-live": "polite",
306
+ children: text.progress(index + 1, steps.length)
307
+ }),
308
+ unavailable ? /*#__PURE__*/ jsxs(Fragment, {
309
+ children: [
310
+ /*#__PURE__*/ jsx("button", {
311
+ type: "button",
312
+ onClick: ()=>retry((value)=>value + 1),
313
+ children: text.retry
314
+ }),
315
+ /*#__PURE__*/ jsx("button", {
316
+ type: "button",
317
+ onClick: ()=>advance(true),
318
+ children: text.skip
319
+ })
320
+ ]
321
+ }) : /*#__PURE__*/ jsx("button", {
322
+ type: "button",
323
+ className: "ov-directory-tour__primary",
324
+ disabled: locating,
325
+ onClick: ()=>advance(false),
326
+ children: step.nextLabel ?? (index === steps.length - 1 ? text.done : text.next)
327
+ })
328
+ ]
329
+ })
330
+ ]
331
+ })
332
+ ]
333
+ }), document.body);
334
+ }
335
+ export { DirectoryTour };
@@ -13,8 +13,42 @@ import { powerpoint } from "@ark-design/ui/file-viewer/adapters/powerpoint";
13
13
  import { table } from "@ark-design/ui/file-viewer/adapters/table";
14
14
  import { text as text_text } from "@ark-design/ui/file-viewer/adapters/text";
15
15
  import { word } from "@ark-design/ui/file-viewer/adapters/word";
16
- import { toFileSource, LoadFailedState, LoadingState, UnsupportedState } from "./30~0.js";
17
- function createFilePreviewAdapterList({ onLinkClick } = {}) {
16
+ import { toFileSource, LoadFailedState, LoadingState, UnsupportedState } from "./3~0.js";
17
+ const PREFIX = './__ov_viking_image__/';
18
+ function imagePreviewTarget(url) {
19
+ return /^viking:\/\//i.test(url) ? PREFIX + encodeURIComponent(url) : url;
20
+ }
21
+ function originalImageTarget(url) {
22
+ if (!url.startsWith(PREFIX)) return url;
23
+ try {
24
+ const original = decodeURIComponent(url.slice(PREFIX.length));
25
+ return /^viking:\/\//i.test(original) ? original : url;
26
+ } catch {
27
+ return url;
28
+ }
29
+ }
30
+ function preserveVikingImages(root) {
31
+ const definitions = new Map();
32
+ function collect(node) {
33
+ if ('definition' === node.type && node.identifier && !definitions.has(node.identifier.toUpperCase())) definitions.set(node.identifier.toUpperCase(), node);
34
+ node.children?.forEach(collect);
35
+ }
36
+ function visit(node) {
37
+ if ('image' === node.type && node.url) node.url = imagePreviewTarget(node.url);
38
+ if ('imageReference' === node.type && node.identifier) {
39
+ const definition = definitions.get(node.identifier.toUpperCase());
40
+ if (definition?.url && /^viking:\/\//i.test(definition.url)) {
41
+ node.type = 'image';
42
+ node.url = imagePreviewTarget(definition.url);
43
+ node.title = definition.title;
44
+ }
45
+ }
46
+ node.children?.forEach(visit);
47
+ }
48
+ collect(root);
49
+ visit(root);
50
+ }
51
+ function createFilePreviewAdapterList({ onLinkClick, resolveImage } = {}) {
18
52
  return [
19
53
  code({
20
54
  showLineNumbers: true
@@ -26,7 +60,31 @@ function createFilePreviewAdapterList({ onLinkClick } = {}) {
26
60
  defaultExpandDepth: 4
27
61
  }),
28
62
  markdown({
29
- onLinkClick
63
+ onLinkClick,
64
+ rendererProps: {
65
+ astPlugins: (current)=>[
66
+ ...current,
67
+ {
68
+ name: 'ov-viking-images',
69
+ config: {
70
+ priority: 2
71
+ },
72
+ modifier: (root)=>{
73
+ preserveVikingImages(root);
74
+ },
75
+ before: ()=>{},
76
+ after: ()=>{},
77
+ beforeEach: ()=>{},
78
+ afterEach: ()=>{}
79
+ }
80
+ ],
81
+ imageOptions: {
82
+ processSrcBeforeLoad: resolveImage ? (src)=>resolveImage(originalImageTarget(src)) : void 0,
83
+ forceHttps: false,
84
+ objectFit: 'contain',
85
+ responsiveNaturalSize: true
86
+ }
87
+ }
30
88
  }),
31
89
  html(),
32
90
  table(),
@@ -44,9 +102,10 @@ function createFilePreviewAdapterList({ onLinkClick } = {}) {
44
102
  diff()
45
103
  ];
46
104
  }
47
- function createFilePreviewAdapters({ onHandleChange, onViewModesChange, onLinkClick }) {
105
+ function createFilePreviewAdapters({ onHandleChange, onViewModesChange, onLinkClick, resolveImage }) {
48
106
  return createFilePreviewAdapterList({
49
- onLinkClick
107
+ onLinkClick,
108
+ resolveImage
50
109
  }).map((adapter)=>{
51
110
  const wrap = (context)=>{
52
111
  const descriptor = adapter(context);
@@ -89,14 +148,37 @@ function sourceDeps(source) {
89
148
  }
90
149
  function FilePreviewViewer({ tab, text, locale, viewMode, onViewModeChange, onDownload, onHandleChange, onViewModesChange, onLinkClick }) {
91
150
  const source = useMemo(()=>toFileSource(tab.source), sourceDeps(tab.source));
151
+ const imageInput = useRef(tab.source);
152
+ imageInput.current = tab.source;
153
+ const imageResolver = tab.resolveImage;
154
+ const resolveImage = useCallback((src)=>imageResolver(src, imageInput.current), [
155
+ imageResolver
156
+ ]);
157
+ const resources = useMemo(()=>tab.resources?.flatMap((resource)=>{
158
+ const key = imagePreviewTarget(resource.key);
159
+ return key === resource.key ? [
160
+ resource
161
+ ] : [
162
+ resource,
163
+ {
164
+ ...resource,
165
+ key
166
+ }
167
+ ];
168
+ }), [
169
+ tab.resources
170
+ ]);
92
171
  const adapters = useMemo(()=>createFilePreviewAdapters({
93
172
  onHandleChange,
94
173
  onViewModesChange,
95
- onLinkClick
174
+ onLinkClick,
175
+ resolveImage: imageResolver ? resolveImage : void 0
96
176
  }), [
97
177
  onHandleChange,
98
178
  onViewModesChange,
99
- onLinkClick
179
+ onLinkClick,
180
+ resolveImage,
181
+ imageResolver
100
182
  ]);
101
183
  const canDownload = Boolean(tab.operations?.download);
102
184
  const latest = useRef({
@@ -177,7 +259,7 @@ function FilePreviewViewer({ tab, text, locale, viewMode, onViewModeChange, onDo
177
259
  adapters: adapters,
178
260
  className: "ov-file-preview__viewer",
179
261
  locale: locale,
180
- resources: tab.resources,
262
+ resources: resources,
181
263
  slots: slots,
182
264
  source: source,
183
265
  toolbar: false,
package/dist/f~0.js CHANGED
@@ -1,5 +1,9 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useCallback, useEffect, useId, useRef, useState } from "react";
3
+ import { resolveLocale } from "./nx~0.js";
4
+ import { checkreact } from "./0~0.js";
5
+ import { searchreact } from "./p~0.js";
6
+ import { useLocale, LocaleProvider } from "./28~0.js";
3
7
  const SvgChevronDown = (props)=>/*#__PURE__*/ jsx("svg", {
4
8
  xmlns: "http://www.w3.org/2000/svg",
5
9
  width: 14,
@@ -13,6 +17,33 @@ const SvgChevronDown = (props)=>/*#__PURE__*/ jsx("svg", {
13
17
  })
14
18
  });
15
19
  const chevron_downreact = SvgChevronDown;
20
+ const messages = {
21
+ loading: 'Loading…',
22
+ searchPlaceholder: 'Search',
23
+ empty: 'No options',
24
+ noMatch: 'No matches',
25
+ error: 'Unable to load options'
26
+ };
27
+ const en_US = messages;
28
+ const zh_CN_messages = {
29
+ loading: '加载中…',
30
+ searchPlaceholder: '搜索',
31
+ empty: '暂无选项',
32
+ noMatch: '没有匹配项',
33
+ error: '选项加载失败'
34
+ };
35
+ const zh_CN = zh_CN_messages;
36
+ const LOCALES = {
37
+ 'en-US': en_US,
38
+ 'zh-CN': zh_CN
39
+ };
40
+ function resolveScopeLabels(locale = 'en-US', labels) {
41
+ const defaults = resolveLocale(LOCALES, locale, labels);
42
+ return {
43
+ ...defaults,
44
+ noMatch: labels?.noMatch ?? labels?.empty ?? defaults.noMatch
45
+ };
46
+ }
16
47
  function moveScopeFocus(event) {
17
48
  if (![
18
49
  'ArrowDown',
@@ -30,46 +61,6 @@ function moveScopeFocus(event) {
30
61
  const next = 'Home' === event.key ? 0 : 'End' === event.key ? options.length - 1 : 'ArrowDown' === event.key ? (current + 1) % options.length : current < 0 ? options.length - 1 : (current - 1 + options.length) % options.length;
31
62
  options[next]?.focus();
32
63
  }
33
- const SvgCheck = (props)=>/*#__PURE__*/ jsx("svg", {
34
- xmlns: "http://www.w3.org/2000/svg",
35
- width: 16,
36
- height: 16,
37
- fill: "none",
38
- viewBox: "0 0 16 16",
39
- ...props,
40
- children: /*#__PURE__*/ jsx("path", {
41
- stroke: "currentColor",
42
- strokeLinecap: "round",
43
- strokeLinejoin: "round",
44
- strokeWidth: 1.2,
45
- d: "M13.333 4 6 11.333 2.667 8"
46
- })
47
- });
48
- const checkreact = SvgCheck;
49
- const SvgSearch = (props)=>/*#__PURE__*/ jsx("svg", {
50
- xmlns: "http://www.w3.org/2000/svg",
51
- width: 16,
52
- height: 16,
53
- fill: "none",
54
- viewBox: "0 0 16 16",
55
- ...props,
56
- children: /*#__PURE__*/ jsxs("g", {
57
- stroke: "currentColor",
58
- strokeWidth: 1.2,
59
- children: [
60
- /*#__PURE__*/ jsx("circle", {
61
- cx: 7.167,
62
- cy: 7.167,
63
- r: 4.667
64
- }),
65
- /*#__PURE__*/ jsx("path", {
66
- strokeLinecap: "round",
67
- d: "m10.667 10.667 3 3"
68
- })
69
- ]
70
- })
71
- });
72
- const searchreact = SvgSearch;
73
64
  function Highlight({ text, keyword }) {
74
65
  const needle = keyword.trim().toLocaleLowerCase();
75
66
  if (!needle) return /*#__PURE__*/ jsx(Fragment, {
@@ -112,8 +103,8 @@ function ScopePanel({ label, data, state, slots, actions, onSelect, labels }) {
112
103
  type: "search",
113
104
  className: "ov-scope-switcher__search",
114
105
  value: keyword,
115
- "aria-label": labels?.searchPlaceholder ?? 'Search',
116
- placeholder: labels?.searchPlaceholder ?? 'Search',
106
+ "aria-label": labels.searchPlaceholder,
107
+ placeholder: labels.searchPlaceholder,
117
108
  onChange: (event)=>actions?.onSearchKeywordChange?.(event.currentTarget.value)
118
109
  })
119
110
  ]
@@ -122,11 +113,11 @@ function ScopePanel({ label, data, state, slots, actions, onSelect, labels }) {
122
113
  list = state?.loading ? /*#__PURE__*/ jsx("div", {
123
114
  className: "ov-scope-switcher__state",
124
115
  role: "status",
125
- children: labels?.loading ?? 'Loading…'
116
+ children: labels.loading
126
117
  }) : state?.error ? /*#__PURE__*/ jsx("div", {
127
118
  className: "ov-scope-switcher__state",
128
119
  role: "alert",
129
- children: slots?.errorFallback ?? labels?.error ?? 'Unable to load options'
120
+ children: slots?.errorFallback ?? labels.error
130
121
  }) : options.length ? /*#__PURE__*/ jsx("div", {
131
122
  className: "ov-scope-switcher__list",
132
123
  role: "listbox",
@@ -195,7 +186,7 @@ function ScopePanel({ label, data, state, slots, actions, onSelect, labels }) {
195
186
  }, keyword) : /*#__PURE__*/ jsx("div", {
196
187
  className: "ov-scope-switcher__state",
197
188
  role: "status",
198
- children: slots?.emptyFallback ?? (hasKeyword ? labels?.noMatch ?? labels?.empty ?? 'No matches' : labels?.empty ?? 'No options')
189
+ children: slots?.emptyFallback ?? (hasKeyword ? labels.noMatch : labels.empty)
199
190
  });
200
191
  return /*#__PURE__*/ jsx("div", {
201
192
  role: "group",
@@ -216,7 +207,9 @@ function ScopePanel({ label, data, state, slots, actions, onSelect, labels }) {
216
207
  });
217
208
  }
218
209
  function ScopeSelector(props) {
219
- const { identity, trigger: triggerContent, labels } = props;
210
+ const { identity, trigger: triggerContent } = props;
211
+ const locale = useLocale(props.locale);
212
+ const labels = resolveScopeLabels(locale, props.labels);
220
213
  const selectable = 'selectable' === props.kind ? props : void 0;
221
214
  const data = selectable?.data;
222
215
  const state = selectable?.state;
@@ -346,11 +339,16 @@ function ScopeSelector(props) {
346
339
  ]
347
340
  });
348
341
  }
349
- function ScopeSwitcher({ children, className = '', ...props }) {
350
- return /*#__PURE__*/ jsx("div", {
351
- ...props,
352
- className: `ov-scope-switcher ${className}`,
353
- children: children
342
+ function ScopeSwitcher({ locale: localeProp, children, className = '', ...props }) {
343
+ const locale = useLocale(localeProp);
344
+ return /*#__PURE__*/ jsx(LocaleProvider, {
345
+ locale: locale,
346
+ children: /*#__PURE__*/ jsx("div", {
347
+ lang: locale,
348
+ ...props,
349
+ className: `ov-scope-switcher ${className}`,
350
+ children: children
351
+ })
354
352
  });
355
353
  }
356
354
  export { ScopeSelector, ScopeSwitcher };
package/dist/h~0.js CHANGED
@@ -10,6 +10,7 @@ function groupMessages(messages) {
10
10
  ];
11
11
  previous.turnId ??= message.turnId;
12
12
  previous.streaming = previous.streaming || message.streaming;
13
+ previous.createdAt = message.createdAt ?? previous.createdAt;
13
14
  if (message.action) previous.actions = [
14
15
  ...previous.actions ?? [],
15
16
  {
@@ -42,7 +43,10 @@ function groupByActivity(parts) {
42
43
  for (const part of parts){
43
44
  const groupId = 'groupId' in part ? part.groupId : void 0;
44
45
  const previous = blocks.at(-1);
45
- if (previous && groupId && previous.groupId === groupId) {
46
+ const activity = 'reasoning' === part.type || 'tool' === part.type;
47
+ const previousType = previous?.parts[0]?.type;
48
+ const previousActivity = 'reasoning' === previousType || 'tool' === previousType;
49
+ if (previous && groupId && previous.groupId === groupId && activity === previousActivity) {
46
50
  previous.parts.push(part);
47
51
  continue;
48
52
  }
@@ -0,0 +1,12 @@
1
+ declare const icons: {
2
+ conversation: import("react").FunctionComponent<import("react").SVGProps<SVGSVGElement>>;
3
+ command: import("react").FunctionComponent<import("react").SVGProps<SVGSVGElement>>;
4
+ history: import("react").FunctionComponent<import("react").SVGProps<SVGSVGElement>>;
5
+ newSession: import("react").FunctionComponent<import("react").SVGProps<SVGSVGElement>>;
6
+ historyEmpty: import("react").FunctionComponent<import("react").SVGProps<SVGSVGElement>>;
7
+ };
8
+ /** Private Console controls. Sources and licenses are in packages/icons/README.md. */
9
+ export declare function ConsoleIcon({ name }: {
10
+ name: keyof typeof icons;
11
+ }): import("react").JSX.Element;
12
+ export {};
@@ -31,3 +31,5 @@ export declare const VideoIcon: IconComponent;
31
31
  export declare const WordIcon: IconComponent;
32
32
  export { getFileTypeColor, getFileTypeIcon, resolveFileTypeIconKey, } from './file-type-icon.js';
33
33
  export type { FileTypeIconComponent } from './file-type-icon.js';
34
+ export { VikingBotIcon } from './viking-bot-icons.js';
35
+ export type { VikingBotIconName } from './viking-bot-icons.js';
@@ -0,0 +1,6 @@
1
+ import type { SVGProps } from 'react';
2
+ export type VikingBotIconName = 'bulb' | 'book' | 'video' | 'report' | 'history' | 'newSession' | 'remove' | 'tool';
3
+ /** Reference artwork and the local remove glyph. See packages/icons/README.md. */
4
+ export declare function VikingBotIcon({ name, 'aria-label': ariaLabel, ...props }: SVGProps<SVGSVGElement> & {
5
+ name: VikingBotIconName;
6
+ }): import("react").JSX.Element;
package/dist/icons.js CHANGED
@@ -1 +1,2 @@
1
1
  export { ArrowRightIcon, AudioIcon, ChevronRightIcon, DocumentIcon, FolderIcon, FolderOpenIcon, PdfIcon, PptIcon, VideoIcon, WordIcon, getFileTypeColor, getFileTypeIcon, resolveFileTypeIconKey } from "./k~0.js";
2
+ export { VikingBotIcon } from "./lg~0.js";