@witchcraft/layout 0.3.1 → 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.
Files changed (169) hide show
  1. package/README.md +62 -70
  2. package/dist/module.json +1 -1
  3. package/dist/module.mjs +6 -1
  4. package/dist/runtime/components/FrameDragHandle.vue +1 -1
  5. package/dist/runtime/components/LayoutDecosEdges.d.vue.ts +15 -0
  6. package/dist/runtime/components/LayoutDecosEdges.vue +34 -0
  7. package/dist/runtime/components/LayoutDecosEdges.vue.d.ts +15 -0
  8. package/dist/runtime/components/LayoutDecosRects.d.vue.ts +15 -0
  9. package/dist/runtime/components/LayoutDecosRects.vue +37 -0
  10. package/dist/runtime/components/LayoutDecosRects.vue.d.ts +15 -0
  11. package/dist/runtime/components/LayoutDragEdgeGrabbed.d.vue.ts +2 -0
  12. package/dist/runtime/components/LayoutDragEdgeGrabbed.vue +43 -0
  13. package/dist/runtime/components/LayoutDragEdgeGrabbed.vue.d.ts +2 -0
  14. package/dist/runtime/components/LayoutDragEdgeHandle.d.vue.ts +9 -0
  15. package/dist/runtime/components/LayoutDragEdgeHandle.vue +44 -0
  16. package/dist/runtime/components/LayoutDragEdgeHandle.vue.d.ts +9 -0
  17. package/dist/runtime/components/{LayoutDecos.d.vue.ts → LayoutDragEdgeVisible.d.vue.ts} +3 -2
  18. package/dist/runtime/components/LayoutDragEdgeVisible.vue +38 -0
  19. package/dist/runtime/components/{LayoutDecos.vue.d.ts → LayoutDragEdgeVisible.vue.d.ts} +3 -2
  20. package/dist/runtime/components/LayoutDragEdges.d.vue.ts +21 -0
  21. package/dist/runtime/components/LayoutDragEdges.vue +67 -0
  22. package/dist/runtime/components/LayoutDragEdges.vue.d.ts +21 -0
  23. package/dist/runtime/components/LayoutEdgesActiveFrame.d.vue.ts +2 -0
  24. package/dist/runtime/components/LayoutEdgesActiveFrame.vue +35 -0
  25. package/dist/runtime/components/LayoutEdgesActiveFrame.vue.d.ts +2 -0
  26. package/dist/runtime/components/LayoutFrame.d.vue.ts +7 -6
  27. package/dist/runtime/components/LayoutFrame.vue +18 -14
  28. package/dist/runtime/components/LayoutFrame.vue.d.ts +7 -6
  29. package/dist/runtime/components/LayoutIntersectionHandle.d.vue.ts +10 -0
  30. package/dist/runtime/components/LayoutIntersectionHandle.vue +36 -0
  31. package/dist/runtime/components/LayoutIntersectionHandle.vue.d.ts +10 -0
  32. package/dist/runtime/components/LayoutIntersectionVisible.d.vue.ts +6 -0
  33. package/dist/runtime/components/LayoutIntersectionVisible.vue +34 -0
  34. package/dist/runtime/components/LayoutIntersectionVisible.vue.d.ts +6 -0
  35. package/dist/runtime/components/LayoutIntersections.d.vue.ts +21 -0
  36. package/dist/runtime/components/LayoutIntersections.vue +52 -0
  37. package/dist/runtime/components/LayoutIntersections.vue.d.ts +21 -0
  38. package/dist/runtime/components/{LayoutShapeSquare.d.vue.ts → LayoutShapeRect.d.vue.ts} +2 -2
  39. package/dist/runtime/components/{LayoutShapeSquare.vue.d.ts → LayoutShapeRect.vue.d.ts} +2 -2
  40. package/dist/runtime/components/LayoutWindow.d.vue.ts +252 -14
  41. package/dist/runtime/components/LayoutWindow.vue +27 -48
  42. package/dist/runtime/components/LayoutWindow.vue.d.ts +252 -14
  43. package/dist/runtime/composables/useFrames.d.ts +859 -2
  44. package/dist/runtime/composables/useFrames.js +2 -0
  45. package/dist/runtime/demo/App.vue +122 -74
  46. package/dist/runtime/demo/DemoControls.vue +7 -5
  47. package/dist/runtime/demo/index.html +12 -0
  48. package/dist/runtime/demo/tailwind.css +1 -1
  49. package/dist/runtime/drag/CloseAction.d.ts +1 -2
  50. package/dist/runtime/drag/CloseAction.js +1 -1
  51. package/dist/runtime/drag/DragActionHandler.d.ts +5 -3
  52. package/dist/runtime/drag/DragActionHandler.js +40 -6
  53. package/dist/runtime/drag/FrameDragAction.js +6 -7
  54. package/dist/runtime/drag/SplitAction.d.ts +1 -2
  55. package/dist/runtime/drag/SplitAction.js +1 -1
  56. package/dist/runtime/drag/createDefaultHandlers.d.ts +1 -1
  57. package/dist/runtime/drag/defaultDragActions.d.ts +1 -1
  58. package/dist/runtime/helpers/consoleDebugWindow.d.ts +43 -0
  59. package/dist/runtime/helpers/consoleDebugWindow.js +222 -0
  60. package/dist/runtime/helpers/convertLayoutWindowToWorkspace.js +2 -2
  61. package/dist/runtime/helpers/framesRedistributeFix.d.ts +87 -0
  62. package/dist/runtime/helpers/framesRedistributeFix.js +54 -0
  63. package/dist/runtime/helpers/getMoveEdgeInfo.d.ts +6 -2
  64. package/dist/runtime/helpers/getMoveEdgeInfo.js +11 -2
  65. package/dist/runtime/helpers/getPinnedEdgesForCollapsedFrames.d.ts +5 -0
  66. package/dist/runtime/helpers/getPinnedEdgesForCollapsedFrames.js +18 -0
  67. package/dist/runtime/helpers/getShapeRectCss.d.ts +7 -0
  68. package/dist/runtime/helpers/{getShapeSquareCss.js → getShapeRectCss.js} +1 -1
  69. package/dist/runtime/helpers/index.d.ts +3 -3
  70. package/dist/runtime/helpers/index.js +3 -3
  71. package/dist/runtime/helpers/moveEdge.js +3 -1
  72. package/dist/runtime/helpers/pxSizeToScaledSize.d.ts +2 -0
  73. package/dist/runtime/helpers/{numberToScaledSize.js → pxSizeToScaledSize.js} +1 -1
  74. package/dist/runtime/helpers/updateWindowSizeWithEvent.d.ts +3 -0
  75. package/dist/runtime/helpers/validateLayoutShape.d.ts +5 -0
  76. package/dist/runtime/helpers/validateLayoutShape.js +28 -0
  77. package/dist/runtime/layout/applyFrameChanges.js +6 -0
  78. package/dist/runtime/layout/createSplitDecoShapes.js +1 -1
  79. package/dist/runtime/layout/getFrameCollapseInfo.d.ts +5 -2
  80. package/dist/runtime/layout/getFrameCollapseInfo.js +16 -46
  81. package/dist/runtime/layout/getFrameDockInfo.d.ts +1 -1
  82. package/dist/runtime/layout/getFrameDockInfo.js +5 -1
  83. package/dist/runtime/layout/getFrameUncollapseInfo.d.ts +5 -2
  84. package/dist/runtime/layout/getFrameUncollapseInfo.js +16 -50
  85. package/dist/runtime/layout/getFrameUndockInfo.js +4 -1
  86. package/dist/runtime/layout/getFramesRedistributeInfo.d.ts +20 -4
  87. package/dist/runtime/layout/getFramesRedistributeInfo.js +31 -2
  88. package/dist/runtime/layout/getRelaxFramesInfo.d.ts +7 -0
  89. package/dist/runtime/layout/getRelaxFramesInfo.js +91 -0
  90. package/dist/runtime/layout/getUpdateWindowSizeInfo.d.ts +13 -0
  91. package/dist/runtime/layout/getUpdateWindowSizeInfo.js +65 -0
  92. package/dist/runtime/layout/index.d.ts +1 -0
  93. package/dist/runtime/layout/index.js +1 -0
  94. package/dist/runtime/layout/resizeFrame.js +1 -3
  95. package/dist/runtime/settings.d.ts +26 -19
  96. package/dist/runtime/settings.js +57 -22
  97. package/dist/runtime/types/index.d.ts +1243 -30
  98. package/dist/runtime/types/index.js +22 -8
  99. package/dist/runtime/types/vue.d.ts +41 -0
  100. package/dist/runtime/{drag/types.js → types/vue.js} +1 -0
  101. package/dist/runtime/utils/cssToKey.d.ts +5 -0
  102. package/dist/runtime/utils/cssToKey.js +3 -0
  103. package/package.json +11 -12
  104. package/src/module.ts +6 -1
  105. package/src/runtime/components/FrameDragHandle.vue +1 -1
  106. package/src/runtime/components/LayoutDecosEdges.vue +38 -0
  107. package/src/runtime/components/LayoutDecosRects.vue +42 -0
  108. package/src/runtime/components/LayoutDragEdgeGrabbed.vue +50 -0
  109. package/src/runtime/components/LayoutDragEdgeHandle.vue +52 -0
  110. package/src/runtime/components/LayoutDragEdgeVisible.vue +45 -0
  111. package/src/runtime/components/LayoutDragEdges.vue +78 -0
  112. package/src/runtime/components/LayoutEdgesActiveFrame.vue +43 -0
  113. package/src/runtime/components/LayoutFrame.vue +22 -15
  114. package/src/runtime/components/LayoutIntersectionHandle.vue +45 -0
  115. package/src/runtime/components/LayoutIntersectionVisible.vue +41 -0
  116. package/src/runtime/components/LayoutIntersections.vue +64 -0
  117. package/src/runtime/components/{LayoutShapeSquare.vue → LayoutShapeRect.vue} +2 -2
  118. package/src/runtime/components/LayoutWindow.vue +29 -49
  119. package/src/runtime/composables/useFrames.ts +7 -2
  120. package/src/runtime/demo/App.vue +128 -78
  121. package/src/runtime/demo/DemoControls.vue +7 -5
  122. package/src/runtime/demo/index.html +12 -0
  123. package/src/runtime/demo/tailwind.css +3 -0
  124. package/src/runtime/drag/CloseAction.ts +2 -3
  125. package/src/runtime/drag/DragActionHandler.ts +48 -10
  126. package/src/runtime/drag/FrameDragAction.ts +4 -5
  127. package/src/runtime/drag/SplitAction.ts +4 -3
  128. package/src/runtime/drag/createDefaultHandlers.ts +2 -1
  129. package/src/runtime/drag/defaultDragActions.ts +2 -1
  130. package/src/runtime/helpers/consoleDebugWindow.ts +331 -0
  131. package/src/runtime/helpers/convertLayoutWindowToWorkspace.ts +2 -2
  132. package/src/runtime/helpers/framesRedistributeFix.ts +162 -0
  133. package/src/runtime/helpers/getMoveEdgeInfo.ts +22 -5
  134. package/src/runtime/helpers/getPinnedEdgesForCollapsedFrames.ts +29 -0
  135. package/src/runtime/helpers/{getShapeSquareCss.ts → getShapeRectCss.ts} +3 -3
  136. package/src/runtime/helpers/index.ts +4 -3
  137. package/src/runtime/helpers/moveEdge.ts +3 -1
  138. package/src/runtime/helpers/{numberToScaledSize.ts → pxSizeToScaledSize.ts} +2 -2
  139. package/src/runtime/helpers/updateWindowSizeWithEvent.ts +3 -0
  140. package/src/runtime/helpers/validateLayoutShape.ts +46 -0
  141. package/src/runtime/layout/applyFrameChanges.ts +5 -0
  142. package/src/runtime/layout/createSplitDecoShapes.ts +1 -1
  143. package/src/runtime/layout/getFrameCollapseInfo.ts +26 -85
  144. package/src/runtime/layout/getFrameDockInfo.ts +8 -1
  145. package/src/runtime/layout/getFrameUncollapseInfo.ts +29 -96
  146. package/src/runtime/layout/getFrameUndockInfo.ts +7 -1
  147. package/src/runtime/layout/getFramesRedistributeInfo.ts +60 -5
  148. package/src/runtime/layout/getRelaxFramesInfo.ts +139 -0
  149. package/src/runtime/layout/getUpdateWindowSizeInfo.ts +105 -0
  150. package/src/runtime/layout/index.ts +1 -0
  151. package/src/runtime/layout/resizeFrame.ts +4 -3
  152. package/src/runtime/settings.ts +78 -25
  153. package/src/runtime/types/index.ts +205 -33
  154. package/src/runtime/types/vue.ts +41 -0
  155. package/src/runtime/utils/cssToKey.ts +8 -0
  156. package/dist/runtime/components/LayoutDecos.vue +0 -26
  157. package/dist/runtime/components/LayoutEdges.d.vue.ts +0 -17
  158. package/dist/runtime/components/LayoutEdges.vue +0 -144
  159. package/dist/runtime/components/LayoutEdges.vue.d.ts +0 -17
  160. package/dist/runtime/drag/types.d.ts +0 -161
  161. package/dist/runtime/helpers/clampNumber.d.ts +0 -1
  162. package/dist/runtime/helpers/clampNumber.js +0 -3
  163. package/dist/runtime/helpers/getShapeSquareCss.d.ts +0 -7
  164. package/dist/runtime/helpers/numberToScaledSize.d.ts +0 -2
  165. package/src/runtime/components/LayoutDecos.vue +0 -28
  166. package/src/runtime/components/LayoutEdges.vue +0 -170
  167. package/src/runtime/drag/types.ts +0 -177
  168. package/src/runtime/helpers/clampNumber.ts +0 -9
  169. /package/dist/runtime/components/{LayoutShapeSquare.vue → LayoutShapeRect.vue} +0 -0
