assistant-robot 0.0.1-alpha → 0.0.2-alpha
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/.eslintrc.json +10 -0
- package/dist/Assistant.d.ts +22 -0
- package/dist/AssistantModel.d.ts +31 -0
- package/dist/LanguageModel.d.ts +23 -0
- package/dist/LanguageModel.js +1 -66
- package/dist/LanguageModel.mjs +37 -34
- package/dist/OperationManager.d.ts +12 -0
- package/dist/UserDetector.d.ts +21 -0
- package/dist/constants.d.ts +57 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1 -325
- package/dist/index.mjs +1861 -235
- package/dist/type.d.ts +64 -0
- package/dist/utils-N0deqkZQ.js +153 -0
- package/dist/utils-RQ7tdPHo.mjs +266 -0
- package/dist/utils.d.ts +14 -0
- package/index.d.ts +3 -0
- package/package.json +13 -4
- package/tsconfig.json +26 -0
- package/dist/utils-1rt7_Dvg.js +0 -153
- package/dist/utils-7giLo_Tq.mjs +0 -154
package/dist/type.d.ts
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
import { LanguageModel } from "./LanguageModel";
|
2
|
+
export interface ILanguageModelOptions {
|
3
|
+
[prop: string]: any;
|
4
|
+
}
|
5
|
+
interface ILanguageModelSubclass<T extends LanguageModel> {
|
6
|
+
new (options: ILanguageModelOptions): T;
|
7
|
+
}
|
8
|
+
export interface ILanguageModelConfig<T extends LanguageModel> extends ILanguageModelOptions {
|
9
|
+
Model: ILanguageModelSubclass<T>;
|
10
|
+
}
|
11
|
+
export interface IOperation {
|
12
|
+
key: string;
|
13
|
+
text: string;
|
14
|
+
disable: boolean;
|
15
|
+
}
|
16
|
+
export interface IOperationBoxBoxConfig {
|
17
|
+
hide?: boolean;
|
18
|
+
chatBoxClassName?: string;
|
19
|
+
operationList?: IOperation[];
|
20
|
+
}
|
21
|
+
export interface IModelConfig {
|
22
|
+
position: [number, number, number];
|
23
|
+
rotation: [number, number, number];
|
24
|
+
helloActionName: string;
|
25
|
+
idleActionName: string;
|
26
|
+
helloContent: string;
|
27
|
+
}
|
28
|
+
export interface IModelSceneConfig {
|
29
|
+
backgroundColor: number;
|
30
|
+
backgroundAlpha: number;
|
31
|
+
camera: {
|
32
|
+
fov: number;
|
33
|
+
near: number;
|
34
|
+
far: number;
|
35
|
+
position: [number, number, number];
|
36
|
+
lookAt: [number, number, number];
|
37
|
+
};
|
38
|
+
ambientLight: {
|
39
|
+
color: number;
|
40
|
+
intensity: number;
|
41
|
+
};
|
42
|
+
directionalLight: {
|
43
|
+
color: number;
|
44
|
+
intensity: number;
|
45
|
+
position: [number, number, number];
|
46
|
+
};
|
47
|
+
}
|
48
|
+
export type TRobotModelConfig = Partial<IModelSceneConfig> & {
|
49
|
+
modelConfig?: Partial<IModelConfig>;
|
50
|
+
modelUrl?: string;
|
51
|
+
};
|
52
|
+
export interface IUserDetectorConfig {
|
53
|
+
solutionPath?: string;
|
54
|
+
}
|
55
|
+
export interface IAssistantRobotConfig<T extends LanguageModel> {
|
56
|
+
className: string;
|
57
|
+
languageModel: ILanguageModelConfig<T>;
|
58
|
+
operationBox: IOperationBoxBoxConfig;
|
59
|
+
robotModel: TRobotModelConfig;
|
60
|
+
userDetector: IUserDetectorConfig;
|
61
|
+
}
|
62
|
+
export type TCallback = () => void;
|
63
|
+
export type TEventListenFunc = (...args: any[]) => void;
|
64
|
+
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
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
import { TEventListenFunc } from "./type";
|
2
|
+
import type { Answer } from "@tensorflow-models/qna/dist/question_and_answer";
|
3
|
+
export declare function isiOS(): boolean;
|
4
|
+
export declare function isAndroid(): boolean;
|
5
|
+
export declare function isMobile(): boolean;
|
6
|
+
export declare function parseHTML(htmlString: string): Element | null;
|
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/index.d.ts
ADDED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "assistant-robot",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.2-alpha",
|
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",
|
@@ -21,15 +21,24 @@
|
|
21
21
|
"three": "^0.158.0"
|
22
22
|
},
|
23
23
|
"devDependencies": {
|
24
|
+
"@types/three": "^0.159.0",
|
25
|
+
"@typescript-eslint/eslint-plugin": "^6.13.2",
|
26
|
+
"@typescript-eslint/parser": "^6.13.2",
|
27
|
+
"eslint": "^8.55.0",
|
28
|
+
"typescript": "^5.3.2",
|
24
29
|
"vite": "^5.0.4"
|
25
30
|
},
|
26
31
|
"scripts": {
|
27
|
-
"dev": "vite example",
|
28
|
-
"build": "vite build
|
32
|
+
"dev": "vite example --port 7000",
|
33
|
+
"build": "vite build && tsc",
|
34
|
+
"lint": "eslint . --ext ts --report-unused-disable-directives --max-warnings 0",
|
29
35
|
"preview": "vite preview"
|
30
36
|
},
|
31
37
|
"keywords": [
|
32
38
|
"assistant",
|
39
|
+
"robot",
|
40
|
+
"web-component",
|
41
|
+
"html",
|
33
42
|
"LLM",
|
34
43
|
"AI",
|
35
44
|
"3D",
|
@@ -37,5 +46,5 @@
|
|
37
46
|
"UI"
|
38
47
|
],
|
39
48
|
"author": "ymrdf",
|
40
|
-
"license": "
|
49
|
+
"license": "MIT"
|
41
50
|
}
|
package/tsconfig.json
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
{
|
2
|
+
"compilerOptions": {
|
3
|
+
"target": "ES2020",
|
4
|
+
"useDefineForClassFields": true,
|
5
|
+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
6
|
+
"module": "ESNext",
|
7
|
+
"skipLibCheck": true,
|
8
|
+
|
9
|
+
/* Bundler mode */
|
10
|
+
"moduleResolution": "Node",
|
11
|
+
"allowImportingTsExtensions": true,
|
12
|
+
"resolveJsonModule": true,
|
13
|
+
"isolatedModules": true,
|
14
|
+
"emitDeclarationOnly": true,
|
15
|
+
|
16
|
+
/* Linting */
|
17
|
+
"strict": true,
|
18
|
+
"noUnusedLocals": true,
|
19
|
+
"noUnusedParameters": true,
|
20
|
+
"noFallthroughCasesInSwitch": true,
|
21
|
+
|
22
|
+
"declaration": true, // Ensure this option is set to true
|
23
|
+
"outDir": "dist" // Specify your output directory
|
24
|
+
},
|
25
|
+
"include": ["index.d.ts","src/**/*.ts"]
|
26
|
+
}
|