@agent-native/pinpoint 0.1.4 → 0.1.8

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.
@@ -2955,15 +2955,40 @@ var LINE_WIDTHS = [{
2955
2955
  width: 8,
2956
2956
  name: "Thick"
2957
2957
  }];
2958
+ var EDGE_GAP = 16;
2959
+ var COLLAPSED_TOOLBAR_SIZE = 60;
2960
+ var EXPANDED_TOOLBAR_WIDTH = 320;
2961
+ var AGENT_SIDEBAR_SELECTOR = ".agent-sidebar-panel";
2962
+ function clampRightOffset(right, toolbarWidth) {
2963
+ if (typeof window === "undefined") return right;
2964
+ const maxRight = Math.max(0, window.innerWidth - toolbarWidth - EDGE_GAP);
2965
+ return Math.min(right, maxRight);
2966
+ }
2967
+ function getVisibleRightSidebarInset() {
2968
+ if (typeof window === "undefined") return 0;
2969
+ let inset = 0;
2970
+ for (const panel of document.querySelectorAll(AGENT_SIDEBAR_SELECTOR)) {
2971
+ const style2 = window.getComputedStyle(panel);
2972
+ if (style2.display === "none" || style2.visibility === "hidden" || panel.getAttribute("aria-hidden") === "true") {
2973
+ continue;
2974
+ }
2975
+ const rect = panel.getBoundingClientRect();
2976
+ const isVisible = rect.width > 0 && rect.height > 0;
2977
+ const isAnchoredToRight = rect.right >= window.innerWidth - 1 && rect.left < window.innerWidth - 1;
2978
+ if (!isVisible || !isAnchoredToRight) continue;
2979
+ inset = Math.max(inset, Math.ceil(window.innerWidth - rect.left));
2980
+ }
2981
+ return inset;
2982
+ }
2958
2983
  var Toolbar = (props) => {
2959
2984
  const [pos, setPos] = createSignal(props.position ? {
2960
2985
  right: window.innerWidth - props.position.x,
2961
2986
  bottom: window.innerHeight - props.position.y
2962
2987
  } : {
2963
- right: 16,
2964
- bottom: 16
2988
+ right: EDGE_GAP,
2989
+ bottom: EDGE_GAP
2965
2990
  });
2966
- const [dragging, setDragging] = createSignal(false);
2991
+ const [reservedRight, setReservedRight] = createSignal(0);
2967
2992
  const [dragStart, setDragStart] = createSignal({
2968
2993
  x: 0,
2969
2994
  y: 0,
@@ -2971,9 +2996,41 @@ var Toolbar = (props) => {
2971
2996
  bottom: 0
2972
2997
  });
2973
2998
  const [didDrag, setDidDrag] = createSignal(false);
2999
+ onMount(() => {
3000
+ if (typeof window === "undefined") return;
3001
+ let resizeObserver;
3002
+ const updateReservedRight = () => {
3003
+ setReservedRight(getVisibleRightSidebarInset());
3004
+ resizeObserver?.disconnect();
3005
+ if (typeof ResizeObserver === "undefined") return;
3006
+ resizeObserver = new ResizeObserver(() => {
3007
+ setReservedRight(getVisibleRightSidebarInset());
3008
+ });
3009
+ for (const panel of document.querySelectorAll(AGENT_SIDEBAR_SELECTOR)) {
3010
+ resizeObserver.observe(panel);
3011
+ }
3012
+ };
3013
+ updateReservedRight();
3014
+ const mutationObserver = new MutationObserver(updateReservedRight);
3015
+ mutationObserver.observe(document.body, {
3016
+ attributes: true,
3017
+ attributeFilter: ["class", "style", "aria-hidden"],
3018
+ childList: true,
3019
+ subtree: true
3020
+ });
3021
+ window.addEventListener("resize", updateReservedRight);
3022
+ onCleanup(() => {
3023
+ mutationObserver.disconnect();
3024
+ resizeObserver?.disconnect();
3025
+ window.removeEventListener("resize", updateReservedRight);
3026
+ });
3027
+ });
3028
+ const toolbarRight = () => {
3029
+ const toolbarWidth = props.expanded ? EXPANDED_TOOLBAR_WIDTH : COLLAPSED_TOOLBAR_SIZE;
3030
+ return clampRightOffset((props.expanded ? EDGE_GAP : pos().right) + reservedRight(), toolbarWidth);
3031
+ };
2974
3032
  function handleMouseDown(e) {
2975
3033
  if (props.expanded) return;
2976
- setDragging(true);
2977
3034
  setDidDrag(false);
2978
3035
  setDragStart({
2979
3036
  x: e.clientX,
@@ -2986,20 +3043,20 @@ var Toolbar = (props) => {
2986
3043
  const start = dragStart();
2987
3044
  const dx = e2.clientX - start.x;
2988
3045
  const dy = e2.clientY - start.y;
3046
+ const maxRight = Math.max(0, window.innerWidth - reservedRight() - COLLAPSED_TOOLBAR_SIZE);
2989
3047
  setPos({
2990
- right: Math.max(0, Math.min(window.innerWidth - 60, start.right - dx)),
2991
- bottom: Math.max(0, Math.min(window.innerHeight - 60, start.bottom - dy))
3048
+ right: Math.max(0, Math.min(maxRight, start.right - dx)),
3049
+ bottom: Math.max(0, Math.min(window.innerHeight - COLLAPSED_TOOLBAR_SIZE, start.bottom - dy))
2992
3050
  });
2993
3051
  };
2994
3052
  const handleUp = () => {
2995
- setDragging(false);
2996
3053
  window.removeEventListener("mousemove", handleMove);
2997
3054
  window.removeEventListener("mouseup", handleUp);
2998
3055
  };
2999
3056
  window.addEventListener("mousemove", handleMove);
3000
3057
  window.addEventListener("mouseup", handleUp);
3001
3058
  }
3002
- function handleClick(e) {
3059
+ function handleClick() {
3003
3060
  if (props.expanded) return;
3004
3061
  if (didDrag()) return;
3005
3062
  props.onToggleExpand();
@@ -3347,10 +3404,10 @@ var Toolbar = (props) => {
3347
3404
  createRenderEffect((_p$) => {
3348
3405
  var _v$ = `pp-toolbar ${props.expanded ? "pp-toolbar--expanded" : "pp-toolbar--collapsed"}`, _v$2 = {
3349
3406
  ...props.expanded ? {
3350
- bottom: "16px",
3351
- right: "16px"
3407
+ bottom: `${EDGE_GAP}px`,
3408
+ right: `${toolbarRight()}px`
3352
3409
  } : {
3353
- right: `${pos().right}px`,
3410
+ right: `${toolbarRight()}px`,
3354
3411
  bottom: `${pos().bottom}px`
3355
3412
  }
3356
3413
  };
@@ -4040,7 +4097,6 @@ var PinpointApp = (props) => {
4040
4097
  const [active, setActive] = createSignal(false);
4041
4098
  const [expanded, setExpanded] = createSignal(false);
4042
4099
  const [pins, setPins] = createSignal([]);
4043
- const [hoveredElement, setHoveredElement] = createSignal(null);
4044
4100
  const [hoveredRect, setHoveredRect] = createSignal(null);
4045
4101
  const [selectedElement, setSelectedElement] = createSignal(null);
4046
4102
  const [selectedContext, setSelectedContext] = createSignal(null);
@@ -4099,7 +4155,6 @@ var PinpointApp = (props) => {
4099
4155
  ignoreSelector: "#pinpoint-root, [data-pinpoint-marker]",
4100
4156
  blockInteractions: blockInteractions(),
4101
4157
  onHover: (element, rect) => {
4102
- setHoveredElement(element);
4103
4158
  setHoveredRect(rect);
4104
4159
  if (element && rect) {
4105
4160
  const framework = detectFramework();
@@ -4441,7 +4496,6 @@ var PinpointApp = (props) => {
4441
4496
  picker.deactivate();
4442
4497
  dragSelect.deactivate();
4443
4498
  textSelect.deactivate();
4444
- setHoveredElement(null);
4445
4499
  setHoveredRect(null);
4446
4500
  setSelectionLabelInfo(null);
4447
4501
  }
@@ -4867,4 +4921,4 @@ export {
4867
4921
  mountPinpoint,
4868
4922
  unmountPinpoint
4869
4923
  };
4870
- //# sourceMappingURL=chunk-PQIWC4FE.js.map
4924
+ //# sourceMappingURL=chunk-6YK47AB5.js.map