@@ -2,11 +2,16 @@ import { pushIfNotIn } from "@alanscodelog/utils/pushIfNotIn";
2
2
  import { walk } from "@alanscodelog/utils/walk";
3
3
  import { applyFrameChanges } from "./applyFrameChanges.js";
4
4
  import { getFramesRedistributeInfo } from "./getFramesRedistributeInfo.js";
5
+ import { framesRedistributeFix } from "../helpers/framesRedistributeFix.js";
6
+ import { getPinnedEdgesForCollapsedFrames } from "../helpers/getPinnedEdgesForCollapsedFrames.js";
5
7
  import { oppositeSide } from "../helpers/oppositeSide.js";
6
8
  import { settings } from "../settings.js";
7
9
  import { LAYOUT_ERROR } from "../types/index.js";
8
10
  import { KnownError } from "../utils/KnownError.js";
9
- export function getFrameCollapseInfo(win, frameId) {
11
+ export function getFrameCollapseInfo(win, frameId, {
12
+ collapseSizeScaled
13
+ } = {}) {
14
+ collapseSizeScaled = collapseSizeScaled ?? settings.getCollapseSizeScaled(win);
10
15
  win = walk(win, void 0, { save: true });
11
16
  const frame = win.frames[frameId];
12
17
  if (!frame) throw new Error(`Unknown frame ${frameId}`);
@@ -25,42 +30,17 @@ export function getFrameCollapseInfo(win, frameId) {
25
30
  const posKey = isVertical ? "x" : "y";
26
31
  const oppositePosKey = isVertical ? "y" : "x";
27
32
  const oppositeSizeKey = isVertical ? "height" : "width";
28
- const collapseSize = settings.collapseSizeScaled;
29
33
  const currentSize = frame[sizeKey];
30
- const collapseAmount = collapseSize[sizeKey];
34
+ const collapseAmount = collapseSizeScaled[sizeKey];
31
35
  const shrinkAmount = currentSize - collapseAmount;
32
36
  const dockedSide = frame.docked;
33
- const framesToFix = [];
34
- const opposite = oppositeSide(dockedSide);
35
- for (const other of Object.values(win.frames)) {
36
- if (frame.id === other.id || !other.docked) continue;
37
- if (other.docked === opposite) continue;
38
- if (dockedSide === "left" || dockedSide === "top") {
39
- if (other[posKey] !== 0) continue;
40
- other[posKey] = frame[posKey] + frame[sizeKey];
41
- other[sizeKey] -= frame[sizeKey];
42
- framesToFix.push({
43
- id: other.id,
44
- posKey,
45
- sizeKey,
46
- type: "start"
47
- });
48
- } else {
49
- if (other[posKey] + other[sizeKey] !== settings.maxInt) continue;
50
- other[sizeKey] -= frame[sizeKey];
51
- framesToFix.push({
52
- id: other.id,
53
- posKey,
54
- sizeKey,
55
- type: "end"
56
- });
57
- }
58
- }
37
+ const { applyFixes, toFix } = framesRedistributeFix(win, frame, dockedSide, posKey, sizeKey, "shrink");
59
38
  const otherFrameIds = Object.keys(win.frames).filter((id) => id !== frameId);
60
39
  const redistributeSide = oppositeSide(dockedSide);
61
- const changes = getFramesRedistributeInfo(win, redistributeSide, otherFrameIds, -shrinkAmount, true);
40
+ const pinnedEdgeCoordinates = getPinnedEdgesForCollapsedFrames(win, frame, dockedSide, posKey, sizeKey);
41
+ const changes = getFramesRedistributeInfo(win, redistributeSide, otherFrameIds, -shrinkAmount, { allowOutOfBounds: true, pinnedEdgeCoordinates });
62
42
  if (changes instanceof KnownError) {
63
- if (changes.code === LAYOUT_ERROR.REDISTRIBUTE_OUT_OF_BOUNDS || LAYOUT_ERROR.NO_SPACE_TO_REDISTRIBUTE) {
43
+ if (changes.code === LAYOUT_ERROR.REDISTRIBUTE_OUT_OF_BOUNDS || changes.code === LAYOUT_ERROR.NO_SPACE_TO_REDISTRIBUTE) {
64
44
  changes.message = `This error should never happen, please file a bug report: ${changes.message}`;
65
45
  throw changes;
66
46
  }
@@ -68,24 +48,14 @@ export function getFrameCollapseInfo(win, frameId) {
68
48
  }
69
49
  applyFrameChanges(win, changes);
70
50
  pushIfNotIn(toExtract, changes.modified.map((_) => _.id));
71
- for (const fix of framesToFix) {
72
- const other = win.frames[fix.id];
73
- if (fix.type === "start") {
74
- const sizeDiff = other[fix.posKey];
75
- other[fix.posKey] = 0;
76
- other[fix.sizeKey] += sizeDiff;
77
- } else {
78
- const sizeDiff = settings.maxInt - (other[fix.posKey] + other[fix.sizeKey]);
79
- other[fix.sizeKey] += sizeDiff;
80
- }
81
- }
82
- pushIfNotIn(toExtract, framesToFix.map((_) => _.id));
51
+ applyFixes();
52
+ pushIfNotIn(toExtract, toFix);
83
53
  if (frame.docked === "right" || frame.docked === "bottom") {
84
- frame[posKey] = frame[posKey] + (frame[sizeKey] - collapseSize[sizeKey]);
54
+ frame[posKey] = frame[posKey] + (frame[sizeKey] - collapseSizeScaled[sizeKey]);
85
55
  }
86
- frame[sizeKey] = collapseSize[sizeKey];
56
+ frame[sizeKey] = collapseSizeScaled[sizeKey];
87
57
  frame.collapsed = currentSize;
88
- if (collapseSize[sizeKey] === 0) {
58
+ if (collapseSizeScaled[sizeKey] === 0) {
89
59
  frame[oppositePosKey] = 0;
90
60
  frame[oppositeSizeKey] = settings.maxInt;
91
61
  }
@@ -6,4 +6,4 @@ import { KnownError } from "../utils/KnownError.js";
6
6
  *
7
7
  * Changes can be applied to a window with {@link applyFrameChanges}.
8
8
  */
9
- export declare function getFrameDockInfo(win: LayoutWindow, frameId: string, side: EdgeSide, maxPerpendicularLength?: number): LayoutChange | KnownError<typeof LAYOUT_ERROR.REDISTRIBUTE_OUT_OF_BOUNDS> | KnownError<typeof LAYOUT_ERROR.NO_SPACE_TO_REDISTRIBUTE> | KnownError<typeof LAYOUT_ERROR.CANT_LEAVE_NO_UNDOCKED_FRAMES> | KnownError<typeof LAYOUT_ERROR.FRAME_ALREADY_DOCKED_ON_SIDE> | KnownError<typeof LAYOUT_ERROR.CANT_UNDOCK_COLLAPSED_FRAME> | KnownError<typeof LAYOUT_ERROR.NO_FILL_CANDIDATES>;
9
+ export declare function getFrameDockInfo(win: LayoutWindow, frameId: string, side: EdgeSide, maxPerpendicularLength?: number): LayoutChange | KnownError<typeof LAYOUT_ERROR.REDISTRIBUTE_OUT_OF_BOUNDS> | KnownError<typeof LAYOUT_ERROR.NO_SPACE_TO_REDISTRIBUTE> | KnownError<typeof LAYOUT_ERROR.REDISTRIBUTE_WOULD_RESULT_IN_INVALID_FRAMES> | KnownError<typeof LAYOUT_ERROR.CANT_LEAVE_NO_UNDOCKED_FRAMES> | KnownError<typeof LAYOUT_ERROR.FRAME_ALREADY_DOCKED_ON_SIDE> | KnownError<typeof LAYOUT_ERROR.CANT_UNDOCK_COLLAPSED_FRAME> | KnownError<typeof LAYOUT_ERROR.NO_FILL_CANDIDATES>;
@@ -6,6 +6,7 @@ import { getFramesRedistributeInfo } from "./getFramesRedistributeInfo.js";
6
6
  import { getFrameUndockInfo } from "./getFrameUndockInfo.js";
7
7
  import { cloneFrame } from "../helpers/cloneFrame.js";
8
8
  import { getDockBoundaries } from "../helpers/getDockBoundaries.js";
9
+ import { getPinnedEdgesForCollapsedFrames } from "../helpers/getPinnedEdgesForCollapsedFrames.js";
9
10
  import { oppositeSide } from "../helpers/oppositeSide.js";
10
11
  import { settings } from "../settings.js";
11
12
  import { LAYOUT_ERROR } from "../types/index.js";
@@ -44,7 +45,10 @@ export function getFrameDockInfo(win, frameId, side, maxPerpendicularLength) {
44
45
  applyFrameChanges(win, changes);
45
46
  pushIfNotIn(toExtract, changes.modified.map((_) => _.id));
46
47
  const sideToPushTowards = oppositeSide(side);
47
- const redistributeChanges = getFramesRedistributeInfo(win, sideToPushTowards, nonDockedFrameIds, perpendicularLength);
48
+ const posKey = isHorizontal ? "x" : "y";
49
+ const sizeKey = isHorizontal ? "width" : "height";
50
+ const pinnedEdgeCoordinates = getPinnedEdgesForCollapsedFrames(win, frame, side, posKey, sizeKey);
51
+ const redistributeChanges = getFramesRedistributeInfo(win, sideToPushTowards, nonDockedFrameIds, perpendicularLength, { pinnedEdgeCoordinates });
48
52
  if (redistributeChanges instanceof KnownError) {
49
53
  return redistributeChanges;
50
54
  }
@@ -1,4 +1,4 @@
1
- import type { LayoutChange, LayoutWindow } from "../types/index.js";
1
+ import type { LayoutChange, LayoutWindow, Size } from "../types/index.js";
2
2
  import { LAYOUT_ERROR } from "../types/index.js";
3
3
  import { KnownError } from "../utils/KnownError.js";
4
4
  /**
@@ -9,4 +9,7 @@ import { KnownError } from "../utils/KnownError.js";
9
9
  * Uncollapsing restores the frame to its pre-collapse size, shrinking neighboring
10
10
  * frames to make room.
11
11
  */
12
- export declare function getFrameUncollapseInfo(win: LayoutWindow, frameId: string): LayoutChange | KnownError<typeof LAYOUT_ERROR.CANT_UNCOLLAPSE_NOT_COLLAPSED> | KnownError<typeof LAYOUT_ERROR.REDISTRIBUTE_OUT_OF_BOUNDS> | KnownError<typeof LAYOUT_ERROR.NO_SPACE_TO_REDISTRIBUTE>;
12
+ export declare function getFrameUncollapseInfo(win: LayoutWindow, frameId: string, { restoreSize }?: {
13
+ /** Override the size to restore the frame to. */
14
+ restoreSize?: Size;
15
+ }): LayoutChange | KnownError<typeof LAYOUT_ERROR.CANT_UNCOLLAPSE_NOT_COLLAPSED> | KnownError<typeof LAYOUT_ERROR.REDISTRIBUTE_OUT_OF_BOUNDS> | KnownError<typeof LAYOUT_ERROR.NO_SPACE_TO_REDISTRIBUTE> | KnownError<typeof LAYOUT_ERROR.REDISTRIBUTE_WOULD_RESULT_IN_INVALID_FRAMES>;
@@ -2,11 +2,14 @@ import { pushIfNotIn } from "@alanscodelog/utils/pushIfNotIn";
2
2
  import { walk } from "@alanscodelog/utils/walk";
3
3
  import { applyFrameChanges } from "./applyFrameChanges.js";
4
4
  import { getFramesRedistributeInfo } from "./getFramesRedistributeInfo.js";
5
+ import { framesRedistributeFix } from "../helpers/framesRedistributeFix.js";
6
+ import { getPinnedEdgesForCollapsedFrames } from "../helpers/getPinnedEdgesForCollapsedFrames.js";
5
7
  import { oppositeSide } from "../helpers/oppositeSide.js";
6
- import { settings } from "../settings.js";
7
8
  import { LAYOUT_ERROR } from "../types/index.js";
8
9
  import { KnownError } from "../utils/KnownError.js";
9
- export function getFrameUncollapseInfo(win, frameId) {
10
+ export function getFrameUncollapseInfo(win, frameId, {
11
+ restoreSize
12
+ } = {}) {
10
13
  win = walk(win, void 0, { save: true });
11
14
  const frame = win.frames[frameId];
12
15
  if (!frame) {
@@ -16,69 +19,32 @@ export function getFrameUncollapseInfo(win, frameId) {
16
19
  throw new Error(`Frame ${frameId} is not docked.`);
17
20
  }
18
21
  const toExtract = [frame.id];
19
- const storedSize = frame.collapsed;
20
- if (storedSize === void 0) {
22
+ const isVertical = frame.docked === "left" || frame.docked === "right";
23
+ const sizeKey = isVertical ? "width" : "height";
24
+ const posKey = isVertical ? "x" : "y";
25
+ const currentSize = frame[sizeKey];
26
+ const storedSize = restoreSize !== void 0 ? restoreSize[sizeKey] : frame.collapsed;
27
+ if (frame.collapsed === void 0) {
21
28
  return new KnownError(
22
29
  LAYOUT_ERROR.CANT_UNCOLLAPSE_NOT_COLLAPSED,
23
30
  `Frame ${frameId} is not collapsed.`,
24
31
  { frame }
25
32
  );
26
33
  }
27
- const isVertical = frame.docked === "left" || frame.docked === "right";
28
- const sizeKey = isVertical ? "width" : "height";
29
- const posKey = isVertical ? "x" : "y";
30
- const currentSize = frame[sizeKey];
31
34
  const expandAmount = storedSize - currentSize;
32
35
  const dockedSide = frame.docked;
33
- const framesToFix = [];
34
- const opposite = oppositeSide(dockedSide);
35
- if (frame[sizeKey] !== 0) {
36
- for (const other of Object.values(win.frames)) {
37
- if (frame.id === other.id || !other.docked) continue;
38
- if (other.width === 0 || other.height === 0) continue;
39
- if (other.docked === opposite) continue;
40
- if (dockedSide === "left" || dockedSide === "top") {
41
- if (other[posKey] !== 0) continue;
42
- other[posKey] = frame[posKey] + frame[sizeKey];
43
- other[sizeKey] -= frame[sizeKey];
44
- framesToFix.push({
45
- id: other.id,
46
- posKey,
47
- sizeKey,
48
- type: "start"
49
- });
50
- } else {
51
- if (other[posKey] + other[sizeKey] !== settings.maxInt) continue;
52
- other[sizeKey] -= frame[sizeKey];
53
- framesToFix.push({
54
- id: other.id,
55
- posKey,
56
- sizeKey,
57
- type: "end"
58
- });
59
- }
60
- }
61
- }
36
+ const { applyFixes, toFix } = framesRedistributeFix(win, frame, dockedSide, posKey, sizeKey, "expand");
62
37
  const otherFrameIds = Object.keys(win.frames).filter((id) => id !== frameId);
63
38
  const redistributeSide = oppositeSide(frame.docked);
64
- const changes = getFramesRedistributeInfo(win, redistributeSide, otherFrameIds, expandAmount);
39
+ const pinnedEdgeCoordinates = getPinnedEdgesForCollapsedFrames(win, frame, dockedSide, posKey, sizeKey);
40
+ const changes = getFramesRedistributeInfo(win, redistributeSide, otherFrameIds, expandAmount, { pinnedEdgeCoordinates });
65
41
  if (changes instanceof KnownError) {
66
42
  return changes;
67
43
  }
68
44
  applyFrameChanges(win, changes);
69
45
  pushIfNotIn(toExtract, changes.modified.map((_) => _.id));
70
- for (const fix of framesToFix) {
71
- const other = win.frames[fix.id];
72
- if (fix.type === "start") {
73
- const sizeDiff = other[fix.posKey];
74
- other[fix.posKey] = 0;
75
- other[fix.sizeKey] += sizeDiff;
76
- } else {
77
- const sizeDiff = settings.maxInt - (other[fix.posKey] + other[fix.sizeKey]);
78
- other[fix.sizeKey] += sizeDiff;
79
- }
80
- }
81
- pushIfNotIn(toExtract, framesToFix.map((_) => _.id));
46
+ applyFixes();
47
+ pushIfNotIn(toExtract, toFix);
82
48
  frame[sizeKey] = storedSize;
83
49
  frame.collapsed = void 0;
84
50
  if (frame.docked === "right" || frame.docked === "bottom") {
@@ -34,6 +34,7 @@ export function getFrameUndockInfo(win, frameId) {
34
34
  const adjustmentKey = frameSide === "left" ? "x" : frameSide === "top" ? "y" : frameSide === "right" ? "width" : "height";
35
35
  const secondaryAdjustmentKey = frameSide === "left" ? "width" : frameSide === "top" ? "height" : frameSide === "right" ? "x" : "y";
36
36
  const adjustmentValue = frameSide === "left" || frameSide === "top" ? 0 : maxInt;
37
+ const perpendicularSizeKey = isVertical ? "width" : "height";
37
38
  const otherChanges = otherDockedFramesToResize.map((other) => {
38
39
  if (other.docked === shrinkStartKey) {
39
40
  frameClone[posKey] += other[sizeKey];
@@ -41,10 +42,12 @@ export function getFrameUndockInfo(win, frameId) {
41
42
  } else if (other.docked === shrinkEndKey) {
42
43
  frameClone[sizeKey] -= other[sizeKey];
43
44
  }
45
+ const otherIsVertical = other.docked === "left" || other.docked === "right";
46
+ const isSameAxis = isVertical === otherIsVertical;
44
47
  return {
45
48
  ...other,
46
49
  [adjustmentKey]: adjustmentValue,
47
- [secondaryAdjustmentKey]: other[secondaryAdjustmentKey] + other[adjustmentKey]
50
+ ...isSameAxis ? { [secondaryAdjustmentKey]: other[secondaryAdjustmentKey] + other[adjustmentKey] } : { [perpendicularSizeKey]: maxInt }
48
51
  };
49
52
  });
50
53
  return { modified: [frameClone, ...otherChanges], created: [], deleted: [] };
@@ -10,7 +10,7 @@ import { KnownError } from "../utils/KnownError.js";
10
10
  *
11
11
  * If you try to resize a layout like this to the right, you will get issues with frame edges not lining up as frame B would be resized less than A. If you had a frame at the empty space that you excluded, it's right edge would no longer align with B's.
12
12
  *
13
- * See {@link getFrameCollapseInfo} and {@link getFrameUncollapseInfo} for how to work around this (you must move frames like A to share the edge then move them back). Excluding them from the calcuation usually leads to subtler errors. Such as if there are frames after A and B to the right, excluding A would mean A's right edge would stop aligning with those other frames.
13
+ * See {@link framesRedistributeFix} for the helper that is used internally to get around this.
14
14
  *
15
15
  * ┌────────────┐
16
16
  * │A │
@@ -19,11 +19,27 @@ import { KnownError } from "../utils/KnownError.js";
19
19
  * └─────────┘
20
20
  *
21
21
  * Also note that it automatically excludes all collapsed frames without an area (height or width === 0).
22
+ *
23
+ * ## Pinned Edges
24
+ *
25
+ * Pinned edges will not be moved, space will be redistributed amongst remaining space. If doing this would cause edges to get "flipped", function will return {@link LAYOUT_ERROR.REDISTRIBUTE_WOULD_RESULT_IN_INVALID_FRAMES}.
26
+ *
27
+ * ┌──┬──────────────┐
28
+ * │ │ │
29
+ * │ ├──────────┬───┤
30
+ * │ │ │ │
31
+ * │ │ │ │
32
+ * └──┴──────────┴───┘
22
33
  */
23
34
  export declare function getFramesRedistributeInfo(win: LayoutWindow,
24
35
  /** Side to expand/shrink to. */
25
36
  side: EdgeSide, frameIds: string[],
26
37
  /** This can be negative to expand the frames instead (e.g. when collapsing a docked frame). */
27
- amountScaled: number,
28
- /** Allow the resize span to exceed window bounds. */
29
- allowOutOfBounds?: boolean): LayoutChange | KnownError<typeof LAYOUT_ERROR.REDISTRIBUTE_OUT_OF_BOUNDS> | KnownError<typeof LAYOUT_ERROR.NO_SPACE_TO_REDISTRIBUTE>;
38
+ amountScaled: number, { allowOutOfBounds, pinnedEdgeCoordinates, skipMinSizeCheck }?: {
39
+ /** Allow the resize span to exceed window bounds. */
40
+ allowOutOfBounds?: boolean;
41
+ /** Frame IDs whose position and size must not change. Must be a subset of frameIds. */
42
+ pinnedEdgeCoordinates?: number[];
43
+ /** Skip the per-frame min size check. Frames may shrink very small but not to 0 or below. */
44
+ skipMinSizeCheck?: boolean;
45
+ }): LayoutChange | KnownError<typeof LAYOUT_ERROR.REDISTRIBUTE_OUT_OF_BOUNDS> | KnownError<typeof LAYOUT_ERROR.NO_SPACE_TO_REDISTRIBUTE> | KnownError<typeof LAYOUT_ERROR.REDISTRIBUTE_WOULD_RESULT_IN_INVALID_FRAMES>;
@@ -1,12 +1,22 @@
1
1
  import { settings } from "../settings.js";
2
2
  import { LAYOUT_ERROR } from "../types/index.js";
3
3
  import { KnownError } from "../utils/KnownError.js";
4
- export function getFramesRedistributeInfo(win, side, frameIds, amountScaled, allowOutOfBounds = false) {
4
+ export function getFramesRedistributeInfo(win, side, frameIds, amountScaled, {
5
+ allowOutOfBounds = false,
6
+ pinnedEdgeCoordinates,
7
+ skipMinSizeCheck = false
8
+ } = {}) {
5
9
  const isLeftOrTop = side === "left" || side === "top";
6
10
  const isHorizontalSide = side === "left" || side === "right";
7
11
  const posKey = isHorizontalSide ? "x" : "y";
8
12
  const sizeKey = isHorizontalSide ? "width" : "height";
9
13
  const frames = frameIds.map((id) => win.frames[id]);
14
+ const pinnedEdges = /* @__PURE__ */ new Set();
15
+ if (pinnedEdgeCoordinates) {
16
+ for (const coord of pinnedEdgeCoordinates) {
17
+ pinnedEdges.add(coord);
18
+ }
19
+ }
10
20
  const edgeSet = /* @__PURE__ */ new Set();
11
21
  for (const frame of frames) {
12
22
  edgeSet.add(frame[posKey]);
@@ -31,7 +41,26 @@ export function getFramesRedistributeInfo(win, side, frameIds, amountScaled, all
31
41
  }
32
42
  const oppositeEdgeIndex = isLeftOrTop ? uniqueEdges.length - 1 : 0;
33
43
  newEdges[oppositeEdgeIndex] = isLeftOrTop ? anchorEdge + newSpan : anchorEdge - newSpan;
34
- const minSize = settings.minSizeScaled[sizeKey];
44
+ if (pinnedEdges.size > 0) {
45
+ for (let i = 0; i < uniqueEdges.length; i++) {
46
+ if (pinnedEdges.has(uniqueEdges[i])) {
47
+ newEdges[i] = uniqueEdges[i];
48
+ }
49
+ }
50
+ for (let i = 0; i < uniqueEdges.length - 1; i++) {
51
+ const startEdge = uniqueEdges[i];
52
+ const endEdge = uniqueEdges[i + 1];
53
+ const newStart = newEdges[i];
54
+ const newEnd = newEdges[i + 1];
55
+ if (newStart > newEnd) {
56
+ const hasPinnedEdge = pinnedEdges.has(startEdge) || pinnedEdges.has(endEdge);
57
+ if (hasPinnedEdge) {
58
+ return new KnownError(LAYOUT_ERROR.REDISTRIBUTE_WOULD_RESULT_IN_INVALID_FRAMES, `Redistribution would cause frames to cross pinned edge at ${pinnedEdges.has(startEdge) ? startEdge : endEdge}.`, { problemEdgeCoordinates: [startEdge, endEdge] });
59
+ }
60
+ }
61
+ }
62
+ }
63
+ const minSize = skipMinSizeCheck ? 0 : settings.minSizeScaled[sizeKey];
35
64
  const result = [];
36
65
  for (const frame of frames) {
37
66
  if (frame.collapsed && (frame.width === 0 || frame.height === 0)) continue;
@@ -0,0 +1,7 @@
1
+ import type { LayoutChange, LayoutWindow } from "../types/index.js";
2
+ /**
3
+ * Experimental frame "relaxation" algorithm.
4
+ *
5
+ * Useful for expanding frames that have gotten too small. Used internally by {@link getUpdateWindowSizeInfo}
6
+ */
7
+ export declare function getRelaxFramesInfo(win: LayoutWindow, passes?: number): LayoutChange<any>;
@@ -0,0 +1,91 @@
1
+ import { pushIfNotIn } from "@alanscodelog/utils/pushIfNotIn";
2
+ import { walk } from "@alanscodelog/utils/walk";
3
+ import { getMoveEdgeInfo } from "../helpers/getMoveEdgeInfo.js";
4
+ import { settings } from "../settings.js";
5
+ import { KnownError } from "../utils/KnownError.js";
6
+ export function getRelaxFramesInfo(win, passes = 2) {
7
+ win = walk(win, void 0, { save: true });
8
+ const toExtract = [];
9
+ const framesSortedHorizontal = Object.values(win.frames).filter((f) => f.width > 0 && f.width < settings.minSizeScaled.width && !f.collapsed).sort((a, b) => a.x - b.x);
10
+ const framesSortedVertical = Object.values(win.frames).filter((f) => f.height > 0 && f.height < settings.minSizeScaled.height && !f.collapsed).sort((a, b) => a.y - b.y);
11
+ for (let pass = 0; pass < passes; pass++) {
12
+ let anyChanged = false;
13
+ for (const orientation of ["horizontal", "vertical"]) {
14
+ const sizeKey = orientation === "horizontal" ? "width" : "height";
15
+ const posKey = orientation === "horizontal" ? "x" : "y";
16
+ const minSize = settings.minSizeScaled[sizeKey];
17
+ const frames = orientation === "horizontal" ? framesSortedHorizontal : framesSortedVertical;
18
+ if (frames.length === 0) {
19
+ continue;
20
+ }
21
+ for (const frame of frames) {
22
+ const deficit = minSize - frame[sizeKey];
23
+ if (deficit <= 0) continue;
24
+ const endEdge = {
25
+ startX: frame.x + frame.width,
26
+ startY: frame.y + frame.height,
27
+ endX: frame.x + frame.width,
28
+ endY: frame.y + frame.height
29
+ };
30
+ const touchingEnd = Object.values(win.frames).filter(
31
+ (f) => f.id !== frame.id && f[posKey] === frame[posKey] + frame[sizeKey] && !f.collapsed
32
+ );
33
+ if (touchingEnd.length > 0) {
34
+ const targetPos = {
35
+ x: orientation === "horizontal" ? frame.x + frame.width + deficit : frame.x,
36
+ y: orientation === "vertical" ? frame.y + frame.height + deficit : frame.y
37
+ };
38
+ const result = getMoveEdgeInfo(touchingEnd, endEdge, targetPos, settings.minSizeScaled, true, true);
39
+ if (!(result instanceof KnownError) && result.distance > 0) {
40
+ const expandBy = Math.min(deficit, result.distance);
41
+ frame[sizeKey] += expandBy;
42
+ for (const f of touchingEnd) {
43
+ f[posKey] += expandBy;
44
+ f[sizeKey] -= expandBy;
45
+ }
46
+ pushIfNotIn(toExtract, [frame.id, ...touchingEnd.map((f) => f.id)]);
47
+ anyChanged = true;
48
+ if (frame[sizeKey] >= minSize) continue;
49
+ }
50
+ }
51
+ if (frame[sizeKey] < minSize) {
52
+ const remainingDeficit = minSize - frame[sizeKey];
53
+ const startEdge = {
54
+ startX: frame.x,
55
+ startY: frame.y,
56
+ endX: frame.x,
57
+ endY: frame.y
58
+ };
59
+ const touchingStart = Object.values(win.frames).filter(
60
+ (f) => f.id !== frame.id && f[posKey] + f[sizeKey] === frame[posKey] && !f.collapsed
61
+ );
62
+ if (touchingStart.length > 0) {
63
+ const targetPos = {
64
+ x: orientation === "horizontal" ? frame.x - remainingDeficit : frame.x,
65
+ y: orientation === "vertical" ? frame.y - remainingDeficit : frame.y
66
+ };
67
+ const result = getMoveEdgeInfo(touchingStart, startEdge, targetPos, settings.minSizeScaled, true, true);
68
+ if (!(result instanceof KnownError) && result.distance > 0) {
69
+ const expandBy = Math.min(remainingDeficit, result.distance);
70
+ frame[posKey] -= expandBy;
71
+ frame[sizeKey] += expandBy;
72
+ for (const f of touchingStart) {
73
+ f[sizeKey] -= expandBy;
74
+ }
75
+ pushIfNotIn(toExtract, [frame.id, ...touchingStart.map((f) => f.id)]);
76
+ anyChanged = true;
77
+ }
78
+ }
79
+ }
80
+ }
81
+ }
82
+ if (!anyChanged) {
83
+ break;
84
+ }
85
+ }
86
+ return {
87
+ modified: toExtract.map((id) => win.frames[id]),
88
+ created: [],
89
+ deleted: []
90
+ };
91
+ }
@@ -0,0 +1,13 @@
1
+ import type { LayoutChange, LayoutWindow, PxSize } from "../types/index.js";
2
+ /**
3
+ * Returns info to update the window size, keeping non-0 collapsed frames the same pixel size IF possible. Never returns an error.
4
+ *
5
+ * This sacrifices the min (percentage) size of other frames if needed, although not to the point of making them 0 size (which would break the layout).
6
+ *
7
+ * If there is absolutely no space, it will leave things as they are. This just means that the collapsed frame will shrink further than your ideal pixel width, but percentage size will stay the same.
8
+ *
9
+ * @experimental
10
+ */
11
+ export declare function getUpdateWindowSizeInfo(win: LayoutWindow, event: PxSize, { relaxPasses }?: {
12
+ relaxPasses?: number;
13
+ }): LayoutChange<any>;
@@ -0,0 +1,65 @@
1
+ import { pushIfNotIn } from "@alanscodelog/utils/pushIfNotIn";
2
+ import { walk } from "@alanscodelog/utils/walk";
3
+ import { applyFrameChanges } from "../layout/applyFrameChanges.js";
4
+ import { getFrameCollapseInfo } from "../layout/getFrameCollapseInfo.js";
5
+ import { getFrameUncollapseInfo } from "../layout/getFrameUncollapseInfo.js";
6
+ import { getRelaxFramesInfo } from "../layout/getRelaxFramesInfo.js";
7
+ import { settings } from "../settings.js";
8
+ import { KnownError } from "../utils/KnownError.js";
9
+ export function getUpdateWindowSizeInfo(win, event, { relaxPasses = 2 } = {}) {
10
+ win = walk(win, void 0, { save: true });
11
+ win.pxWidth = event.pxWidth;
12
+ win.pxHeight = event.pxHeight;
13
+ const maxInt = settings.maxInt;
14
+ const frames = Object.values(win.frames);
15
+ const dockedFrameIds = frames.filter((f) => f.collapsed).map((f) => f.id);
16
+ if (dockedFrameIds.length === 0) {
17
+ return {
18
+ modified: [],
19
+ created: [],
20
+ deleted: [],
21
+ window: { pxWidth: event.pxWidth, pxHeight: event.pxHeight }
22
+ };
23
+ }
24
+ const toExtract = [];
25
+ for (const frameId of dockedFrameIds) {
26
+ const frame = win.frames[frameId];
27
+ const orientation = frame.docked === "left" || frame.docked === "right" ? "horizontal" : "vertical";
28
+ const sizeKey = orientation === "horizontal" ? "width" : "height";
29
+ const targetPxSize = settings.collapseSizePx[sizeKey];
30
+ const targetScaled = Math.round(targetPxSize / (orientation === "horizontal" ? win.pxWidth : win.pxHeight) * maxInt);
31
+ if (frame[sizeKey] === targetScaled) continue;
32
+ if (frame[sizeKey] === 0) continue;
33
+ let result;
34
+ const wasCollapsed = frame.collapsed;
35
+ const wasMinSize = { ...settings.minSize };
36
+ settings.minSize = 1;
37
+ if (targetScaled < frame[sizeKey]) {
38
+ frame.collapsed = void 0;
39
+ result = getFrameCollapseInfo(win, frame.id, { collapseSizeScaled: { width: targetScaled, height: targetScaled } });
40
+ } else {
41
+ frame.collapsed = Infinity;
42
+ result = getFrameUncollapseInfo(win, frame.id, { restoreSize: { width: targetScaled, height: targetScaled } });
43
+ }
44
+ if (!(result instanceof KnownError)) {
45
+ applyFrameChanges(win, result);
46
+ pushIfNotIn(toExtract, result.modified.map((f) => f.id));
47
+ }
48
+ frame.collapsed = wasCollapsed;
49
+ settings.minSize = wasMinSize;
50
+ const result2 = getRelaxFramesInfo(win, relaxPasses);
51
+ if (!(result2 instanceof KnownError)) {
52
+ applyFrameChanges(win, result2);
53
+ pushIfNotIn(toExtract, result2.modified.map((f) => f.id));
54
+ }
55
+ }
56
+ return {
57
+ modified: toExtract.map((id) => win.frames[id]),
58
+ created: [],
59
+ deleted: [],
60
+ window: {
61
+ pxWidth: event.pxWidth,
62
+ pxHeight: event.pxHeight
63
+ }
64
+ };
65
+ }
@@ -19,6 +19,7 @@ export { getFrameSwapInfo } from "./getFrameSwapInfo.js";
19
19
  export { getFrameTo } from "./getFrameTo.js";
20
20
  export { getFrameUncollapseInfo } from "./getFrameUncollapseInfo.js";
21
21
  export { getFrameUndockInfo } from "./getFrameUndockInfo.js";
22
+ export { getUpdateWindowSizeInfo } from "./getUpdateWindowSizeInfo.js";
22
23
  export { getWindowDragZones } from "./getWindowDragZones.js";
23
24
  export { isPointInRect } from "./isPointInRect.js";
24
25
  export { layoutAddWindow } from "./layoutAddWindow.js";
@@ -19,6 +19,7 @@ export { getFrameSwapInfo } from "./getFrameSwapInfo.js";
19
19
  export { getFrameTo } from "./getFrameTo.js";
20
20
  export { getFrameUncollapseInfo } from "./getFrameUncollapseInfo.js";
21
21
  export { getFrameUndockInfo } from "./getFrameUndockInfo.js";
22
+ export { getUpdateWindowSizeInfo } from "./getUpdateWindowSizeInfo.js";
22
23
  export { getWindowDragZones } from "./getWindowDragZones.js";
23
24
  export { isPointInRect } from "./isPointInRect.js";
24
25
  export { layoutAddWindow } from "./layoutAddWindow.js";
@@ -1,5 +1,5 @@
1
+ import { clampNumber } from "@alanscodelog/utils/clampNumber";
1
2
  import { findFramesTouchingEdge } from "./findFramesTouchingEdge.js";
2
- import { clampNumber } from "../helpers/clampNumber.js";
3
3
  import { frameToEdges } from "../helpers/frameToEdges.js";
4
4
  import { getEdgeOrientation } from "../helpers/getEdgeOrientation.js";
5
5
  import { getResizeLimit } from "../helpers/getResizeLimit.js";
@@ -8,7 +8,6 @@ import { isWindowEdge } from "../helpers/isWindowEdge.js";
8
8
  import { resizeByEdge } from "../helpers/resizeByEdge.js";
9
9
  import { settings } from "../settings.js";
10
10
  export function resizeFrame(win, frame, dir, distance, minSize = settings.minSizeScaled) {
11
- const originalDistance = distance;
12
11
  const frameEdges = frameToEdges(frame);
13
12
  const resizeEdges = dir === "up" ? [frameEdges.top] : dir === "down" ? [frameEdges.bottom] : dir === "vertical" ? [frameEdges.top, frameEdges.bottom] : dir === "left" ? [frameEdges.left] : dir === "right" ? [frameEdges.right] : [frameEdges.left, frameEdges.right];
14
13
  let divideDistance = false;
@@ -52,7 +51,6 @@ export function resizeFrame(win, frame, dir, distance, minSize = settings.minSiz
52
51
  }
53
52
  }
54
53
  if (!foundEdge) {
55
- distance = originalDistance;
56
54
  continue;
57
55
  }
58
56
  const touchingFrames = findFramesTouchingEdge(foundEdge, Object.values(win.frames))?.map((_) => _.frame);
@@ -1,5 +1,20 @@
1
1
  import type { Point, Size } from "./types/index.js";
2
2
  export declare class Settings {
3
+ private initialized;
4
+ constructor();
5
+ resetToDefaults(): void;
6
+ _zoneSizes: {
7
+ frameEdgePx: number;
8
+ windowEdgePx: number;
9
+ };
10
+ get zoneSizes(): {
11
+ frameEdgePx: number;
12
+ windowEdgePx: number;
13
+ };
14
+ set zoneSizes(v: number | {
15
+ frameEdgePx: number;
16
+ windowEdgePx: number;
17
+ });
3
18
  private _scale;
4
19
  private _maxInt;
5
20
  get scale(): number;
@@ -7,7 +22,7 @@ export declare class Settings {
7
22
  get maxInt(): number;
8
23
  private _snapPoint;
9
24
  private _snapPointScaled;
10
- get snapPoint(): number | Point;
25
+ get snapPoint(): Point;
11
26
  set snapPoint(v: number | Point);
12
27
  get snapPointScaled(): {
13
28
  x: number;
@@ -15,23 +30,19 @@ export declare class Settings {
15
30
  };
16
31
  private _minSize;
17
32
  private _minSizeScaled;
18
- get minSize(): number | Size;
33
+ get minSize(): Size;
19
34
  set minSize(v: number | Size);
20
- get minSizeScaled(): {
21
- width: number;
22
- height: number;
23
- };
24
- private _collapseSize;
25
- private _collapseSizeScaled;
26
- get collapseSize(): number | Size;
27
- set collapseSize(v: number | Size);
28
- get collapseSizeScaled(): {
29
- width: number;
30
- height: number;
31
- };
35
+ get minSizeScaled(): Size;
36
+ private _collapseSizePx;
37
+ get collapseSizePx(): Size;
38
+ set collapseSizePx(v: number | Size);
39
+ getCollapseSizeScaled(win: {
40
+ pxWidth: number;
41
+ pxHeight: number;
42
+ }): Size;
32
43
  private _maxPerpendicularLength;
33
44
  private _maxPerpendicularLengthScaled;
34
- get maxPerpendicularLength(): number | Size;
45
+ get maxPerpendicularLength(): Size;
35
46
  set maxPerpendicularLength(v: number | Size);
36
47
  get maxPerpendicularLengthScaled(): {
37
48
  width: number;
@@ -40,9 +51,5 @@ export declare class Settings {
40
51
  private _scalePoint;
41
52
  private _scaleSize;
42
53
  private _recalcAll;
43
- zoneSizes: {
44
- frameEdgePx: number;
45
- windowEdgePx: number;
46
- };
47
54
  }
48
55
  export declare const settings: Settings;