@pablopunk/webr 0.2.1 → 0.3.2

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.
@@ -1,23 +0,0 @@
1
- import type { Pane, Thread } from './models';
2
- import type { Layout, Rect } from '../shared/runtime';
3
-
4
- export type PeekSide = 'right' | 'bottom';
5
- export const threadAgent = (thread: Thread): Pane | undefined => thread.panes.find((pane) => pane.kind === 'agent') ?? thread.panes[0];
6
- export const threadShell = (thread: Thread): Pane | undefined => { const main = threadAgent(thread); return thread.panes.find((pane) => pane.kind === 'shell' && pane.id !== main?.id); };
7
- export const peekSide = (shell: Rect, area: Rect): PeekSide => shell.x > area.x && shell.y === area.y ? 'right' : 'bottom';
8
- export const terminalDirection = (side: PeekSide) => side === 'right' ? 'right' as const : 'down' as const;
9
-
10
- export function hiddenTerminalLayout(thread: Thread, layout: Layout) {
11
- const shell = threadShell(thread); const agent = threadAgent(thread);
12
- const shellRect = shell && layout.panes.find((rect) => rect.paneId === shell.id)?.rect;
13
- const otherPanes = thread.panes.filter((pane) => pane.id !== shell?.id && pane.id !== agent?.id);
14
- if (!thread.terminalHidden || !shell || !agent || !shellRect || otherPanes.length) return undefined;
15
- return { shell, agent, side: peekSide(shellRect, layout.area) };
16
- }
17
-
18
- export function currentTerminalDirection(thread: Thread, layouts: Layout[], narrow: boolean) {
19
- const shell = threadShell(thread);
20
- const layout = layouts.find((layout) => layout.panes.some((rect) => rect.paneId === shell?.id));
21
- const rect = layout?.panes.find((rect) => rect.paneId === shell?.id)?.rect;
22
- return rect && layout ? terminalDirection(peekSide(rect, layout.area)) : narrow ? 'down' : 'right';
23
- }