@myrialabs/clopen 0.2.18 → 0.2.19
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,6 +1,6 @@
|
|
|
1
1
|
import type { Browser, BrowserContext, Page } from 'puppeteer';
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
|
-
import { getViewportDimensions } from '$
|
|
3
|
+
import { getViewportDimensions } from '$shared/constants/preview.js';
|
|
4
4
|
import type { BrowserTab, BrowserTabInfo, DeviceSize, Rotation } from './types';
|
|
5
5
|
import { DEFAULT_STREAMING_CONFIG } from './types';
|
|
6
6
|
import { browserPool } from './browser-pool';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Browser, BrowserContext, Page } from 'puppeteer';
|
|
2
|
-
import type { DeviceSize, Rotation } from '$
|
|
2
|
+
import type { DeviceSize, Rotation } from '$shared/constants/preview.js';
|
|
3
3
|
|
|
4
4
|
// Re-export types from preview config
|
|
5
5
|
export type { DeviceSize, Rotation };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@myrialabs/clopen",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.19",
|
|
4
4
|
"description": "All-in-one web workspace for Claude Code & OpenCode — chat, terminal, git, browser preview, checkpoints, and real-time collaboration",
|
|
5
5
|
"author": "Myria Labs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Preview Configuration
|
|
2
|
+
// Centralized configuration for preview components
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Device viewport dimensions
|
|
6
|
+
* These are the physical pixel dimensions for each device type.
|
|
7
|
+
* Desktop and laptop are naturally landscape (width > height).
|
|
8
|
+
* Tablet and mobile are naturally portrait (height > width).
|
|
9
|
+
*/
|
|
10
|
+
export const DEVICE_VIEWPORTS = {
|
|
11
|
+
desktop: { width: 1920, height: 1080 }, // Naturally landscape
|
|
12
|
+
laptop: { width: 1280, height: 800 }, // Naturally landscape
|
|
13
|
+
tablet: { width: 820, height: 1050 }, // Naturally portrait
|
|
14
|
+
mobile: { width: 393, height: 740 } // Naturally portrait
|
|
15
|
+
} as const;
|
|
16
|
+
|
|
17
|
+
// Type exports
|
|
18
|
+
export type DeviceSize = keyof typeof DEVICE_VIEWPORTS;
|
|
19
|
+
export type Rotation = 'portrait' | 'landscape';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Get viewport dimensions based on device size and rotation
|
|
23
|
+
*
|
|
24
|
+
* SIMPLE RULE:
|
|
25
|
+
* - Portrait: height > width (vertical orientation)
|
|
26
|
+
* - Landscape: width > height (horizontal orientation)
|
|
27
|
+
*/
|
|
28
|
+
export function getViewportDimensions(
|
|
29
|
+
deviceSize: DeviceSize,
|
|
30
|
+
rotation: Rotation
|
|
31
|
+
): { width: number; height: number } {
|
|
32
|
+
const viewport = DEVICE_VIEWPORTS[deviceSize];
|
|
33
|
+
|
|
34
|
+
// Get the larger and smaller dimension
|
|
35
|
+
const larger = Math.max(viewport.width, viewport.height);
|
|
36
|
+
const smaller = Math.min(viewport.width, viewport.height);
|
|
37
|
+
|
|
38
|
+
if (rotation === 'portrait') {
|
|
39
|
+
// Portrait: height > width (vertical)
|
|
40
|
+
return { width: smaller, height: larger };
|
|
41
|
+
} else {
|
|
42
|
+
// Landscape: width > height (horizontal)
|
|
43
|
+
return { width: larger, height: smaller };
|
|
44
|
+
}
|
|
45
|
+
}
|