@devosurf/vynt 0.1.5 → 0.1.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devosurf/vynt",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "bin",
@@ -27,6 +27,7 @@
27
27
  hoveredObjectiveElement: null,
28
28
  statusText: "Connecting...",
29
29
  position: null,
30
+ lastExpandedWidth: null,
30
31
  };
31
32
 
32
33
  let eventSource = null;
@@ -39,7 +40,7 @@
39
40
  next: `<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"></polyline></svg>`,
40
41
  apply: `<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg>`,
41
42
  collapse: `<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>`,
42
- vynt: `<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5"/></svg>`
43
+ vynt: `<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><path d="M4 6.5L10.5 18L14 11.5L20 18"/><path d="M9.6 6.5H20"/></svg>`
43
44
  };
44
45
 
45
46
  const css = `
@@ -696,6 +697,44 @@
696
697
  root.style.bottom = "auto";
697
698
  }
698
699
 
700
+ function getCollapsedWidth() {
701
+ const cssValue = parseFloat(getComputedStyle(shell).getPropertyValue("--vynt-height"));
702
+ return Number.isFinite(cssValue) && cssValue > 0 ? cssValue : 48;
703
+ }
704
+
705
+ function adjustPositionForCollapse(nextCollapsed) {
706
+ if (!state.position) return;
707
+
708
+ const currentWidth = shell.getBoundingClientRect().width;
709
+ if (!(currentWidth > 0)) return;
710
+
711
+ if (nextCollapsed) {
712
+ state.lastExpandedWidth = currentWidth;
713
+ const targetCollapsedWidth = getCollapsedWidth();
714
+ const delta = Math.max(0, currentWidth - targetCollapsedWidth);
715
+ if (delta > 0) {
716
+ state.position = {
717
+ x: state.position.x + delta,
718
+ y: state.position.y,
719
+ };
720
+ }
721
+ } else {
722
+ const targetExpandedWidth =
723
+ typeof state.lastExpandedWidth === "number" && state.lastExpandedWidth > 0
724
+ ? state.lastExpandedWidth
725
+ : currentWidth;
726
+ const delta = Math.max(0, targetExpandedWidth - currentWidth);
727
+ if (delta > 0) {
728
+ state.position = {
729
+ x: state.position.x - delta,
730
+ y: state.position.y,
731
+ };
732
+ }
733
+ }
734
+
735
+ state.position = constrainPosition(state.position);
736
+ }
737
+
699
738
  function persistPosition() {
700
739
  if (!state.position) return;
701
740
  try {
@@ -796,6 +835,13 @@
796
835
  }
797
836
 
798
837
  renderObjectiveOverlay();
838
+
839
+ if (hasOptions && !state.collapsed) {
840
+ const expandedWidth = shell.getBoundingClientRect().width;
841
+ if (expandedWidth > 0) {
842
+ state.lastExpandedWidth = expandedWidth;
843
+ }
844
+ }
799
845
  }
800
846
 
801
847
  async function api(path, init) {
@@ -1013,7 +1059,9 @@
1013
1059
  }, 300);
1014
1060
  } else {
1015
1061
  if (state.collapsed && isLogoBtn) {
1062
+ adjustPositionForCollapse(false);
1016
1063
  state.collapsed = false;
1064
+ persistPosition();
1017
1065
  render();
1018
1066
  }
1019
1067
  }
@@ -1049,7 +1097,9 @@
1049
1097
 
1050
1098
  collapseBtn.addEventListener("click", (event) => {
1051
1099
  event.stopPropagation();
1100
+ adjustPositionForCollapse(true);
1052
1101
  state.collapsed = true;
1102
+ persistPosition();
1053
1103
  render();
1054
1104
  });
1055
1105