@octaviaflow/core 3.1.0-beta.95 → 3.1.0-beta.96

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.
@@ -0,0 +1,33 @@
1
+ import type { Position, Viewport } from "../../editor";
2
+ export interface PresenceCursorMember {
3
+ /** Stable identity. Used as the React key. */
4
+ userId: string;
5
+ /** Shown on the pointer's label. */
6
+ name: string;
7
+ /** This person's identity colour — the same one on their avatar. */
8
+ colour: string;
9
+ /** Where they are, in FLOW space. Omit and they are simply not drawn. */
10
+ cursor?: Position;
11
+ }
12
+ export interface PresenceCursorsProps {
13
+ /** The other people. The local user should already be filtered out. */
14
+ members: PresenceCursorMember[];
15
+ /**
16
+ * Called with the local pointer's position in FLOW space, at most once per
17
+ * animation frame, and with `null` when the pointer leaves the canvas.
18
+ *
19
+ * Coalescing beyond a frame (down to the ~10Hz that actually goes on the
20
+ * wire) is the host's job — it owns the transport.
21
+ */
22
+ onCursorMove?: (position: Position | null) => void;
23
+ /**
24
+ * Override the viewport instead of subscribing to the enclosing canvas.
25
+ * Only needed outside a `<FlowCanvas>` — a story, a static preview.
26
+ */
27
+ viewport?: Viewport;
28
+ /** Hide labels and draw pointers only. */
29
+ showLabels?: boolean;
30
+ className?: string;
31
+ }
32
+ export declare function PresenceCursors({ members, onCursorMove, viewport, showLabels, className, }: Readonly<PresenceCursorsProps>): import("react/jsx-runtime").JSX.Element;
33
+ //# sourceMappingURL=PresenceCursors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PresenceCursors.d.ts","sourceRoot":"","sources":["../../../../src/workflow/components/PresenceCursors/PresenceCursors.tsx"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAIvD,MAAM,WAAW,oBAAoB;IACnC,8CAA8C;IAC9C,MAAM,EAAE,MAAM,CAAC;IACf,oCAAoC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,oEAAoE;IACpE,MAAM,EAAE,MAAM,CAAC;IACf,yEAAyE;IACzE,MAAM,CAAC,EAAE,QAAQ,CAAC;CACnB;AAED,MAAM,WAAW,oBAAoB;IACnC,uEAAuE;IACvE,OAAO,EAAE,oBAAoB,EAAE,CAAC;IAChC;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,KAAK,IAAI,CAAC;IACnD;;;OAGG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,0CAA0C;IAC1C,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAID,wBAAgB,eAAe,CAAC,EAC9B,OAAO,EACP,YAAY,EACZ,QAAQ,EACR,UAAiB,EACjB,SAAS,GACV,EAAE,QAAQ,CAAC,oBAAoB,CAAC,2CAmKhC"}
@@ -21,6 +21,7 @@ export { Handle, type HandleProps } from "./components/Handle/Handle";
21
21
  export { ActionNode, type BuiltInNodeData, ConditionNode, DEFAULT_NODE_KINDS, ErrorNode, ForEachNode, GroupNode, HttpRequestNode, OutputNode, ParallelNode, StickyNode, TriggerNode, WaitNode, WebhookNode, } from "./components/kinds";
22
22
  export { NodeResizer, type NodeResizerProps } from "./components/NodeResizer/NodeResizer";
23
23
  export { NodeToolbar, type NodeToolbarProps } from "./components/NodeToolbar/NodeToolbar";
24
+ export { PresenceCursors, type PresenceCursorMember, type PresenceCursorsProps, } from "./components/PresenceCursors/PresenceCursors";
24
25
  export type { EdgeRouting } from "./editor";
25
26
  export { collapseFor, toggleGroupCollapse } from "./utils/collapse";
26
27
  export { bezierPath, DEFAULT_NODE_HEIGHT, DEFAULT_NODE_WIDTH, flowToScreen, handleCentre, screenToFlow, } from "./utils/geometry";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/workflow/index.ts"],"names":[],"mappings":"AAOA,YAAY,EACV,eAAe,EACf,eAAe,EACf,e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AU,EACV,mBAAmB,EACnB,kBAAkB,EAClB,YAAY,EACZ,YAAY,EACZ,YAAY,GACb,MAAM,kBAAkB,CAAC;AAI1B,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,YAAY,EACZ,mBAAmB,GACpB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,UAAU,IAAI,YAAY,EAC1B,aAAa,EACb,KAAK,WAAW,IAAI,eAAe,EACnC,KAAK,YAAY,EACjB,cAAc,EACd,QAAQ,EACR,YAAY,GACb,MAAM,eAAe,CAAC"}
