assistant-robot 0.0.1 → 0.0.2-beta
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 +22 -0
- package/dist/AssistantModel.d.ts +2 -6
- package/dist/LanguageModel.js +1 -1
- package/dist/LanguageModel.mjs +1 -1
- package/dist/OperationManager.d.ts +12 -0
- package/dist/UserDetector.d.ts +5 -2
- package/dist/constants.d.ts +33 -5
- package/dist/index.d.ts +3 -16
- package/dist/index.js +1 -1
- package/dist/index.mjs +933 -854
- package/dist/type.d.ts +15 -2
- package/dist/utils-N0deqkZQ.js +153 -0
- package/dist/utils-RQ7tdPHo.mjs +266 -0
- package/dist/utils.d.ts +8 -0
- package/package.json +2 -2
- package/dist/QuestionManager.d.ts +0 -9
- package/dist/utils-ePOYkfFK.js +0 -64
- package/dist/utils-vFpckT4x.mjs +0 -136
package/dist/type.d.ts
CHANGED
@@ -8,9 +8,15 @@ interface ILanguageModelSubclass<T extends LanguageModel> {
|
|
8
8
|
export interface ILanguageModelConfig<T extends LanguageModel> extends ILanguageModelOptions {
|
9
9
|
Model: ILanguageModelSubclass<T>;
|
10
10
|
}
|
11
|
-
export interface
|
11
|
+
export interface IOperation {
|
12
|
+
key: string;
|
13
|
+
text: string;
|
14
|
+
disable: boolean;
|
15
|
+
}
|
16
|
+
export interface IOperationBoxBoxConfig {
|
12
17
|
hide?: boolean;
|
13
18
|
chatBoxClassName?: string;
|
19
|
+
operationList?: IOperation[];
|
14
20
|
}
|
15
21
|
export interface IModelConfig {
|
16
22
|
position: [number, number, number];
|
@@ -49,9 +55,16 @@ export interface IUserDetectorConfig {
|
|
49
55
|
export interface IAssistantRobotConfig<T extends LanguageModel> {
|
50
56
|
className: string;
|
51
57
|
languageModel: ILanguageModelConfig<T>;
|
52
|
-
|
58
|
+
operationBox: IOperationBoxBoxConfig;
|
53
59
|
robotModel: TRobotModelConfig;
|
54
60
|
userDetector: IUserDetectorConfig;
|
55
61
|
}
|
56
62
|
export type TCallback = () => void;
|
63
|
+
export type TEventListenFunc = (...args: any[]) => void;
|
64
|
+
export interface IActionConfig {
|
65
|
+
loop?: boolean;
|
66
|
+
weight?: number;
|
67
|
+
timeScale?: number;
|
68
|
+
repetitions?: number;
|
69
|
+
}
|
57
70
|
export {};
|
@@ -0,0 +1,153 @@
|
|
1
|
+
"use strict";var E=Object.defineProperty;var x=(e,t,o)=>t in e?E(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o;var d=(e,t,o)=>(x(e,typeof t!="symbol"?t+"":t,o),o);const b={position:[0,0,0],rotation:[0,Math.PI,0],helloActionName:"hello",idleActionName:"idle",helloContent:"Hi, you can talk to me!"},I={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]}},N={big:{width:640,height:480},small:{width:360,height:270}},s="assistant-robot-model-container",n="assistant_tip_container",f='<div class="assistant-robot-container ',C=`">
|
2
|
+
<style>
|
3
|
+
.assistant-robot-container{
|
4
|
+
width: 100%;
|
5
|
+
height: 100%;
|
6
|
+
display: flex;
|
7
|
+
flex-direction: column;
|
8
|
+
}
|
9
|
+
.${s}{
|
10
|
+
flex: 1;
|
11
|
+
position:relative;
|
12
|
+
width:100%;
|
13
|
+
}
|
14
|
+
.${n}{
|
15
|
+
position: absolute;
|
16
|
+
top: 2px;
|
17
|
+
left: 50%;
|
18
|
+
min-width: 100px;
|
19
|
+
border: 1px solid #aaaaaa;
|
20
|
+
border-radius: 6px;
|
21
|
+
background: #fff;
|
22
|
+
transform: translate(-50%);
|
23
|
+
padding: 12px 20px;
|
24
|
+
text-align: center;
|
25
|
+
animation: fadeInOut 0.4s ease-in-out;
|
26
|
+
}
|
27
|
+
@keyframes fadeInOut {
|
28
|
+
0% { opacity: 0; }
|
29
|
+
100% { opacity: 1; }
|
30
|
+
}
|
31
|
+
.${n}::after{
|
32
|
+
content: '';
|
33
|
+
display: block;
|
34
|
+
position: absolute;
|
35
|
+
bottom: -6px;
|
36
|
+
left: 50%;
|
37
|
+
width: 8px;
|
38
|
+
height: 8px;
|
39
|
+
transform: rotate(45deg);
|
40
|
+
border-bottom: 1px solid #aaaaaa;
|
41
|
+
border-right: 1px solid #aaaaaa;
|
42
|
+
background: #fff;
|
43
|
+
}
|
44
|
+
</style>
|
45
|
+
<div class="${s}">
|
46
|
+
<div class="${n}">HI!</div>
|
47
|
+
|
48
|
+
</div>
|
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 c=(e=>(e.openCamera="openCamera",e.hello="hello",e))(c||{});const _="assistant-robot-input",O="assistant-robot-btn",p="operation_container",l="menu_btn",a="menu_list",S='<div class="assistant-robot-chartbox',m=`">
|
51
|
+
<style>
|
52
|
+
.assistant-robot-chartbox{
|
53
|
+
width: 100%;
|
54
|
+
height: 32px;
|
55
|
+
display: flex;
|
56
|
+
flex: 0 0 auto;
|
57
|
+
flex-wrap: wrap;
|
58
|
+
align-items: center;
|
59
|
+
border-radius: 54px;
|
60
|
+
box-shadow: 0 1px 2px -2px rgba(0, 0, 0, 0.16),
|
61
|
+
0 3px 6px 0 rgba(0, 0, 0, 0.12),
|
62
|
+
0 5px 12px 4px rgba(0, 0, 0, 0.09);
|
63
|
+
padding: 10px 12px;
|
64
|
+
}
|
65
|
+
.assistant-robot-input{
|
66
|
+
flex: 1;
|
67
|
+
min-width: 200px;
|
68
|
+
background: rgba(0,0,0,0);
|
69
|
+
border: 1px solid #dedede;
|
70
|
+
height: 28px;
|
71
|
+
margin-right: 6px;
|
72
|
+
outline:none;
|
73
|
+
color: #666666;
|
74
|
+
}
|
75
|
+
.assistant-robot-btn{
|
76
|
+
flex: 0 0 auto;
|
77
|
+
height: 24px;
|
78
|
+
}
|
79
|
+
|
80
|
+
.${p}{
|
81
|
+
position: relative;
|
82
|
+
height: 24px;
|
83
|
+
}
|
84
|
+
.${l}{
|
85
|
+
color: #dedede;
|
86
|
+
width:24px;
|
87
|
+
height: 24px;
|
88
|
+
cursor: pointer;
|
89
|
+
}
|
90
|
+
|
91
|
+
.${a} {
|
92
|
+
display: none;
|
93
|
+
position: absolute;
|
94
|
+
top: 30px;
|
95
|
+
left: 0px;
|
96
|
+
background-color: #fff;
|
97
|
+
border: 1px solid #ccc;
|
98
|
+
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
|
99
|
+
padding: 10px;
|
100
|
+
border-radius: 5px;
|
101
|
+
animation: fadeInOut 0.4s ease-in-out;
|
102
|
+
list-style: none;
|
103
|
+
}
|
104
|
+
|
105
|
+
.${a} li{
|
106
|
+
line-height: 32px;
|
107
|
+
text-wrap: nowrap;
|
108
|
+
border-bottom: 1px solid #dedede;
|
109
|
+
cursor: pointer;
|
110
|
+
}
|
111
|
+
|
112
|
+
.${a} li:last-child{
|
113
|
+
border-bottom: none;
|
114
|
+
}
|
115
|
+
|
116
|
+
@keyframes fadeInOut {
|
117
|
+
0% { opacity: 0; }
|
118
|
+
100% { opacity: 1; }
|
119
|
+
}
|
120
|
+
</style>
|
121
|
+
<span class="${p}">
|
122
|
+
<svg
|
123
|
+
t="1702017878997"
|
124
|
+
class="${l}"
|
125
|
+
viewBox="0 0 1024 1024"
|
126
|
+
version="1.1"
|
127
|
+
p-id="1322"
|
128
|
+
width="32"
|
129
|
+
height="32"
|
130
|
+
>
|
131
|
+
<path
|
132
|
+
d="M512 512m-116.949333 0a116.949333 116.949333 0 1 0 233.898666 0 116.949333 116.949333 0 1 0-233.898666 0Z"
|
133
|
+
fill="currentColor"
|
134
|
+
p-id="1323"
|
135
|
+
></path>
|
136
|
+
<path
|
137
|
+
d="M512 159.616m-116.949333 0a116.949333 116.949333 0 1 0 233.898666 0 116.949333 116.949333 0 1 0-233.898666 0Z"
|
138
|
+
fill="currentColor"
|
139
|
+
p-id="1324"
|
140
|
+
></path>
|
141
|
+
<path
|
142
|
+
d="M512 864.384m-116.949333 0a116.949333 116.949333 0 1 0 233.898666 0 116.949333 116.949333 0 1 0-233.898666 0Z"
|
143
|
+
fill="currentColor"
|
144
|
+
p-id="1325"
|
145
|
+
></path>
|
146
|
+
</svg>
|
147
|
+
<ul class="${a}">
|
148
|
+
<li data-id="openCamera">Open the Camera</li>
|
149
|
+
`,R=`</ul>
|
150
|
+
</span>
|
151
|
+
<input class="${_}" type="text" />
|
152
|
+
<button class="${O}">ask</button>
|
153
|
+
</div>`;var T=(e=>(e[e.loading=1]="loading",e[e.ready=2]="ready",e[e.error=3]="error",e))(T||{});const y=50,L=2e3;var h=(e=>(e.init="init",e.ready="ready",e.openCameraRejected="openCameraRejected",e.userMediaUnavailable="userMediaUnavailable",e.faceDetectorCreateError="faceDetectorCreateError",e.error="error",e))(h||{});const u="userDetectorStatusChange";var A=(e=>(e.languageModelLoaded="languageModelLoaded",e[e.userDetectorStatusChange=u]="userDetectorStatusChange",e.menuClick="menuClick",e.ask="ask",e.say="say",e))(A||{});function v(){return/iPhone|iPad|iPod/i.test(navigator.userAgent)}function B(){return/Android/i.test(navigator.userAgent)}function D(){return B()||v()}function M(e){return new DOMParser().parseFromString(e,"text/html").body.firstElementChild}function P(e){if(!Array.isArray(e)||e.length===0)return null;let t=-1/0,o=null;for(let i=0;i<e.length;i++){const r=e[i];r&&typeof r.score=="number"&&r.score>t&&(t=r.score,o=r)}return o}class w{constructor(){d(this,"listeners",{})}addEventListener(t,o){this.listeners[t]?this.get(t).push(o):this.listeners[t]=[o]}removeEventListener(t,o){this.listeners[t]&&(this.listeners[t]=this.get(t).filter(i=>i!==o))}emit(t,...o){this.get(t).map(i=>{i(...o)})}get(t){return this.listeners[t]||[]}}exports.ASSISTANT_MODEL_CONTAINER_CLASS=s;exports.ASSISTANT_TIP_CONTAINER=n;exports.CONTAINER_BODY=C;exports.CONTAINER_HEAD=f;exports.EAssistantEvent=A;exports.ELanguageModelStatus=T;exports.EMenuKey=c;exports.EUserDetectorStatus=h;exports.EventListener=w;exports.MENU_BTN_CLASS=l;exports.MENU_LIST_CLASS=a;exports.MODEL_CONFIG=b;exports.MODEL_SCENE_CONFIG=I;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=O;exports.ROBOT_OPERATION_INPUT_CLASS=_;exports.TARGET_FPS=60;exports.USER_DETECTOR_STATUS_CHANGE_EVENT=u;exports.VIDEO_SIZE=N;exports.findHighestScoreItem=P;exports.isMobile=D;exports.parseHTML=M;exports.tips=g;
|
@@ -0,0 +1,266 @@
|
|
1
|
+
var c = Object.defineProperty;
|
2
|
+
var h = (e, t, a) => t in e ? c(e, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : e[t] = a;
|
3
|
+
var n = (e, t, a) => (h(e, typeof t != "symbol" ? t + "" : t, a), a);
|
4
|
+
const A = 60, y = {
|
5
|
+
position: [0, 0, 0],
|
6
|
+
rotation: [0, Math.PI, 0],
|
7
|
+
helloActionName: "hello",
|
8
|
+
idleActionName: "idle",
|
9
|
+
helloContent: "Hi, you can talk to me!"
|
10
|
+
}, I = {
|
11
|
+
backgroundColor: 0,
|
12
|
+
backgroundAlpha: 0,
|
13
|
+
camera: {
|
14
|
+
fov: 50,
|
15
|
+
near: 0.1,
|
16
|
+
far: 10,
|
17
|
+
position: [0, 0, 2],
|
18
|
+
lookAt: [0, 0, 0]
|
19
|
+
},
|
20
|
+
ambientLight: {
|
21
|
+
color: 16777215,
|
22
|
+
intensity: 0.5
|
23
|
+
},
|
24
|
+
directionalLight: {
|
25
|
+
color: 16777215,
|
26
|
+
intensity: 2,
|
27
|
+
position: [10, 10, 0]
|
28
|
+
}
|
29
|
+
}, N = {
|
30
|
+
big: { width: 640, height: 480 },
|
31
|
+
small: { width: 360, height: 270 }
|
32
|
+
}, l = "assistant-robot-model-container", s = "assistant_tip_container", v = '<div class="assistant-robot-container ', R = `">
|
33
|
+
<style>
|
34
|
+
.assistant-robot-container{
|
35
|
+
width: 100%;
|
36
|
+
height: 100%;
|
37
|
+
display: flex;
|
38
|
+
flex-direction: column;
|
39
|
+
}
|
40
|
+
.${l}{
|
41
|
+
flex: 1;
|
42
|
+
position:relative;
|
43
|
+
width:100%;
|
44
|
+
}
|
45
|
+
.${s}{
|
46
|
+
position: absolute;
|
47
|
+
top: 2px;
|
48
|
+
left: 50%;
|
49
|
+
min-width: 100px;
|
50
|
+
border: 1px solid #aaaaaa;
|
51
|
+
border-radius: 6px;
|
52
|
+
background: #fff;
|
53
|
+
transform: translate(-50%);
|
54
|
+
padding: 12px 20px;
|
55
|
+
text-align: center;
|
56
|
+
animation: fadeInOut 0.4s ease-in-out;
|
57
|
+
}
|
58
|
+
@keyframes fadeInOut {
|
59
|
+
0% { opacity: 0; }
|
60
|
+
100% { opacity: 1; }
|
61
|
+
}
|
62
|
+
.${s}::after{
|
63
|
+
content: '';
|
64
|
+
display: block;
|
65
|
+
position: absolute;
|
66
|
+
bottom: -6px;
|
67
|
+
left: 50%;
|
68
|
+
width: 8px;
|
69
|
+
height: 8px;
|
70
|
+
transform: rotate(45deg);
|
71
|
+
border-bottom: 1px solid #aaaaaa;
|
72
|
+
border-right: 1px solid #aaaaaa;
|
73
|
+
background: #fff;
|
74
|
+
}
|
75
|
+
</style>
|
76
|
+
<div class="${l}">
|
77
|
+
<div class="${s}">HI!</div>
|
78
|
+
|
79
|
+
</div>
|
80
|
+
<div>
|
81
|
+
`, S = {
|
82
|
+
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.",
|
83
|
+
alreadyOpenCamera: "the camera have be opened"
|
84
|
+
};
|
85
|
+
var x = /* @__PURE__ */ ((e) => (e.openCamera = "openCamera", e.hello = "hello", e))(x || {});
|
86
|
+
const u = "assistant-robot-input", b = "assistant-robot-btn", d = "operation_container", p = "menu_btn", i = "menu_list", w = '<div class="assistant-robot-chartbox', E = `">
|
87
|
+
<style>
|
88
|
+
.assistant-robot-chartbox{
|
89
|
+
width: 100%;
|
90
|
+
height: 32px;
|
91
|
+
display: flex;
|
92
|
+
flex: 0 0 auto;
|
93
|
+
flex-wrap: wrap;
|
94
|
+
align-items: center;
|
95
|
+
border-radius: 54px;
|
96
|
+
box-shadow: 0 1px 2px -2px rgba(0, 0, 0, 0.16),
|
97
|
+
0 3px 6px 0 rgba(0, 0, 0, 0.12),
|
98
|
+
0 5px 12px 4px rgba(0, 0, 0, 0.09);
|
99
|
+
padding: 10px 12px;
|
100
|
+
}
|
101
|
+
.assistant-robot-input{
|
102
|
+
flex: 1;
|
103
|
+
min-width: 200px;
|
104
|
+
background: rgba(0,0,0,0);
|
105
|
+
border: 1px solid #dedede;
|
106
|
+
height: 28px;
|
107
|
+
margin-right: 6px;
|
108
|
+
outline:none;
|
109
|
+
color: #666666;
|
110
|
+
}
|
111
|
+
.assistant-robot-btn{
|
112
|
+
flex: 0 0 auto;
|
113
|
+
height: 24px;
|
114
|
+
}
|
115
|
+
|
116
|
+
.${d}{
|
117
|
+
position: relative;
|
118
|
+
height: 24px;
|
119
|
+
}
|
120
|
+
.${p}{
|
121
|
+
color: #dedede;
|
122
|
+
width:24px;
|
123
|
+
height: 24px;
|
124
|
+
cursor: pointer;
|
125
|
+
}
|
126
|
+
|
127
|
+
.${i} {
|
128
|
+
display: none;
|
129
|
+
position: absolute;
|
130
|
+
top: 30px;
|
131
|
+
left: 0px;
|
132
|
+
background-color: #fff;
|
133
|
+
border: 1px solid #ccc;
|
134
|
+
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
|
135
|
+
padding: 10px;
|
136
|
+
border-radius: 5px;
|
137
|
+
animation: fadeInOut 0.4s ease-in-out;
|
138
|
+
list-style: none;
|
139
|
+
}
|
140
|
+
|
141
|
+
.${i} li{
|
142
|
+
line-height: 32px;
|
143
|
+
text-wrap: nowrap;
|
144
|
+
border-bottom: 1px solid #dedede;
|
145
|
+
cursor: pointer;
|
146
|
+
}
|
147
|
+
|
148
|
+
.${i} li:last-child{
|
149
|
+
border-bottom: none;
|
150
|
+
}
|
151
|
+
|
152
|
+
@keyframes fadeInOut {
|
153
|
+
0% { opacity: 0; }
|
154
|
+
100% { opacity: 1; }
|
155
|
+
}
|
156
|
+
</style>
|
157
|
+
<span class="${d}">
|
158
|
+
<svg
|
159
|
+
t="1702017878997"
|
160
|
+
class="${p}"
|
161
|
+
viewBox="0 0 1024 1024"
|
162
|
+
version="1.1"
|
163
|
+
p-id="1322"
|
164
|
+
width="32"
|
165
|
+
height="32"
|
166
|
+
>
|
167
|
+
<path
|
168
|
+
d="M512 512m-116.949333 0a116.949333 116.949333 0 1 0 233.898666 0 116.949333 116.949333 0 1 0-233.898666 0Z"
|
169
|
+
fill="currentColor"
|
170
|
+
p-id="1323"
|
171
|
+
></path>
|
172
|
+
<path
|
173
|
+
d="M512 159.616m-116.949333 0a116.949333 116.949333 0 1 0 233.898666 0 116.949333 116.949333 0 1 0-233.898666 0Z"
|
174
|
+
fill="currentColor"
|
175
|
+
p-id="1324"
|
176
|
+
></path>
|
177
|
+
<path
|
178
|
+
d="M512 864.384m-116.949333 0a116.949333 116.949333 0 1 0 233.898666 0 116.949333 116.949333 0 1 0-233.898666 0Z"
|
179
|
+
fill="currentColor"
|
180
|
+
p-id="1325"
|
181
|
+
></path>
|
182
|
+
</svg>
|
183
|
+
<ul class="${i}">
|
184
|
+
<li data-id="openCamera">Open the Camera</li>
|
185
|
+
`, k = `</ul>
|
186
|
+
</span>
|
187
|
+
<input class="${u}" type="text" />
|
188
|
+
<button class="${b}">ask</button>
|
189
|
+
</div>`;
|
190
|
+
var f = /* @__PURE__ */ ((e) => (e[e.loading = 1] = "loading", e[e.ready = 2] = "ready", e[e.error = 3] = "error", e))(f || {});
|
191
|
+
const $ = 50, L = 2e3;
|
192
|
+
var m = /* @__PURE__ */ ((e) => (e.init = "init", e.ready = "ready", e.openCameraRejected = "openCameraRejected", e.userMediaUnavailable = "userMediaUnavailable", e.faceDetectorCreateError = "faceDetectorCreateError", e.error = "error", e))(m || {});
|
193
|
+
const O = "userDetectorStatusChange";
|
194
|
+
var g = /* @__PURE__ */ ((e) => (e.languageModelLoaded = "languageModelLoaded", e[e.userDetectorStatusChange = O] = "userDetectorStatusChange", e.menuClick = "menuClick", e.ask = "ask", e.say = "say", e))(g || {});
|
195
|
+
function _() {
|
196
|
+
return /iPhone|iPad|iPod/i.test(navigator.userAgent);
|
197
|
+
}
|
198
|
+
function T() {
|
199
|
+
return /Android/i.test(navigator.userAgent);
|
200
|
+
}
|
201
|
+
function P() {
|
202
|
+
return T() || _();
|
203
|
+
}
|
204
|
+
function B(e) {
|
205
|
+
return new DOMParser().parseFromString(e, "text/html").body.firstElementChild;
|
206
|
+
}
|
207
|
+
function M(e) {
|
208
|
+
if (!Array.isArray(e) || e.length === 0)
|
209
|
+
return null;
|
210
|
+
let t = -1 / 0, a = null;
|
211
|
+
for (let o = 0; o < e.length; o++) {
|
212
|
+
const r = e[o];
|
213
|
+
r && typeof r.score == "number" && r.score > t && (t = r.score, a = r);
|
214
|
+
}
|
215
|
+
return a;
|
216
|
+
}
|
217
|
+
class D {
|
218
|
+
constructor() {
|
219
|
+
n(this, "listeners", {});
|
220
|
+
}
|
221
|
+
addEventListener(t, a) {
|
222
|
+
this.listeners[t] ? this.get(t).push(a) : this.listeners[t] = [a];
|
223
|
+
}
|
224
|
+
removeEventListener(t, a) {
|
225
|
+
this.listeners[t] && (this.listeners[t] = this.get(t).filter(
|
226
|
+
(o) => o !== a
|
227
|
+
));
|
228
|
+
}
|
229
|
+
emit(t, ...a) {
|
230
|
+
this.get(t).map((o) => {
|
231
|
+
o(...a);
|
232
|
+
});
|
233
|
+
}
|
234
|
+
get(t) {
|
235
|
+
return this.listeners[t] || [];
|
236
|
+
}
|
237
|
+
}
|
238
|
+
export {
|
239
|
+
s as A,
|
240
|
+
v as C,
|
241
|
+
D as E,
|
242
|
+
I as M,
|
243
|
+
$ as O,
|
244
|
+
L as R,
|
245
|
+
A as T,
|
246
|
+
O as U,
|
247
|
+
N as V,
|
248
|
+
y as a,
|
249
|
+
m as b,
|
250
|
+
w as c,
|
251
|
+
E as d,
|
252
|
+
k as e,
|
253
|
+
b as f,
|
254
|
+
u as g,
|
255
|
+
p as h,
|
256
|
+
P as i,
|
257
|
+
i as j,
|
258
|
+
R as k,
|
259
|
+
l,
|
260
|
+
g as m,
|
261
|
+
x as n,
|
262
|
+
f as o,
|
263
|
+
B as p,
|
264
|
+
M as q,
|
265
|
+
S as t
|
266
|
+
};
|
package/dist/utils.d.ts
CHANGED
@@ -1,6 +1,14 @@
|
|
1
|
+
import { TEventListenFunc } from "./type";
|
1
2
|
import type { Answer } from "@tensorflow-models/qna/dist/question_and_answer";
|
2
3
|
export declare function isiOS(): boolean;
|
3
4
|
export declare function isAndroid(): boolean;
|
4
5
|
export declare function isMobile(): boolean;
|
5
6
|
export declare function parseHTML(htmlString: string): Element | null;
|
6
7
|
export declare function findHighestScoreItem(data: Answer[]): Answer | null;
|
8
|
+
export declare class EventListener {
|
9
|
+
private listeners;
|
10
|
+
addEventListener(name: string, func: TEventListenFunc): void;
|
11
|
+
removeEventListener(name: string, func: TEventListenFunc): void;
|
12
|
+
emit(event: string, ...args: any[]): void;
|
13
|
+
get(name: string): TEventListenFunc[];
|
14
|
+
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "assistant-robot",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.2-beta",
|
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",
|
@@ -29,7 +29,7 @@
|
|
29
29
|
"vite": "^5.0.4"
|
30
30
|
},
|
31
31
|
"scripts": {
|
32
|
-
"dev": "vite example",
|
32
|
+
"dev": "vite example --port 7000",
|
33
33
|
"build": "vite build && tsc",
|
34
34
|
"lint": "eslint . --ext ts --report-unused-disable-directives --max-warnings 0",
|
35
35
|
"preview": "vite preview"
|
@@ -1,9 +0,0 @@
|
|
1
|
-
import { IChatBoxConfig } from "./type";
|
2
|
-
export declare class QuestionManager {
|
3
|
-
btnDom: HTMLButtonElement | undefined;
|
4
|
-
inputDom: HTMLInputElement | undefined;
|
5
|
-
onAsk: (question: string) => void;
|
6
|
-
constructor(container: Element, onAsk: (question: string) => void, options?: IChatBoxConfig);
|
7
|
-
initChatBox(container: Element, options?: IChatBoxConfig): void;
|
8
|
-
addEventListener(): void;
|
9
|
-
}
|
package/dist/utils-ePOYkfFK.js
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
"use strict";const _={position:[0,0,0],rotation:[0,Math.PI,0],helloActionName:"hello",idleActionName:"idle",helloContent:"Hi, you can talk to me!"},T={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]}},A={big:{width:640,height:480},small:{width:360,height:270}},e="assistant-robot-model-container",i="assistant_tip_container",d='<div class="assistant-robot-container ',O=`">
|
2
|
-
<style>
|
3
|
-
.assistant-robot-container{
|
4
|
-
width: 100%;
|
5
|
-
height: 100%;
|
6
|
-
display: flex;
|
7
|
-
flex-direction: column;
|
8
|
-
}
|
9
|
-
.${e}{
|
10
|
-
flex: 1;
|
11
|
-
position:relative;
|
12
|
-
width:100%;
|
13
|
-
}
|
14
|
-
.${i}{
|
15
|
-
position: absolute;
|
16
|
-
top: 2px;
|
17
|
-
left: 50%;
|
18
|
-
min-width: 100px;
|
19
|
-
border: 1px solid #aaaaaa;
|
20
|
-
border-radius: 6px;
|
21
|
-
background: #fff;
|
22
|
-
transform: translate(-50%);
|
23
|
-
padding: 12px 20px;
|
24
|
-
text-align: center;
|
25
|
-
}
|
26
|
-
.${i}::after{
|
27
|
-
content: '';
|
28
|
-
display: block;
|
29
|
-
position: absolute;
|
30
|
-
bottom: -6px;
|
31
|
-
left: 50%;
|
32
|
-
width: 8px;
|
33
|
-
height: 8px;
|
34
|
-
transform: rotate(45deg);
|
35
|
-
border-bottom: 1px solid #aaaaaa;
|
36
|
-
border-right: 1px solid #aaaaaa;
|
37
|
-
background: #fff;
|
38
|
-
}
|
39
|
-
</style>
|
40
|
-
<div class="${e}">
|
41
|
-
<div class="${i}">HI!</div>
|
42
|
-
|
43
|
-
</div>
|
44
|
-
<div>
|
45
|
-
`,a="assistant-robot-input",l="assistant-robot-btn",E='<div class="assistant-robot-chartbox',p=`">
|
46
|
-
<style>
|
47
|
-
.assistant-robot-chartbox{
|
48
|
-
width: 100%;
|
49
|
-
display: flex;
|
50
|
-
flex-wrap: wrap;
|
51
|
-
}
|
52
|
-
.assistant-robot-input{
|
53
|
-
flex: 1;
|
54
|
-
min-width: 200px;
|
55
|
-
background: rgba(0,0,0,0);
|
56
|
-
border: 1px solid #aaaaaa;
|
57
|
-
}
|
58
|
-
.assistant-robot-btn{
|
59
|
-
flex: 0 0 auto;
|
60
|
-
}
|
61
|
-
</style>
|
62
|
-
<input class="${a}" type="text" />
|
63
|
-
<button class="${l}">ask</button>
|
64
|
-
</div>`;var c=(t=>(t[t.loading=1]="loading",t[t.ready=2]="ready",t[t.error=3]="error",t))(c||{});const b=50,I=2e3;function f(){return/iPhone|iPad|iPod/i.test(navigator.userAgent)}function N(){return/Android/i.test(navigator.userAgent)}function h(){return N()||f()}function S(t){return new DOMParser().parseFromString(t,"text/html").body.firstElementChild}function C(t){if(!Array.isArray(t)||t.length===0)return null;let n=-1/0,r=null;for(let s=0;s<t.length;s++){const o=t[s];o&&typeof o.score=="number"&&o.score>n&&(n=o.score,r=o)}return r}exports.ASSISTANT_MODEL_CONTAINER_CLASS=e;exports.ASSISTANT_TIP_CONTAINER=i;exports.CONTAINER_BODY=O;exports.CONTAINER_HEAD=d;exports.ELanguageModelStatus=c;exports.MODEL_CONFIG=_;exports.MODEL_SCENE_CONFIG=T;exports.ONE_LETTER_READ_TIME=b;exports.READ_WAIT_TIME=I;exports.ROBOT_CHAT_BOX_BODY=p;exports.ROBOT_CHAT_BOX_HEAD=E;exports.ROBOT_CHAT_BTN_CLASS=l;exports.ROBOT_CHAT_INPUT_CLASS=a;exports.TARGET_FPS=60;exports.VIDEO_SIZE=A;exports.findHighestScoreItem=C;exports.isMobile=h;exports.parseHTML=S;
|
package/dist/utils-vFpckT4x.mjs
DELETED
@@ -1,136 +0,0 @@
|
|
1
|
-
const b = 60, f = {
|
2
|
-
position: [0, 0, 0],
|
3
|
-
rotation: [0, Math.PI, 0],
|
4
|
-
helloActionName: "hello",
|
5
|
-
idleActionName: "idle",
|
6
|
-
helloContent: "Hi, you can talk to me!"
|
7
|
-
}, h = {
|
8
|
-
backgroundColor: 0,
|
9
|
-
backgroundAlpha: 0,
|
10
|
-
camera: {
|
11
|
-
fov: 50,
|
12
|
-
near: 0.1,
|
13
|
-
far: 10,
|
14
|
-
position: [0, 0, 2],
|
15
|
-
lookAt: [0, 0, 0]
|
16
|
-
},
|
17
|
-
ambientLight: {
|
18
|
-
color: 16777215,
|
19
|
-
intensity: 0.5
|
20
|
-
},
|
21
|
-
directionalLight: {
|
22
|
-
color: 16777215,
|
23
|
-
intensity: 2,
|
24
|
-
position: [10, 10, 0]
|
25
|
-
}
|
26
|
-
}, A = {
|
27
|
-
big: { width: 640, height: 480 },
|
28
|
-
small: { width: 360, height: 270 }
|
29
|
-
}, r = "assistant-robot-model-container", n = "assistant_tip_container", _ = '<div class="assistant-robot-container ', x = `">
|
30
|
-
<style>
|
31
|
-
.assistant-robot-container{
|
32
|
-
width: 100%;
|
33
|
-
height: 100%;
|
34
|
-
display: flex;
|
35
|
-
flex-direction: column;
|
36
|
-
}
|
37
|
-
.${r}{
|
38
|
-
flex: 1;
|
39
|
-
position:relative;
|
40
|
-
width:100%;
|
41
|
-
}
|
42
|
-
.${n}{
|
43
|
-
position: absolute;
|
44
|
-
top: 2px;
|
45
|
-
left: 50%;
|
46
|
-
min-width: 100px;
|
47
|
-
border: 1px solid #aaaaaa;
|
48
|
-
border-radius: 6px;
|
49
|
-
background: #fff;
|
50
|
-
transform: translate(-50%);
|
51
|
-
padding: 12px 20px;
|
52
|
-
text-align: center;
|
53
|
-
}
|
54
|
-
.${n}::after{
|
55
|
-
content: '';
|
56
|
-
display: block;
|
57
|
-
position: absolute;
|
58
|
-
bottom: -6px;
|
59
|
-
left: 50%;
|
60
|
-
width: 8px;
|
61
|
-
height: 8px;
|
62
|
-
transform: rotate(45deg);
|
63
|
-
border-bottom: 1px solid #aaaaaa;
|
64
|
-
border-right: 1px solid #aaaaaa;
|
65
|
-
background: #fff;
|
66
|
-
}
|
67
|
-
</style>
|
68
|
-
<div class="${r}">
|
69
|
-
<div class="${n}">HI!</div>
|
70
|
-
|
71
|
-
</div>
|
72
|
-
<div>
|
73
|
-
`, e = "assistant-robot-input", c = "assistant-robot-btn", T = '<div class="assistant-robot-chartbox', O = `">
|
74
|
-
<style>
|
75
|
-
.assistant-robot-chartbox{
|
76
|
-
width: 100%;
|
77
|
-
display: flex;
|
78
|
-
flex-wrap: wrap;
|
79
|
-
}
|
80
|
-
.assistant-robot-input{
|
81
|
-
flex: 1;
|
82
|
-
min-width: 200px;
|
83
|
-
background: rgba(0,0,0,0);
|
84
|
-
border: 1px solid #aaaaaa;
|
85
|
-
}
|
86
|
-
.assistant-robot-btn{
|
87
|
-
flex: 0 0 auto;
|
88
|
-
}
|
89
|
-
</style>
|
90
|
-
<input class="${e}" type="text" />
|
91
|
-
<button class="${c}">ask</button>
|
92
|
-
</div>`;
|
93
|
-
var l = /* @__PURE__ */ ((t) => (t[t.loading = 1] = "loading", t[t.ready = 2] = "ready", t[t.error = 3] = "error", t))(l || {});
|
94
|
-
const u = 50, m = 2e3;
|
95
|
-
function d() {
|
96
|
-
return /iPhone|iPad|iPod/i.test(navigator.userAgent);
|
97
|
-
}
|
98
|
-
function p() {
|
99
|
-
return /Android/i.test(navigator.userAgent);
|
100
|
-
}
|
101
|
-
function I() {
|
102
|
-
return p() || d();
|
103
|
-
}
|
104
|
-
function g(t) {
|
105
|
-
return new DOMParser().parseFromString(t, "text/html").body.firstElementChild;
|
106
|
-
}
|
107
|
-
function y(t) {
|
108
|
-
if (!Array.isArray(t) || t.length === 0)
|
109
|
-
return null;
|
110
|
-
let s = -1 / 0, i = null;
|
111
|
-
for (let a = 0; a < t.length; a++) {
|
112
|
-
const o = t[a];
|
113
|
-
o && typeof o.score == "number" && o.score > s && (s = o.score, i = o);
|
114
|
-
}
|
115
|
-
return i;
|
116
|
-
}
|
117
|
-
export {
|
118
|
-
n as A,
|
119
|
-
_ as C,
|
120
|
-
l as E,
|
121
|
-
h as M,
|
122
|
-
u as O,
|
123
|
-
m as R,
|
124
|
-
b as T,
|
125
|
-
A as V,
|
126
|
-
f as a,
|
127
|
-
T as b,
|
128
|
-
O as c,
|
129
|
-
c as d,
|
130
|
-
e,
|
131
|
-
x as f,
|
132
|
-
r as g,
|
133
|
-
y as h,
|
134
|
-
I as i,
|
135
|
-
g as p
|
136
|
-
};
|