@tearleads/windowing 0.1.1 → 0.2.3

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 (62) hide show
  1. package/README.md +64 -11
  2. package/createRequiredContext.js.map +1 -1
  3. package/index.js.map +1 -1
  4. package/menu/Menu.js.map +1 -1
  5. package/menu/MenuItem.js.map +1 -1
  6. package/menu/useContextMenuState.js.map +1 -1
  7. package/menu/useMenuKeyboard.js.map +1 -1
  8. package/package.json +6 -1
  9. package/sidebar/SidebarResize.js.map +1 -1
  10. package/window/CurrentWindowContext.js.map +1 -1
  11. package/window/Window.d.ts +8 -1
  12. package/window/Window.js +9 -12
  13. package/window/Window.js.map +1 -1
  14. package/window/WindowBody.css +17 -0
  15. package/window/WindowBody.js.map +1 -1
  16. package/window/WindowChromeActions.d.ts +7 -0
  17. package/window/WindowChromeActions.js +3 -1
  18. package/window/WindowChromeActions.js.map +1 -1
  19. package/window/WindowCloseButton.js.map +1 -1
  20. package/window/WindowMaximizeButton.js.map +1 -1
  21. package/window/WindowMenuBar.js.map +1 -1
  22. package/window/WindowMenuContext.js.map +1 -1
  23. package/window/WindowMinimizeButton.js.map +1 -1
  24. package/window/WindowResizeHandle.css +121 -32
  25. package/window/WindowResizeHandle.d.ts +8 -4
  26. package/window/WindowResizeHandle.js +18 -3
  27. package/window/WindowResizeHandle.js.map +1 -1
  28. package/window/WindowSidebar.js.map +1 -1
  29. package/window/WindowSidebarContext.js.map +1 -1
  30. package/window/WindowStateProvider/WindowStateProvider.js.map +1 -1
  31. package/window/WindowStateProvider/context.js.map +1 -1
  32. package/window/WindowStateProvider/index.js.map +1 -1
  33. package/window/WindowStateProvider/types.js.map +1 -1
  34. package/window/WindowStateProvider/useWindowActions.js.map +1 -1
  35. package/window/WindowStateProvider/useWindowStateActions.js.map +1 -1
  36. package/window/WindowStateProvider/useWindowStateData.js.map +1 -1
  37. package/window/WindowStateProvider/util/bringWindowToFront.js.map +1 -1
  38. package/window/WindowStateProvider/util/createWindowEntry.js.map +1 -1
  39. package/window/WindowStateProvider/util/findAdjacentWindow.js.map +1 -1
  40. package/window/WindowStateProvider/util/findTopWindow.js.map +1 -1
  41. package/window/WindowStateProvider/util/getMaxWindowZIndex.js.map +1 -1
  42. package/window/WindowStateProvider/util/index.js.map +1 -1
  43. package/window/WindowStateProvider/util/swapWindowZIndexes.js.map +1 -1
  44. package/window/WindowStateProvider/util/updateWindowFlag.js.map +1 -1
  45. package/window/WindowStatusBar.js.map +1 -1
  46. package/window/WindowTitleBar.d.ts +1 -0
  47. package/window/WindowTitleBar.js.map +1 -1
  48. package/window/WindowToolBar.css +6 -0
  49. package/window/WindowToolBar.js.map +1 -1
  50. package/window/useWindowGeometry.d.ts +2 -2
  51. package/window/useWindowGeometry.js +5 -5
  52. package/window/useWindowGeometry.js.map +1 -1
  53. package/window/useWindowItemRegistration.js.map +1 -1
  54. package/window/useWindowItemRegistry.js.map +1 -1
  55. package/window/useWindowKeyboardGeometry.js +14 -1
  56. package/window/useWindowKeyboardGeometry.js.map +1 -1
  57. package/window/useWindowLayout.js.map +1 -1
  58. package/window/useWindowToolbarReservationRegistry.js.map +1 -1
  59. package/window/windowGeometry.d.ts +2 -2
  60. package/window/windowGeometry.js +8 -4
  61. package/window/windowGeometry.js.map +1 -1
  62. package/window/windowMenuRegistrations.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"useWindowLayout.js","sourceRoot":"","sources":["../../../../../../../Users/a2f0/github/tearleads5/packages/windowing/src/window/useWindowLayout.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,WAAW,EACX,SAAS,EACT,MAAM,GACP,MAAM,OAAO,CAAC;AAMf,OAAO,EACL,mBAAmB,GAIpB,MAAM,kBAAkB,CAAC;AAc1B,8EAA8E;AAC9E,+EAA+E;AAC/E,gEAAgE;AAChE,SAAS,cAAc,CACrB,QAAkD,EAClD,QAAoD;IAEpD,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAA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,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;IAE1E,wEAAwE;IACxE,oBAAoB;IACpB,MAAM,IAAI,GAAG,WAAW,CACtB,CAAC,OAAgB,EAAE,EAAE;QACnB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;YACjC,QAAQ,CAAC,OAAO,GAAG,KAAK,CAAC;YACzB,MAAM,CAAC,IAAI,CAAC,CAAC;QACf,CAAC;IACH,CAAC,EACD,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,CACzB,CAAC;IAEF,OAAO,EAAE,IAAI,EAAE,CAAC;AAClB,CAAC","sourcesContent":["import {\n type MutableRefObject,\n type RefObject,\n useCallback,\n useEffect,\n useRef,\n} from \"react\";\nimport type {\n WindowEntry,\n WindowPosition,\n WindowSize,\n} from \"./WindowStateProvider\";\nimport {\n clampWindowPosition,\n type LiveGeometry,\n type WindowDragState,\n type WindowResizeState,\n} from \"./windowGeometry\";\n\ninterface WindowLayoutInput {\n clamp: (x: number, y: number) => WindowPosition;\n commit: () => void;\n dragging: MutableRefObject<WindowDragState | null>;\n entry: WindowEntry;\n live: MutableRefObject<LiveGeometry>;\n resizing: MutableRefObject<WindowResizeState | null>;\n setPosition: (value: WindowPosition) => void;\n size: WindowSize | null;\n windowRef: RefObject<HTMLElement | null>;\n}\n\n// A gesture (a pointer drag or resize, or a keyboard move or resize) owns the\n// live geometry until it ends: layout holds off meanwhile, so it never commits\n// an unconfirmed frame, and runs once when the gesture lets go.\nfunction useGestureHold(\n dragging: MutableRefObject<WindowDragState | null>,\n resizing: MutableRefObject<WindowResizeState | null>,\n) {\n const held = useRef(false);\n const deferred = useRef(false);\n const isBusy = useCallback(\n () =>\n held.current || dragging.current !== null || resizing.current !== null,\n [dragging, resizing],\n );\n return { deferred, held, isBusy };\n}\n\n// A surface with no size is hidden (display: none), so nothing measured\n// against it is meaningful.\nfunction isUnsized(container: HTMLElement) {\n return container.clientWidth === 0 && container.clientHeight === 0;\n}\n\n// The surface changing size (a workspace shown after being hidden, a resized\n// viewport) lays the window out again.\nfunction useSurfaceObserver(\n windowRef: RefObject<HTMLElement | null>,\n minimized: boolean,\n layout: () => void,\n) {\n useEffect(() => {\n const container = windowRef.current?.parentElement;\n if (minimized || !container || typeof ResizeObserver === \"undefined\") {\n return;\n }\n const observer = new ResizeObserver(() => layout());\n observer.observe(container);\n return () => observer.disconnect();\n }, [layout, minimized, windowRef]);\n}\n\nexport function useWindowLayout({\n clamp,\n commit,\n dragging,\n entry,\n live,\n resizing,\n setPosition,\n size,\n windowRef,\n}: WindowLayoutInput) {\n // Lay the window out from its committed position, or from its viewport\n // starting point the first time, and commit where it actually landed. A\n // minimized window has no element to measure and a maximized one measures at\n // full size, so this waits both out. A hidden surface (an inactive\n // workspace) measures at zero: the window takes its intended position\n // unclamped and nothing is committed until the surface has a size.\n const { deferred, held, isBusy } = useGestureHold(dragging, resizing);\n // `release` lays out from the live geometry a gesture just finished with,\n // which the committed position does not reflect until it re-renders.\n const layout = useCallback(\n (release = false) => {\n const element = windowRef.current;\n const container = element?.parentElement;\n if (entry.minimized || entry.maximized || !element || !container) {\n return;\n }\n if (isBusy()) {\n deferred.current = true;\n return;\n }\n if (!live.current.size) {\n // A cleared size has not re-rendered yet; drop the old inline size so the\n // window measures at the stylesheet default it is about to take.\n element.style.removeProperty(\"width\");\n element.style.removeProperty(\"height\");\n }\n const containerRect = container.getBoundingClientRect();\n const start = (release ? live.current.position : null) ??\n entry.position ?? {\n x: entry.initialX - containerRect.left,\n y: entry.initialY - containerRect.top,\n };\n if (isUnsized(container)) {\n setPosition(start);\n return;\n }\n setPosition(clamp(start.x, start.y));\n commit();\n },\n [\n clamp,\n commit,\n deferred,\n entry.initialX,\n entry.initialY,\n entry.maximized,\n entry.minimized,\n entry.position,\n isBusy,\n live,\n setPosition,\n windowRef,\n ],\n );\n\n useEffect(() => {\n layout();\n }, [layout]);\n\n useSurfaceObserver(windowRef, entry.minimized, layout);\n\n // Once the window renders at a new size, including a cleared size falling\n // back to its stylesheet default, keep it inside the surface.\n useEffect(() => {\n const current = live.current.position;\n const container = windowRef.current?.parentElement;\n if (\n !current ||\n entry.maximized ||\n isBusy() ||\n !container ||\n isUnsized(container)\n ) {\n return;\n }\n const clamped = clampWindowPosition(\n windowRef.current,\n current.x,\n current.y,\n size,\n );\n if (clamped.x !== current.x || clamped.y !== current.y) {\n setPosition(clamped);\n commit();\n }\n }, [commit, entry.maximized, isBusy, live, setPosition, size, windowRef]);\n\n // Holds layout for a keyboard gesture; releasing it runs any layout the\n // gesture deferred.\n const hold = useCallback(\n (holding: boolean) => {\n held.current = holding;\n if (!holding && deferred.current) {\n deferred.current = false;\n layout(true);\n }\n },\n [deferred, held, layout],\n );\n\n return { hold };\n}\n"]}
