assistant-robot 0.0.2-beta → 0.0.2-epsilon

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/type.d.ts CHANGED
@@ -15,7 +15,7 @@ export interface IOperation {
15
15
  }
16
16
  export interface IOperationBoxBoxConfig {
17
17
  hide?: boolean;
18
- chatBoxClassName?: string;
18
+ perationBoxClassName?: string;
19
19
  operationList?: IOperation[];
20
20
  }
21
21
  export interface IModelConfig {
@@ -1,6 +1,6 @@
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);
1
+ var p = Object.defineProperty;
2
+ var h = (t, e, o) => e in t ? p(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o;
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],
6
6
  rotation: [0, Math.PI, 0],
@@ -29,7 +29,7 @@ const A = 60, y = {
29
29
  }, N = {
30
30
  big: { width: 640, height: 480 },
31
31
  small: { width: 360, height: 270 }
32
- }, l = "assistant-robot-model-container", s = "assistant_tip_container", v = '<div class="assistant-robot-container ', R = `">
32
+ }, l = "assistant-robot-model-container", s = "assistant-robot-tip-container", v = '<div class="assistant-robot-container ', R = `">
33
33
  <style>
34
34
  .assistant-robot-container{
35
35
  width: 100%;
@@ -78,14 +78,15 @@ const A = 60, y = {
78
78
 
79
79
  </div>
80
80
  <div>
81
- `, S = {
81
+ `, w = {
82
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
83
  alreadyOpenCamera: "the camera have be opened"
84
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 = `">
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-operation_container", c = "assistant-robot-menu_btn", r = "assistant-robot-menu_list", S = '<div class="assistant-robot-chartbox', E = `">
87
87
  <style>
88
88
  .assistant-robot-chartbox{
89
+ box-sizing: content-box;
89
90
  width: 100%;
90
91
  height: 32px;
91
92
  display: flex;
@@ -96,6 +97,7 @@ const u = "assistant-robot-input", b = "assistant-robot-btn", d = "operation_con
96
97
  box-shadow: 0 1px 2px -2px rgba(0, 0, 0, 0.16),
97
98
  0 3px 6px 0 rgba(0, 0, 0, 0.12),
98
99
  0 5px 12px 4px rgba(0, 0, 0, 0.09);
100
+ background-color: #fff;
99
101
  padding: 10px 12px;
100
102
  }
101
103
  .assistant-robot-input{
@@ -117,14 +119,14 @@ const u = "assistant-robot-input", b = "assistant-robot-btn", d = "operation_con
117
119
  position: relative;
118
120
  height: 24px;
119
121
  }
120
- .${p}{
122
+ .${c}{
121
123
  color: #dedede;
122
124
  width:24px;
123
125
  height: 24px;
124
126
  cursor: pointer;
125
127
  }
126
128
 
127
- .${i} {
129
+ .${r} {
128
130
  display: none;
129
131
  position: absolute;
130
132
  top: 30px;
@@ -138,14 +140,14 @@ const u = "assistant-robot-input", b = "assistant-robot-btn", d = "operation_con
138
140
  list-style: none;
139
141
  }
140
142
 
141
- .${i} li{
143
+ .${r} li{
142
144
  line-height: 32px;
143
145
  text-wrap: nowrap;
144
146
  border-bottom: 1px solid #dedede;
145
147
  cursor: pointer;
146
148
  }
147
149
 
148
- .${i} li:last-child{
150
+ .${r} li:last-child{
149
151
  border-bottom: none;
150
152
  }
151
153
 
@@ -157,7 +159,7 @@ const u = "assistant-robot-input", b = "assistant-robot-btn", d = "operation_con
157
159
  <span class="${d}">
158
160
  <svg
159
161
  t="1702017878997"
160
- class="${p}"
162
+ class="${c}"
161
163
  viewBox="0 0 1024 1024"
162
164
  version="1.1"
163
165
  p-id="1322"
@@ -180,61 +182,66 @@ const u = "assistant-robot-input", b = "assistant-robot-btn", d = "operation_con
180
182
  p-id="1325"
181
183
  ></path>
182
184
  </svg>
183
- <ul class="${i}">
185
+ <ul class="${r}">
184
186
  <li data-id="openCamera">Open the Camera</li>
185
187
  `, k = `</ul>
186
188
  </span>
187
- <input class="${u}" type="text" />
188
- <button class="${b}">ask</button>
189
+ <input class="${x}" type="text" />
190
+ <button class="${u}">ask</button>
189
191
  </div>`;
190
- var f = /* @__PURE__ */ ((e) => (e[e.loading = 1] = "loading", e[e.ready = 2] = "ready", e[e.error = 3] = "error", e))(f || {});
192
+ var f = /* @__PURE__ */ ((t) => (t[t.loading = 1] = "loading", t[t.ready = 2] = "ready", t[t.error = 3] = "error", t))(f || {});
191
193
  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 || {});
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
+ const m = "userDetectorStatusChange";
196
+ var O = /* @__PURE__ */ ((t) => (t.languageModelLoaded = "languageModelLoaded", t[t.userDetectorStatusChange = m] = "userDetectorStatusChange", t.menuClick = "menuClick", t.ask = "ask", t.say = "say", t))(O || {});
195
197
  function _() {
196
198
  return /iPhone|iPad|iPod/i.test(navigator.userAgent);
197
199
  }
198
- function T() {
200
+ function C() {
199
201
  return /Android/i.test(navigator.userAgent);
200
202
  }
201
203
  function P() {
202
- return T() || _();
204
+ return C() || _();
203
205
  }
204
- function B(e) {
205
- return new DOMParser().parseFromString(e, "text/html").body.firstElementChild;
206
+ function B(t) {
207
+ return new DOMParser().parseFromString(t, "text/html").body.firstElementChild;
206
208
  }
207
- function M(e) {
208
- if (!Array.isArray(e) || e.length === 0)
209
+ function M(t) {
210
+ if (!Array.isArray(t) || t.length === 0)
209
211
  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);
212
+ let e = -1 / 0, o = null;
213
+ for (let a = 0; a < t.length; a++) {
214
+ const i = t[a];
215
+ i && typeof i.score == "number" && i.score > e && (e = i.score, o = i);
214
216
  }
215
- return a;
217
+ return o;
216
218
  }
217
219
  class D {
218
220
  constructor() {
219
221
  n(this, "listeners", {});
220
222
  }
221
- addEventListener(t, a) {
222
- this.listeners[t] ? this.get(t).push(a) : this.listeners[t] = [a];
223
+ addEventListener(e, o) {
224
+ this.listeners[e] ? this.get(e).push(o) : this.listeners[e] = [o];
223
225
  }
224
- removeEventListener(t, a) {
225
- this.listeners[t] && (this.listeners[t] = this.get(t).filter(
226
- (o) => o !== a
226
+ removeEventListener(e, o) {
227
+ this.listeners[e] && (this.listeners[e] = this.get(e).filter(
228
+ (a) => a !== o
227
229
  ));
228
230
  }
229
- emit(t, ...a) {
230
- this.get(t).map((o) => {
231
- o(...a);
231
+ emit(e, ...o) {
232
+ this.get(e).map((a) => {
233
+ a(...o);
232
234
  });
233
235
  }
234
- get(t) {
235
- return this.listeners[t] || [];
236
+ get(e) {
237
+ return this.listeners[e] || [];
236
238
  }
237
239
  }
240
+ function H(t, e) {
241
+ for (; t.firstChild; )
242
+ t.removeChild(t.firstChild);
243
+ t.appendChild(e);
244
+ }
238
245
  export {
239
246
  s as A,
240
247
  v as C,
@@ -243,24 +250,25 @@ export {
243
250
  $ as O,
244
251
  L as R,
245
252
  A as T,
246
- O as U,
253
+ m as U,
247
254
  N as V,
248
255
  y as a,
249
- m as b,
250
- w as c,
256
+ g as b,
257
+ S as c,
251
258
  E as d,
252
259
  k as e,
253
- b as f,
254
- u as g,
255
- p as h,
260
+ u as f,
261
+ x as g,
262
+ c as h,
256
263
  P as i,
257
- i as j,
264
+ r as j,
258
265
  R as k,
259
266
  l,
260
- g as m,
261
- x as n,
267
+ O as m,
268
+ b as n,
262
269
  f as o,
263
270
  B as p,
264
271
  M as q,
265
- S as t
272
+ H as r,
273
+ w as t
266
274
  };
@@ -1,4 +1,4 @@
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=`">
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]}},C={big:{width:640,height:480},small:{width:360,height:270}},s="assistant-robot-model-container",n="assistant-robot-tip-container",I='<div class="assistant-robot-container ',N=`">
2
2
  <style>
3
3
  .assistant-robot-container{
4
4
  width: 100%;
@@ -47,9 +47,10 @@
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 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=`">
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 h="assistant-robot-input",_="assistant-robot-btn",c="assistant-robot-operation_container",l="assistant-robot-menu_btn",a="assistant-robot-menu_list",m='<div class="assistant-robot-chartbox',S=`">
51
51
  <style>
52
52
  .assistant-robot-chartbox{
53
+ box-sizing: content-box;
53
54
  width: 100%;
54
55
  height: 32px;
55
56
  display: flex;
@@ -60,6 +61,7 @@
60
61
  box-shadow: 0 1px 2px -2px rgba(0, 0, 0, 0.16),
61
62
  0 3px 6px 0 rgba(0, 0, 0, 0.12),
62
63
  0 5px 12px 4px rgba(0, 0, 0, 0.09);
64
+ background-color: #fff;
63
65
  padding: 10px 12px;
64
66
  }
65
67
  .assistant-robot-input{
@@ -77,7 +79,7 @@
77
79
  height: 24px;
78
80
  }
79
81
 
80
- .${p}{
82
+ .${c}{
81
83
  position: relative;
82
84
  height: 24px;
83
85
  }
@@ -118,7 +120,7 @@
118
120
  100% { opacity: 1; }
119
121
  }
120
122
  </style>
121
- <span class="${p}">
123
+ <span class="${c}">
122
124
  <svg
123
125
  t="1702017878997"
124
126
  class="${l}"
@@ -148,6 +150,6 @@
148
150
  <li data-id="openCamera">Open the Camera</li>
149
151
  `,R=`</ul>
150
152
  </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;
153
+ <input class="${h}" type="text" />
154
+ <button class="${_}">ask</button>
155
+ </div>`;var O=(t=>(t[t.loading=1]="loading",t[t.ready=2]="ready",t[t.error=3]="error",t))(O||{});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 u="userDetectorStatusChange";var b=(t=>(t.languageModelLoaded="languageModelLoaded",t[t.userDetectorStatusChange=u]="userDetectorStatusChange",t.menuClick="menuClick",t.ask="ask",t.say="say",t))(b||{});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=I;exports.EAssistantEvent=b;exports.ELanguageModelStatus=O;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=S;exports.ROBOT_OPERATION_BOX_HEAD=m;exports.ROBOT_OPERATION_BOX_TAIL=R;exports.ROBOT_OPERATION_BTN_CLASS=_;exports.ROBOT_OPERATION_INPUT_CLASS=h;exports.TARGET_FPS=60;exports.USER_DETECTOR_STATUS_CHANGE_EVENT=u;exports.VIDEO_SIZE=C;exports.findHighestScoreItem=M;exports.isMobile=D;exports.parseHTML=w;exports.replaceChildren=k;exports.tips=g;
package/dist/utils.d.ts CHANGED
@@ -12,3 +12,4 @@ export declare class EventListener {
12
12
  emit(event: string, ...args: any[]): void;
13
13
  get(name: string): TEventListenFunc[];
14
14
  }
15
+ 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-beta",
3
+ "version": "0.0.2-epsilon",
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",