assistant-robot 0.0.2-epsilon → 0.0.2
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/Assistant.d.ts +18 -1
- package/dist/AssistantModel.d.ts +33 -1
- package/dist/LanguageModel.d.ts +14 -0
- package/dist/LanguageModel.js +1 -1
- package/dist/LanguageModel.mjs +10 -1
- package/dist/OperationManager.d.ts +8 -3
- package/dist/UserDetector.d.ts +4 -0
- package/dist/constants.d.ts +5 -5
- package/dist/index.js +1 -1
- package/dist/index.mjs +345 -262
- package/dist/type.d.ts +27 -3
- package/dist/{utils-u6rFqFWg.mjs → utils-FAxjgnse.mjs} +14 -14
- package/dist/{utils-ybKQi2Om.js → utils-_ulwJfGD.js} +10 -10
- package/dist/utils.d.ts +14 -1
- package/package.json +1 -1
- package/readme.md +0 -0
package/dist/type.d.ts
CHANGED
@@ -11,9 +11,14 @@ export interface ILanguageModelConfig<T extends LanguageModel> extends ILanguage
|
|
11
11
|
export interface IOperation {
|
12
12
|
key: string;
|
13
13
|
text: string;
|
14
|
-
|
14
|
+
/**
|
15
|
+
* To mark that is this item disabled,
|
16
|
+
* we just add a `data-disabled` attribute to the menu item,
|
17
|
+
* user should implement the funtion
|
18
|
+
*/
|
19
|
+
disabled: boolean;
|
15
20
|
}
|
16
|
-
export interface
|
21
|
+
export interface IOperationBoxConfig {
|
17
22
|
hide?: boolean;
|
18
23
|
perationBoxClassName?: string;
|
19
24
|
operationList?: IOperation[];
|
@@ -25,6 +30,10 @@ export interface IModelConfig {
|
|
25
30
|
idleActionName: string;
|
26
31
|
helloContent: string;
|
27
32
|
}
|
33
|
+
/**
|
34
|
+
* Configs for the scene of the assistant robot's 3d model.
|
35
|
+
* To see all default value's, look at MODEL_SCENE_CONFIG
|
36
|
+
*/
|
28
37
|
export interface IModelSceneConfig {
|
29
38
|
backgroundColor: number;
|
30
39
|
backgroundAlpha: number;
|
@@ -35,27 +44,42 @@ export interface IModelSceneConfig {
|
|
35
44
|
position: [number, number, number];
|
36
45
|
lookAt: [number, number, number];
|
37
46
|
};
|
47
|
+
/**
|
48
|
+
* config of the ambient light in the scene.
|
49
|
+
* the light globally illuminates all objects in the scene equally.
|
50
|
+
*/
|
38
51
|
ambientLight: {
|
39
52
|
color: number;
|
40
53
|
intensity: number;
|
41
54
|
};
|
55
|
+
/**
|
56
|
+
* config of the directional light in the scene.
|
57
|
+
* A light that gets emitted in a specific direction
|
58
|
+
*/
|
42
59
|
directionalLight: {
|
43
60
|
color: number;
|
44
61
|
intensity: number;
|
45
62
|
position: [number, number, number];
|
46
63
|
};
|
47
64
|
}
|
65
|
+
/**
|
66
|
+
* config for the 3d render part.
|
67
|
+
*/
|
48
68
|
export type TRobotModelConfig = Partial<IModelSceneConfig> & {
|
49
69
|
modelConfig?: Partial<IModelConfig>;
|
50
70
|
modelUrl?: string;
|
51
71
|
};
|
52
72
|
export interface IUserDetectorConfig {
|
73
|
+
/**
|
74
|
+
* The path to where the files of the face detect model are located.
|
75
|
+
* If your user can not get the public one, the files can be download from there:https://github.com/ymrdf/assistant-robot/tree/main/example/public/face_detection
|
76
|
+
*/
|
53
77
|
solutionPath?: string;
|
54
78
|
}
|
55
79
|
export interface IAssistantRobotConfig<T extends LanguageModel> {
|
56
80
|
className: string;
|
57
81
|
languageModel: ILanguageModelConfig<T>;
|
58
|
-
operationBox:
|
82
|
+
operationBox: IOperationBoxConfig;
|
59
83
|
robotModel: TRobotModelConfig;
|
60
84
|
userDetector: IUserDetectorConfig;
|
61
85
|
}
|
@@ -1,5 +1,5 @@
|
|
1
|
-
var
|
2
|
-
var h = (t, e, o) => e in t ?
|
1
|
+
var c = Object.defineProperty;
|
2
|
+
var h = (t, e, o) => e in t ? c(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o;
|
3
3
|
var n = (t, e, o) => (h(t, typeof e != "symbol" ? e + "" : e, o), o);
|
4
4
|
const A = 60, y = {
|
5
5
|
position: [0, 0, 0],
|
@@ -83,12 +83,12 @@ const A = 60, y = {
|
|
83
83
|
alreadyOpenCamera: "the camera have be opened"
|
84
84
|
};
|
85
85
|
var b = /* @__PURE__ */ ((t) => (t.openCamera = "openCamera", t.hello = "hello", t))(b || {});
|
86
|
-
const x = "assistant-robot-input", u = "assistant-robot-btn", d = "assistant-robot-
|
86
|
+
const x = "assistant-robot-input", u = "assistant-robot-btn", d = "assistant-robot-operation-container", p = "assistant-robot-menu-btn", r = "assistant-robot-menu-list", S = '<div class="assistant-robot-operationbox', E = `">
|
87
87
|
<style>
|
88
|
-
.assistant-robot-
|
89
|
-
box-sizing:
|
88
|
+
.assistant-robot-operationbox{
|
89
|
+
box-sizing: border-box;
|
90
90
|
width: 100%;
|
91
|
-
height:
|
91
|
+
height: 52px;
|
92
92
|
display: flex;
|
93
93
|
flex: 0 0 auto;
|
94
94
|
flex-wrap: wrap;
|
@@ -119,8 +119,8 @@ const x = "assistant-robot-input", u = "assistant-robot-btn", d = "assistant-rob
|
|
119
119
|
position: relative;
|
120
120
|
height: 24px;
|
121
121
|
}
|
122
|
-
.${
|
123
|
-
color: #
|
122
|
+
.${p}{
|
123
|
+
color: #aaaaaa;
|
124
124
|
width:24px;
|
125
125
|
height: 24px;
|
126
126
|
cursor: pointer;
|
@@ -159,7 +159,7 @@ const x = "assistant-robot-input", u = "assistant-robot-btn", d = "assistant-rob
|
|
159
159
|
<span class="${d}">
|
160
160
|
<svg
|
161
161
|
t="1702017878997"
|
162
|
-
class="${
|
162
|
+
class="${p}"
|
163
163
|
viewBox="0 0 1024 1024"
|
164
164
|
version="1.1"
|
165
165
|
p-id="1322"
|
@@ -183,7 +183,7 @@ const x = "assistant-robot-input", u = "assistant-robot-btn", d = "assistant-rob
|
|
183
183
|
></path>
|
184
184
|
</svg>
|
185
185
|
<ul class="${r}">
|
186
|
-
<li data-id="openCamera">
|
186
|
+
<li data-id="openCamera">eye contact</li>
|
187
187
|
`, k = `</ul>
|
188
188
|
</span>
|
189
189
|
<input class="${x}" type="text" />
|
@@ -194,14 +194,14 @@ const $ = 50, L = 2e3;
|
|
194
194
|
var g = /* @__PURE__ */ ((t) => (t.init = "init", t.ready = "ready", t.openCameraRejected = "openCameraRejected", t.userMediaUnavailable = "userMediaUnavailable", t.faceDetectorCreateError = "faceDetectorCreateError", t.error = "error", t))(g || {});
|
195
195
|
const m = "userDetectorStatusChange";
|
196
196
|
var O = /* @__PURE__ */ ((t) => (t.languageModelLoaded = "languageModelLoaded", t[t.userDetectorStatusChange = m] = "userDetectorStatusChange", t.menuClick = "menuClick", t.ask = "ask", t.say = "say", t))(O || {});
|
197
|
-
function
|
197
|
+
function C() {
|
198
198
|
return /iPhone|iPad|iPod/i.test(navigator.userAgent);
|
199
199
|
}
|
200
|
-
function
|
200
|
+
function T() {
|
201
201
|
return /Android/i.test(navigator.userAgent);
|
202
202
|
}
|
203
203
|
function P() {
|
204
|
-
return
|
204
|
+
return T() || C();
|
205
205
|
}
|
206
206
|
function B(t) {
|
207
207
|
return new DOMParser().parseFromString(t, "text/html").body.firstElementChild;
|
@@ -259,7 +259,7 @@ export {
|
|
259
259
|
k as e,
|
260
260
|
u as f,
|
261
261
|
x as g,
|
262
|
-
|
262
|
+
p as h,
|
263
263
|
P as i,
|
264
264
|
r as j,
|
265
265
|
R as k,
|
@@ -1,4 +1,4 @@
|
|
1
|
-
"use strict";var A=Object.defineProperty;var E=(t,e,o)=>e in t?A(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o;var d=(t,e,o)=>(E(t,typeof e!="symbol"?e+"":e,o),o);const x={position:[0,0,0],rotation:[0,Math.PI,0],helloActionName:"hello",idleActionName:"idle",helloContent:"Hi, you can talk to me!"},f={backgroundColor:0,backgroundAlpha:0,camera:{fov:50,near:.1,far:10,position:[0,0,2],lookAt:[0,0,0]},ambientLight:{color:16777215,intensity:.5},directionalLight:{color:16777215,intensity:2,position:[10,10,0]}},
|
1
|
+
"use strict";var A=Object.defineProperty;var E=(t,e,o)=>e in t?A(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o;var d=(t,e,o)=>(E(t,typeof e!="symbol"?e+"":e,o),o);const x={position:[0,0,0],rotation:[0,Math.PI,0],helloActionName:"hello",idleActionName:"idle",helloContent:"Hi, you can talk to me!"},f={backgroundColor:0,backgroundAlpha:0,camera:{fov:50,near:.1,far:10,position:[0,0,2],lookAt:[0,0,0]},ambientLight:{color:16777215,intensity:.5},directionalLight:{color:16777215,intensity:2,position:[10,10,0]}},I={big:{width:640,height:480},small:{width:360,height:270}},s="assistant-robot-model-container",n="assistant-robot-tip-container",C='<div class="assistant-robot-container ',N=`">
|
2
2
|
<style>
|
3
3
|
.assistant-robot-container{
|
4
4
|
width: 100%;
|
@@ -47,12 +47,12 @@
|
|
47
47
|
|
48
48
|
</div>
|
49
49
|
<div>
|
50
|
-
`,g={openCamera:"To interactive with the assistant, we'd like to access your device's camera.Take it easy, your pictures and information won't be sent anywhere or be stored.",alreadyOpenCamera:"the camera have be opened"};var p=(t=>(t.openCamera="openCamera",t.hello="hello",t))(p||{});const
|
50
|
+
`,g={openCamera:"To interactive with the assistant, we'd like to access your device's camera.Take it easy, your pictures and information won't be sent anywhere or be stored.",alreadyOpenCamera:"the camera have be opened"};var p=(t=>(t.openCamera="openCamera",t.hello="hello",t))(p||{});const O="assistant-robot-input",h="assistant-robot-btn",c="assistant-robot-operation-container",l="assistant-robot-menu-btn",a="assistant-robot-menu-list",S='<div class="assistant-robot-operationbox',m=`">
|
51
51
|
<style>
|
52
|
-
.assistant-robot-
|
53
|
-
box-sizing:
|
52
|
+
.assistant-robot-operationbox{
|
53
|
+
box-sizing: border-box;
|
54
54
|
width: 100%;
|
55
|
-
height:
|
55
|
+
height: 52px;
|
56
56
|
display: flex;
|
57
57
|
flex: 0 0 auto;
|
58
58
|
flex-wrap: wrap;
|
@@ -84,7 +84,7 @@
|
|
84
84
|
height: 24px;
|
85
85
|
}
|
86
86
|
.${l}{
|
87
|
-
color: #
|
87
|
+
color: #aaaaaa;
|
88
88
|
width:24px;
|
89
89
|
height: 24px;
|
90
90
|
cursor: pointer;
|
@@ -147,9 +147,9 @@
|
|
147
147
|
></path>
|
148
148
|
</svg>
|
149
149
|
<ul class="${a}">
|
150
|
-
<li data-id="openCamera">
|
150
|
+
<li data-id="openCamera">eye contact</li>
|
151
151
|
`,R=`</ul>
|
152
152
|
</span>
|
153
|
-
<input class="${
|
154
|
-
<button class="${
|
155
|
-
</div>`;var
|
153
|
+
<input class="${O}" type="text" />
|
154
|
+
<button class="${h}">ask</button>
|
155
|
+
</div>`;var _=(t=>(t[t.loading=1]="loading",t[t.ready=2]="ready",t[t.error=3]="error",t))(_||{});const y=50,L=2e3;var T=(t=>(t.init="init",t.ready="ready",t.openCameraRejected="openCameraRejected",t.userMediaUnavailable="userMediaUnavailable",t.faceDetectorCreateError="faceDetectorCreateError",t.error="error",t))(T||{});const b="userDetectorStatusChange";var u=(t=>(t.languageModelLoaded="languageModelLoaded",t[t.userDetectorStatusChange=b]="userDetectorStatusChange",t.menuClick="menuClick",t.ask="ask",t.say="say",t))(u||{});function v(){return/iPhone|iPad|iPod/i.test(navigator.userAgent)}function B(){return/Android/i.test(navigator.userAgent)}function D(){return B()||v()}function w(t){return new DOMParser().parseFromString(t,"text/html").body.firstElementChild}function M(t){if(!Array.isArray(t)||t.length===0)return null;let e=-1/0,o=null;for(let i=0;i<t.length;i++){const r=t[i];r&&typeof r.score=="number"&&r.score>e&&(e=r.score,o=r)}return o}class P{constructor(){d(this,"listeners",{})}addEventListener(e,o){this.listeners[e]?this.get(e).push(o):this.listeners[e]=[o]}removeEventListener(e,o){this.listeners[e]&&(this.listeners[e]=this.get(e).filter(i=>i!==o))}emit(e,...o){this.get(e).map(i=>{i(...o)})}get(e){return this.listeners[e]||[]}}function k(t,e){for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(e)}exports.ASSISTANT_MODEL_CONTAINER_CLASS=s;exports.ASSISTANT_TIP_CONTAINER=n;exports.CONTAINER_BODY=N;exports.CONTAINER_HEAD=C;exports.EAssistantEvent=u;exports.ELanguageModelStatus=_;exports.EMenuKey=p;exports.EUserDetectorStatus=T;exports.EventListener=P;exports.MENU_BTN_CLASS=l;exports.MENU_LIST_CLASS=a;exports.MODEL_CONFIG=x;exports.MODEL_SCENE_CONFIG=f;exports.ONE_LETTER_READ_TIME=y;exports.READ_WAIT_TIME=L;exports.ROBOT_OPERATION_BOX_BODY=m;exports.ROBOT_OPERATION_BOX_HEAD=S;exports.ROBOT_OPERATION_BOX_TAIL=R;exports.ROBOT_OPERATION_BTN_CLASS=h;exports.ROBOT_OPERATION_INPUT_CLASS=O;exports.TARGET_FPS=60;exports.USER_DETECTOR_STATUS_CHANGE_EVENT=b;exports.VIDEO_SIZE=I;exports.findHighestScoreItem=M;exports.isMobile=D;exports.parseHTML=w;exports.replaceChildren=k;exports.tips=g;
|
package/dist/utils.d.ts
CHANGED
@@ -1,10 +1,18 @@
|
|
1
|
-
import { TEventListenFunc } from "./type";
|
2
1
|
import type { Answer } from "@tensorflow-models/qna/dist/question_and_answer";
|
2
|
+
import { TEventListenFunc } from "./type";
|
3
3
|
export declare function isiOS(): boolean;
|
4
4
|
export declare function isAndroid(): boolean;
|
5
5
|
export declare function isMobile(): boolean;
|
6
|
+
/**
|
7
|
+
* turn a html string to dom
|
8
|
+
* @param htmlString a html string
|
9
|
+
* @returns a dom tree
|
10
|
+
*/
|
6
11
|
export declare function parseHTML(htmlString: string): Element | null;
|
7
12
|
export declare function findHighestScoreItem(data: Answer[]): Answer | null;
|
13
|
+
/**
|
14
|
+
* utils class which implement Observer Pattern
|
15
|
+
*/
|
8
16
|
export declare class EventListener {
|
9
17
|
private listeners;
|
10
18
|
addEventListener(name: string, func: TEventListenFunc): void;
|
@@ -12,4 +20,9 @@ export declare class EventListener {
|
|
12
20
|
emit(event: string, ...args: any[]): void;
|
13
21
|
get(name: string): TEventListenFunc[];
|
14
22
|
}
|
23
|
+
/**
|
24
|
+
* to replace all children of parentNode to a new node
|
25
|
+
* @param parentNode the pareent node
|
26
|
+
* @param newNode the child node will insert to the parent node
|
27
|
+
*/
|
15
28
|
export declare function replaceChildren(parentNode: Node, newNode: Node): void;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "assistant-robot",
|
3
|
-
"version": "0.0.2
|
3
|
+
"version": "0.0.2",
|
4
4
|
"description": "An assistant widget, have a 3D robot which can interact with user, have a simple LLM which can chat with user.",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"module": "dist/index.mjs",
|
package/readme.md
ADDED
File without changes
|