@genai-fi/base 4.1.2 → 4.1.4

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.
@@ -1,8 +1,9 @@
1
1
  interface Props {
2
2
  api: string;
3
+ checkURL?: string;
3
4
  appName: string;
4
5
  visibility?: number;
5
6
  noCheck?: boolean;
6
7
  }
7
- export default function ConnectionStatus({ api, appName, visibility, noCheck }: Props): import("react/jsx-runtime").JSX.Element;
8
+ export default function ConnectionStatus({ api, checkURL, appName, visibility, noCheck }: Props): import("react/jsx-runtime").JSX.Element;
8
9
  export {};
@@ -1,24 +1,24 @@
1
- import { jsx as r, Fragment as I, jsxs as L } from "react/jsx-runtime";
2
- import { iceConfig as W, webrtcActive as q } from "../../state/webrtcState.js";
3
- import { useRef as F, useState as g, useEffect as o } from "react";
4
- import { getRTConfig as P } from "./ice.js";
5
- import { W as R, F as z } from "../../FlashWifi-DkGhdWqj.js";
6
- import { useTranslation as E } from "react-i18next";
7
- import { c as b } from "../../createSvgIcon-DQhMxTx4.js";
8
- import { checkP2P as j } from "./check.js";
9
- import { usePeerObject as x } from "../../hooks/peer.js";
10
- import { a as T } from "../../react-D_xU5dL6.js";
11
- import '../../assets/ConnectionStatus.css';const A = "_containerConnecting_1p4sr_15 _container_1p4sr_3", U = "_containerSuccess_1p4sr_20 _container_1p4sr_3", k = "_containerMedium_1p4sr_25 _container_1p4sr_3", w = "_containerBad_1p4sr_30 _container_1p4sr_3", D = "_message_1p4sr_35", a = {
12
- containerConnecting: A,
13
- containerSuccess: U,
14
- containerMedium: k,
15
- containerBad: w,
16
- message: D
17
- }, O = b(/* @__PURE__ */ r("path", {
1
+ import { jsx as r, Fragment as W, jsxs as q } from "react/jsx-runtime";
2
+ import { iceConfig as F, webrtcActive as L } from "../../state/webrtcState.js";
3
+ import { useRef as P, useState as g, useEffect as o } from "react";
4
+ import { getRTConfig as z } from "./ice.js";
5
+ import { W as E, F as R } from "../../FlashWifi-DkGhdWqj.js";
6
+ import { useTranslation as b } from "react-i18next";
7
+ import { c as j } from "../../createSvgIcon-DQhMxTx4.js";
8
+ import { checkP2P as x } from "./check.js";
9
+ import { usePeerObject as A } from "../../hooks/peer.js";
10
+ import { a as B } from "../../react-D_xU5dL6.js";
11
+ import '../../assets/ConnectionStatus.css';const w = "_containerConnecting_1p4sr_15 _container_1p4sr_3", D = "_containerSuccess_1p4sr_20 _container_1p4sr_3", O = "_containerMedium_1p4sr_25 _container_1p4sr_3", U = "_containerBad_1p4sr_30 _container_1p4sr_3", $ = "_message_1p4sr_35", a = {
12
+ containerConnecting: w,
13
+ containerSuccess: D,
14
+ containerMedium: O,
15
+ containerBad: U,
16
+ message: $
17
+ }, k = j(/* @__PURE__ */ r("path", {
18
18
  d: "M24 8.98C20.93 5.9 16.69 4 12 4S3.07 5.9 0 8.98L12 21v-9h8.99zM19.59 14l-2.09 2.09L15.41 14 14 15.41l2.09 2.09L14 19.59 15.41 21l2.09-2.08L19.59 21 21 19.59l-2.08-2.09L21 15.41z"
19
- }), "SignalWifiBad"), $ = 6e4;
20
- function ee({ api: f, appName: h, visibility: S, noCheck: v }) {
21
- const { t: p } = E(), e = x(), [u, y] = T(W), [C, l] = T(q), m = F(), [n, d] = g("connecting"), [s, _] = g(0), [, B] = g(!1), [c, M] = g(!1), i = n === "ready";
19
+ }), "SignalWifiBad"), N = 6e4;
20
+ function te({ api: f, checkURL: S, appName: h, visibility: v, noCheck: y }) {
21
+ const { t: p } = b(), e = A(), [u, C] = B(F), [M, l] = B(L), m = P(), [n, d] = g("connecting"), [s, _] = g(0), [, I] = g(!1), [c, T] = g(!1), i = n === "ready";
22
22
  return o(() => {
23
23
  if (e)
24
24
  return e.on("status", d), e.on("quality", _), d(e.status), _(e.quality), () => {
@@ -26,48 +26,48 @@ function ee({ api: f, appName: h, visibility: S, noCheck: v }) {
26
26
  };
27
27
  _(0), d("connecting");
28
28
  }, [e]), o(() => {
29
- u || P(f, h, (t) => {
30
- y(t);
29
+ u || z(f, h, (t) => {
30
+ C(t);
31
31
  });
32
- }, [u, y, f, h]), o(() => {
32
+ }, [u, C, f, h]), o(() => {
33
33
  if (n !== "ready") {
34
34
  const t = setTimeout(() => {
35
- M(!0);
36
- }, $);
35
+ T(!0);
36
+ }, N);
37
37
  return () => {
38
38
  clearTimeout(t);
39
39
  };
40
40
  } else
41
- M(!1);
41
+ T(!1);
42
42
  }, [n]), o(() => {
43
- u && C === "unset" && (navigator != null && navigator.mediaDevices ? navigator.mediaDevices.getUserMedia({ video: !0 }).then((t) => {
43
+ u && M === "unset" && (navigator != null && navigator.mediaDevices ? navigator.mediaDevices.getUserMedia({ video: !0 }).then((t) => {
44
44
  m.current = t, l("full");
45
45
  }).catch(() => {
46
46
  l("relay");
47
47
  }) : l("relay"));
48
- }, [u, C, l]), o(() => {
48
+ }, [u, M, l]), o(() => {
49
49
  i && m.current && (m.current.getTracks().forEach(function(t) {
50
50
  t.stop();
51
51
  }), m.current = void 0);
52
52
  }, [i, n]), o(() => {
53
- i && e && !v && e.code && j(f, e.code).then((t) => {
54
- B(t);
53
+ i && e && !y && e.code && x(S || f, e.code).then((t) => {
54
+ I(t);
55
55
  });
56
- }, [i, e, f, v]), /* @__PURE__ */ r(I, { children: (S === void 0 || s <= S) && /* @__PURE__ */ L(
56
+ }, [i, e, f, S, y]), /* @__PURE__ */ r(W, { children: (v === void 0 || s <= v) && /* @__PURE__ */ q(
57
57
  "div",
58
58
  {
59
59
  className: n === "connecting" && !c ? a.containerConnecting : s === 3 ? a.containerSuccess : s === 2 ? a.containerMedium : a.containerBad,
60
60
  children: [
61
61
  !c && s > 0 && /* @__PURE__ */ r(
62
- R,
62
+ E,
63
63
  {
64
64
  fontSize: "large",
65
65
  color: "inherit"
66
66
  }
67
67
  ),
68
- !c && s <= 0 && /* @__PURE__ */ r(z, {}),
68
+ !c && s <= 0 && /* @__PURE__ */ r(R, {}),
69
69
  c && /* @__PURE__ */ r(
70
- O,
70
+ k,
71
71
  {
72
72
  fontSize: "large",
73
73
  color: "inherit"
@@ -79,5 +79,5 @@ function ee({ api: f, appName: h, visibility: S, noCheck: v }) {
79
79
  ) });
80
80
  }
81
81
  export {
82
- ee as default
82
+ te as default
83
83
  };
@@ -13,5 +13,5 @@ interface Props extends Callbacks {
13
13
  hidden?: boolean;
14
14
  size: number;
15
15
  }
16
- export default function Webcam({ interval, capture, disable, direct, hidden, size, ...props }: Props): import("react/jsx-runtime").JSX.Element;
16
+ export default function Webcam({ interval, capture, disable, direct, hidden, size, onActivated, onFatal, onPostprocess, onCapture, onPreprocess, }: Props): import("react/jsx-runtime").JSX.Element;
17
17
  export {};
@@ -1,41 +1,41 @@
1
- import { jsx as c, jsxs as j, Fragment as D } from "react/jsx-runtime";
2
- import * as X from "react";
3
- import { useState as T, useRef as b, useEffect as C, useCallback as B } from "react";
4
- import { useTranslation as H } from "react-i18next";
5
- import { IconButton as P } from "@mui/material";
6
- import { c as K } from "../../createSvgIcon-DQhMxTx4.js";
7
- import { WebcamClass as L } from "./webcamClass.js";
8
- import { g as G, u as J, s as Q, c as Y, a as Z, m as W } from "../../DefaultPropsProvider-BurgXZzw.js";
9
- import { g as tt, P as n } from "../../createTheme-DV959X3d.js";
10
- import { css as z, keyframes as q } from "@emotion/react";
11
- import '../../assets/Webcam.css';function et(t) {
12
- return String(t).match(/[\d.\-+]*\s*(.*)/)[1] || "";
1
+ import { jsx as c, jsxs as F, Fragment as q } from "react/jsx-runtime";
2
+ import * as G from "react";
3
+ import { useState as N, useRef as T, useEffect as b, useCallback as E } from "react";
4
+ import { useTranslation as J } from "react-i18next";
5
+ import { IconButton as V } from "@mui/material";
6
+ import { c as Q } from "../../createSvgIcon-DQhMxTx4.js";
7
+ import { WebcamClass as Y } from "./webcamClass.js";
8
+ import { g as Z, u as P, s as W, c as ee, a as te, m as ae } from "../../DefaultPropsProvider-BurgXZzw.js";
9
+ import { g as ne, P as a } from "../../createTheme-DV959X3d.js";
10
+ import { css as A, keyframes as H } from "@emotion/react";
11
+ import '../../assets/Webcam.css';function re(e) {
12
+ return String(e).match(/[\d.\-+]*\s*(.*)/)[1] || "";
13
13
  }
14
- function nt(t) {
15
- return parseFloat(t);
14
+ function ie(e) {
15
+ return parseFloat(e);
16
16
  }
17
- const rt = "_container_u6uf5_1", at = "_wrapContainer_u6uf5_5", ot = "_flipButton_u6uf5_10", F = {
18
- container: rt,
19
- wrapContainer: at,
20
- flipButton: ot
17
+ const oe = "_container_u6uf5_1", se = "_wrapContainer_u6uf5_5", ce = "_flipButton_u6uf5_10", $ = {
18
+ container: oe,
19
+ wrapContainer: se,
20
+ flipButton: ce
21
21
  };
22
- function it(t) {
23
- return tt("MuiSkeleton", t);
22
+ function le(e) {
23
+ return ne("MuiSkeleton", e);
24
24
  }
25
- G("MuiSkeleton", ["root", "text", "rectangular", "rounded", "circular", "pulse", "wave", "withChildren", "fitContent", "heightAuto"]);
26
- const st = (t) => {
25
+ Z("MuiSkeleton", ["root", "text", "rectangular", "rounded", "circular", "pulse", "wave", "withChildren", "fitContent", "heightAuto"]);
26
+ const ue = (e) => {
27
27
  const {
28
- classes: o,
29
- variant: a,
30
- animation: i,
31
- hasChildren: p,
32
- width: y,
33
- height: m
34
- } = t;
35
- return Z({
36
- root: ["root", a, i, p && "withChildren", p && !y && "fitContent", p && !m && "heightAuto"]
37
- }, it, o);
38
- }, M = q`
28
+ classes: i,
29
+ variant: r,
30
+ animation: o,
31
+ hasChildren: u,
32
+ width: v,
33
+ height: s
34
+ } = e;
35
+ return te({
36
+ root: ["root", r, o, u && "withChildren", u && !v && "fitContent", u && !s && "heightAuto"]
37
+ }, le, i);
38
+ }, j = H`
39
39
  0% {
40
40
  opacity: 1;
41
41
  }
@@ -47,7 +47,7 @@ const st = (t) => {
47
47
  100% {
48
48
  opacity: 1;
49
49
  }
50
- `, _ = q`
50
+ `, D = H`
51
51
  0% {
52
52
  transform: translateX(-100%);
53
53
  }
@@ -60,29 +60,29 @@ const st = (t) => {
60
60
  100% {
61
61
  transform: translateX(100%);
62
62
  }
63
- `, ct = typeof M != "string" ? z`
64
- animation: ${M} 2s ease-in-out 0.5s infinite;
65
- ` : null, lt = typeof _ != "string" ? z`
63
+ `, fe = typeof j != "string" ? A`
64
+ animation: ${j} 2s ease-in-out 0.5s infinite;
65
+ ` : null, pe = typeof D != "string" ? A`
66
66
  &::after {
67
- animation: ${_} 2s linear 0.5s infinite;
67
+ animation: ${D} 2s linear 0.5s infinite;
68
68
  }
69
- ` : null, ut = Q("span", {
69
+ ` : null, de = W("span", {
70
70
  name: "MuiSkeleton",
71
71
  slot: "Root",
72
- overridesResolver: (t, o) => {
72
+ overridesResolver: (e, i) => {
73
73
  const {
74
- ownerState: a
75
- } = t;
76
- return [o.root, o[a.variant], a.animation !== !1 && o[a.animation], a.hasChildren && o.withChildren, a.hasChildren && !a.width && o.fitContent, a.hasChildren && !a.height && o.heightAuto];
74
+ ownerState: r
75
+ } = e;
76
+ return [i.root, i[r.variant], r.animation !== !1 && i[r.animation], r.hasChildren && i.withChildren, r.hasChildren && !r.width && i.fitContent, r.hasChildren && !r.height && i.heightAuto];
77
77
  }
78
- })(W(({
79
- theme: t
78
+ })(ae(({
79
+ theme: e
80
80
  }) => {
81
- const o = et(t.shape.borderRadius) || "px", a = nt(t.shape.borderRadius);
81
+ const i = re(e.shape.borderRadius) || "px", r = ie(e.shape.borderRadius);
82
82
  return {
83
83
  display: "block",
84
84
  // Create a "on paper" color with sufficient contrast retaining the color
85
- backgroundColor: t.vars ? t.vars.palette.Skeleton.bg : t.alpha(t.palette.text.primary, t.palette.mode === "light" ? 0.11 : 0.13),
85
+ backgroundColor: e.vars ? e.vars.palette.Skeleton.bg : e.alpha(e.palette.text.primary, e.palette.mode === "light" ? 0.11 : 0.13),
86
86
  height: "1.2em",
87
87
  variants: [{
88
88
  props: {
@@ -94,7 +94,7 @@ const st = (t) => {
94
94
  height: "auto",
95
95
  transformOrigin: "0 55%",
96
96
  transform: "scale(1, 0.60)",
97
- borderRadius: `${a}${o}/${Math.round(a / 0.6 * 10) / 10}${o}`,
97
+ borderRadius: `${r}${i}/${Math.round(r / 0.6 * 10) / 10}${i}`,
98
98
  "&:empty:before": {
99
99
  content: '"\\00a0"'
100
100
  }
@@ -111,12 +111,12 @@ const st = (t) => {
111
111
  variant: "rounded"
112
112
  },
113
113
  style: {
114
- borderRadius: (t.vars || t).shape.borderRadius
114
+ borderRadius: (e.vars || e).shape.borderRadius
115
115
  }
116
116
  }, {
117
117
  props: ({
118
- ownerState: i
119
- }) => i.hasChildren,
118
+ ownerState: o
119
+ }) => o.hasChildren,
120
120
  style: {
121
121
  "& > *": {
122
122
  visibility: "hidden"
@@ -124,15 +124,15 @@ const st = (t) => {
124
124
  }
125
125
  }, {
126
126
  props: ({
127
- ownerState: i
128
- }) => i.hasChildren && !i.width,
127
+ ownerState: o
128
+ }) => o.hasChildren && !o.width,
129
129
  style: {
130
130
  maxWidth: "fit-content"
131
131
  }
132
132
  }, {
133
133
  props: ({
134
- ownerState: i
135
- }) => i.hasChildren && !i.height,
134
+ ownerState: o
135
+ }) => o.hasChildren && !o.height,
136
136
  style: {
137
137
  height: "auto"
138
138
  }
@@ -140,8 +140,8 @@ const st = (t) => {
140
140
  props: {
141
141
  animation: "pulse"
142
142
  },
143
- style: ct || {
144
- animation: `${M} 2s ease-in-out 0.5s infinite`
143
+ style: fe || {
144
+ animation: `${j} 2s ease-in-out 0.5s infinite`
145
145
  }
146
146
  }, {
147
147
  props: {
@@ -156,7 +156,7 @@ const st = (t) => {
156
156
  background: `linear-gradient(
157
157
  90deg,
158
158
  transparent,
159
- ${(t.vars || t).palette.action.hover},
159
+ ${(e.vars || e).palette.action.hover},
160
160
  transparent
161
161
  )`,
162
162
  content: '""',
@@ -172,47 +172,47 @@ const st = (t) => {
172
172
  props: {
173
173
  animation: "wave"
174
174
  },
175
- style: lt || {
175
+ style: pe || {
176
176
  "&::after": {
177
- animation: `${_} 2s linear 0.5s infinite`
177
+ animation: `${D} 2s linear 0.5s infinite`
178
178
  }
179
179
  }
180
180
  }]
181
181
  };
182
- })), E = /* @__PURE__ */ X.forwardRef(function(o, a) {
183
- const i = J({
184
- props: o,
182
+ })), K = /* @__PURE__ */ G.forwardRef(function(i, r) {
183
+ const o = P({
184
+ props: i,
185
185
  name: "MuiSkeleton"
186
186
  }), {
187
- animation: p = "pulse",
188
- className: y,
189
- component: m = "span",
190
- height: h,
191
- style: e,
192
- variant: A = "text",
193
- width: v,
194
- ...f
195
- } = i, g = {
196
- ...i,
197
- animation: p,
198
- component: m,
199
- variant: A,
200
- hasChildren: !!f.children
201
- }, u = st(g);
202
- return /* @__PURE__ */ c(ut, {
203
- as: m,
204
- ref: a,
205
- className: Y(u.root, y),
206
- ownerState: g,
207
- ...f,
187
+ animation: u = "pulse",
188
+ className: v,
189
+ component: s = "span",
190
+ height: d,
191
+ style: w,
192
+ variant: m = "text",
193
+ width: y,
194
+ ...h
195
+ } = o, t = {
196
+ ...o,
197
+ animation: u,
198
+ component: s,
199
+ variant: m,
200
+ hasChildren: !!h.children
201
+ }, M = ue(t);
202
+ return /* @__PURE__ */ c(de, {
203
+ as: s,
204
+ ref: r,
205
+ className: ee(M.root, v),
206
+ ownerState: t,
207
+ ...h,
208
208
  style: {
209
- width: v,
210
- height: h,
211
- ...e
209
+ width: y,
210
+ height: d,
211
+ ...w
212
212
  }
213
213
  });
214
214
  });
215
- process.env.NODE_ENV !== "production" && (E.propTypes = {
215
+ process.env.NODE_ENV !== "production" && (K.propTypes = {
216
216
  // ┌────────────────────────────── Warning ──────────────────────────────┐
217
217
  // │ These PropTypes are generated from the TypeScript type definitions. │
218
218
  // │ To update them, edit the d.ts file and run `pnpm proptypes`. │
@@ -222,159 +222,169 @@ process.env.NODE_ENV !== "production" && (E.propTypes = {
222
222
  * If `false` the animation effect is disabled.
223
223
  * @default 'pulse'
224
224
  */
225
- animation: n.oneOf(["pulse", "wave", !1]),
225
+ animation: a.oneOf(["pulse", "wave", !1]),
226
226
  /**
227
227
  * Optional children to infer width and height from.
228
228
  */
229
- children: n.node,
229
+ children: a.node,
230
230
  /**
231
231
  * Override or extend the styles applied to the component.
232
232
  */
233
- classes: n.object,
233
+ classes: a.object,
234
234
  /**
235
235
  * @ignore
236
236
  */
237
- className: n.string,
237
+ className: a.string,
238
238
  /**
239
239
  * The component used for the root node.
240
240
  * Either a string to use a HTML element or a component.
241
241
  */
242
- component: n.elementType,
242
+ component: a.elementType,
243
243
  /**
244
244
  * Height of the skeleton.
245
245
  * Useful when you don't want to adapt the skeleton to a text element but for instance a card.
246
246
  */
247
- height: n.oneOfType([n.number, n.string]),
247
+ height: a.oneOfType([a.number, a.string]),
248
248
  /**
249
249
  * @ignore
250
250
  */
251
- style: n.object,
251
+ style: a.object,
252
252
  /**
253
253
  * The system prop that allows defining system overrides as well as additional CSS styles.
254
254
  */
255
- sx: n.oneOfType([n.arrayOf(n.oneOfType([n.func, n.object, n.bool])), n.func, n.object]),
255
+ sx: a.oneOfType([a.arrayOf(a.oneOfType([a.func, a.object, a.bool])), a.func, a.object]),
256
256
  /**
257
257
  * The type of content that will be rendered.
258
258
  * @default 'text'
259
259
  */
260
- variant: n.oneOfType([n.oneOf(["circular", "rectangular", "rounded", "text"]), n.string]),
260
+ variant: a.oneOfType([a.oneOf(["circular", "rectangular", "rounded", "text"]), a.string]),
261
261
  /**
262
262
  * Width of the skeleton.
263
263
  * Useful when the skeleton is inside an inline element with no width of its own.
264
264
  */
265
- width: n.oneOfType([n.number, n.string])
265
+ width: a.oneOfType([a.number, a.string])
266
266
  });
267
- const U = K([/* @__PURE__ */ c("path", {
267
+ const X = Q([/* @__PURE__ */ c("path", {
268
268
  d: "M16 7h-1l-1-1h-4L9 7H8c-1.1 0-2 .9-2 2v6c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V9c0-1.1-.9-2-2-2m-4 7c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2"
269
269
  }, "0"), /* @__PURE__ */ c("path", {
270
270
  d: "m8.57.51 4.48 4.48V2.04c4.72.47 8.48 4.23 8.95 8.95h2C23.34 3.02 15.49-1.59 8.57.51m2.38 21.45c-4.72-.47-8.48-4.23-8.95-8.95H0c.66 7.97 8.51 12.58 15.43 10.48l-4.48-4.48z"
271
271
  }, "1")], "Cameraswitch");
272
- function bt({ interval: t, capture: o, disable: a, direct: i, hidden: p, size: y, ...m }) {
273
- const { t: h } = H(), [e, A] = T(null), v = b(null), f = b(-1), g = b(0), u = b(), s = b({}), [k, V] = T(!1), [R, I] = T(!1);
274
- s.current = m;
275
- const d = Math.floor(y);
276
- C(() => {
277
- u.current = async (r) => {
272
+ function Re({
273
+ interval: e,
274
+ capture: i,
275
+ disable: r,
276
+ direct: o,
277
+ hidden: u,
278
+ size: v,
279
+ onActivated: s,
280
+ onFatal: d,
281
+ onPostprocess: w,
282
+ onCapture: m,
283
+ onPreprocess: y
284
+ }) {
285
+ const { t: h } = J(), [t, M] = N(null), C = T(null), k = T(-1), _ = T(0), f = T(), [R, L] = N(!1), [S, B] = N(!1), p = Math.floor(v);
286
+ b(() => {
287
+ f.current = async (n) => {
278
288
  var l;
279
- if (a) {
280
- u.current && (f.current = window.requestAnimationFrame(u.current));
289
+ if (r) {
290
+ f.current && (k.current = window.requestAnimationFrame(f.current));
281
291
  return;
282
292
  }
283
- if (e && e.canvas) {
284
- e.update();
285
- const S = t !== void 0 ? t : 1e3;
286
- if (s.current.onPreprocess && await s.current.onPreprocess(e.canvas), o && s.current.onCapture && r - g.current >= S) {
287
- if (i && e.canvas)
288
- await s.current.onCapture(e.canvas);
293
+ if (t && t.canvas) {
294
+ t.update();
295
+ const x = e !== void 0 ? e : 1e3;
296
+ if (y && await y(t.canvas), i && m && n - _.current >= x) {
297
+ if (o && t.canvas)
298
+ await m(t.canvas);
289
299
  else {
290
- const w = document.createElement("canvas");
291
- w.width = e.canvas.width, w.height = e.canvas.height;
292
- const x = w.getContext("2d");
293
- x || console.error("Failed to get context"), x == null || x.drawImage(e.canvas, 0, 0), await s.current.onCapture(w);
300
+ const g = document.createElement("canvas");
301
+ g.width = t.canvas.width, g.height = t.canvas.height;
302
+ const O = g.getContext("2d");
303
+ O || console.error("Failed to get context"), O == null || O.drawImage(t.canvas, 0, 0), await m(g);
294
304
  }
295
- g.current = r;
305
+ _.current = n;
296
306
  }
297
- const O = (l = v.current) == null ? void 0 : l.getContext("2d");
298
- O && (O.drawImage(e.canvas, 0, 0), s.current.onPostprocess && v.current && await s.current.onPostprocess(v.current));
307
+ const I = (l = C.current) == null ? void 0 : l.getContext("2d");
308
+ I && (I.drawImage(t.canvas, 0, 0), w && C.current && await w(C.current));
299
309
  }
300
- u.current && (f.current = window.requestAnimationFrame(u.current));
301
- }, f.current === -1 && (f.current = window.requestAnimationFrame(u.current));
302
- }, [e, t, o, i, a]);
303
- const N = B(
304
- async (r) => {
310
+ f.current && (k.current = window.requestAnimationFrame(f.current));
311
+ }, k.current === -1 && (k.current = window.requestAnimationFrame(f.current));
312
+ }, [t, e, i, o, r, m, y, w]);
313
+ const U = E(
314
+ async (n) => {
305
315
  var l;
306
- if (await r.setup({ facingMode: R ? "user" : "environment" }), r.webcam && (r.webcam.playsInline = !0, r.webcam.muted = !0, r.webcam.onsuspend = () => r.play(), A(r)), (l = navigator.mediaDevices) != null && l.enumerateDevices)
316
+ if (await n.setup({ facingMode: S ? "user" : "environment" }), n.webcam && (n.webcam.playsInline = !0, n.webcam.muted = !0, n.webcam.onsuspend = () => n.play(), M(n)), (l = navigator.mediaDevices) != null && l.enumerateDevices)
307
317
  try {
308
- (await navigator.mediaDevices.enumerateDevices()).filter((w) => w.kind === "videoinput").length > 1 && (k || V(!0), r.flip = R);
309
- } catch (S) {
310
- console.error(S);
318
+ (await navigator.mediaDevices.enumerateDevices()).filter((g) => g.kind === "videoinput").length > 1 && (R || L(!0), n.flip = S);
319
+ } catch (x) {
320
+ console.error(x);
311
321
  }
312
- return s.current.onActivated && s.current.onActivated(!0), r;
322
+ return s && s(!0), n;
313
323
  },
314
- [R, k]
324
+ [S, R, s]
315
325
  );
316
- C(() => {
317
- o && (g.current = 0);
318
- }, [o]), C(() => {
319
- const r = new L(d, d, !0);
320
- return N(r).catch((l) => {
321
- s.current.onActivated && s.current.onActivated(!1), console.error("No webcam", l), s.current.onFatal && s.current.onFatal();
326
+ b(() => {
327
+ i && (_.current = 0);
328
+ }, [i]), b(() => {
329
+ const n = new Y(p, p, !0);
330
+ return U(n).catch((l) => {
331
+ s && s(!1), console.error("No webcam", l), d && d();
322
332
  }), () => {
323
333
  var l;
324
- (l = r.webcam) != null && l.srcObject && r.stop();
334
+ (l = n.webcam) != null && l.srcObject && n.stop();
325
335
  };
326
- }, [R, N, d]), C(() => () => {
327
- var r;
328
- u.current = void 0, (r = e == null ? void 0 : e.webcam) != null && r.srcObject && e.stop();
329
- }, [e]), C(() => {
330
- e && (a ? e.pause() : e.play());
331
- }, [e, a]);
332
- const $ = B(() => {
333
- I((r) => !r);
334
- }, [I]);
335
- return p ? /* @__PURE__ */ c(D, { children: k && /* @__PURE__ */ c(
336
- P,
336
+ }, [S, U, p, s, d]), b(() => () => {
337
+ var n;
338
+ f.current = void 0, (n = t == null ? void 0 : t.webcam) != null && n.srcObject && t.stop();
339
+ }, [t]), b(() => {
340
+ t && (r ? t.pause() : t.play());
341
+ }, [t, r]);
342
+ const z = E(() => {
343
+ B((n) => !n);
344
+ }, [B]);
345
+ return u ? /* @__PURE__ */ c(q, { children: R && /* @__PURE__ */ c(
346
+ V,
337
347
  {
338
348
  size: "large",
339
349
  color: "inherit",
340
- onClick: $,
350
+ onClick: z,
341
351
  "aria-label": h("webcam.aria.flip"),
342
- children: /* @__PURE__ */ c(U, { fontSize: "large" })
352
+ children: /* @__PURE__ */ c(X, { fontSize: "large" })
343
353
  }
344
- ) }) : /* @__PURE__ */ j(D, { children: [
345
- !e && /* @__PURE__ */ c(
346
- E,
354
+ ) }) : /* @__PURE__ */ F(q, { children: [
355
+ !t && /* @__PURE__ */ c(
356
+ K,
347
357
  {
348
358
  variant: "rounded",
349
- width: d,
350
- height: d
359
+ width: p,
360
+ height: p
351
361
  }
352
362
  ),
353
- e && /* @__PURE__ */ j("div", { className: F.wrapContainer, children: [
354
- k && /* @__PURE__ */ c(
355
- P,
363
+ t && /* @__PURE__ */ F("div", { className: $.wrapContainer, children: [
364
+ R && /* @__PURE__ */ c(
365
+ V,
356
366
  {
357
- className: F.flipButton,
367
+ className: $.flipButton,
358
368
  size: "large",
359
369
  color: "inherit",
360
- onClick: $,
370
+ onClick: z,
361
371
  "aria-label": h("webcam.aria.flip"),
362
- children: /* @__PURE__ */ c(U, { fontSize: "large" })
372
+ children: /* @__PURE__ */ c(X, { fontSize: "large" })
363
373
  }
364
374
  ),
365
375
  /* @__PURE__ */ c(
366
376
  "div",
367
377
  {
368
378
  "data-testid": "webcam",
369
- className: F.container,
379
+ className: $.container,
370
380
  role: "img",
371
381
  "aria-label": h("webcam.aria.video"),
372
382
  children: /* @__PURE__ */ c(
373
383
  "canvas",
374
384
  {
375
- width: d,
376
- height: d,
377
- ref: v
385
+ width: p,
386
+ height: p,
387
+ ref: C
378
388
  }
379
389
  )
380
390
  }
@@ -383,5 +393,5 @@ function bt({ interval: t, capture: o, disable: a, direct: i, hidden: p, size: y
383
393
  ] });
384
394
  }
385
395
  export {
386
- bt as default
396
+ Re as default
387
397
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@genai-fi/base",
3
- "version": "4.1.2",
3
+ "version": "4.1.4",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",