empathai-core 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +16 -3
- package/README.md +8 -26
- package/dist/index.d.ts +22 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +95 -11
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +5 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -11
- package/dist/hooks/useEmpathAI.d.ts +0 -3
- package/dist/hooks/useEmpathAI.d.ts.map +0 -1
- package/dist/hooks/useEmpathAI.js +0 -15
- package/dist/hooks/useEmpathAI.js.map +0 -1
package/LICENSE
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2026 Mrityunjoy (Piklu)
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
7
11
|
|
|
8
|
-
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -47,38 +47,20 @@ pnpm add empathai-core
|
|
|
47
47
|
|
|
48
48
|
## Usage Examples
|
|
49
49
|
|
|
50
|
-
###
|
|
51
|
-
```jsx
|
|
52
|
-
import { useEmpathAI } from 'empathai-core/hooks';
|
|
53
|
-
|
|
54
|
-
function App() {
|
|
55
|
-
const { emotion } = useEmpathAI({
|
|
56
|
-
enableMouseTracking: true,
|
|
57
|
-
enableKeyboardTracking: true,
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
return (
|
|
61
|
-
<div>
|
|
62
|
-
<h2>Current emotion</h2>
|
|
63
|
-
<p>{emotion.type}</p>
|
|
64
|
-
<p>Confidence: {emotion.confidence}</p>
|
|
65
|
-
</div>
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export default App;
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
---
|
|
73
|
-
|
|
74
|
-
### JavaScript (Vanilla JS)
|
|
50
|
+
### JavaScript (Framework-Agnostic)
|
|
75
51
|
```javascript
|
|
76
52
|
import { createEmpathAI } from 'empathai-core';
|
|
77
53
|
|
|
78
54
|
const empathAI = createEmpathAI({
|
|
79
55
|
onEmotionDetected: (emotion) => {
|
|
80
56
|
console.log('Emotion detected:', emotion);
|
|
81
|
-
}
|
|
57
|
+
},
|
|
58
|
+
// Optional configuration
|
|
59
|
+
signalWindowMs: 3000, // 3 second window
|
|
60
|
+
analysisIntervalMs: 1000, // Analyze every second
|
|
61
|
+
mouseThrottleMs: 50, // Throttle mouse events
|
|
62
|
+
confidenceThreshold: 0.3, // Minimum confidence
|
|
63
|
+
debugMode: false, // Enable for debugging
|
|
82
64
|
});
|
|
83
65
|
|
|
84
66
|
empathAI.init();
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { EmotionData, EmpathAIOptions } from './types';
|
|
1
|
+
import { EmotionType, EmotionData, EmpathAIOptions } from './types';
|
|
2
|
+
export type { EmotionType, EmotionData, EmpathAIOptions };
|
|
2
3
|
/**
|
|
3
4
|
* Core EmpathAI engine
|
|
4
5
|
* - Behavior-signal driven
|
|
@@ -13,8 +14,12 @@ export declare class EmpathAI {
|
|
|
13
14
|
private emotionListeners;
|
|
14
15
|
private mouseSignals;
|
|
15
16
|
private keySignals;
|
|
17
|
+
private lastMouseEventTime;
|
|
16
18
|
private readonly SIGNAL_WINDOW_MS;
|
|
17
19
|
private readonly ANALYSIS_INTERVAL_MS;
|
|
20
|
+
private readonly MOUSE_THROTTLE_MS;
|
|
21
|
+
private readonly CONFIDENCE_THRESHOLD;
|
|
22
|
+
private readonly DEBUG_MODE;
|
|
18
23
|
private analysisTimer?;
|
|
19
24
|
private initialized;
|
|
20
25
|
constructor(options?: EmpathAIOptions);
|
|
@@ -27,7 +32,7 @@ export declare class EmpathAI {
|
|
|
27
32
|
*/
|
|
28
33
|
destroy(): void;
|
|
29
34
|
/**
|
|
30
|
-
* Mouse movement tracking
|
|
35
|
+
* Mouse movement tracking with throttling
|
|
31
36
|
*/
|
|
32
37
|
private handleMouseMove;
|
|
33
38
|
/**
|
|
@@ -36,11 +41,15 @@ export declare class EmpathAI {
|
|
|
36
41
|
private handleKeyDown;
|
|
37
42
|
/**
|
|
38
43
|
* Core emotion inference logic
|
|
39
|
-
*
|
|
44
|
+
* Implements all 7 emotion types with nuanced detection
|
|
40
45
|
*/
|
|
41
46
|
private analyzeSignals;
|
|
42
47
|
/**
|
|
43
|
-
*
|
|
48
|
+
* Calculate mouse movement variance to detect erratic vs smooth patterns
|
|
49
|
+
*/
|
|
50
|
+
private calculateMouseVariance;
|
|
51
|
+
/**
|
|
52
|
+
* Emit emotion change event (only if different from current)
|
|
44
53
|
*/
|
|
45
54
|
private emitEmotion;
|
|
46
55
|
/**
|
|
@@ -52,6 +61,15 @@ export declare class EmpathAI {
|
|
|
52
61
|
* Get current emotion snapshot
|
|
53
62
|
*/
|
|
54
63
|
getCurrentEmotion(): EmotionData;
|
|
64
|
+
/**
|
|
65
|
+
* Get performance metrics (for monitoring)
|
|
66
|
+
*/
|
|
67
|
+
getPerformanceMetrics(): {
|
|
68
|
+
mouseSignalCount: number;
|
|
69
|
+
keySignalCount: number;
|
|
70
|
+
listenerCount: number;
|
|
71
|
+
isInitialized: boolean;
|
|
72
|
+
};
|
|
55
73
|
}
|
|
56
74
|
/**
|
|
57
75
|
* Factory method (recommended usage)
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,WAAW,EACX,WAAW,EACX,eAAe,EAChB,MAAM,SAAS,CAAC;AAGjB,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,eAAe,EAAE,CAAC;AAiB1D;;;;;;GAMG;AACH,qBAAa,QAAQ;IAoBP,OAAO,CAAC,OAAO;IAnB3B,OAAO,CAAC,cAAc,CAA0B;IAChD,OAAO,CAAC,iBAAiB,CAAO;IAEhC,OAAO,CAAC,gBAAgB,CAA0C;IAElE,OAAO,CAAC,YAAY,CAAqB;IACzC,OAAO,CAAC,UAAU,CAAmB;IACrC,OAAO,CAAC,kBAAkB,CAAK;IAG/B,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAS;IAC1C,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAS;IAC9C,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAS;IAC3C,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAS;IAC9C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAU;IAErC,OAAO,CAAC,aAAa,CAAC,CAAiC;IACvD,OAAO,CAAC,WAAW,CAAS;gBAER,OAAO,GAAE,eAAoB;IASjD;;OAEG;IACH,IAAI;IA+BJ;;OAEG;IACH,OAAO;IAoBP;;OAEG;IACH,OAAO,CAAC,eAAe,CAerB;IAEF;;OAEG;IACH,OAAO,CAAC,aAAa,CAKnB;IAEF;;;OAGG;IACH,OAAO,CAAC,cAAc,CAmFpB;IAEF;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAU9B;;OAEG;IACH,OAAO,CAAC,WAAW;IAmBnB;;;OAGG;IACH,eAAe,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI;IAUrD;;OAEG;IACH,iBAAiB,IAAI,WAAW;IAQhC;;OAEG;IACH,qBAAqB;;;;;;CAQtB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,CAAC,EAAE,eAAe,YAEvD"}
|
package/dist/index.js
CHANGED
|
@@ -14,17 +14,22 @@ export class EmpathAI {
|
|
|
14
14
|
this.emotionListeners = [];
|
|
15
15
|
this.mouseSignals = [];
|
|
16
16
|
this.keySignals = [];
|
|
17
|
-
this.
|
|
18
|
-
this.ANALYSIS_INTERVAL_MS = 1000;
|
|
17
|
+
this.lastMouseEventTime = 0;
|
|
19
18
|
this.initialized = false;
|
|
20
19
|
/**
|
|
21
|
-
* Mouse movement tracking
|
|
20
|
+
* Mouse movement tracking with throttling
|
|
22
21
|
*/
|
|
23
22
|
this.handleMouseMove = (e) => {
|
|
23
|
+
const now = Date.now();
|
|
24
|
+
// Throttle mouse events for performance
|
|
25
|
+
if (now - this.lastMouseEventTime < this.MOUSE_THROTTLE_MS) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
this.lastMouseEventTime = now;
|
|
24
29
|
const speed = Math.abs(e.movementX) + Math.abs(e.movementY);
|
|
25
30
|
this.mouseSignals.push({
|
|
26
31
|
speed,
|
|
27
|
-
timestamp:
|
|
32
|
+
timestamp: now,
|
|
28
33
|
});
|
|
29
34
|
};
|
|
30
35
|
/**
|
|
@@ -38,7 +43,7 @@ export class EmpathAI {
|
|
|
38
43
|
};
|
|
39
44
|
/**
|
|
40
45
|
* Core emotion inference logic
|
|
41
|
-
*
|
|
46
|
+
* Implements all 7 emotion types with nuanced detection
|
|
42
47
|
*/
|
|
43
48
|
this.analyzeSignals = () => {
|
|
44
49
|
const now = Date.now();
|
|
@@ -46,26 +51,70 @@ export class EmpathAI {
|
|
|
46
51
|
this.mouseSignals = this.mouseSignals.filter((s) => now - s.timestamp <= this.SIGNAL_WINDOW_MS);
|
|
47
52
|
this.keySignals = this.keySignals.filter((s) => now - s.timestamp <= this.SIGNAL_WINDOW_MS);
|
|
48
53
|
let nextEmotion = 'neutral';
|
|
49
|
-
let confidence =
|
|
54
|
+
let confidence = this.CONFIDENCE_THRESHOLD;
|
|
55
|
+
// Calculate metrics
|
|
50
56
|
const avgMouseSpeed = this.mouseSignals.reduce((sum, s) => sum + s.speed, 0) /
|
|
51
57
|
(this.mouseSignals.length || 1);
|
|
52
58
|
const backspaceCount = this.keySignals.filter((k) => k.key === 'Backspace').length;
|
|
59
|
+
const deleteCount = this.keySignals.filter((k) => k.key === 'Delete').length;
|
|
53
60
|
const typingCount = this.keySignals.length;
|
|
54
|
-
|
|
55
|
-
|
|
61
|
+
const errorRate = typingCount > 0 ? (backspaceCount + deleteCount) / typingCount : 0;
|
|
62
|
+
// Calculate mouse movement variance (for detecting erratic vs smooth)
|
|
63
|
+
const mouseVariance = this.calculateMouseVariance();
|
|
64
|
+
// --- Enhanced emotion inference rules (all 7 types) ---
|
|
65
|
+
// FRUSTRATED: Fast erratic mouse + many corrections
|
|
66
|
+
if (avgMouseSpeed > 60 && backspaceCount > 2 && mouseVariance > 30) {
|
|
56
67
|
nextEmotion = 'frustrated';
|
|
68
|
+
confidence = 0.85;
|
|
69
|
+
}
|
|
70
|
+
// STRESSED: Very high typing rate + high error rate + fast mouse
|
|
71
|
+
else if (typingCount > 20 && errorRate > 0.3 && avgMouseSpeed > 50) {
|
|
72
|
+
nextEmotion = 'stressed';
|
|
57
73
|
confidence = 0.8;
|
|
58
74
|
}
|
|
59
|
-
|
|
75
|
+
// FOCUSED: Steady typing + low errors + moderate mouse activity
|
|
76
|
+
else if (typingCount > 15 && errorRate < 0.1 && mouseVariance < 20) {
|
|
60
77
|
nextEmotion = 'focused';
|
|
78
|
+
confidence = 0.75;
|
|
79
|
+
}
|
|
80
|
+
// CURIOUS: Varied mouse patterns + moderate activity
|
|
81
|
+
else if (this.mouseSignals.length > 10 && mouseVariance > 20 && mouseVariance < 50 && typingCount < 10) {
|
|
82
|
+
nextEmotion = 'curious';
|
|
61
83
|
confidence = 0.7;
|
|
62
84
|
}
|
|
85
|
+
// HAPPY: Smooth deliberate movements + steady typing
|
|
86
|
+
else if (avgMouseSpeed > 20 && avgMouseSpeed < 50 && mouseVariance < 15 && typingCount > 5 && errorRate < 0.15) {
|
|
87
|
+
nextEmotion = 'happy';
|
|
88
|
+
confidence = 0.65;
|
|
89
|
+
}
|
|
90
|
+
// BORED: Very low activity
|
|
63
91
|
else if (typingCount === 0 && this.mouseSignals.length < 3) {
|
|
64
92
|
nextEmotion = 'bored';
|
|
65
93
|
confidence = 0.6;
|
|
66
94
|
}
|
|
95
|
+
// NEUTRAL: Default state
|
|
96
|
+
else {
|
|
97
|
+
nextEmotion = 'neutral';
|
|
98
|
+
confidence = 0.5;
|
|
99
|
+
}
|
|
100
|
+
if (this.DEBUG_MODE) {
|
|
101
|
+
console.log('[EmpathAI] Analysis:', {
|
|
102
|
+
avgMouseSpeed: avgMouseSpeed.toFixed(2),
|
|
103
|
+
mouseVariance: mouseVariance.toFixed(2),
|
|
104
|
+
typingCount,
|
|
105
|
+
errorRate: (errorRate * 100).toFixed(1) + '%',
|
|
106
|
+
emotion: nextEmotion,
|
|
107
|
+
confidence: confidence.toFixed(2),
|
|
108
|
+
});
|
|
109
|
+
}
|
|
67
110
|
this.emitEmotion(nextEmotion, confidence);
|
|
68
111
|
};
|
|
112
|
+
// Initialize configurable parameters
|
|
113
|
+
this.SIGNAL_WINDOW_MS = options.signalWindowMs ?? 3000;
|
|
114
|
+
this.ANALYSIS_INTERVAL_MS = options.analysisIntervalMs ?? 1000;
|
|
115
|
+
this.MOUSE_THROTTLE_MS = options.mouseThrottleMs ?? 50;
|
|
116
|
+
this.CONFIDENCE_THRESHOLD = options.confidenceThreshold ?? 0.3;
|
|
117
|
+
this.DEBUG_MODE = options.debugMode ?? false;
|
|
69
118
|
}
|
|
70
119
|
/**
|
|
71
120
|
* Initialize tracking (idempotent)
|
|
@@ -83,6 +132,14 @@ export class EmpathAI {
|
|
|
83
132
|
window.addEventListener('keydown', this.handleKeyDown);
|
|
84
133
|
}
|
|
85
134
|
this.analysisTimer = setInterval(this.analyzeSignals, this.ANALYSIS_INTERVAL_MS);
|
|
135
|
+
if (this.DEBUG_MODE) {
|
|
136
|
+
console.log('[EmpathAI] Initialized with config:', {
|
|
137
|
+
signalWindowMs: this.SIGNAL_WINDOW_MS,
|
|
138
|
+
analysisIntervalMs: this.ANALYSIS_INTERVAL_MS,
|
|
139
|
+
mouseThrottleMs: this.MOUSE_THROTTLE_MS,
|
|
140
|
+
confidenceThreshold: this.CONFIDENCE_THRESHOLD,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
86
143
|
this.options.onInit?.();
|
|
87
144
|
}
|
|
88
145
|
/**
|
|
@@ -101,13 +158,29 @@ export class EmpathAI {
|
|
|
101
158
|
this.mouseSignals = [];
|
|
102
159
|
this.keySignals = [];
|
|
103
160
|
this.initialized = false;
|
|
161
|
+
if (this.DEBUG_MODE) {
|
|
162
|
+
console.log('[EmpathAI] Destroyed');
|
|
163
|
+
}
|
|
104
164
|
}
|
|
105
165
|
/**
|
|
106
|
-
*
|
|
166
|
+
* Calculate mouse movement variance to detect erratic vs smooth patterns
|
|
167
|
+
*/
|
|
168
|
+
calculateMouseVariance() {
|
|
169
|
+
if (this.mouseSignals.length < 2)
|
|
170
|
+
return 0;
|
|
171
|
+
const speeds = this.mouseSignals.map(s => s.speed);
|
|
172
|
+
const avg = speeds.reduce((sum, s) => sum + s, 0) / speeds.length;
|
|
173
|
+
const variance = speeds.reduce((sum, s) => sum + Math.pow(s - avg, 2), 0) / speeds.length;
|
|
174
|
+
return Math.sqrt(variance);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Emit emotion change event (only if different from current)
|
|
107
178
|
*/
|
|
108
179
|
emitEmotion(type, confidence) {
|
|
109
|
-
if
|
|
180
|
+
// Only emit if emotion changed and confidence meets threshold
|
|
181
|
+
if (type === this.currentEmotion || confidence < this.CONFIDENCE_THRESHOLD) {
|
|
110
182
|
return;
|
|
183
|
+
}
|
|
111
184
|
this.currentEmotion = type;
|
|
112
185
|
this.currentConfidence = confidence;
|
|
113
186
|
const payload = {
|
|
@@ -138,6 +211,17 @@ export class EmpathAI {
|
|
|
138
211
|
timestamp: Date.now(),
|
|
139
212
|
};
|
|
140
213
|
}
|
|
214
|
+
/**
|
|
215
|
+
* Get performance metrics (for monitoring)
|
|
216
|
+
*/
|
|
217
|
+
getPerformanceMetrics() {
|
|
218
|
+
return {
|
|
219
|
+
mouseSignalCount: this.mouseSignals.length,
|
|
220
|
+
keySignalCount: this.keySignals.length,
|
|
221
|
+
listenerCount: this.emotionListeners.length,
|
|
222
|
+
isInitialized: this.initialized,
|
|
223
|
+
};
|
|
224
|
+
}
|
|
141
225
|
}
|
|
142
226
|
/**
|
|
143
227
|
* Factory method (recommended usage)
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6BAA6B;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6BAA6B;AA0B7B;;;;;;GAMG;AACH,MAAM,OAAO,QAAQ;IAoBnB,YAAoB,UAA2B,E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AI,CAAC,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAClD,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,QAAQ,CACtB,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,iBAAiB;QACf,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,cAAc;YACzB,UAAU,EAAE,IAAI,CAAC,iBAAiB;YAClC,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;SACtB,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,qBAAqB;QACnB,OAAO;YACL,gBAAgB,EAAE,IAAI,CAAC,YAAY,CAAC,MAAM;YAC1C,cAAc,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM;YACtC,aAAa,EAAE,IAAI,CAAC,gBAAgB,CAAC,MAAM;YAC3C,aAAa,EAAE,IAAI,CAAC,WAAW;SAChC,CAAC;IACJ,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,OAAyB;IACtD,OAAO,IAAI,QAAQ,CAAC,OAAO,CAAC,CAAC;AAC/B,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -9,6 +9,11 @@ export interface EmpathAIOptions {
|
|
|
9
9
|
enableKeyboardTracking?: boolean;
|
|
10
10
|
enableMicTracking?: boolean;
|
|
11
11
|
enableCameraTracking?: boolean;
|
|
12
|
+
signalWindowMs?: number;
|
|
13
|
+
analysisIntervalMs?: number;
|
|
14
|
+
mouseThrottleMs?: number;
|
|
15
|
+
confidenceThreshold?: number;
|
|
16
|
+
debugMode?: boolean;
|
|
12
17
|
onInit?: () => void;
|
|
13
18
|
onEmotionDetected?: (emotion: EmotionData) => void;
|
|
14
19
|
}
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,WAAW,GACnB,SAAS,GACT,SAAS,GACT,YAAY,GACZ,OAAO,GACP,OAAO,GACP,SAAS,GACT,UAAU,CAAC;AAGf,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,WAAW,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAGD,MAAM,WAAW,eAAe;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,WAAW,GACnB,SAAS,GACT,SAAS,GACT,YAAY,GACZ,OAAO,GACP,OAAO,GACP,SAAS,GACT,UAAU,CAAC;AAGf,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,WAAW,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAGD,MAAM,WAAW,eAAe;IAE9B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAG/B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,eAAe,CAAC,EAAE,MAAM,CAAC;IAGzB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAG7B,SAAS,CAAC,EAAE,OAAO,CAAC;IAGpB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,iBAAiB,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,CAAC;CACpD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "empathai-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Non-intrusive behavior-based emotion detection SDK (keyboard & mouse) — EmpathAI core.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -9,6 +9,13 @@
|
|
|
9
9
|
"README.md",
|
|
10
10
|
"LICENSE"
|
|
11
11
|
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsc",
|
|
14
|
+
"dev": "tsc --watch",
|
|
15
|
+
"test": "vitest",
|
|
16
|
+
"check-types": "tsc --noEmit",
|
|
17
|
+
"lint": "eslint ./src --ext .ts,.tsx"
|
|
18
|
+
},
|
|
12
19
|
"keywords": [
|
|
13
20
|
"emotion",
|
|
14
21
|
"ai",
|
|
@@ -27,9 +34,6 @@
|
|
|
27
34
|
"url": "https://github.com/Pikxul/empathai/issues"
|
|
28
35
|
},
|
|
29
36
|
"homepage": "https://github.com/Pikxul/empathai",
|
|
30
|
-
"peerDependencies": {
|
|
31
|
-
"react": "^17 || ^18 || ^19"
|
|
32
|
-
},
|
|
33
37
|
"devDependencies": {
|
|
34
38
|
"@types/node": "^20.0.0",
|
|
35
39
|
"eslint": "^8.0.0",
|
|
@@ -39,12 +43,5 @@
|
|
|
39
43
|
},
|
|
40
44
|
"publishConfig": {
|
|
41
45
|
"access": "public"
|
|
42
|
-
},
|
|
43
|
-
"scripts": {
|
|
44
|
-
"build": "tsc",
|
|
45
|
-
"dev": "tsc --watch",
|
|
46
|
-
"test": "vitest",
|
|
47
|
-
"check-types": "tsc --noEmit",
|
|
48
|
-
"lint": "eslint ./src --ext .ts,.tsx"
|
|
49
46
|
}
|
|
50
47
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useEmpathAI.d.ts","sourceRoot":"","sources":["../../src/hooks/useEmpathAI.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAExD,eAAO,MAAM,WAAW,GAAI,UAAU,eAAe,gBAapD,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// src/hooks/useEmpathAI.ts
|
|
2
|
-
import { useEffect, useState } from 'react';
|
|
3
|
-
import { empathAI } from '../index';
|
|
4
|
-
export const useEmpathAI = (options) => {
|
|
5
|
-
const [emotion, setEmotion] = useState('neutral');
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
empathAI.onEmotionChange(setEmotion);
|
|
8
|
-
empathAI.init();
|
|
9
|
-
return () => {
|
|
10
|
-
empathAI.destroy();
|
|
11
|
-
};
|
|
12
|
-
}, []);
|
|
13
|
-
return emotion;
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=useEmpathAI.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useEmpathAI.js","sourceRoot":"","sources":["../../src/hooks/useEmpathAI.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGpC,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,OAAyB,EAAE,EAAE;IACvD,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAc,SAAS,CAAC,CAAC;IAE/D,SAAS,CAAC,GAAG,EAAE;QACb,QAAQ,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;QACrC,QAAQ,CAAC,IAAI,EAAE,CAAC;QAEhB,OAAO,GAAG,EAAE;YACV,QAAQ,CAAC,OAAO,EAAE,CAAC;QACrB,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC"}
|