@witchcraft/layout 0.5.3 → 0.5.5

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.
@@ -13,4 +13,4 @@ import { KnownError } from "../utils/KnownError.js";
13
13
  export declare function getFrameCollapseInfo(win: LayoutWindow, frameId: string, { collapseSizeScaled }?: {
14
14
  /** Override the target collapse size. If provided, the frame will collapse to this size instead of settings.collapseSizeScaled. */
15
15
  collapseSizeScaled?: Size;
16
- }): LayoutChange | KnownError<typeof LAYOUT_ERROR.CANT_COLLAPSE_NOT_DOCKED> | KnownError<typeof LAYOUT_ERROR.REDISTRIBUTE_WOULD_RESULT_IN_INVALID_FRAMES> | KnownError<typeof LAYOUT_ERROR.CANT_RESIZE_SINGLE_FRAME>;
16
+ }): LayoutChange | KnownError<typeof LAYOUT_ERROR.CANT_COLLAPSE_NOT_DOCKED> | KnownError<typeof LAYOUT_ERROR.REDISTRIBUTE_WOULD_RESULT_IN_INVALID_FRAMES> | KnownError<typeof LAYOUT_ERROR.CANT_RESIZE_SINGLE_FRAME> | KnownError<typeof LAYOUT_ERROR.NO_SPACE_TO_REDISTRIBUTE>;
@@ -11,4 +11,4 @@ import { KnownError } from "../utils/KnownError.js";
11
11
  export declare function getFrameShrinkInfo(win: LayoutWindow, frameId: string, amount: number, shrinkSide: EdgeSide, { allowOutOfBounds }?: {
12
12
  /** Allow the resize span to exceed window bounds. */
13
13
  allowOutOfBounds?: boolean;
14
- }): LayoutChange | KnownError<typeof LAYOUT_ERROR.REDISTRIBUTE_WOULD_RESULT_IN_INVALID_FRAMES> | KnownError<typeof LAYOUT_ERROR.CANT_RESIZE_SINGLE_FRAME>;
14
+ }): LayoutChange | KnownError<typeof LAYOUT_ERROR.REDISTRIBUTE_WOULD_RESULT_IN_INVALID_FRAMES> | KnownError<typeof LAYOUT_ERROR.CANT_RESIZE_SINGLE_FRAME> | KnownError<typeof LAYOUT_ERROR.NO_SPACE_TO_REDISTRIBUTE>;
@@ -30,7 +30,7 @@ export function getFrameShrinkInfo(win, frameId, amount, shrinkSide, {
30
30
  const pinnedEdgeCoordinates = getPinnedEdgesForCollapsedFrames(win, frame, shrinkSide, posKey, sizeKey);
31
31
  const changes = getFramesRedistributeInfo(win, redistributeSide, otherFrameIds, -amount, { allowOutOfBounds, pinnedEdgeCoordinates });
32
32
  if (changes instanceof KnownError) {
33
- if (changes.code === LAYOUT_ERROR.REDISTRIBUTE_OUT_OF_BOUNDS || changes.code === LAYOUT_ERROR.NO_SPACE_TO_REDISTRIBUTE) {
33
+ if (changes.code === LAYOUT_ERROR.REDISTRIBUTE_OUT_OF_BOUNDS) {
34
34
  changes.message = `This error should never happen, please file a bug report: ${changes.message}`;
35
35
  throw changes;
36
36
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@witchcraft/layout",
3
3
  "description": "Headless layout manager.",
4
- "version": "0.5.3",
4
+ "version": "0.5.5",
5
5
  "main": "./dist/runtime/index.js",
6
6
  "type": "module",
7
7
  "sideEffects": false,
@@ -146,7 +146,7 @@ actionHandler.shapes = reactive([])
146
146
  actionHandler.textHints = reactive({ actions: [], errors: [] })
147
147
  const shapes = actionHandler.shapes
148
148
 
149
- const dragContext = useFrames(
149
+ const moveContext = useFrames(
150
150
  win,
151
151
  actionHandler
152
152
  )
@@ -158,9 +158,9 @@ const {
158
158
  state,
159
159
  movingFrameId,
160
160
  showMoving,
161
- } = dragContext
161
+ } = moveContext
162
162
 
163
- provide(moveContextInjectionKey, dragContext)
163
+ provide(moveContextInjectionKey, moveContext)
164
164
 
165
165
  function getWindowOffset() {
166
166
  const windowElRect = windowEl.value!.getBoundingClientRect()
@@ -209,6 +209,7 @@ defineExpose({
209
209
  win,
210
210
  getUpdateWindowSizeInfo,
211
211
  actionHandler: actionHandler as ActionHandler<any, any>,
212
+ moveContext
212
213
  })
213
214
  </script>
214
215
 
@@ -30,7 +30,8 @@ export function getFrameCollapseInfo(
30
30
  ): LayoutChange
31
31
  | KnownError<typeof LAYOUT_ERROR.CANT_COLLAPSE_NOT_DOCKED>
32
32
  | KnownError<typeof LAYOUT_ERROR.REDISTRIBUTE_WOULD_RESULT_IN_INVALID_FRAMES>
33
- | KnownError<typeof LAYOUT_ERROR.CANT_RESIZE_SINGLE_FRAME> {
33
+ | KnownError<typeof LAYOUT_ERROR.CANT_RESIZE_SINGLE_FRAME>
34
+ | KnownError<typeof LAYOUT_ERROR.NO_SPACE_TO_REDISTRIBUTE> {
34
35
  collapseSizeScaled = collapseSizeScaled ?? settings.getCollapseSizeScaled(win)
35
36
  win = walk(win, undefined, { save: true }) as typeof win
36
37
  const frame = win.frames[frameId]
@@ -32,7 +32,8 @@ export function getFrameShrinkInfo(
32
32
  } = {}
33
33
  ): LayoutChange
34
34
  | KnownError<typeof LAYOUT_ERROR.REDISTRIBUTE_WOULD_RESULT_IN_INVALID_FRAMES>
35
- | KnownError<typeof LAYOUT_ERROR.CANT_RESIZE_SINGLE_FRAME> {
35
+ | KnownError<typeof LAYOUT_ERROR.CANT_RESIZE_SINGLE_FRAME>
36
+ | KnownError<typeof LAYOUT_ERROR.NO_SPACE_TO_REDISTRIBUTE> {
36
37
  win = walk(win, undefined, { save: true }) as typeof win
37
38
  const frame = win.frames[frameId]
38
39
  if (!frame) throw new Error(`Unknown frame ${frameId}`)
@@ -65,7 +66,7 @@ export function getFrameShrinkInfo(
65
66
 
66
67
  if (changes instanceof KnownError) {
67
68
  // we should never get out of bounds and because this is a shrink there should always be space
68
- if (changes.code === LAYOUT_ERROR.REDISTRIBUTE_OUT_OF_BOUNDS || changes.code === LAYOUT_ERROR.NO_SPACE_TO_REDISTRIBUTE) {
69
+ if (changes.code === LAYOUT_ERROR.REDISTRIBUTE_OUT_OF_BOUNDS) {
69
70
  changes.message = `This error should never happen, please file a bug report: ${changes.message}`
70
71
  throw changes
71
72
  }