package/dist/workflow.cjs CHANGED
@@ -53,6 +53,7 @@ __export(workflow_exports, {
53
53
  NodeToolbar: () => NodeToolbar,
54
54
  OutputNode: () => OutputNode,
55
55
  ParallelNode: () => ParallelNode,
56
+ PresenceCursors: () => PresenceCursors,
56
57
  StickyNode: () => StickyNode,
57
58
  TriggerNode: () => TriggerNode,
58
59
  WaitNode: () => WaitNode,
@@ -10835,6 +10836,120 @@ function transformOriginFor(side, align) {
10835
10836
  return align === "start" ? "left top" : align === "end" ? "left bottom" : "left center";
10836
10837
  }
10837
10838
 
10839
+ // src/workflow/components/PresenceCursors/PresenceCursors.tsx
10840
+ var import_react53 = require("react");
10841
+ var import_jsx_runtime33 = require("react/jsx-runtime");
10842
+ var IDENTITY_VIEWPORT = { x: 0, y: 0, zoom: 1 };
10843
+ function PresenceCursors({
10844
+ members,
10845
+ onCursorMove,
10846
+ viewport,
10847
+ showLabels = true,
10848
+ className
10849
+ }) {
10850
+ const layerRef = (0, import_react53.useRef)(null);
10851
+ const liveViewport = useViewportOrNull();
10852
+ const vp = viewport ?? liveViewport ?? IDENTITY_VIEWPORT;
10853
+ const vpRef = (0, import_react53.useRef)(vp);
10854
+ const reportRef = (0, import_react53.useRef)(onCursorMove);
10855
+ (0, import_react53.useEffect)(() => {
10856
+ vpRef.current = vp;
10857
+ reportRef.current = onCursorMove;
10858
+ });
10859
+ const isReporting = Boolean(onCursorMove);
10860
+ (0, import_react53.useEffect)(() => {
10861
+ const layer = layerRef.current;
10862
+ if (!layer || !isReporting) return;
10863
+ let frameId = 0;
10864
+ let scheduled = false;
10865
+ let disposed = false;
10866
+ let pendingClient = null;
10867
+ const flush = () => {
10868
+ scheduled = false;
10869
+ if (disposed) return;
10870
+ if (!pendingClient) {
10871
+ reportRef.current?.(null);
10872
+ return;
10873
+ }
10874
+ const rect = layer.getBoundingClientRect();
10875
+ const inside = pendingClient.x >= rect.left && pendingClient.x <= rect.right && pendingClient.y >= rect.top && pendingClient.y <= rect.bottom;
10876
+ reportRef.current?.(
10877
+ inside ? screenToFlow(
10878
+ { x: pendingClient.x - rect.left, y: pendingClient.y - rect.top },
10879
+ vpRef.current
10880
+ ) : null
10881
+ );
10882
+ };
10883
+ const schedule = () => {
10884
+ if (scheduled || disposed) return;
10885
+ scheduled = true;
10886
+ frameId = requestAnimationFrame(flush);
10887
+ };
10888
+ const onMove = (e) => {
10889
+ pendingClient = { x: e.clientX, y: e.clientY };
10890
+ schedule();
10891
+ };
10892
+ const onLeave = () => {
10893
+ pendingClient = null;
10894
+ schedule();
10895
+ };
10896
+ const onVisibility = () => {
10897
+ if (document.visibilityState === "hidden") onLeave();
10898
+ };
10899
+ window.addEventListener("pointermove", onMove, { passive: true });
10900
+ window.addEventListener("pointerleave", onLeave);
10901
+ window.addEventListener("blur", onLeave);
10902
+ document.addEventListener("visibilitychange", onVisibility);
10903
+ return () => {
10904
+ disposed = true;
10905
+ window.removeEventListener("pointermove", onMove);
10906
+ window.removeEventListener("pointerleave", onLeave);
10907
+ window.removeEventListener("blur", onLeave);
10908
+ document.removeEventListener("visibilitychange", onVisibility);
10909
+ if (frameId) cancelAnimationFrame(frameId);
10910
+ };
10911
+ }, [isReporting]);
10912
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { ref: layerRef, className: cn("ods-presence-cursors", className), "aria-hidden": "true", children: members.map((m) => {
10913
+ if (!m.cursor) return null;
10914
+ const p = flowToScreen(m.cursor, vp);
10915
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
10916
+ "div",
10917
+ {
10918
+ className: "ods-presence-cursors__pointer",
10919
+ style: {
10920
+ transform: `translate3d(${p.x}px, ${p.y}px, 0)`,
10921
+ color: m.colour
10922
+ },
10923
+ children: [
10924
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
10925
+ "svg",
10926
+ {
10927
+ className: "ods-presence-cursors__arrow",
10928
+ width: "18",
10929
+ height: "18",
10930
+ viewBox: "0 0 18 18",
10931
+ fill: "none",
10932
+ "aria-hidden": "true",
10933
+ children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
10934
+ "path",
10935
+ {
10936
+ d: "M2 1.5 L2 14 L5.6 10.7 L8 15.8 L10.6 14.6 L8.2 9.6 L13 9.3 Z",
10937
+ fill: "currentColor",
10938
+ stroke: "var(--ods-surface-canvas)",
10939
+ strokeWidth: "1.2",
10940
+ strokeLinejoin: "round"
10941
+ }
10942
+ )
10943
+ }
10944
+ ),
10945
+ showLabels && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { className: "ods-presence-cursors__label", children: m.name })
10946
+ ]
10947
+ },
10948
+ m.userId
10949
+ );
10950
+ }) });
10951
+ }
10952
+
10838
10953
  // src/workflow/utils/collapse.ts
10839
10954
  function collapseFor(nodes, edges) {
10840
10955
  const collapsedAncestorOf = /* @__PURE__ */ new Map();
@@ -10935,6 +11050,7 @@ function toggleGroupCollapse(groupId, nodes) {
10935
11050
  NodeToolbar,
10936
11051
  OutputNode,
10937
11052
  ParallelNode,
11053
+ PresenceCursors,
10938
11054
  StickyNode,
10939
11055
  TriggerNode,
10940
11056
  WaitNode,