@vaia-lab/sdk 0.4.0 → 0.4.1

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.
@@ -991,7 +991,8 @@ var HANDEIA_POR_DEFECTO = "https://handeia.com";
991
991
  var RUTA_TURNO = "/api/agent/space";
992
992
  function acotar(x, y) {
993
993
  const M = 8;
994
- const vv = typeof window !== "undefined" ? window.visualViewport : null;
994
+ if (typeof window === "undefined") return { x, y };
995
+ const vv = window.visualViewport;
995
996
  const w = vv?.width ?? window.innerWidth;
996
997
  const h = vv?.height ?? window.innerHeight;
997
998
  return {
@@ -1001,6 +1002,7 @@ function acotar(x, y) {
1001
1002
  }
1002
1003
  function HandeiaAgent(props) {
1003
1004
  const base = (props.handeiaUrl ?? HANDEIA_POR_DEFECTO).replace(/\/$/, "");
1005
+ const [montado, setMontado] = (0, import_react3.useState)(false);
1004
1006
  const [fieldOpen, setFieldOpen] = (0, import_react3.useState)(false);
1005
1007
  const [pos, setPos] = (0, import_react3.useState)(null);
1006
1008
  const drag = (0, import_react3.useRef)(null);
@@ -1043,6 +1045,7 @@ function HandeiaAgent(props) {
1043
1045
  drag.current = null;
1044
1046
  if (d && !d.moved) setFieldOpen((v) => !v);
1045
1047
  };
1048
+ (0, import_react3.useEffect)(() => setMontado(true), []);
1046
1049
  (0, import_react3.useEffect)(() => {
1047
1050
  const reacomodar = () => setPos((p) => p ? { ...p, ...acotar(p.x, p.y) } : p);
1048
1051
  window.addEventListener("resize", reacomodar);
@@ -1127,9 +1130,10 @@ function HandeiaAgent(props) {
1127
1130
  historial.current.push({ role: "user", text: t });
1128
1131
  void turno(t);
1129
1132
  }, [texto, fase, turno]);
1133
+ if (!montado) return null;
1130
1134
  const sinMover = !pos;
1131
1135
  const left = sinMover ? "50%" : pos.openLeft ? pos.x - FIELD_GAP : pos.x + CIRCLE_SIZE + FIELD_GAP;
1132
- const top = sinMover ? window?.innerHeight - 20 : pos.openAbove ? pos.y - FIELD_GAP : pos.y + CIRCLE_SIZE + FIELD_GAP;
1136
+ const top = sinMover ? window.innerHeight - 20 : pos.openAbove ? pos.y - FIELD_GAP : pos.y + CIRCLE_SIZE + FIELD_GAP;
1133
1137
  const tx = sinMover ? "-50%" : pos.openLeft ? "-100%" : "0%";
1134
1138
  const ty = sinMover ? "-100%" : pos.openAbove ? "-100%" : "0%";
1135
1139
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
@@ -14,7 +14,7 @@ interface HandeiaAgentProps {
14
14
  onAction?: ((name: string, args: Record<string, unknown>) => Promise<AgentActionResult> | AgentActionResult) | undefined;
15
15
  placeholder?: string | undefined;
16
16
  }
17
- declare function HandeiaAgent(props: HandeiaAgentProps): react.JSX.Element;
17
+ declare function HandeiaAgent(props: HandeiaAgentProps): react.JSX.Element | null;
18
18
 
19
19
  /**
20
20
  * El campo de texto de Handeia — EL MISMO, no una imitación.
@@ -14,7 +14,7 @@ interface HandeiaAgentProps {
14
14
  onAction?: ((name: string, args: Record<string, unknown>) => Promise<AgentActionResult> | AgentActionResult) | undefined;
15
15
  placeholder?: string | undefined;
16
16
  }
17
- declare function HandeiaAgent(props: HandeiaAgentProps): react.JSX.Element;
17
+ declare function HandeiaAgent(props: HandeiaAgentProps): react.JSX.Element | null;
18
18
 
19
19
  /**
20
20
  * El campo de texto de Handeia — EL MISMO, no una imitación.
@@ -980,7 +980,8 @@ var HANDEIA_POR_DEFECTO = "https://handeia.com";
980
980
  var RUTA_TURNO = "/api/agent/space";
981
981
  function acotar(x, y) {
982
982
  const M = 8;
983
- const vv = typeof window !== "undefined" ? window.visualViewport : null;
983
+ if (typeof window === "undefined") return { x, y };
984
+ const vv = window.visualViewport;
984
985
  const w = vv?.width ?? window.innerWidth;
985
986
  const h = vv?.height ?? window.innerHeight;
986
987
  return {
@@ -990,6 +991,7 @@ function acotar(x, y) {
990
991
  }
991
992
  function HandeiaAgent(props) {
992
993
  const base = (props.handeiaUrl ?? HANDEIA_POR_DEFECTO).replace(/\/$/, "");
994
+ const [montado, setMontado] = useState2(false);
993
995
  const [fieldOpen, setFieldOpen] = useState2(false);
994
996
  const [pos, setPos] = useState2(null);
995
997
  const drag = useRef2(null);
@@ -1032,6 +1034,7 @@ function HandeiaAgent(props) {
1032
1034
  drag.current = null;
1033
1035
  if (d && !d.moved) setFieldOpen((v) => !v);
1034
1036
  };
1037
+ useEffect2(() => setMontado(true), []);
1035
1038
  useEffect2(() => {
1036
1039
  const reacomodar = () => setPos((p) => p ? { ...p, ...acotar(p.x, p.y) } : p);
1037
1040
  window.addEventListener("resize", reacomodar);
@@ -1116,9 +1119,10 @@ function HandeiaAgent(props) {
1116
1119
  historial.current.push({ role: "user", text: t });
1117
1120
  void turno(t);
1118
1121
  }, [texto, fase, turno]);
1122
+ if (!montado) return null;
1119
1123
  const sinMover = !pos;
1120
1124
  const left = sinMover ? "50%" : pos.openLeft ? pos.x - FIELD_GAP : pos.x + CIRCLE_SIZE + FIELD_GAP;
1121
- const top = sinMover ? window?.innerHeight - 20 : pos.openAbove ? pos.y - FIELD_GAP : pos.y + CIRCLE_SIZE + FIELD_GAP;
1125
+ const top = sinMover ? window.innerHeight - 20 : pos.openAbove ? pos.y - FIELD_GAP : pos.y + CIRCLE_SIZE + FIELD_GAP;
1122
1126
  const tx = sinMover ? "-50%" : pos.openLeft ? "-100%" : "0%";
1123
1127
  const ty = sinMover ? "-100%" : pos.openAbove ? "-100%" : "0%";
1124
1128
  return /* @__PURE__ */ jsxs2(Fragment2, { children: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaia-lab/sdk",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "VAIA SDK — platform integration for Gandia-7 and Handeia developers",
5
5
  "author": "VAIA <hello@vaia.dev>",
6
6
  "license": "MIT",