1
+ {"version":3,"file":"useWindowLayout.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/window/useWindowLayout.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,WAAW,EACX,SAAS,EACT,MAAM,GACP,MAAM,OAAO,CAAC;AAMf,OAAO,EACL,mBAAmB,GAIpB,MAAM,kBAAkB,CAAC;AAc1B,8EAA8E;AAC9E,+EAA+E;AAC/E,gEAAgE;AAChE,SAAS,cAAc,CACrB,QAAkD,EAClD,QAAoD;IAEpD,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3B,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC/B,MAAM,MAAM,GAAG,WAAW,CACxB,GAAG,EAAE,CACH,IAAI,CAAC,OAAO,IAAI,QAAQ,CAAC,OAAO,KAAK,IAAI,IAAI,QAAQ,CAAC,OAAO,KAAK,IAAI,EACxE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CACrB,CAAC;IACF,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,CA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AAC,CAAC;QACf,CAAC;IACH,CAAC,EACD,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,CACzB,CAAC;IAEF,OAAO,EAAE,IAAI,EAAE,CAAC;AAClB,CAAC","sourcesContent":["import {\n type MutableRefObject,\n type RefObject,\n useCallback,\n useEffect,\n useRef,\n} from \"react\";\nimport type {\n WindowEntry,\n WindowPosition,\n WindowSize,\n} from \"./WindowStateProvider\";\nimport {\n clampWindowPosition,\n type LiveGeometry,\n type WindowDragState,\n type WindowResizeState,\n} from \"./windowGeometry\";\n\ninterface WindowLayoutInput {\n clamp: (x: number, y: number) => WindowPosition;\n commit: () => void;\n dragging: MutableRefObject<WindowDragState | null>;\n entry: WindowEntry;\n live: MutableRefObject<LiveGeometry>;\n resizing: MutableRefObject<WindowResizeState | null>;\n setPosition: (value: WindowPosition) => void;\n size: WindowSize | null;\n windowRef: RefObject<HTMLElement | null>;\n}\n\n// A gesture (a pointer drag or resize, or a keyboard move or resize) owns the\n// live geometry until it ends: layout holds off meanwhile, so it never commits\n// an unconfirmed frame, and runs once when the gesture lets go.\nfunction useGestureHold(\n dragging: MutableRefObject<WindowDragState | null>,\n resizing: MutableRefObject<WindowResizeState | null>,\n) {\n const held = useRef(false);\n const deferred = useRef(false);\n const isBusy = useCallback(\n () =>\n held.current || dragging.current !== null || resizing.current !== null,\n [dragging, resizing],\n );\n return { deferred, held, isBusy };\n}\n\n// A surface with no size is hidden (display: none), so nothing measured\n// against it is meaningful.\nfunction isUnsized(container: HTMLElement) {\n return container.clientWidth === 0 && container.clientHeight === 0;\n}\n\n// The surface changing size (a workspace shown after being hidden, a resized\n// viewport) lays the window out again.\nfunction useSurfaceObserver(\n windowRef: RefObject<HTMLElement | null>,\n minimized: boolean,\n layout: () => void,\n) {\n useEffect(() => {\n const container = windowRef.current?.parentElement;\n if (minimized || !container || typeof ResizeObserver === \"undefined\") {\n return;\n }\n const observer = new ResizeObserver(() => layout());\n observer.observe(container);\n return () => observer.disconnect();\n }, [layout, minimized, windowRef]);\n}\n\nexport function useWindowLayout({\n clamp,\n commit,\n dragging,\n entry,\n live,\n resizing,\n setPosition,\n size,\n windowRef,\n}: WindowLayoutInput) {\n // Lay the window out from its committed position, or from its viewport\n // starting point the first time, and commit where it actually landed. A\n // minimized window has no element to measure and a maximized one measures at\n // full size, so this waits both out. A hidden surface (an inactive\n // workspace) measures at zero: the window takes its intended position\n // unclamped and nothing is committed until the surface has a size.\n const { deferred, held, isBusy } = useGestureHold(dragging, resizing);\n // `release` lays out from the live geometry a gesture just finished with,\n // which the committed position does not reflect until it re-renders.\n const layout = useCallback(\n (release = false) => {\n const element = windowRef.current;\n const container = element?.parentElement;\n if (entry.minimized || entry.maximized || !element || !container) {\n return;\n }\n if (isBusy()) {\n deferred.current = true;\n return;\n }\n if (!live.current.size) {\n // A cleared size has not re-rendered yet; drop the old inline size so the\n // window measures at the stylesheet default it is about to take.\n element.style.removeProperty(\"width\");\n element.style.removeProperty(\"height\");\n }\n const containerRect = container.getBoundingClientRect();\n const start = (release ? live.current.position : null) ??\n entry.position ?? {\n x: entry.initialX - containerRect.left,\n y: entry.initialY - containerRect.top,\n };\n if (isUnsized(container)) {\n setPosition(start);\n return;\n }\n setPosition(clamp(start.x, start.y));\n commit();\n },\n [\n clamp,\n commit,\n deferred,\n entry.initialX,\n entry.initialY,\n entry.maximized,\n entry.minimized,\n entry.position,\n isBusy,\n live,\n setPosition,\n windowRef,\n ],\n );\n\n useEffect(() => {\n layout();\n }, [layout]);\n\n useSurfaceObserver(windowRef, entry.minimized, layout);\n\n // Once the window renders at a new size, including a cleared size falling\n // back to its stylesheet default, keep it inside the surface.\n useEffect(() => {\n const current = live.current.position;\n const container = windowRef.current?.parentElement;\n if (\n !current ||\n entry.maximized ||\n isBusy() ||\n !container ||\n isUnsized(container)\n ) {\n return;\n }\n const clamped = clampWindowPosition(\n windowRef.current,\n current.x,\n current.y,\n size,\n );\n if (clamped.x !== current.x || clamped.y !== current.y) {\n setPosition(clamped);\n commit();\n }\n }, [commit, entry.maximized, isBusy, live, setPosition, size, windowRef]);\n\n // Holds layout for a keyboard gesture; releasing it runs any layout the\n // gesture deferred.\n const hold = useCallback(\n (holding: boolean) => {\n held.current = holding;\n if (!holding && deferred.current) {\n deferred.current = false;\n layout(true);\n }\n },\n [deferred, held, layout],\n );\n\n return { hold };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"useWindowToolbarReservationRegistry.js","sourceRoot":"","sources":["../../../../../../../Users/a2f0/github/tearleads5/packages/windowing/src/window/useWindowToolbarReservationRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAShE,4EAA4E;AAC5E,6EAA6E;AAC7E,SAAS,sBAAsB,CAC7B,IAAyB,EACzB,KAAc;IAEd,OAAO,IAAI,KAAK,KAAK,CAAC;AACxB,CAAC;AAED,MAAM,UAAU,mCAAmC;IACjD,MAAM,WAAW,GAAG,qBAAqB,CAAU,sBAAsB,CAAC,CAAC;IAC3E,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACtE,MAAM,QAAQ,GAAG,WAAW,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC;IAEzD,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC;QACL,QAAQ,EAAE,WAAW,CAAC,YAAY;QAClC,QAAQ;QACR,QAAQ;QACR,UAAU,EAAE,WAAW,CAAC,cAAc;KACvC,CAAC,EACF,CAAC,QAAQ,EAAE,QAAQ,EAAE,WAAW,CAAC,YAAY,EAAE,WAAW,CAAC,cAAc,CAAC,CAC3E,CAAC;AACJ,CAAC","sourcesContent":["import { useMemo } from \"react\";\nimport { useWindowItemRegistry } from \"./useWindowItemRegistry\";\n\ninterface WindowToolbarReservationRegistry {\n register: (id: object, reserved: boolean) => void;\n released: boolean;\n reserved: boolean;\n unregister: (id: object) => void;\n}\n\n// Module scope on purpose: the registry keys its callback identities on the\n// comparator, so an inline closure here re-registers every render and loops.\nfunction sameToolbarReservation(\n left: boolean | undefined,\n right: boolean,\n): boolean {\n return left === right;\n}\n\nexport function useWindowToolbarReservationRegistry(): WindowToolbarReservationRegistry {\n const reservation = useWindowItemRegistry<boolean>(sameToolbarReservation);\n const reserved = Array.from(reservation.items.values()).some(Boolean);\n const released = reservation.items.size > 0 && !reserved;\n\n return useMemo(\n () => ({\n register: reservation.registerItem,\n released,\n reserved,\n unregister: reservation.unregisterItem,\n }),\n [released, reserved, reservation.registerItem, reservation.unregisterItem],\n );\n}\n"]}
1
+ {"version":3,"file":"useWindowToolbarReservationRegistry.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/window/useWindowToolbarReservationRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAShE,4EAA4E;AAC5E,6EAA6E;AAC7E,SAAS,sBAAsB,CAC7B,IAAyB,EACzB,KAAc;IAEd,OAAO,IAAI,KAAK,KAAK,CAAC;AACxB,CAAC;AAED,MAAM,UAAU,mCAAmC;IACjD,MAAM,WAAW,GAAG,qBAAqB,CAAU,sBAAsB,CAAC,CAAC;IAC3E,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACtE,MAAM,QAAQ,GAAG,WAAW,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC;IAEzD,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC;QACL,QAAQ,EAAE,WAAW,CAAC,YAAY;QAClC,QAAQ;QACR,QAAQ;QACR,UAAU,EAAE,WAAW,CAAC,cAAc;KACvC,CAAC,EACF,CAAC,QAAQ,EAAE,QAAQ,EAAE,WAAW,CAAC,YAAY,EAAE,WAAW,CAAC,cAAc,CAAC,CAC3E,CAAC;AACJ,CAAC","sourcesContent":["import { useMemo } from \"react\";\nimport { useWindowItemRegistry } from \"./useWindowItemRegistry\";\n\ninterface WindowToolbarReservationRegistry {\n register: (id: object, reserved: boolean) => void;\n released: boolean;\n reserved: boolean;\n unregister: (id: object) => void;\n}\n\n// Module scope on purpose: the registry keys its callback identities on the\n// comparator, so an inline closure here re-registers every render and loops.\nfunction sameToolbarReservation(\n left: boolean | undefined,\n right: boolean,\n): boolean {\n return left === right;\n}\n\nexport function useWindowToolbarReservationRegistry(): WindowToolbarReservationRegistry {\n const reservation = useWindowItemRegistry<boolean>(sameToolbarReservation);\n const reserved = Array.from(reservation.items.values()).some(Boolean);\n const released = reservation.items.size > 0 && !reserved;\n\n return useMemo(\n () => ({\n register: reservation.registerItem,\n released,\n reserved,\n unregister: reservation.unregisterItem,\n }),\n [released, reserved, reservation.registerItem, reservation.unregisterItem],\n );\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { ResizeCorner } from "./WindowResizeHandle.js";
1
+ import type { ResizeEdge } from "./WindowResizeHandle.js";
2
2
  import type { WindowPosition, WindowSize } from "./WindowStateProvider/index.js";
3
3
  export declare const MIN_WIDTH = 200;
4
4
  export declare const MIN_HEIGHT = 100;
@@ -8,7 +8,7 @@ export interface WindowDragState {
8
8
  pointerId: number;
9
9
  }
10
10
  export interface WindowResizeState {
11
- corner: ResizeCorner;
11
+ edge: ResizeEdge;
12
12
  pointerId: number;
13
13
  startHeight: number;
14
14
  startLeft: number;
@@ -22,10 +22,14 @@ export function clampWindowPosition(element, x, y, size) {
22
22
  export function resizeWindowWithinContainer(resizeState, clientX, clientY, container) {
23
23
  const deltaX = clientX - resizeState.startX;
24
24
  const deltaY = clientY - resizeState.startY;
25
- const movesLeft = resizeState.corner.includes("w");
26
- const movesUp = resizeState.corner.includes("n");
27
- let width = Math.max(MIN_WIDTH, resizeState.startWidth + deltaX * (movesLeft ? -1 : 1));
28
- let height = Math.max(MIN_HEIGHT, resizeState.startHeight + deltaY * (movesUp ? -1 : 1));
25
+ const { edge } = resizeState;
26
+ const movesLeft = edge.includes("w");
27
+ const movesUp = edge.includes("n");
28
+ // A side handle drags one edge, so the other axis keeps its start size.
29
+ const resizesX = movesLeft || edge.includes("e");
30
+ const resizesY = movesUp || edge.includes("s");
31
+ let width = Math.max(MIN_WIDTH, resizeState.startWidth + (resizesX ? deltaX * (movesLeft ? -1 : 1) : 0));
32
+ let height = Math.max(MIN_HEIGHT, resizeState.startHeight + (resizesY ? deltaY * (movesUp ? -1 : 1) : 0));
29
33
  let x = movesLeft
30
34
  ? resizeState.startLeft + resizeState.startWidth - width
31
35
  : resizeState.startLeft;
@@ -1 +1 @@
1
- {"version":3,"file":"windowGeometry.js","sourceRoot":"","sources":["../../../../../../../Users/a2f0/github/tearleads5/packages/windowing/src/window/windowGeometry.ts"],"names":[],"mappings":"AAGA,8EAA8E;AAC9E,2DAA2D;AAE3D,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,CAAC;AAC7B,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,CAAC;AA0B9B,6EAA6E;AAC7E,0EAA0E;AAC1E,MAAM,UAAU,mBAAmB,CACjC,OAA2B,EAC3B,CAAS,EACT,CAAS,EACT,IAAuB;IAEvB,MAAM,SAAS,GAAG,OAAO,EAAE,aAAa,CAAC;IACzC,IAAI,CAAC,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC;QAC3B,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;IAClB,CAAC;IACD,sEAAsE;IACtE,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,C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CAAC,CAAC,WAAW,CAAC,SAAS,GAAG,WAAW,CAAC,UAAU,GAAG,KAAK;QACxD,CAAC,CAAC,WAAW,CAAC,SAAS,CAAC;IAC1B,IAAI,CAAC,GAAG,OAAO;QACb,CAAC,CAAC,WAAW,CAAC,QAAQ,GAAG,WAAW,CAAC,WAAW,GAAG,MAAM;QACzD,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC;IAEzB,IAAI,SAAS,EAAE,CAAC;QACd,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YACV,KAAK,IAAI,CAAC,CAAC;YACX,CAAC,GAAG,CAAC,CAAC;QACR,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YACV,MAAM,IAAI,CAAC,CAAC;YACZ,CAAC,GAAG,CAAC,CAAC;QACR,CAAC;QACD,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,CAAC,WAAW,GAAG,CAAC,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;QACzE,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,YAAY,GAAG,CAAC,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;QAC5E,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QACnC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IACxC,CAAC;IAED,OAAO;QACL,QAAQ,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE;QAClB,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE;KACxB,CAAC;AACJ,CAAC","sourcesContent":["import type { ResizeCorner } from \"./WindowResizeHandle\";\nimport type { WindowPosition, WindowSize } from \"./WindowStateProvider\";\n\n// Window geometry math shared by the pointer, keyboard, and layout hooks. All\n// positions and sizes are relative to the desktop surface.\n\nexport const MIN_WIDTH = 200;\nexport const MIN_HEIGHT = 100;\n\nexport interface WindowDragState {\n offsetX: number;\n offsetY: number;\n pointerId: number;\n}\n\nexport interface WindowResizeState {\n corner: ResizeCorner;\n pointerId: number;\n startHeight: number;\n startLeft: number;\n startTop: number;\n startWidth: number;\n startX: number;\n startY: number;\n borderX: number;\n borderY: number;\n}\n\nexport interface LiveGeometry {\n position: WindowPosition | null;\n size: WindowSize | null;\n}\n\n// Clamps against the size the window is about to render at when it is known,\n// so a position committed with a new size is not measured at the old one.\nexport function clampWindowPosition(\n element: HTMLElement | null,\n x: number,\n y: number,\n size: WindowSize | null,\n): WindowPosition {\n const container = element?.parentElement;\n if (!element || !container) {\n return { x, y };\n }\n // A requested size renders no smaller than the stylesheet's minimums.\n const width = size ? Math.max(MIN_WIDTH, size.width) : element.offsetWidth;\n const height = size\n ? Math.max(MIN_HEIGHT, size.height)\n : element.offsetHeight;\n\n return {\n x: Math.max(0, Math.min(x, container.clientWidth - width)),\n y: Math.max(0, Math.min(y, container.clientHeight - height)),\n };\n}\n\nexport function resizeWindowWithinContainer(\n resizeState: WindowResizeState,\n clientX: number,\n clientY: number,\n container: HTMLElement | null,\n) {\n const deltaX = clientX - resizeState.startX;\n const deltaY = clientY - resizeState.startY;\n const movesLeft = resizeState.corner.includes(\"w\");\n const movesUp = resizeState.corner.includes(\"n\");\n let width = Math.max(\n MIN_WIDTH,\n resizeState.startWidth + deltaX * (movesLeft ? -1 : 1),\n );\n let height = Math.max(\n MIN_HEIGHT,\n resizeState.startHeight + deltaY * (movesUp ? -1 : 1),\n );\n let x = movesLeft\n ? resizeState.startLeft + resizeState.startWidth - width\n : resizeState.startLeft;\n let y = movesUp\n ? resizeState.startTop + resizeState.startHeight - height\n : resizeState.startTop;\n\n if (container) {\n if (x < 0) {\n width += x;\n x = 0;\n }\n if (y < 0) {\n height += y;\n y = 0;\n }\n width = Math.min(width, container.clientWidth - x - resizeState.borderX);\n height = Math.min(height, container.clientHeight - y - resizeState.borderY);\n width = Math.max(MIN_WIDTH, width);\n height = Math.max(MIN_HEIGHT, height);\n }\n\n return {\n position: { x, y },\n size: { width, height },\n };\n}\n"]}
1
+ {"version":3,"file":"windowGeometry.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/window/windowGeometry.ts"],"names":[],"mappings":"AAGA,8EAA8E;AAC9E,2DAA2D;AAE3D,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,CAAC;AAC7B,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,CAAC;AA0B9B,6EAA6E;AAC7E,0EAA0E;AAC1E,MAAM,UAAU,mBAAmB,CACjC,OAA2B,EAC3B,CAAS,EACT,CAAS,EACT,IAAuB;IAEvB,MAAM,SAAS,GAAG,OAAO,EAAE,aAAa,CAAC;IACzC,IAAI,CAAC,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC;QAC3B,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;IAClB,CAAC;IACD,sEAAsE;IACtE,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC;IAC3E,MAAM,MAAM,GAAG,IAAI;QACjB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC;QACnC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC;IAEzB,OAAO;QACL,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,CAAC,WAAW,GAAG,KAAK,CAAC,CAAC;QAC1D,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,CAAC,YAAY,GAAG,MAAM,CAAC,CAAC;KAC7D,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,2BAA2B,CACzC,WAA8B,EAC9B,O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MAAM;QACzD,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC;IAEzB,IAAI,SAAS,EAAE,CAAC;QACd,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YACV,KAAK,IAAI,CAAC,CAAC;YACX,CAAC,GAAG,CAAC,CAAC;QACR,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YACV,MAAM,IAAI,CAAC,CAAC;YACZ,CAAC,GAAG,CAAC,CAAC;QACR,CAAC;QACD,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,CAAC,WAAW,GAAG,CAAC,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;QACzE,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,YAAY,GAAG,CAAC,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;QAC5E,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QACnC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IACxC,CAAC;IAED,OAAO;QACL,QAAQ,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE;QAClB,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE;KACxB,CAAC;AACJ,CAAC","sourcesContent":["import type { ResizeEdge } from \"./WindowResizeHandle\";\nimport type { WindowPosition, WindowSize } from \"./WindowStateProvider\";\n\n// Window geometry math shared by the pointer, keyboard, and layout hooks. All\n// positions and sizes are relative to the desktop surface.\n\nexport const MIN_WIDTH = 200;\nexport const MIN_HEIGHT = 100;\n\nexport interface WindowDragState {\n offsetX: number;\n offsetY: number;\n pointerId: number;\n}\n\nexport interface WindowResizeState {\n edge: ResizeEdge;\n pointerId: number;\n startHeight: number;\n startLeft: number;\n startTop: number;\n startWidth: number;\n startX: number;\n startY: number;\n borderX: number;\n borderY: number;\n}\n\nexport interface LiveGeometry {\n position: WindowPosition | null;\n size: WindowSize | null;\n}\n\n// Clamps against the size the window is about to render at when it is known,\n// so a position committed with a new size is not measured at the old one.\nexport function clampWindowPosition(\n element: HTMLElement | null,\n x: number,\n y: number,\n size: WindowSize | null,\n): WindowPosition {\n const container = element?.parentElement;\n if (!element || !container) {\n return { x, y };\n }\n // A requested size renders no smaller than the stylesheet's minimums.\n const width = size ? Math.max(MIN_WIDTH, size.width) : element.offsetWidth;\n const height = size\n ? Math.max(MIN_HEIGHT, size.height)\n : element.offsetHeight;\n\n return {\n x: Math.max(0, Math.min(x, container.clientWidth - width)),\n y: Math.max(0, Math.min(y, container.clientHeight - height)),\n };\n}\n\nexport function resizeWindowWithinContainer(\n resizeState: WindowResizeState,\n clientX: number,\n clientY: number,\n container: HTMLElement | null,\n) {\n const deltaX = clientX - resizeState.startX;\n const deltaY = clientY - resizeState.startY;\n const { edge } = resizeState;\n const movesLeft = edge.includes(\"w\");\n const movesUp = edge.includes(\"n\");\n // A side handle drags one edge, so the other axis keeps its start size.\n const resizesX = movesLeft || edge.includes(\"e\");\n const resizesY = movesUp || edge.includes(\"s\");\n let width = Math.max(\n MIN_WIDTH,\n resizeState.startWidth + (resizesX ? deltaX * (movesLeft ? -1 : 1) : 0),\n );\n let height = Math.max(\n MIN_HEIGHT,\n resizeState.startHeight + (resizesY ? deltaY * (movesUp ? -1 : 1) : 0),\n );\n let x = movesLeft\n ? resizeState.startLeft + resizeState.startWidth - width\n : resizeState.startLeft;\n let y = movesUp\n ? resizeState.startTop + resizeState.startHeight - height\n : resizeState.startTop;\n\n if (container) {\n if (x < 0) {\n width += x;\n x = 0;\n }\n if (y < 0) {\n height += y;\n y = 0;\n }\n width = Math.min(width, container.clientWidth - x - resizeState.borderX);\n height = Math.min(height, container.clientHeight - y - resizeState.borderY);\n width = Math.max(MIN_WIDTH, width);\n height = Math.max(MIN_HEIGHT, height);\n }\n\n return {\n position: { x, y },\n size: { width, height },\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"windowMenuRegistrations.js","sourceRoot":"","sources":["../../../../../../../Users/a2f0/github/tearleads5/packages/windowing/src/window/windowMenuRegistrations.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAC;AACvC,MAAM,gBAAgB,GAAG,eAAe,CAAC;AAkBzC,MAAM,UAAU,eAAe,CAC7B,KAAoD;IAEpD,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;SAC9B,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;SACrD,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACd,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,OAAO,EAAE,GAAG,EAAE;YACZ,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC;QACtB,CAAC;KACF,CAAC,CAAC,CAAC;AACR,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,IAA4C;IAE5C,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO;QACL,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,UAAU;QAC1C,EAAE,EAAE,gBAAgB;QACpB,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK;QACtD,OAAO,EAAE,GAAG,EAAE;YACZ,KAAK,IAAI,CAAC,SAAS,EAAE,CAAC;QACxB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { WindowMenuItem } from \"./WindowMenuBar\";\n\n/*\n * The shapes a mini-app's menu registration takes, and the pure projections\n * from a registry map to the items a menu bar (or the routed app bar) renders.\n * The React seams — the context, the provider, and the register/read hooks —\n * live in WindowMenuContext.tsx.\n */\n\nexport const REFRESH_LABEL = \"Refresh\";\nconst REFRESHING_LABEL = \"Refreshing...\";\n\nexport interface RegisteredWindowMenuItem {\n disabled: boolean;\n id: string;\n label: string;\n onClick: () => unknown;\n priority: number;\n}\n\nexport interface RegisteredWindowRefreshMenuItem {\n disabled: boolean;\n label: string;\n onRefresh: () => unknown;\n priority: number;\n refreshing: boolean;\n}\n\nexport function createMenuItems(\n items: ReadonlyMap<object, RegisteredWindowMenuItem>,\n): WindowMenuItem[] {\n return Array.from(items.values())\n .sort((left, right) => right.priority - left.priority)\n .map((item) => ({\n disabled: item.disabled,\n id: item.id,\n label: item.label,\n onClick: () => {\n void item.onClick();\n },\n }));\n}\n\nexport function createRefreshMenuItem(\n item: RegisteredWindowRefreshMenuItem | null,\n): WindowMenuItem | null {\n if (!item) {\n return null;\n }\n\n return {\n disabled: item.disabled || item.refreshing,\n id: \"window-refresh\",\n label: item.refreshing ? REFRESHING_LABEL : item.label,\n onClick: () => {\n void item.onRefresh();\n },\n };\n}\n"]}
1
+ {"version":3,"file":"windowMenuRegistrations.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/window/windowMenuRegistrations.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAC;AACvC,MAAM,gBAAgB,GAAG,eAAe,CAAC;AAkBzC,MAAM,UAAU,eAAe,CAC7B,KAAoD;IAEpD,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;SAC9B,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;SACrD,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACd,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,OAAO,EAAE,GAAG,EAAE;YACZ,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC;QACtB,CAAC;KACF,CAAC,CAAC,CAAC;AACR,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,IAA4C;IAE5C,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO;QACL,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,UAAU;QAC1C,EAAE,EAAE,gBAAgB;QACpB,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK;QACtD,OAAO,EAAE,GAAG,EAAE;YACZ,KAAK,IAAI,CAAC,SAAS,EAAE,CAAC;QACxB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { WindowMenuItem } from \"./WindowMenuBar\";\n\n/*\n * The shapes a mini-app's menu registration takes, and the pure projections\n * from a registry map to the items a menu bar (or the routed app bar) renders.\n * The React seams — the context, the provider, and the register/read hooks —\n * live in WindowMenuContext.tsx.\n */\n\nexport const REFRESH_LABEL = \"Refresh\";\nconst REFRESHING_LABEL = \"Refreshing...\";\n\nexport interface RegisteredWindowMenuItem {\n disabled: boolean;\n id: string;\n label: string;\n onClick: () => unknown;\n priority: number;\n}\n\nexport interface RegisteredWindowRefreshMenuItem {\n disabled: boolean;\n label: string;\n onRefresh: () => unknown;\n priority: number;\n refreshing: boolean;\n}\n\nexport function createMenuItems(\n items: ReadonlyMap<object, RegisteredWindowMenuItem>,\n): WindowMenuItem[] {\n return Array.from(items.values())\n .sort((left, right) => right.priority - left.priority)\n .map((item) => ({\n disabled: item.disabled,\n id: item.id,\n label: item.label,\n onClick: () => {\n void item.onClick();\n },\n }));\n}\n\nexport function createRefreshMenuItem(\n item: RegisteredWindowRefreshMenuItem | null,\n): WindowMenuItem | null {\n if (!item) {\n return null;\n }\n\n return {\n disabled: item.disabled || item.refreshing,\n id: \"window-refresh\",\n label: item.refreshing ? REFRESHING_LABEL : item.label,\n onClick: () => {\n void item.onRefresh();\n },\n };\n}\n"]}