@particle-academy/agent-integrations 0.28.1 → 0.28.2

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/index.cjs CHANGED
@@ -4905,6 +4905,23 @@ function CoBrowsePresence({ session, connectUrl, shareBaseUrl, className }) {
4905
4905
  ] });
4906
4906
  }
4907
4907
  CoBrowsePresence.displayName = "CoBrowsePresence";
4908
+ var CURSOR_EDGE_INSET = 24;
4909
+ var FLUID_CURSOR_SPEED_PX_PER_SECOND = 1050;
4910
+ var MIN_GLIDE_MS = 240;
4911
+ var MAX_GLIDE_MS = 1200;
4912
+ function visibleCursorPoint(rect, viewport) {
4913
+ const x = rect.x + rect.width / 2;
4914
+ const y = rect.y + rect.height / 2;
4915
+ return {
4916
+ x: Math.min(Math.max(x, CURSOR_EDGE_INSET), Math.max(CURSOR_EDGE_INSET, viewport.width - CURSOR_EDGE_INSET)),
4917
+ y: Math.min(Math.max(y, CURSOR_EDGE_INSET), Math.max(CURSOR_EDGE_INSET, viewport.height - CURSOR_EDGE_INSET))
4918
+ };
4919
+ }
4920
+ function fluidGlideDuration(from, to) {
4921
+ if (!from) return 0;
4922
+ const distance = Math.hypot(to.x - from.x, to.y - from.y);
4923
+ return Math.round(Math.min(MAX_GLIDE_MS, Math.max(MIN_GLIDE_MS, distance / FLUID_CURSOR_SPEED_PX_PER_SECOND * 1e3)));
4924
+ }
4908
4925
  function CoBrowseCursorLayer({ active = true, zIndex = 2147483e3 }) {
4909
4926
  const { latest } = useAgentActivity(void 0, { capacity: 12 });
4910
4927
  const [cursor, setCursor] = react.useState(
@@ -4914,7 +4931,7 @@ function CoBrowseCursorLayer({ active = true, zIndex = 2147483e3 }) {
4914
4931
  react.useEffect(() => {
4915
4932
  if (!latest || (latest.source ?? "agent") === "user") return;
4916
4933
  if (latest.action === "agent_disconnected") {
4917
- setCursor(null);
4934
+ setCursor((prev) => prev ? { ...prev, status: "Standing by", glideMs: 0 } : prev);
4918
4935
  setPulse(null);
4919
4936
  return;
4920
4937
  }
@@ -4923,11 +4940,19 @@ function CoBrowseCursorLayer({ active = true, zIndex = 2147483e3 }) {
4923
4940
  const status = latest.target?.label ?? latest.action;
4924
4941
  const rect = latest.meta?.rect;
4925
4942
  if (rect) {
4926
- setCursor({ x: rect.x + rect.width / 2, y: rect.y + rect.height / 2, name, color, status });
4943
+ const target = visibleCursorPoint(rect, { width: window.innerWidth, height: window.innerHeight });
4944
+ const reduceMotion = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ?? false;
4945
+ setCursor((prev) => ({
4946
+ ...target,
4947
+ name,
4948
+ color,
4949
+ status,
4950
+ glideMs: reduceMotion ? 0 : fluidGlideDuration(prev, target)
4951
+ }));
4927
4952
  setPulse({ rect, color, key: latest.timestamp });
4928
4953
  } else {
4929
4954
  setCursor(
4930
- (prev) => prev ? { ...prev, status, name, color } : { x: window.innerWidth / 2, y: window.innerHeight / 2, name, color, status }
4955
+ (prev) => prev ? { ...prev, status, name, color } : { x: window.innerWidth / 2, y: window.innerHeight / 2, name, color, status, glideMs: 0 }
4931
4956
  );
4932
4957
  }
4933
4958
  }, [latest?.timestamp]);
@@ -4953,7 +4978,9 @@ function CoBrowseCursorLayer({ active = true, zIndex = 2147483e3 }) {
4953
4978
  name: cursor.name,
4954
4979
  color: cursor.color,
4955
4980
  status: cursor.status,
4956
- style: { transition: "left .35s cubic-bezier(.22,.61,.36,1), top .35s cubic-bezier(.22,.61,.36,1)" }
4981
+ style: {
4982
+ transition: cursor.glideMs ? `left ${cursor.glideMs}ms cubic-bezier(.22,.61,.36,1), top ${cursor.glideMs}ms cubic-bezier(.22,.61,.36,1)` : "none"
4983
+ }
4957
4984
  }
4958
4985
  )
4959
4986
  ] }),