@opensumi/ide-core-browser 3.0.4 → 3.0.5-next-1717466130.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.
Files changed (69) hide show
  1. package/lib/ai-native/command.d.ts +6 -0
  2. package/lib/ai-native/command.d.ts.map +1 -1
  3. package/lib/ai-native/command.js +8 -2
  4. package/lib/ai-native/command.js.map +1 -1
  5. package/lib/application/runtime/base-socket.d.ts +9 -1
  6. package/lib/application/runtime/base-socket.d.ts.map +1 -1
  7. package/lib/application/runtime/base-socket.js +34 -4
  8. package/lib/application/runtime/base-socket.js.map +1 -1
  9. package/lib/application/runtime/electron-renderer/socket.d.ts +1 -1
  10. package/lib/application/runtime/index.d.ts +5 -0
  11. package/lib/application/runtime/index.d.ts.map +1 -1
  12. package/lib/application/runtime/index.js +30 -0
  13. package/lib/application/runtime/index.js.map +1 -1
  14. package/lib/bootstrap/app.d.ts +0 -1
  15. package/lib/bootstrap/app.d.ts.map +1 -1
  16. package/lib/bootstrap/app.interface.d.ts +0 -3
  17. package/lib/bootstrap/app.interface.d.ts.map +1 -1
  18. package/lib/bootstrap/app.js +7 -28
  19. package/lib/bootstrap/app.js.map +1 -1
  20. package/lib/bootstrap/connection.d.ts +3 -6
  21. package/lib/bootstrap/connection.d.ts.map +1 -1
  22. package/lib/bootstrap/connection.js +6 -13
  23. package/lib/bootstrap/connection.js.map +1 -1
  24. package/lib/bootstrap/inner-providers.d.ts.map +1 -1
  25. package/lib/bootstrap/inner-providers.js +5 -0
  26. package/lib/bootstrap/inner-providers.js.map +1 -1
  27. package/lib/components/ai-native/ai-action/index.d.ts +6 -0
  28. package/lib/components/ai-native/ai-action/index.d.ts.map +1 -1
  29. package/lib/components/ai-native/ai-action/index.js +33 -16
  30. package/lib/components/ai-native/ai-action/index.js.map +1 -1
  31. package/lib/components/ai-native/ai-action/index.module.less +61 -27
  32. package/lib/components/ai-native/index.d.ts +2 -0
  33. package/lib/components/ai-native/index.d.ts.map +1 -1
  34. package/lib/components/ai-native/index.js +2 -0
  35. package/lib/components/ai-native/index.js.map +1 -1
  36. package/lib/components/ai-native/interactive-input/index.d.ts +14 -0
  37. package/lib/components/ai-native/interactive-input/index.d.ts.map +1 -0
  38. package/lib/components/ai-native/interactive-input/index.js +101 -0
  39. package/lib/components/ai-native/interactive-input/index.js.map +1 -0
  40. package/lib/components/ai-native/interactive-input/index.module.less +54 -0
  41. package/lib/components/ai-native/loading/index.d.ts +5 -0
  42. package/lib/components/ai-native/loading/index.d.ts.map +1 -0
  43. package/lib/components/ai-native/loading/index.js +11 -0
  44. package/lib/components/ai-native/loading/index.js.map +1 -0
  45. package/lib/components/ai-native/loading/index.module.less +16 -0
  46. package/lib/layout/constants.d.ts +0 -1
  47. package/lib/layout/constants.d.ts.map +1 -1
  48. package/lib/layout/constants.js +1 -4
  49. package/lib/layout/constants.js.map +1 -1
  50. package/lib/react-providers/config-provider.d.ts +2 -0
  51. package/lib/react-providers/config-provider.d.ts.map +1 -1
  52. package/lib/react-providers/config-provider.js.map +1 -1
  53. package/package.json +5 -5
  54. package/src/ai-native/command.ts +9 -1
  55. package/src/application/runtime/base-socket.ts +29 -2
  56. package/src/application/runtime/index.ts +38 -0
  57. package/src/bootstrap/app.interface.ts +1 -5
  58. package/src/bootstrap/app.ts +10 -42
  59. package/src/bootstrap/connection.ts +9 -18
  60. package/src/bootstrap/inner-providers.ts +5 -0
  61. package/src/components/ai-native/ai-action/index.module.less +61 -27
  62. package/src/components/ai-native/ai-action/index.tsx +79 -22
  63. package/src/components/ai-native/index.ts +2 -0
  64. package/src/components/ai-native/interactive-input/index.module.less +54 -0
  65. package/src/components/ai-native/interactive-input/index.tsx +204 -0
  66. package/src/components/ai-native/loading/index.module.less +16 -0
  67. package/src/components/ai-native/loading/index.tsx +12 -0
  68. package/src/layout/constants.ts +1 -5
  69. package/src/react-providers/config-provider.tsx +5 -0
