@bytexbyte/nxtlinq-ai-agent-sdk 1.6.28 → 1.6.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/nxtlinq-api.d.ts.map +1 -1
- package/dist/api/nxtlinq-api.js +5 -1
- package/dist/components/context/ChatBotContext.d.ts.map +1 -1
- package/dist/components/context/ChatBotContext.js +216 -69
- package/dist/components/types/ChatBotTypes.d.ts +8 -1
- package/dist/components/types/ChatBotTypes.d.ts.map +1 -1
- package/dist/components/ui/ChatBotUI.d.ts.map +1 -1
- package/dist/components/ui/ChatBotUI.js +255 -16
- package/dist/components/ui/MessageList.d.ts.map +1 -1
- package/dist/components/ui/MessageList.js +6 -2
- package/dist/components/ui/styles/isolatedStyles.d.ts +14 -0
- package/dist/components/ui/styles/isolatedStyles.d.ts.map +1 -1
- package/dist/components/ui/styles/isolatedStyles.js +138 -7
- package/dist/core/lib/textToSpeech.js +1 -1
- package/dist/core/lib/useDraggable.d.ts +15 -0
- package/dist/core/lib/useDraggable.d.ts.map +1 -0
- package/dist/core/lib/useDraggable.js +158 -0
- package/dist/core/lib/useResizable.d.ts +16 -0
- package/dist/core/lib/useResizable.d.ts.map +1 -0
- package/dist/core/lib/useResizable.js +180 -0
- package/dist/core/lib/useSpeechToTextFromMic/helper.d.ts.map +1 -1
- package/dist/core/lib/useSpeechToTextFromMic/helper.js +13 -1
- package/dist/types/ait-api.d.ts +7 -0
- package/dist/types/ait-api.d.ts.map +1 -1
- package/package.json +1 -1
- package/umd/nxtlinq-ai-agent.umd.js +140 -125
- package/dist/assets/images/adilasDogHeadTiltDataUri.d.ts +0 -2
- package/dist/assets/images/adilasDogHeadTiltDataUri.d.ts.map +0 -1
- package/dist/assets/images/adilasDogHeadTiltDataUri.js +0 -1
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { useState, useRef, useCallback, useEffect } from 'react';
|
|
2
|
+
import useLocalStorage from './useLocalStorage';
|
|
3
|
+
const DEFAULT_POSITION = { x: 0, y: 0 }; // Default position, will be calculated
|
|
4
|
+
const VIEWPORT_MARGIN = 20; // Keep space from viewport edges
|
|
5
|
+
export const useDraggable = (dimensions) => {
|
|
6
|
+
const dragState = useRef({
|
|
7
|
+
startX: 0,
|
|
8
|
+
startY: 0,
|
|
9
|
+
startPosition: DEFAULT_POSITION
|
|
10
|
+
});
|
|
11
|
+
// Keep track of current position for saving
|
|
12
|
+
const currentPositionRef = useRef(DEFAULT_POSITION);
|
|
13
|
+
// Track if we've already loaded from localStorage to prevent loops
|
|
14
|
+
const hasLoadedFromStorage = useRef(false);
|
|
15
|
+
// Clamp position to keep window within viewport
|
|
16
|
+
const clampPosition = useCallback((pos, dims) => {
|
|
17
|
+
if (typeof window === 'undefined') {
|
|
18
|
+
return pos;
|
|
19
|
+
}
|
|
20
|
+
const maxX = Math.max(VIEWPORT_MARGIN, window.innerWidth - dims.width - VIEWPORT_MARGIN);
|
|
21
|
+
const maxY = Math.max(VIEWPORT_MARGIN, window.innerHeight - dims.height - VIEWPORT_MARGIN);
|
|
22
|
+
return {
|
|
23
|
+
x: Math.max(VIEWPORT_MARGIN, Math.min(pos.x, maxX)),
|
|
24
|
+
y: Math.max(VIEWPORT_MARGIN, Math.min(pos.y, maxY))
|
|
25
|
+
};
|
|
26
|
+
}, []);
|
|
27
|
+
// Calculate initial position from bottom/right (default behavior)
|
|
28
|
+
const calculateInitialPosition = useCallback(() => {
|
|
29
|
+
if (typeof window === 'undefined') {
|
|
30
|
+
return DEFAULT_POSITION;
|
|
31
|
+
}
|
|
32
|
+
// Default position: bottom-right corner with margin
|
|
33
|
+
const initialPos = {
|
|
34
|
+
x: window.innerWidth - dimensions.width - VIEWPORT_MARGIN,
|
|
35
|
+
y: window.innerHeight - dimensions.height - VIEWPORT_MARGIN
|
|
36
|
+
};
|
|
37
|
+
return clampPosition(initialPos, dimensions);
|
|
38
|
+
}, [dimensions.width, dimensions.height, clampPosition]);
|
|
39
|
+
// Load position from localStorage or use default
|
|
40
|
+
const [savedPosition, setSavedPosition, isPositionInitialized] = useLocalStorage('chat-window-position', null);
|
|
41
|
+
const [position, setPosition] = useState(() => {
|
|
42
|
+
// Always start with calculated initial position
|
|
43
|
+
// Will be updated when savedPosition loads from localStorage
|
|
44
|
+
const initialPos = calculateInitialPosition();
|
|
45
|
+
currentPositionRef.current = initialPos;
|
|
46
|
+
return initialPos;
|
|
47
|
+
});
|
|
48
|
+
// Update position when saved position loads from localStorage (only once)
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (isPositionInitialized && !hasLoadedFromStorage.current) {
|
|
51
|
+
if (savedPosition) {
|
|
52
|
+
// Use saved position
|
|
53
|
+
const clampedPos = clampPosition(savedPosition, dimensions);
|
|
54
|
+
currentPositionRef.current = clampedPos;
|
|
55
|
+
setPosition(clampedPos);
|
|
56
|
+
}
|
|
57
|
+
// Mark as loaded regardless of whether we have saved position
|
|
58
|
+
hasLoadedFromStorage.current = true;
|
|
59
|
+
}
|
|
60
|
+
}, [isPositionInitialized, savedPosition, dimensions, clampPosition]);
|
|
61
|
+
// Update position when dimensions change (to keep window in viewport, but only after initial load)
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
if (!isPositionInitialized || !hasLoadedFromStorage.current)
|
|
64
|
+
return;
|
|
65
|
+
setPosition((current) => {
|
|
66
|
+
const clampedPosition = clampPosition(current, dimensions);
|
|
67
|
+
if (clampedPosition.x !== current.x || clampedPosition.y !== current.y) {
|
|
68
|
+
currentPositionRef.current = clampedPosition;
|
|
69
|
+
return clampedPosition;
|
|
70
|
+
}
|
|
71
|
+
return current;
|
|
72
|
+
});
|
|
73
|
+
}, [dimensions.width, dimensions.height, isPositionInitialized, clampPosition]);
|
|
74
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
75
|
+
const handleDragStart = (event) => {
|
|
76
|
+
// Don't start dragging if clicking on buttons or interactive elements
|
|
77
|
+
const target = event.target;
|
|
78
|
+
if (target.tagName === 'BUTTON' ||
|
|
79
|
+
target.closest('button') ||
|
|
80
|
+
target.closest('[role="button"]') ||
|
|
81
|
+
target.closest('input') ||
|
|
82
|
+
target.closest('select') ||
|
|
83
|
+
target.closest('textarea')) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
event.preventDefault();
|
|
87
|
+
event.stopPropagation();
|
|
88
|
+
dragState.current = {
|
|
89
|
+
startX: event.clientX,
|
|
90
|
+
startY: event.clientY,
|
|
91
|
+
startPosition: position
|
|
92
|
+
};
|
|
93
|
+
setIsDragging(true);
|
|
94
|
+
document.body.style.userSelect = 'none';
|
|
95
|
+
document.body.style.cursor = 'grabbing';
|
|
96
|
+
};
|
|
97
|
+
// Handle pointer move and up events
|
|
98
|
+
useEffect(() => {
|
|
99
|
+
if (!isDragging) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const handlePointerMove = (event) => {
|
|
103
|
+
const deltaX = event.clientX - dragState.current.startX;
|
|
104
|
+
const deltaY = event.clientY - dragState.current.startY;
|
|
105
|
+
const newPosition = {
|
|
106
|
+
x: dragState.current.startPosition.x + deltaX,
|
|
107
|
+
y: dragState.current.startPosition.y + deltaY
|
|
108
|
+
};
|
|
109
|
+
const clampedPos = clampPosition(newPosition, dimensions);
|
|
110
|
+
currentPositionRef.current = clampedPos;
|
|
111
|
+
setPosition(clampedPos);
|
|
112
|
+
};
|
|
113
|
+
const handlePointerUp = () => {
|
|
114
|
+
setIsDragging(false);
|
|
115
|
+
document.body.style.userSelect = '';
|
|
116
|
+
document.body.style.cursor = '';
|
|
117
|
+
// Save position to localStorage (only after initial load)
|
|
118
|
+
if (hasLoadedFromStorage.current) {
|
|
119
|
+
setSavedPosition(currentPositionRef.current);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
document.addEventListener('pointermove', handlePointerMove);
|
|
123
|
+
document.addEventListener('pointerup', handlePointerUp);
|
|
124
|
+
return () => {
|
|
125
|
+
document.removeEventListener('pointermove', handlePointerMove);
|
|
126
|
+
document.removeEventListener('pointerup', handlePointerUp);
|
|
127
|
+
document.body.style.userSelect = '';
|
|
128
|
+
document.body.style.cursor = '';
|
|
129
|
+
};
|
|
130
|
+
}, [isDragging, clampPosition, dimensions, setSavedPosition]);
|
|
131
|
+
// Handle window resize to keep window in viewport
|
|
132
|
+
useEffect(() => {
|
|
133
|
+
const handleResize = () => {
|
|
134
|
+
setPosition((current) => {
|
|
135
|
+
const clamped = clampPosition(current, dimensions);
|
|
136
|
+
currentPositionRef.current = clamped;
|
|
137
|
+
return clamped;
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
window.addEventListener('resize', handleResize);
|
|
141
|
+
return () => window.removeEventListener('resize', handleResize);
|
|
142
|
+
}, [clampPosition, dimensions]);
|
|
143
|
+
const updatePosition = useCallback((newPosition) => {
|
|
144
|
+
const clamped = clampPosition(newPosition, dimensions);
|
|
145
|
+
currentPositionRef.current = clamped;
|
|
146
|
+
setPosition(clamped);
|
|
147
|
+
// Save position to localStorage when updated (only after initial load)
|
|
148
|
+
if (hasLoadedFromStorage.current) {
|
|
149
|
+
setSavedPosition(clamped);
|
|
150
|
+
}
|
|
151
|
+
}, [clampPosition, dimensions, setSavedPosition]);
|
|
152
|
+
return {
|
|
153
|
+
position,
|
|
154
|
+
handleDragStart,
|
|
155
|
+
isDragging,
|
|
156
|
+
updatePosition
|
|
157
|
+
};
|
|
158
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
interface Dimensions {
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
5
|
+
}
|
|
6
|
+
interface Position {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
}
|
|
10
|
+
export declare const useResizable: (currentPositionRef?: RefObject<Position>) => {
|
|
11
|
+
dimensions: Dimensions;
|
|
12
|
+
handleResizeStart: (event: React.PointerEvent<HTMLDivElement>) => void;
|
|
13
|
+
positionAdjustment: Position | null;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=useResizable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useResizable.d.ts","sourceRoot":"","sources":["../../../src/core/lib/useResizable.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4C,SAAS,EAAE,MAAM,OAAO,CAAC;AAoB5E,UAAU,UAAU;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,QAAQ;IAChB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,eAAO,MAAM,YAAY,GAAI,qBAAqB,SAAS,CAAC,QAAQ,CAAC;;+BAuFjC,KAAK,CAAC,YAAY,CAAC,cAAc,CAAC;;CA2GrE,CAAC"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { useState, useRef, useCallback, useEffect } from 'react';
|
|
2
|
+
import useLocalStorage from './useLocalStorage';
|
|
3
|
+
// Resizable chat window defaults
|
|
4
|
+
const DEFAULT_WIDTH = 500;
|
|
5
|
+
const DEFAULT_HEIGHT = 600;
|
|
6
|
+
const ASPECT_RATIO = DEFAULT_WIDTH / DEFAULT_HEIGHT;
|
|
7
|
+
const MIN_WIDTH = 320;
|
|
8
|
+
const MIN_HEIGHT = 380;
|
|
9
|
+
const VIEWPORT_MARGIN = 40; // Keep space from viewport edges
|
|
10
|
+
export const useResizable = (currentPositionRef) => {
|
|
11
|
+
const resizeState = useRef({
|
|
12
|
+
startX: 0,
|
|
13
|
+
startY: 0,
|
|
14
|
+
startWidth: DEFAULT_WIDTH,
|
|
15
|
+
startHeight: DEFAULT_HEIGHT,
|
|
16
|
+
startPosition: undefined,
|
|
17
|
+
fixedRightBottom: undefined
|
|
18
|
+
});
|
|
19
|
+
const [positionAdjustment, setPositionAdjustment] = useState(null);
|
|
20
|
+
// Load dimensions from localStorage or use default
|
|
21
|
+
const [savedDimensions, setSavedDimensions, isDimensionsInitialized] = useLocalStorage('chat-window-dimensions', null);
|
|
22
|
+
const [isResizing, setIsResizing] = useState(false);
|
|
23
|
+
// Clamp dimensions to keep window within viewport and maintain aspect ratio
|
|
24
|
+
const clampDimensions = useCallback((width, height) => {
|
|
25
|
+
if (typeof window === 'undefined') {
|
|
26
|
+
return { width, height };
|
|
27
|
+
}
|
|
28
|
+
const maxWidth = Math.max(MIN_WIDTH, window.innerWidth - VIEWPORT_MARGIN);
|
|
29
|
+
const maxHeight = Math.max(MIN_HEIGHT, window.innerHeight - VIEWPORT_MARGIN);
|
|
30
|
+
const clampedWidth = Math.min(Math.max(width, MIN_WIDTH), maxWidth);
|
|
31
|
+
let clampedHeight = clampedWidth / ASPECT_RATIO;
|
|
32
|
+
if (clampedHeight > maxHeight) {
|
|
33
|
+
clampedHeight = maxHeight;
|
|
34
|
+
const adjustedWidth = clampedHeight * ASPECT_RATIO;
|
|
35
|
+
return { width: adjustedWidth, height: clampedHeight };
|
|
36
|
+
}
|
|
37
|
+
if (clampedHeight < MIN_HEIGHT) {
|
|
38
|
+
clampedHeight = MIN_HEIGHT;
|
|
39
|
+
const adjustedWidth = clampedHeight * ASPECT_RATIO;
|
|
40
|
+
return { width: adjustedWidth, height: clampedHeight };
|
|
41
|
+
}
|
|
42
|
+
return { width: clampedWidth, height: clampedHeight };
|
|
43
|
+
}, []);
|
|
44
|
+
// Helper function to calculate dimensions - reuse clampDimensions logic
|
|
45
|
+
const calculateDimensions = useCallback((savedDims) => {
|
|
46
|
+
if (typeof window === 'undefined') {
|
|
47
|
+
return { width: DEFAULT_WIDTH, height: DEFAULT_HEIGHT };
|
|
48
|
+
}
|
|
49
|
+
// Use saved dimensions or default
|
|
50
|
+
const baseDimensions = savedDims || { width: DEFAULT_WIDTH, height: DEFAULT_HEIGHT };
|
|
51
|
+
// Reuse clampDimensions to ensure consistency
|
|
52
|
+
return clampDimensions(baseDimensions.width, baseDimensions.height);
|
|
53
|
+
}, [clampDimensions]);
|
|
54
|
+
const [dimensions, setDimensions] = useState(() => {
|
|
55
|
+
// Calculate initial dimensions - use clampDimensions for consistency
|
|
56
|
+
// We can't use clampDimensions directly in useState due to dependency, but we replicate the logic
|
|
57
|
+
if (typeof window === 'undefined') {
|
|
58
|
+
return { width: DEFAULT_WIDTH, height: DEFAULT_HEIGHT };
|
|
59
|
+
}
|
|
60
|
+
const maxWidth = Math.max(MIN_WIDTH, window.innerWidth - VIEWPORT_MARGIN);
|
|
61
|
+
const maxHeight = Math.max(MIN_HEIGHT, window.innerHeight - VIEWPORT_MARGIN);
|
|
62
|
+
let width = Math.min(Math.max(DEFAULT_WIDTH, MIN_WIDTH), maxWidth);
|
|
63
|
+
let height = width / ASPECT_RATIO;
|
|
64
|
+
if (height > maxHeight) {
|
|
65
|
+
height = maxHeight;
|
|
66
|
+
width = height * ASPECT_RATIO;
|
|
67
|
+
}
|
|
68
|
+
if (height < MIN_HEIGHT) {
|
|
69
|
+
height = MIN_HEIGHT;
|
|
70
|
+
width = height * ASPECT_RATIO;
|
|
71
|
+
}
|
|
72
|
+
return { width, height };
|
|
73
|
+
});
|
|
74
|
+
// Track if we've already loaded from localStorage to prevent loops
|
|
75
|
+
const hasLoadedFromStorage = useRef(false);
|
|
76
|
+
// Update dimensions when savedDimensions loads from localStorage (only once)
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
if (isDimensionsInitialized && !hasLoadedFromStorage.current) {
|
|
79
|
+
const newDimensions = calculateDimensions(savedDimensions);
|
|
80
|
+
setDimensions(newDimensions);
|
|
81
|
+
hasLoadedFromStorage.current = true;
|
|
82
|
+
}
|
|
83
|
+
}, [isDimensionsInitialized, savedDimensions, calculateDimensions]);
|
|
84
|
+
const handleResizeStart = (event) => {
|
|
85
|
+
event.preventDefault();
|
|
86
|
+
event.stopPropagation();
|
|
87
|
+
const currentPos = currentPositionRef?.current ?? undefined;
|
|
88
|
+
// Calculate fixed bottom-right corner position
|
|
89
|
+
const fixedRightBottom = currentPos ? {
|
|
90
|
+
x: currentPos.x + dimensions.width,
|
|
91
|
+
y: currentPos.y + dimensions.height
|
|
92
|
+
} : undefined;
|
|
93
|
+
resizeState.current = {
|
|
94
|
+
startX: event.clientX,
|
|
95
|
+
startY: event.clientY,
|
|
96
|
+
startWidth: dimensions.width,
|
|
97
|
+
startHeight: dimensions.height,
|
|
98
|
+
startPosition: currentPos,
|
|
99
|
+
fixedRightBottom
|
|
100
|
+
};
|
|
101
|
+
setIsResizing(true);
|
|
102
|
+
setPositionAdjustment(null);
|
|
103
|
+
document.body.style.userSelect = 'none';
|
|
104
|
+
};
|
|
105
|
+
// Handle pointer move and up events
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
if (!isResizing) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const handlePointerMove = (event) => {
|
|
111
|
+
// When resizing from top-left, keep bottom-right corner fixed
|
|
112
|
+
const fixedRightBottom = resizeState.current.fixedRightBottom;
|
|
113
|
+
if (fixedRightBottom) {
|
|
114
|
+
// Calculate new dimensions based on cursor position and fixed bottom-right corner
|
|
115
|
+
const deltaX = fixedRightBottom.x - event.clientX;
|
|
116
|
+
const deltaY = fixedRightBottom.y - event.clientY;
|
|
117
|
+
// Calculate target dimensions from both X and Y deltas
|
|
118
|
+
const targetFromX = deltaX;
|
|
119
|
+
const targetFromY = deltaY * ASPECT_RATIO;
|
|
120
|
+
// Blend X/Y intent so dragging diagonally feels natural while keeping aspect ratio
|
|
121
|
+
const nextWidth = (targetFromX + targetFromY) / 2;
|
|
122
|
+
const nextHeight = nextWidth / ASPECT_RATIO;
|
|
123
|
+
const newDimensions = clampDimensions(nextWidth, nextHeight);
|
|
124
|
+
setDimensions(newDimensions);
|
|
125
|
+
// Calculate new position to keep bottom-right corner fixed
|
|
126
|
+
// newX = fixedRightBottomX - newWidth
|
|
127
|
+
// newY = fixedRightBottomY - newHeight
|
|
128
|
+
setPositionAdjustment({
|
|
129
|
+
x: fixedRightBottom.x - newDimensions.width,
|
|
130
|
+
y: fixedRightBottom.y - newDimensions.height
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
// Fallback to original behavior if no fixed corner
|
|
135
|
+
const deltaX = resizeState.current.startX - event.clientX;
|
|
136
|
+
const deltaY = resizeState.current.startY - event.clientY;
|
|
137
|
+
const targetFromX = resizeState.current.startWidth + deltaX;
|
|
138
|
+
const targetFromY = resizeState.current.startWidth + (deltaY * ASPECT_RATIO);
|
|
139
|
+
const nextWidth = (targetFromX + targetFromY) / 2;
|
|
140
|
+
const nextHeight = nextWidth / ASPECT_RATIO;
|
|
141
|
+
const newDimensions = clampDimensions(nextWidth, nextHeight);
|
|
142
|
+
setDimensions(newDimensions);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
const handlePointerUp = () => {
|
|
146
|
+
setIsResizing(false);
|
|
147
|
+
setPositionAdjustment(null);
|
|
148
|
+
document.body.style.userSelect = '';
|
|
149
|
+
};
|
|
150
|
+
document.addEventListener('pointermove', handlePointerMove);
|
|
151
|
+
document.addEventListener('pointerup', handlePointerUp);
|
|
152
|
+
return () => {
|
|
153
|
+
document.removeEventListener('pointermove', handlePointerMove);
|
|
154
|
+
document.removeEventListener('pointerup', handlePointerUp);
|
|
155
|
+
document.body.style.userSelect = '';
|
|
156
|
+
};
|
|
157
|
+
}, [clampDimensions, isResizing]);
|
|
158
|
+
// Save dimensions to localStorage when they change (but not during resizing or initial load)
|
|
159
|
+
useEffect(() => {
|
|
160
|
+
if (!isResizing && isDimensionsInitialized && hasLoadedFromStorage.current) {
|
|
161
|
+
setSavedDimensions(dimensions);
|
|
162
|
+
}
|
|
163
|
+
}, [dimensions, isResizing, isDimensionsInitialized, setSavedDimensions]);
|
|
164
|
+
// Handle window resize
|
|
165
|
+
useEffect(() => {
|
|
166
|
+
const handleResize = () => {
|
|
167
|
+
setDimensions((current) => {
|
|
168
|
+
const clamped = clampDimensions(current.width, current.height);
|
|
169
|
+
return clamped;
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
window.addEventListener('resize', handleResize);
|
|
173
|
+
return () => window.removeEventListener('resize', handleResize);
|
|
174
|
+
}, [clampDimensions]);
|
|
175
|
+
return {
|
|
176
|
+
dimensions,
|
|
177
|
+
handleResizeStart,
|
|
178
|
+
positionAdjustment
|
|
179
|
+
};
|
|
180
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../../../src/core/lib/useSpeechToTextFromMic/helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,gBAAgB,EACjB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAIjD;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,GACnC,sBAAsB,QAAQ,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC,CAAC,EAAI,sBAAsB;AAClF,QAAQ;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,EAC7C,YAAY,KAAK,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC,EAC5C,UAAU,KAAK,CAAC,gBAAgB,CAAC,MAAM,CAAC,EACxC,uBAAuB,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,KACtD,OAAO,CAAC,gBAAgB,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../../../src/core/lib/useSpeechToTextFromMic/helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,gBAAgB,EACjB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAIjD;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,GACnC,sBAAsB,QAAQ,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC,CAAC,EAAI,sBAAsB;AAClF,QAAQ;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,EAC7C,YAAY,KAAK,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC,EAC5C,UAAU,KAAK,CAAC,gBAAgB,CAAC,MAAM,CAAC,EACxC,uBAAuB,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,KACtD,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAyEtC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,YAAY,gBAAgB,GAAG,SAAS,SAIvE,CAAC;AAEF,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;;;;;;;;GAwBxE"}
|
|
@@ -31,7 +31,19 @@ config, historyRef, indexRef, setPartialTranscript // temporary partial transcri
|
|
|
31
31
|
// finalized sentences
|
|
32
32
|
recognizer.recognized = (_s, e) => {
|
|
33
33
|
if (e.result.reason === ResultReason.RecognizedSpeech) {
|
|
34
|
-
const text = e.result.text;
|
|
34
|
+
const text = e.result.text.trim();
|
|
35
|
+
// Filter out very short text (likely background noise or false positives)
|
|
36
|
+
// Minimum 3 characters to reduce sensitivity to background sounds
|
|
37
|
+
if (text.length < 3) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
// Check confidence if available (some SDK versions provide this)
|
|
41
|
+
// Lower confidence results are more likely to be background noise
|
|
42
|
+
// Increased threshold to 0.4 to better filter out low-volume background noise
|
|
43
|
+
const confidence = e.result.confidence;
|
|
44
|
+
if (confidence !== undefined && confidence < 0.4) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
35
47
|
historyRef.current[indexRef.current] = text;
|
|
36
48
|
indexRef.current += 1;
|
|
37
49
|
// return only the latest finalized sentence to the UI
|
package/dist/types/ait-api.d.ts
CHANGED
|
@@ -5,6 +5,12 @@ export interface Message {
|
|
|
5
5
|
timestamp: string;
|
|
6
6
|
button?: string;
|
|
7
7
|
error?: string;
|
|
8
|
+
isStreaming?: boolean;
|
|
9
|
+
streamingToolName?: string;
|
|
10
|
+
streamingStatus?: string;
|
|
11
|
+
streamingProgress?: number;
|
|
12
|
+
streamingSteps?: string[];
|
|
13
|
+
partialContent?: string;
|
|
8
14
|
metadata?: {
|
|
9
15
|
model?: string;
|
|
10
16
|
permissions?: string[];
|
|
@@ -99,6 +105,7 @@ export interface AITApi {
|
|
|
99
105
|
getAITByServiceIdAndController: (params: {
|
|
100
106
|
serviceId: string;
|
|
101
107
|
controller: string;
|
|
108
|
+
customUsername?: string;
|
|
102
109
|
}, token: string) => Promise<AITInfo | {
|
|
103
110
|
error: string;
|
|
104
111
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ait-api.d.ts","sourceRoot":"","sources":["../../src/types/ait-api.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"ait-api.d.ts","sourceRoot":"","sources":["../../src/types/ait-api.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,cAAc,CAA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