empathai-core 0.1.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/README.md +0 -0
- package/dist/hooks/useEmpathAI.d.ts +3 -0
- package/dist/hooks/useEmpathAI.d.ts.map +1 -0
- package/dist/hooks/useEmpathAI.js +15 -0
- package/dist/hooks/useEmpathAI.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +56 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +15 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +32 -0
package/README.md
ADDED
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { EmotionType, EmpathAIOptions } from './types';
|
|
2
|
+
export declare class EmpathAI {
|
|
3
|
+
private options?;
|
|
4
|
+
private emotion;
|
|
5
|
+
private listeners;
|
|
6
|
+
constructor(options?: EmpathAIOptions | undefined);
|
|
7
|
+
init(): void;
|
|
8
|
+
destroy(): void;
|
|
9
|
+
private handleMouseMove;
|
|
10
|
+
private handleKeyDown;
|
|
11
|
+
private updateEmotion;
|
|
12
|
+
onEmotionChange(callback: (emotion: EmotionType) => void): void;
|
|
13
|
+
getCurrentEmotion(): EmotionType;
|
|
14
|
+
}
|
|
15
|
+
export declare const empathAI: EmpathAI;
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAEvD,qBAAa,QAAQ;IAIP,OAAO,CAAC,OAAO,CAAC;IAH5B,OAAO,CAAC,OAAO,CAA0B;IACzC,OAAO,CAAC,SAAS,CAA6C;gBAE1C,OAAO,CAAC,EAAE,eAAe,YAAA;IAE7C,IAAI;IAcJ,OAAO;IAKP,OAAO,CAAC,eAAe,CAQrB;IAEF,OAAO,CAAC,aAAa,CAOnB;IAEF,OAAO,CAAC,aAAa;IAOrB,eAAe,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI;IAIxD,iBAAiB,IAAI,WAAW;CAGjC;AAGD,eAAO,MAAM,QAAQ,UAAiB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export class EmpathAI {
|
|
2
|
+
constructor(options) {
|
|
3
|
+
this.options = options;
|
|
4
|
+
this.emotion = 'neutral';
|
|
5
|
+
this.listeners = [];
|
|
6
|
+
this.handleMouseMove = (e) => {
|
|
7
|
+
// Sample rule: fast/erratic movement = frustration
|
|
8
|
+
const speed = Math.abs(e.movementX) + Math.abs(e.movementY);
|
|
9
|
+
if (speed > 50) {
|
|
10
|
+
this.updateEmotion('frustrated');
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
this.updateEmotion('neutral');
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
this.handleKeyDown = (e) => {
|
|
17
|
+
// Sample rule: fast typing = focus; delete spam = frustration
|
|
18
|
+
if (e.key === 'Backspace') {
|
|
19
|
+
this.updateEmotion('frustrated');
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
this.updateEmotion('focused');
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
init() {
|
|
27
|
+
if (this.options?.enableMouseTracking !== false) {
|
|
28
|
+
window.addEventListener('mousemove', this.handleMouseMove);
|
|
29
|
+
}
|
|
30
|
+
if (this.options?.enableKeyboardTracking !== false) {
|
|
31
|
+
window.addEventListener('keydown', this.handleKeyDown);
|
|
32
|
+
}
|
|
33
|
+
if (this.options?.onInit) {
|
|
34
|
+
this.options.onInit();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
destroy() {
|
|
38
|
+
window.removeEventListener('mousemove', this.handleMouseMove);
|
|
39
|
+
window.removeEventListener('keydown', this.handleKeyDown);
|
|
40
|
+
}
|
|
41
|
+
updateEmotion(newEmotion) {
|
|
42
|
+
if (this.emotion !== newEmotion) {
|
|
43
|
+
this.emotion = newEmotion;
|
|
44
|
+
this.listeners.forEach((listener) => listener(this.emotion));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
onEmotionChange(callback) {
|
|
48
|
+
this.listeners.push(callback);
|
|
49
|
+
}
|
|
50
|
+
getCurrentEmotion() {
|
|
51
|
+
return this.emotion;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// ⚡️ Export reusable instance — import { empathAI } from '@empathai/core'
|
|
55
|
+
export const empathAI = new EmpathAI();
|
|
56
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,QAAQ;IAInB,YAAoB,OAAyB;QAAzB,YAAO,GAAP,OAAO,CAAkB;QAHrC,YAAO,GAAgB,SAAS,CAAC;QACjC,cAAS,GAA0C,EAAE,CAAC;QAuBtD,oBAAe,GAAG,CAAC,CAAa,EAAE,EAAE;YAC1C,mDAAmD;YACnD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;YAC5D,IAAI,KAAK,GAAG,EAAE,EAAE,CAAC;gBACf,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;YACnC,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;YAChC,CAAC;QACH,CAAC,CAAC;QAEM,kBAAa,GAAG,CAAC,CA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IAChC,CAAC;IAED,iBAAiB;QACf,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF;AAED,0EAA0E;AAC1E,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,QAAQ,EAAE,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type EmotionType = 'neutral' | 'focused' | 'frustrated' | 'happy' | 'bored' | 'curious' | 'stressed';
|
|
2
|
+
export interface EmotionData {
|
|
3
|
+
type: EmotionType;
|
|
4
|
+
confidence: number;
|
|
5
|
+
timestamp: number;
|
|
6
|
+
}
|
|
7
|
+
export interface EmpathAIOptions {
|
|
8
|
+
enableMouseTracking?: boolean;
|
|
9
|
+
enableKeyboardTracking?: boolean;
|
|
10
|
+
enableMicTracking?: boolean;
|
|
11
|
+
enableCameraTracking?: boolean;
|
|
12
|
+
onInit?: () => void;
|
|
13
|
+
onEmotionDetected?: (emotion: EmotionData) => void;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +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;IAC9B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,iBAAiB,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,CAAC;CACpD"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,eAAe"}
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "empathai-core",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Progressive, multimodal emotion detection SDK for real-time apps",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"keywords": [
|
|
11
|
+
"emotion",
|
|
12
|
+
"ai",
|
|
13
|
+
"sdk",
|
|
14
|
+
"empathai",
|
|
15
|
+
"user behavior",
|
|
16
|
+
"multimodal"
|
|
17
|
+
],
|
|
18
|
+
"author": "Mrityunjoy",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"private": false,
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"react": "^19.1.1"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/react": "^19.1.8",
|
|
26
|
+
"typescript": "^5.4.5"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsc",
|
|
30
|
+
"dev": "tsc --watch"
|
|
31
|
+
}
|
|
32
|
+
}
|