@@ -0,0 +1,204 @@
1
+ import cls from 'classnames';
2
+ import React, { MutableRefObject, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
3
+
4
+ import { IInputBaseProps, Popover, PopoverPosition, TextArea, getIcon } from '@opensumi/ide-components';
5
+ import { isUndefined, localize, uuid } from '@opensumi/ide-core-common';
6
+
7
+ import { EnhanceIcon } from '../index';
8
+
9
+ import styles from './index.module.less';
10
+
11
+ const MAX_WRAPPER_HEIGHT = 160;
12
+ const DEFAULT_HEIGHT = 32;
13
+
14
+ export interface IInteractiveInputProps extends IInputBaseProps<HTMLTextAreaElement> {
15
+ style?: React.CSSProperties;
16
+ onKeyDown?: (e: React.KeyboardEvent<HTMLTextAreaElement>) => void;
17
+ onHeightChange?: (height: number) => void;
18
+ onSend?: (value: string) => void;
19
+ width?: number;
20
+ height?: number;
21
+ sendBtnClassName?: string;
22
+ popoverPosition?: PopoverPosition;
23
+ }
24
+
25
+ export const InteractiveInput = React.forwardRef(
26
+ (props: IInteractiveInputProps, ref: MutableRefObject<HTMLTextAreaElement>) => {
27
+ const {
28
+ placeholder,
29
+ onKeyDown,
30
+ onBlur,
31
+ onValueChange,
32
+ onHeightChange,
33
+ onFocus,
34
+ onSend,
35
+ disabled = false,
36
+ className,
37
+ height,
38
+ width,
39
+ sendBtnClassName,
40
+ popoverPosition,
41
+ } = props;
42
+
43
+ const internalRef = useRef<HTMLTextAreaElement>(null);
44
+
45
+ const [internalValue, setInternalValue] = useState(props.value || '');
46
+ const [wrapperHeight, setWrapperHeight] = useState(height || DEFAULT_HEIGHT);
47
+ const [focus, setFocus] = useState(false);
48
+
49
+ useImperativeHandle(ref, () => internalRef.current as HTMLTextAreaElement);
50
+
51
+ useEffect(() => {
52
+ const value = props.value;
53
+ if (isUndefined(value)) {
54
+ return;
55
+ }
56
+
57
+ if (value !== internalRef.current?.value) {
58
+ setInternalValue(value || '');
59
+ }
60
+ }, [props.value, internalValue, internalRef]);
61
+
62
+ useEffect(() => {
63
+ if (isUndefined(height)) {
64
+ return;
65
+ }
66
+
67
+ if (height !== wrapperHeight) {
68
+ setWrapperHeight(height);
69
+ }
70
+ }, [height, wrapperHeight, onHeightChange]);
71
+
72
+ useEffect(() => {
73
+ if (!internalValue) {
74
+ setWrapperHeight(DEFAULT_HEIGHT);
75
+ return;
76
+ }
77
+
78
+ if (internalRef && internalRef.current && wrapperHeight <= MAX_WRAPPER_HEIGHT) {
79
+ internalRef.current.style.height = 0 + 'px';
80
+ const scrollHeight = internalRef.current.scrollHeight;
81
+ internalRef.current.style.height = Math.min(scrollHeight, MAX_WRAPPER_HEIGHT) + 'px';
82
+ const wrapperHeight = Math.min(scrollHeight + 12, MAX_WRAPPER_HEIGHT);
83
+ setWrapperHeight(wrapperHeight);
84
+ }
85
+ }, [internalRef, internalValue, onHeightChange, wrapperHeight]);
86
+
87
+ useEffect(() => {
88
+ onHeightChange?.(wrapperHeight);
89
+ }, [wrapperHeight]);
90
+
91
+ const handleInputChange = useCallback(
92
+ (value: string) => {
93
+ setInternalValue(value);
94
+ onValueChange?.(value);
95
+ },
96
+ [onValueChange],
97
+ );
98
+
99
+ const handleFocus = useCallback(
100
+ (e) => {
101
+ setFocus(true);
102
+ onFocus?.(e);
103
+ },
104
+ [onFocus],
105
+ );
106
+
107
+ const handleBlur = useCallback(
108
+ (e) => {
109
+ setFocus(false);
110
+ onBlur?.(e);
111
+ },
112
+ [onBlur],
113
+ );
114
+
115
+ const handleSend = useCallback(() => {
116
+ if (disabled) {
117
+ return;
118
+ }
119
+
120
+ if (!internalValue.trim()) {
121
+ return;
122
+ }
123
+
124
+ onSend?.(internalValue);
125
+ }, [onSend, internalValue, disabled]);
126
+
127
+ const handleKeyDown = useCallback(
128
+ (event: React.KeyboardEvent<HTMLTextAreaElement>) => {
129
+ if (event.key === 'Enter' && !event.nativeEvent.isComposing) {
130
+ if (event.shiftKey) {
131
+ return;
132
+ }
133
+
134
+ event.preventDefault();
135
+ handleSend();
136
+ return;
137
+ }
138
+
139
+ onKeyDown?.(event);
140
+ },
141
+ [onKeyDown, handleSend],
142
+ );
143
+
144
+ const renderAddonAfter = useMemo(
145
+ () => (
146
+ <div className={styles.input_icon_container}>
147
+ <div
148
+ className={cls(styles.send_chat_btn, focus && styles.active, disabled && styles.disabled, sendBtnClassName)}
149
+ >
150
+ {disabled ? (
151
+ <div className={styles.ai_loading}>
152
+ <div className={styles.loader}></div>
153
+ <div className={styles.loader}></div>
154
+ <div className={styles.loader}></div>
155
+ </div>
156
+ ) : (
157
+ <Popover
158
+ id={`ai_chat_input_send_${uuid(4)}`}
159
+ content={localize('aiNative.chat.enter.send')}
160
+ delay={1500}
161
+ position={popoverPosition ?? PopoverPosition.top}
162
+ disable={disabled}
163
+ >
164
+ <EnhanceIcon
165
+ wrapperClassName={styles.send_icon}
166
+ className={getIcon('send-solid')}
167
+ onClick={handleSend}
168
+ />
169
+ </Popover>
170
+ )}
171
+ </div>
172
+ </div>
173
+ ),
174
+ [focus, disabled, sendBtnClassName, internalValue, popoverPosition],
175
+ );
176
+
177
+ const wrapperWidth = useMemo(() => {
178
+ if (isUndefined(width)) {
179
+ return '100%';
180
+ }
181
+
182
+ return width + 'px';
183
+ }, [width]);
184
+
185
+ return (
186
+ <TextArea
187
+ ref={internalRef}
188
+ placeholder={placeholder}
189
+ wrapperStyle={{ height: wrapperHeight + 'px', width: wrapperWidth }}
190
+ style={{ height: wrapperHeight - 10 + 'px' }}
191
+ value={internalValue}
192
+ onKeyDown={handleKeyDown}
193
+ onFocus={handleFocus}
194
+ onBlur={handleBlur}
195
+ onValueChange={handleInputChange}
196
+ disabled={disabled}
197
+ className={cls(styles.interactive_input_container, focus ? styles.active : null, className)}
198
+ addonAfter={renderAddonAfter}
199
+ />
200
+ );
201
+ },
202
+ );
203
+
204
+ InteractiveInput.displayName = 'interactiveInput';
@@ -0,0 +1,16 @@
1
+ .loading_indicator {
2
+ background: linear-gradient(to right, #9c03ff, #00f6ff);
3
+ -webkit-background-clip: text;
4
+ -webkit-text-fill-color: transparent;
5
+ animation: spin 1.5s infinite linear;
6
+ }
7
+
8
+ @keyframes spin {
9
+ 0% {
10
+ transform: rotate(0deg);
11
+ }
12
+
13
+ 100% {
14
+ transform: rotate(360deg);
15
+ }
16
+ }
@@ -0,0 +1,12 @@
1
+ import cls from 'classnames';
2
+ import React from 'react';
3
+
4
+ import { Icon, getIcon } from '@opensumi/ide-components';
5
+
6
+ import styles from './index.module.less';
7
+
8
+ export const Loading = React.memo((props: { className?: string }) => (
9
+ <Icon className={cls(props.className, styles.loading_indicator)} iconClass={getIcon('loading')} />
10
+ ));
11
+
12
+ Loading.displayName = 'Loading';
@@ -123,7 +123,7 @@ export class LayoutViewSizeConfig implements ILayoutViewSize {
123
123
  export class DesignLayoutConfig implements IDesignLayoutConfig {
124
124
  private internalLayout: Required<IDesignLayoutConfig> = {
125
125
  useMergeRightWithLeftPanel: false,
126
- useMenubarView: true,
126
+ useMenubarView: false,
127
127
  menubarLogo: '',
128
128
  };
129
129
 
@@ -135,10 +135,6 @@ export class DesignLayoutConfig implements IDesignLayoutConfig {
135
135
  return this.internalLayout.useMergeRightWithLeftPanel;
136
136
  }
137
137
 
138
- get useMenubarView(): boolean {
139
- return this.internalLayout.useMenubarView;
140
- }
141
-
142
138
  get menubarLogo(): string {
143
139
  return this.internalLayout.menubarLogo;
144
140
  }
@@ -277,6 +277,11 @@ export interface AppConfig {
277
277
  * Define the default size (height) of each layout block in the IDE
278
278
  */
279
279
  layoutViewSize?: Partial<ILayoutViewSize>;
280
+
281
+ // 自定义前后端通信路径
282
+ connectionPath?: UrlProvider;
283
+ // 支持的通信协议类型
284
+ connectionProtocols?: string[];
280
285
  }
281
286
 
282
287
  export interface ICollaborationClientOpts {