ssovee-os-web-ui 0.1.91 → 0.1.92

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.
package/dist/index.cjs CHANGED
@@ -2453,7 +2453,17 @@ function PluginPlayground({
2453
2453
  );
2454
2454
  }
2455
2455
  var SIDEBAR_WIDTH = 200;
2456
- var TOP_BAR_HEIGHT = 37;
2456
+ var initialState = {
2457
+ position: { x: 0, y: 40 },
2458
+ isDragging: false,
2459
+ startPosition: { x: 0, y: 40 },
2460
+ isMinimized: false,
2461
+ isMaximized: false,
2462
+ windowSize: { width: 600, height: 300 },
2463
+ resizeStart: null,
2464
+ defaultSize: { width: 600, height: 300 },
2465
+ preMaximizeState: null
2466
+ };
2457
2467
  var reducer = (state, action) => {
2458
2468
  switch (action.type) {
2459
2469
  case "START_DRAG":
@@ -2463,7 +2473,10 @@ var reducer = (state, action) => {
2463
2473
  case "STOP_DRAG":
2464
2474
  return { ...state, isDragging: false };
2465
2475
  case "START_RESIZE":
2466
- return { ...state, resizeStart: action.payload };
2476
+ return {
2477
+ ...state,
2478
+ resizeStart: action.payload
2479
+ };
2467
2480
  case "RESIZE":
2468
2481
  return { ...state, windowSize: action.payload };
2469
2482
  case "STOP_RESIZE":
@@ -2489,7 +2502,7 @@ var reducer = (state, action) => {
2489
2502
  ...state,
2490
2503
  isMaximized: false,
2491
2504
  windowSize: state.preMaximizeState?.windowSize || state.defaultSize,
2492
- position: state.preMaximizeState?.position || { x: 0, y: TOP_BAR_HEIGHT },
2505
+ position: state.preMaximizeState?.position || { x: 0, y: 40 },
2493
2506
  preMaximizeState: null
2494
2507
  };
2495
2508
  }
@@ -2501,28 +2514,11 @@ var reducer = (state, action) => {
2501
2514
  windowSize: state.windowSize
2502
2515
  },
2503
2516
  windowSize: action.payload || {
2504
- width: typeof window !== "undefined" ? window.innerWidth : 600,
2505
- height: typeof window !== "undefined" ? window.innerHeight - TOP_BAR_HEIGHT : 300
2517
+ width: window.innerWidth,
2518
+ height: window.innerHeight
2506
2519
  },
2507
- position: { x: 0, y: TOP_BAR_HEIGHT }
2520
+ position: { x: 0, y: 40 }
2508
2521
  };
2509
- case "CLAMP_BOUNDS": {
2510
- const clampedWidth = Math.min(state.windowSize.width, action.payload.maxW);
2511
- const clampedHeight = Math.min(state.windowSize.height, action.payload.maxH);
2512
- const clampedX = Math.max(
2513
- 0,
2514
- Math.min(state.position.x, action.payload.maxW - clampedWidth)
2515
- );
2516
- const clampedY = Math.max(
2517
- TOP_BAR_HEIGHT,
2518
- Math.min(state.position.y, action.payload.maxH - clampedHeight)
2519
- );
2520
- return {
2521
- ...state,
2522
- windowSize: state.isMaximized ? { width: action.payload.maxW, height: action.payload.maxH } : { width: clampedWidth, height: clampedHeight },
2523
- position: state.isMaximized ? { x: 0, y: TOP_BAR_HEIGHT } : { x: clampedX, y: clampedY }
2524
- };
2525
- }
2526
2522
  default:
2527
2523
  return state;
2528
2524
  }
@@ -2541,40 +2537,12 @@ var WindowWithSideMenu = ({
2541
2537
  removeShortcutListener,
2542
2538
  getShortcutByCommand
2543
2539
  } = useShortcutFormatter_default({ globalKeyboardShortcuts });
2544
- const getInitialDimensions = React23.useCallback(() => {
2545
- const rawSize = app.windowSize.windowSize ?? defaultSize;
2546
- if (typeof window === "undefined") return rawSize;
2547
- return {
2548
- width: Math.min(rawSize.width, window.innerWidth),
2549
- height: Math.min(rawSize.height, window.innerHeight - TOP_BAR_HEIGHT)
2550
- };
2551
- }, [app.windowSize.windowSize, defaultSize]);
2552
- const initialDimensions = getInitialDimensions();
2553
2540
  const [state, dispatch] = React23.useReducer(reducer, {
2554
- position: { x: 0, y: TOP_BAR_HEIGHT },
2555
- isDragging: false,
2556
- startPosition: { x: 0, y: TOP_BAR_HEIGHT },
2557
- isMinimized: false,
2558
- isMaximized: false,
2559
- windowSize: initialDimensions,
2560
- resizeStart: null,
2561
- defaultSize: initialDimensions,
2562
- preMaximizeState: null
2541
+ ...initialState,
2542
+ windowSize: app.windowSize.windowSize ?? defaultSize,
2543
+ defaultSize: app.windowSize.windowSize ?? defaultSize
2563
2544
  });
2564
2545
  const windowRef = React23.useRef(null);
2565
- React23.useEffect(() => {
2566
- const handleViewportResize = () => {
2567
- dispatch({
2568
- type: "CLAMP_BOUNDS",
2569
- payload: {
2570
- maxW: window.innerWidth,
2571
- maxH: window.innerHeight - TOP_BAR_HEIGHT
2572
- }
2573
- });
2574
- };
2575
- window.addEventListener("resize", handleViewportResize);
2576
- return () => window.removeEventListener("resize", handleViewportResize);
2577
- }, []);
2578
2546
  React23.useEffect(() => {
2579
2547
  if (app.isMinimize !== state.isMinimized) {
2580
2548
  dispatch({ type: "SYNC_MINIMIZE_STATE", payload: app.isMinimize });
@@ -2590,66 +2558,48 @@ var WindowWithSideMenu = ({
2590
2558
  }
2591
2559
  });
2592
2560
  };
2593
- const handleMouseMove = React23.useCallback(
2594
- (e) => {
2595
- if (state.isDragging) {
2596
- const newX = e.clientX - state.startPosition.x;
2597
- const newY = e.clientY - state.startPosition.y;
2598
- const boundedX = Math.max(
2599
- 0,
2600
- Math.min(newX, window.innerWidth - state.windowSize.width)
2601
- );
2602
- const boundedY = Math.max(
2603
- TOP_BAR_HEIGHT,
2604
- Math.min(newY, window.innerHeight - state.windowSize.height)
2605
- );
2606
- dispatch({ type: "DRAG", payload: { x: boundedX, y: boundedY } });
2607
- }
2608
- if (state.resizeStart && isResizable && app.windowSize.isAppWindowResizing) {
2609
- const effectiveMinWidth = Math.min(
2610
- Math.max(defaultSize.width, state.defaultSize.width),
2611
- window.innerWidth
2612
- );
2613
- const effectiveMinHeight = Math.min(
2614
- Math.max(defaultSize.height, state.defaultSize.height),
2615
- window.innerHeight - TOP_BAR_HEIGHT
2616
- );
2617
- let newWidth = state.windowSize.width + (e.clientX - state.resizeStart.x);
2618
- let newHeight = state.windowSize.height + (e.clientY - state.resizeStart.y);
2619
- newWidth = Math.max(effectiveMinWidth, newWidth);
2620
- newHeight = Math.max(effectiveMinHeight, newHeight);
2621
- const maxWidth = window.innerWidth - state.position.x;
2622
- const maxHeight = window.innerHeight - state.position.y;
2623
- newWidth = Math.min(newWidth, maxWidth);
2624
- newHeight = Math.min(newHeight, maxHeight);
2625
- dispatch({
2626
- type: "RESIZE",
2627
- payload: {
2628
- width: newWidth,
2629
- height: newHeight
2630
- }
2631
- });
2632
- }
2633
- },
2634
- [
2635
- state.isDragging,
2636
- state.resizeStart,
2637
- state.startPosition,
2638
- state.windowSize,
2639
- state.position,
2640
- state.defaultSize,
2641
- defaultSize.width,
2642
- defaultSize.height,
2643
- isResizable,
2644
- app.windowSize.isAppWindowResizing
2645
- ]
2646
- );
2647
- const handleMouseUp = React23.useCallback(() => {
2561
+ const handleMouseMove = (e) => {
2562
+ if (state.isDragging) {
2563
+ const newX = e.clientX - state.startPosition.x;
2564
+ const newY = e.clientY - state.startPosition.y;
2565
+ const boundedX = Math.max(
2566
+ 0,
2567
+ Math.min(newX, window.innerWidth - state.windowSize.width)
2568
+ );
2569
+ const boundedY = Math.max(
2570
+ 0,
2571
+ Math.min(newY, window.innerHeight - state.windowSize.height)
2572
+ );
2573
+ dispatch({ type: "DRAG", payload: { x: boundedX, y: boundedY } });
2574
+ }
2575
+ if (state.resizeStart && isResizable && app.windowSize.isAppWindowResizing) {
2576
+ let newWidth = state.windowSize.width + (e.clientX - (state.resizeStart?.x ?? 0));
2577
+ let newHeight = state.windowSize.height + (e.clientY - (state.resizeStart?.y ?? 0));
2578
+ newWidth = Math.max(defaultSize.width, newWidth, state.defaultSize.width);
2579
+ newHeight = Math.max(
2580
+ defaultSize.height,
2581
+ newHeight,
2582
+ state.defaultSize.height
2583
+ );
2584
+ const maxWidth = window.innerWidth - state.position.x;
2585
+ const maxHeight = window.innerHeight - state.position.y;
2586
+ newWidth = Math.min(newWidth, maxWidth);
2587
+ newHeight = Math.min(newHeight, maxHeight);
2588
+ dispatch({
2589
+ type: "RESIZE",
2590
+ payload: {
2591
+ width: newWidth,
2592
+ height: newHeight
2593
+ }
2594
+ });
2595
+ }
2596
+ };
2597
+ const handleMouseUp = () => {
2648
2598
  if (state.isDragging) dispatch({ type: "STOP_DRAG" });
2649
2599
  if (state.resizeStart) dispatch({ type: "STOP_RESIZE" });
2650
- }, [state.isDragging, state.resizeStart]);
2600
+ };
2651
2601
  const handleResizeStart = (e) => {
2652
- if (!isResizable || !app.windowSize.isAppWindowResizing) return;
2602
+ if (!isResizable && !app.windowSize.isAppWindowResizing) return;
2653
2603
  e.stopPropagation();
2654
2604
  document.body.style.userSelect = "none";
2655
2605
  dispatch({ type: "START_RESIZE", payload: { x: e.clientX, y: e.clientY } });
@@ -2664,34 +2614,27 @@ var WindowWithSideMenu = ({
2664
2614
  window.removeEventListener("mouseup", handleMouseUp);
2665
2615
  document.body.style.userSelect = "";
2666
2616
  };
2667
- }, [state.isDragging, state.resizeStart, handleMouseMove, handleMouseUp]);
2617
+ }, [state.isDragging, state.resizeStart]);
2668
2618
  React23.useEffect(() => {
2669
- const currentRef = windowRef.current;
2670
- const handleActive = () => {
2671
- if (app?.callback) {
2672
- app.callback("CLICKED");
2673
- }
2674
- };
2675
- if (currentRef) {
2676
- currentRef.addEventListener("click", handleActive);
2619
+ if (windowRef.current) {
2620
+ windowRef.current.addEventListener("click", () => {
2621
+ if (app?.callback) {
2622
+ app?.callback("CLICKED");
2623
+ }
2624
+ });
2677
2625
  }
2678
- return () => {
2679
- if (currentRef) {
2680
- currentRef.removeEventListener("click", handleActive);
2681
- }
2682
- };
2683
- }, [app?.slug, app]);
2626
+ }, [app?.slug, windowRef]);
2684
2627
  React23.useEffect(() => {
2685
2628
  const handleExitApp = () => {
2686
2629
  if (app?.callback) {
2687
- app.callback("CLOSE_APP");
2630
+ app?.callback("CLOSE_APP");
2688
2631
  }
2689
2632
  };
2690
2633
  addShortcutListener("exit_app", handleExitApp);
2691
2634
  return () => {
2692
2635
  removeShortcutListener("exit_app", handleExitApp);
2693
2636
  };
2694
- }, [app?.slug, app.isActive, app, addShortcutListener, removeShortcutListener]);
2637
+ }, [app?.slug, app.isActive]);
2695
2638
  React23.useEffect(() => {
2696
2639
  const handleMinimize = () => {
2697
2640
  if (app?.slug && app.isActive) {
@@ -2700,7 +2643,7 @@ var WindowWithSideMenu = ({
2700
2643
  payload: state.windowSize
2701
2644
  });
2702
2645
  if (app?.callback) {
2703
- app.callback("MINIMIZE_APP");
2646
+ app?.callback("MINIMIZE_APP");
2704
2647
  }
2705
2648
  }
2706
2649
  };
@@ -2708,7 +2651,7 @@ var WindowWithSideMenu = ({
2708
2651
  return () => {
2709
2652
  removeShortcutListener("minimize_app", handleMinimize);
2710
2653
  };
2711
- }, [app?.slug, app.isActive, state.isMinimized, state.windowSize, app, addShortcutListener, removeShortcutListener]);
2654
+ }, [app?.slug, app.isActive, state.isMinimized, state.windowSize]);
2712
2655
  React23.useEffect(() => {
2713
2656
  const handleMaximize = () => {
2714
2657
  if (app?.slug && app.isActive) {
@@ -2716,7 +2659,7 @@ var WindowWithSideMenu = ({
2716
2659
  type: "TOGGLE_MAXIMIZE",
2717
2660
  payload: {
2718
2661
  width: window.innerWidth,
2719
- height: window.innerHeight - TOP_BAR_HEIGHT
2662
+ height: window.innerHeight - 37
2720
2663
  }
2721
2664
  });
2722
2665
  }
@@ -2725,7 +2668,7 @@ var WindowWithSideMenu = ({
2725
2668
  return () => {
2726
2669
  removeShortcutListener("maximize_app", handleMaximize);
2727
2670
  };
2728
- }, [app?.slug, app.isActive, addShortcutListener, removeShortcutListener]);
2671
+ }, [app?.slug, app.isActive]);
2729
2672
  if (state.isMinimized) {
2730
2673
  return null;
2731
2674
  }
@@ -2733,31 +2676,33 @@ var WindowWithSideMenu = ({
2733
2676
  "div",
2734
2677
  {
2735
2678
  ref: windowRef,
2736
- className: "flex rounded-[10px] overflow-hidden window-drop-shadow",
2679
+ className: "flex rounded-[10px] overflow-hidden window-drop-shadow ",
2737
2680
  style: {
2738
- width: state.isMaximized ? "100vw" : `${state.windowSize.width}px`,
2739
- height: state.isMaximized ? `calc(100vh - ${TOP_BAR_HEIGHT}px)` : `${state.windowSize.height}px`,
2740
- transform: state.isMaximized ? void 0 : `translate(${state.position.x}px, ${state.position.y - TOP_BAR_HEIGHT}px)`,
2681
+ width: `${state.windowSize.width}px`,
2682
+ height: `${state.windowSize.height}px`,
2683
+ transform: state.isMaximized ? void 0 : `translate(${state.position.x}px, ${state.position.y - 37}px)`,
2684
+ overflow: state.isMinimized ? "hidden" : "auto",
2741
2685
  position: "absolute",
2742
- minWidth: state.isMaximized ? "100vw" : `min(${state.defaultSize.width}px, 100vw)`,
2743
- minHeight: state.isMaximized ? `calc(100vh - ${TOP_BAR_HEIGHT}px)` : `min(${state.defaultSize.height}px, 100vh)`,
2686
+ minWidth: `${state.defaultSize.width}px`,
2687
+ minHeight: `${state.defaultSize.height}px`,
2744
2688
  zIndex: state.isDragging ? 3 : app?.isActive ? 2 : 1
2745
2689
  },
2746
2690
  children: [
2747
2691
  /* @__PURE__ */ jsxRuntime.jsxs(
2748
2692
  "div",
2749
2693
  {
2750
- className: "bg-primary flex flex-col shrink-0 overflow-y-auto",
2694
+ className: "bg-primary flex flex-col",
2751
2695
  style: {
2752
2696
  width: `${SIDEBAR_WIDTH}px`,
2753
2697
  minWidth: `${SIDEBAR_WIDTH}px`,
2754
- maxWidth: `${SIDEBAR_WIDTH}px`
2698
+ maxWidth: `${SIDEBAR_WIDTH}px`,
2699
+ flexShrink: 0
2755
2700
  },
2756
2701
  children: [
2757
2702
  /* @__PURE__ */ jsxRuntime.jsxs(
2758
2703
  "div",
2759
2704
  {
2760
- className: "flex items-center gap-[8px] pl-[20px] pt-[20px] select-none",
2705
+ className: "flex items-center gap-[8px] pl-[20px] pt-[20px]",
2761
2706
  onMouseDown: handleMouseDown,
2762
2707
  style: { cursor: state.isMaximized ? "default" : "move" },
2763
2708
  children: [
@@ -2767,7 +2712,7 @@ var WindowWithSideMenu = ({
2767
2712
  className: "w-[12px] h-[12px] bg-[#FF6157] rounded-full",
2768
2713
  onClick: () => {
2769
2714
  if (app?.callback) {
2770
- app.callback("CLOSE_APP");
2715
+ app?.callback("CLOSE_APP");
2771
2716
  }
2772
2717
  },
2773
2718
  title: `Close ${formatKeys(getShortcutByCommand("exit_app"))}`,
@@ -2785,7 +2730,7 @@ var WindowWithSideMenu = ({
2785
2730
  payload: state.windowSize
2786
2731
  });
2787
2732
  if (app?.callback) {
2788
- app.callback("MINIMIZE_APP");
2733
+ app?.callback("MINIMIZE_APP");
2789
2734
  }
2790
2735
  },
2791
2736
  title: state.isMinimized ? "Restore" : `Minimize ${formatKeys(getShortcutByCommand("minimize_app"))}`,
@@ -2802,7 +2747,7 @@ var WindowWithSideMenu = ({
2802
2747
  type: "TOGGLE_MAXIMIZE",
2803
2748
  payload: {
2804
2749
  width: window.innerWidth,
2805
- height: window.innerHeight - TOP_BAR_HEIGHT
2750
+ height: window.innerHeight - 37
2806
2751
  }
2807
2752
  });
2808
2753
  },
@@ -2829,14 +2774,14 @@ var WindowWithSideMenu = ({
2829
2774
  ]
2830
2775
  }
2831
2776
  ) }),
2832
- menu && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-[15px] flex flex-col text-[13px]", children: menu.items.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs(
2777
+ menu && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-[15px] flex flex-col text-[13px]", children: menu?.items.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs(
2833
2778
  "button",
2834
2779
  {
2835
- className: `${item.isActive ? "bg-brand-color text-white" : "text-neutral-500"} px-[10px] mx-2 flex items-center gap-[8px] rounded-[6px] h-[30px] cursor-pointer transition-all duration-200`,
2780
+ className: `${item.isActive ? "bg-brand-color text-white" : "text-neutral-500"} px-[10px] mx-2 flex items-center gap-[8px] rounded-[6px] h-[30px] text-neutral-400 cursor-pointer transition-all duration-200`,
2836
2781
  onClick: item.onClick,
2837
2782
  children: [
2838
2783
  item.icon,
2839
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: item.title })
2784
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "", children: item.title })
2840
2785
  ]
2841
2786
  },
2842
2787
  index
@@ -2847,36 +2792,50 @@ var WindowWithSideMenu = ({
2847
2792
  /* @__PURE__ */ jsxRuntime.jsxs(
2848
2793
  "div",
2849
2794
  {
2850
- className: "flex-1 bg-secondary flex flex-col min-w-0 h-full overflow-hidden",
2795
+ className: "flex-1 bg-secondary flex flex-col",
2851
2796
  style: {
2797
+ minWidth: 0,
2852
2798
  width: `calc(100% - ${SIDEBAR_WIDTH}px)`
2853
2799
  },
2854
2800
  children: [
2855
2801
  /* @__PURE__ */ jsxRuntime.jsxs(
2856
2802
  "div",
2857
2803
  {
2858
- className: "h-[50px] py-2 flex flex-col border-b border-b-surface-1 border-b-[0.5px] justify-center text-[13px] px-[12px] select-none shrink-0",
2804
+ className: "h-min-[50px] py-2 flex flex-col border-b border-b-surface-1 border-b-[0.5px] justify-center text-[13px] mx-[12px] select-none",
2859
2805
  onMouseDown: handleMouseDown,
2860
2806
  style: {
2807
+ userSelect: "none",
2808
+ WebkitUserSelect: "none",
2809
+ MozUserSelect: "none",
2810
+ msUserSelect: "none",
2861
2811
  cursor: state.isMaximized ? "default" : "move"
2862
2812
  },
2863
2813
  children: [
2864
- /* @__PURE__ */ jsxRuntime.jsx(Typography_default, { variant: "p", className: "font-medium text-neutral-500 truncate", children: app?.name }),
2865
- /* @__PURE__ */ jsxRuntime.jsx(Typography_default, { variant: "p", className: "text-neutral-400 text-[11px] truncate", children: menu?.items.find((item) => item.isActive)?.title })
2814
+ /* @__PURE__ */ jsxRuntime.jsx(Typography_default, { variant: "p", className: "font-medium text-neutral-500 ", children: app?.name }),
2815
+ /* @__PURE__ */ jsxRuntime.jsx(Typography_default, { variant: "p", className: "text-neutral-400 text-[11px]", children: menu?.items.find((item) => item.isActive)?.title })
2866
2816
  ]
2867
2817
  }
2868
2818
  ),
2869
- !state.isMinimized && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 w-full overflow-y-auto min-h-0", children: React23.isValidElement(children) && typeof children.type !== "string" ? React23__namespace.default.cloneElement(children, {
2870
- windowSize: state.windowSize,
2871
- isAppWindowResizing: state.resizeStart !== null
2872
- }) : children })
2819
+ !state.isMinimized && /* @__PURE__ */ jsxRuntime.jsx(
2820
+ "div",
2821
+ {
2822
+ className: "h-full w-full overflow-y-auto",
2823
+ style: {
2824
+ maxHeight: `${state.windowSize.height - 37}px`
2825
+ },
2826
+ children: React23.isValidElement(children) && typeof children.type !== "string" ? React23__namespace.default.cloneElement(children, {
2827
+ windowSize: state.windowSize,
2828
+ isAppWindowResizing: state.resizeStart !== null
2829
+ }) : children
2830
+ }
2831
+ )
2873
2832
  ]
2874
2833
  }
2875
2834
  ),
2876
2835
  isResizable && !state.isMaximized && /* @__PURE__ */ jsxRuntime.jsx(
2877
2836
  "div",
2878
2837
  {
2879
- className: "absolute bottom-0 right-0 w-5 h-5 cursor-se-resize z-10",
2838
+ className: "absolute bottom-0 right-0 w-5 h-5 cursor-se-resize",
2880
2839
  style: {
2881
2840
  borderBottomRightRadius: "10px"
2882
2841
  },
@@ -2888,7 +2847,17 @@ var WindowWithSideMenu = ({
2888
2847
  );
2889
2848
  };
2890
2849
  var WindowWithSideMenu_default = WindowWithSideMenu;
2891
- var TOP_BAR_HEIGHT2 = 37;
2850
+ var initialState2 = {
2851
+ position: { x: 0, y: 40 },
2852
+ isDragging: false,
2853
+ startPosition: { x: 0, y: 40 },
2854
+ isMinimized: false,
2855
+ isMaximized: false,
2856
+ windowSize: { width: 300, height: 300 },
2857
+ resizeStart: null,
2858
+ defaultSize: { width: 300, height: 300 },
2859
+ preMaximizeState: null
2860
+ };
2892
2861
  var reducer2 = (state, action) => {
2893
2862
  switch (action.type) {
2894
2863
  case "START_DRAG":
@@ -2898,7 +2867,10 @@ var reducer2 = (state, action) => {
2898
2867
  case "STOP_DRAG":
2899
2868
  return { ...state, isDragging: false };
2900
2869
  case "START_RESIZE":
2901
- return { ...state, resizeStart: action.payload };
2870
+ return {
2871
+ ...state,
2872
+ resizeStart: action.payload
2873
+ };
2902
2874
  case "RESIZE":
2903
2875
  return { ...state, windowSize: action.payload };
2904
2876
  case "STOP_RESIZE":
@@ -2924,10 +2896,7 @@ var reducer2 = (state, action) => {
2924
2896
  ...state,
2925
2897
  isMaximized: false,
2926
2898
  windowSize: state.preMaximizeState?.windowSize || state.defaultSize,
2927
- position: state.preMaximizeState?.position || {
2928
- x: 0,
2929
- y: TOP_BAR_HEIGHT2
2930
- },
2899
+ position: state.preMaximizeState?.position || { x: 0, y: 40 },
2931
2900
  preMaximizeState: null
2932
2901
  };
2933
2902
  }
@@ -2939,34 +2908,11 @@ var reducer2 = (state, action) => {
2939
2908
  windowSize: state.windowSize
2940
2909
  },
2941
2910
  windowSize: action.payload || {
2942
- width: typeof window !== "undefined" ? window.innerWidth : 300,
2943
- height: typeof window !== "undefined" ? window.innerHeight - TOP_BAR_HEIGHT2 : 300
2911
+ width: window.innerWidth,
2912
+ height: window.innerHeight
2944
2913
  },
2945
- position: { x: 0, y: TOP_BAR_HEIGHT2 }
2914
+ position: state.position
2946
2915
  };
2947
- case "CLAMP_BOUNDS": {
2948
- const clampedWidth = Math.min(
2949
- state.windowSize.width,
2950
- action.payload.maxW
2951
- );
2952
- const clampedHeight = Math.min(
2953
- state.windowSize.height,
2954
- action.payload.maxH
2955
- );
2956
- const clampedX = Math.max(
2957
- 0,
2958
- Math.min(state.position.x, action.payload.maxW - clampedWidth)
2959
- );
2960
- const clampedY = Math.max(
2961
- TOP_BAR_HEIGHT2,
2962
- Math.min(state.position.y, action.payload.maxH - clampedHeight)
2963
- );
2964
- return {
2965
- ...state,
2966
- windowSize: state.isMaximized ? { width: action.payload.maxW, height: action.payload.maxH } : { width: clampedWidth, height: clampedHeight },
2967
- position: state.isMaximized ? { x: 0, y: TOP_BAR_HEIGHT2 } : { x: clampedX, y: clampedY }
2968
- };
2969
- }
2970
2916
  default:
2971
2917
  return state;
2972
2918
  }
@@ -2983,40 +2929,12 @@ var WindowWithoutSideMenu = ({
2983
2929
  removeShortcutListener,
2984
2930
  getShortcutByCommand
2985
2931
  } = useShortcutFormatter_default({ globalKeyboardShortcuts });
2986
- const getInitialDimensions = React23.useCallback(() => {
2987
- const rawSize = app.windowSize.windowSize ?? defaultSize;
2988
- if (typeof window === "undefined") return rawSize;
2989
- return {
2990
- width: Math.min(rawSize.width, window.innerWidth),
2991
- height: Math.min(rawSize.height, window.innerHeight - TOP_BAR_HEIGHT2)
2992
- };
2993
- }, [app.windowSize.windowSize, defaultSize]);
2994
- const initialDimensions = getInitialDimensions();
2995
2932
  const [state, dispatch] = React23.useReducer(reducer2, {
2996
- position: { x: 0, y: TOP_BAR_HEIGHT2 },
2997
- isDragging: false,
2998
- startPosition: { x: 0, y: TOP_BAR_HEIGHT2 },
2999
- isMinimized: false,
3000
- isMaximized: false,
3001
- windowSize: initialDimensions,
3002
- resizeStart: null,
3003
- defaultSize: initialDimensions,
3004
- preMaximizeState: null
2933
+ ...initialState2,
2934
+ windowSize: app.windowSize.windowSize ?? defaultSize,
2935
+ defaultSize: app.windowSize.windowSize ?? defaultSize
3005
2936
  });
3006
2937
  const windowRef = React23.useRef(null);
3007
- React23.useEffect(() => {
3008
- const handleViewportResize = () => {
3009
- dispatch({
3010
- type: "CLAMP_BOUNDS",
3011
- payload: {
3012
- maxW: window.innerWidth,
3013
- maxH: window.innerHeight - TOP_BAR_HEIGHT2
3014
- }
3015
- });
3016
- };
3017
- window.addEventListener("resize", handleViewportResize);
3018
- return () => window.removeEventListener("resize", handleViewportResize);
3019
- }, []);
3020
2938
  React23.useEffect(() => {
3021
2939
  if (app.isMinimize !== state.isMinimized) {
3022
2940
  dispatch({ type: "SYNC_MINIMIZE_STATE", payload: app.isMinimize });
@@ -3032,64 +2950,44 @@ var WindowWithoutSideMenu = ({
3032
2950
  }
3033
2951
  });
3034
2952
  };
3035
- const handleMouseMove = React23.useCallback(
3036
- (e) => {
3037
- if (state.isDragging) {
3038
- const newX = e.clientX - state.startPosition.x;
3039
- const newY = e.clientY - state.startPosition.y;
3040
- const boundedX = Math.max(
3041
- 0,
3042
- Math.min(newX, window.innerWidth - state.windowSize.width)
3043
- );
3044
- const boundedY = Math.max(
3045
- TOP_BAR_HEIGHT2,
3046
- Math.min(newY, window.innerHeight - state.windowSize.height)
3047
- );
3048
- dispatch({ type: "DRAG", payload: { x: boundedX, y: boundedY } });
3049
- }
3050
- if (state.resizeStart && isResizable && app.windowSize.isAppWindowResizing) {
3051
- const effectiveMinWidth = Math.min(
3052
- state.defaultSize.width,
3053
- window.innerWidth
3054
- );
3055
- const effectiveMinHeight = Math.min(
3056
- state.defaultSize.height,
3057
- window.innerHeight - TOP_BAR_HEIGHT2
3058
- );
3059
- let newWidth = state.windowSize.width + (e.clientX - state.resizeStart.x);
3060
- let newHeight = state.windowSize.height + (e.clientY - state.resizeStart.y);
3061
- newWidth = Math.max(effectiveMinWidth, newWidth);
3062
- newHeight = Math.max(effectiveMinHeight, newHeight);
3063
- const maxWidth = window.innerWidth - state.position.x;
3064
- const maxHeight = window.innerHeight - state.position.y;
3065
- newWidth = Math.min(newWidth, maxWidth);
3066
- newHeight = Math.min(newHeight, maxHeight);
3067
- dispatch({
3068
- type: "RESIZE",
3069
- payload: {
3070
- width: newWidth,
3071
- height: newHeight
3072
- }
3073
- });
3074
- }
3075
- },
3076
- [
3077
- state.isDragging,
3078
- state.resizeStart,
3079
- state.startPosition,
3080
- state.windowSize,
3081
- state.position,
3082
- state.defaultSize,
3083
- isResizable,
3084
- app.windowSize.isAppWindowResizing
3085
- ]
3086
- );
3087
- const handleMouseUp = React23.useCallback(() => {
2953
+ const handleMouseMove = (e) => {
2954
+ if (state.isDragging) {
2955
+ const newX = e.clientX - state.startPosition.x;
2956
+ const newY = e.clientY - state.startPosition.y;
2957
+ const boundedX = Math.max(
2958
+ 0,
2959
+ Math.min(newX, window.innerWidth - state.windowSize.width)
2960
+ );
2961
+ const boundedY = Math.max(
2962
+ 0,
2963
+ Math.min(newY, window.innerHeight - state.windowSize.height)
2964
+ );
2965
+ dispatch({ type: "DRAG", payload: { x: boundedX, y: boundedY } });
2966
+ }
2967
+ if (state.resizeStart && isResizable && app.windowSize.isAppWindowResizing) {
2968
+ let newWidth = state.windowSize.width + (e.clientX - (state.resizeStart?.x ?? 0));
2969
+ let newHeight = state.windowSize.height + (e.clientY - (state.resizeStart?.y ?? 0));
2970
+ newWidth = Math.max(state.defaultSize.width, newWidth);
2971
+ newHeight = Math.max(state.defaultSize.height, newHeight);
2972
+ const maxWidth = window.innerWidth - state.position.x;
2973
+ const maxHeight = window.innerHeight - state.position.y;
2974
+ newWidth = Math.min(newWidth, maxWidth);
2975
+ newHeight = Math.min(newHeight, maxHeight);
2976
+ dispatch({
2977
+ type: "RESIZE",
2978
+ payload: {
2979
+ width: newWidth,
2980
+ height: newHeight
2981
+ }
2982
+ });
2983
+ }
2984
+ };
2985
+ const handleMouseUp = () => {
3088
2986
  if (state.isDragging) dispatch({ type: "STOP_DRAG" });
3089
2987
  if (state.resizeStart) dispatch({ type: "STOP_RESIZE" });
3090
- }, [state.isDragging, state.resizeStart]);
2988
+ };
3091
2989
  const handleResizeStart = (e) => {
3092
- if (!isResizable || !app.windowSize.isAppWindowResizing) return;
2990
+ if (!isResizable && !app.windowSize.isAppWindowResizing) return;
3093
2991
  e.stopPropagation();
3094
2992
  document.body.style.userSelect = "none";
3095
2993
  dispatch({ type: "START_RESIZE", payload: { x: e.clientX, y: e.clientY } });
@@ -3104,40 +3002,27 @@ var WindowWithoutSideMenu = ({
3104
3002
  window.removeEventListener("mouseup", handleMouseUp);
3105
3003
  document.body.style.userSelect = "";
3106
3004
  };
3107
- }, [state.isDragging, state.resizeStart, handleMouseMove, handleMouseUp]);
3005
+ }, [state.isDragging, state.resizeStart]);
3108
3006
  React23.useEffect(() => {
3109
- const currentRef = windowRef.current;
3110
- const handleActive = () => {
3111
- if (app?.callback) {
3112
- app.callback("CLICKED");
3113
- }
3114
- };
3115
- if (currentRef) {
3116
- currentRef.addEventListener("click", handleActive);
3007
+ if (windowRef.current) {
3008
+ windowRef.current.addEventListener("click", () => {
3009
+ if (app?.callback) {
3010
+ app?.callback("CLICKED");
3011
+ }
3012
+ });
3117
3013
  }
3118
- return () => {
3119
- if (currentRef) {
3120
- currentRef.removeEventListener("click", handleActive);
3121
- }
3122
- };
3123
- }, [app?.slug, app]);
3014
+ }, [app?.slug, windowRef]);
3124
3015
  React23.useEffect(() => {
3125
3016
  const handleExitApp = () => {
3126
3017
  if (app?.callback) {
3127
- app.callback("CLOSE_APP");
3018
+ app?.callback("CLOSE_APP");
3128
3019
  }
3129
3020
  };
3130
3021
  addShortcutListener("exit_app", handleExitApp);
3131
3022
  return () => {
3132
3023
  removeShortcutListener("exit_app", handleExitApp);
3133
3024
  };
3134
- }, [
3135
- app?.slug,
3136
- app.isActive,
3137
- app,
3138
- addShortcutListener,
3139
- removeShortcutListener
3140
- ]);
3025
+ }, [app?.slug, app.isActive]);
3141
3026
  React23.useEffect(() => {
3142
3027
  const handleMinimize = () => {
3143
3028
  if (app?.slug && app.isActive) {
@@ -3146,7 +3031,7 @@ var WindowWithoutSideMenu = ({
3146
3031
  payload: state.windowSize
3147
3032
  });
3148
3033
  if (app?.callback) {
3149
- app.callback("MINIMIZE_APP");
3034
+ app?.callback("MINIMIZE_APP");
3150
3035
  }
3151
3036
  }
3152
3037
  };
@@ -3154,15 +3039,7 @@ var WindowWithoutSideMenu = ({
3154
3039
  return () => {
3155
3040
  removeShortcutListener("minimize_app", handleMinimize);
3156
3041
  };
3157
- }, [
3158
- app?.slug,
3159
- app.isActive,
3160
- state.isMinimized,
3161
- state.windowSize,
3162
- app,
3163
- addShortcutListener,
3164
- removeShortcutListener
3165
- ]);
3042
+ }, [app?.slug, app.isActive, state.isMinimized, state.windowSize]);
3166
3043
  React23.useEffect(() => {
3167
3044
  const handleMaximize = () => {
3168
3045
  if (app?.slug && app.isActive) {
@@ -3170,7 +3047,7 @@ var WindowWithoutSideMenu = ({
3170
3047
  type: "TOGGLE_MAXIMIZE",
3171
3048
  payload: {
3172
3049
  width: window.innerWidth,
3173
- height: window.innerHeight - TOP_BAR_HEIGHT2
3050
+ height: window.innerHeight - 37
3174
3051
  }
3175
3052
  });
3176
3053
  }
@@ -3179,7 +3056,7 @@ var WindowWithoutSideMenu = ({
3179
3056
  return () => {
3180
3057
  removeShortcutListener("maximize_app", handleMaximize);
3181
3058
  };
3182
- }, [app?.slug, app.isActive, addShortcutListener, removeShortcutListener]);
3059
+ }, [app?.slug, app.isActive]);
3183
3060
  if (state.isMinimized) {
3184
3061
  return null;
3185
3062
  }
@@ -3187,106 +3064,117 @@ var WindowWithoutSideMenu = ({
3187
3064
  "div",
3188
3065
  {
3189
3066
  ref: windowRef,
3190
- className: "window-drop-shadow rounded-[10px] flex flex-col overflow-hidden",
3067
+ className: "window-drop-shadow rounded-[10px]",
3191
3068
  style: {
3192
- width: state.isMaximized ? "100vw" : `${state.windowSize.width}px`,
3193
- height: state.isMaximized ? `calc(100vh - ${TOP_BAR_HEIGHT2}px)` : `${state.windowSize.height}px`,
3194
- transform: state.isMaximized ? void 0 : `translate(${state.position.x}px, ${state.position.y - TOP_BAR_HEIGHT2}px)`,
3069
+ width: `${state.windowSize.width}px`,
3070
+ height: `${state.windowSize.height}px`,
3071
+ transform: state.isMaximized ? void 0 : `translate(${state.position.x}px, ${state.position.y - 37}px)`,
3072
+ overflow: state.isMinimized ? "hidden" : "auto",
3195
3073
  position: "absolute",
3196
- minWidth: state.isMaximized ? "100vw" : `min(${state.defaultSize.width}px, 100vw)`,
3197
- minHeight: state.isMaximized ? `calc(100vh - ${TOP_BAR_HEIGHT2}px)` : `min(${state.defaultSize.height}px, 100vh)`,
3074
+ minWidth: `${state.defaultSize.width}px`,
3075
+ minHeight: `${state.defaultSize.height}px`,
3198
3076
  zIndex: state.isDragging ? 3 : app?.isActive ? 2 : 1
3199
3077
  },
3200
- children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col h-full w-full relative min-w-0", children: [
3201
- /* @__PURE__ */ jsxRuntime.jsxs(
3202
- "div",
3203
- {
3204
- className: "relative flex items-center bg-primary h-[35px] select-none shrink-0",
3205
- onMouseDown: handleMouseDown,
3206
- style: { cursor: state.isMaximized ? "default" : "move" },
3207
- children: [
3208
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-[8px] pl-[10px]", children: [
3209
- /* @__PURE__ */ jsxRuntime.jsx(
3210
- "button",
3211
- {
3212
- className: "w-[12px] h-[12px] bg-[#FF6157] rounded-full",
3213
- onClick: () => {
3214
- if (app?.callback) {
3215
- app.callback("CLOSE_APP");
3078
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
3079
+ "div",
3080
+ {
3081
+ className: "mx-auto overflow-hidden h-full w-full",
3082
+ style: {
3083
+ minWidth: `${state.defaultSize.width}px`,
3084
+ minHeight: `${state.defaultSize.height}px`,
3085
+ position: "relative"
3086
+ },
3087
+ children: [
3088
+ /* @__PURE__ */ jsxRuntime.jsxs(
3089
+ "div",
3090
+ {
3091
+ className: "relative flex items-center bg-primary h-[35px] select-none",
3092
+ onMouseDown: handleMouseDown,
3093
+ style: { cursor: state.isMaximized ? "default" : "move" },
3094
+ children: [
3095
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-[8px] pl-[10px]", children: [
3096
+ /* @__PURE__ */ jsxRuntime.jsx(
3097
+ "button",
3098
+ {
3099
+ className: "w-[12px] h-[12px] bg-[#FF6157] rounded-full",
3100
+ onClick: () => {
3101
+ if (app?.callback) {
3102
+ app?.callback("CLOSE_APP");
3103
+ }
3104
+ },
3105
+ title: `Close ${formatKeys(getShortcutByCommand("exit_app"))}`,
3106
+ style: { outline: "none", border: "none" }
3216
3107
  }
3217
- },
3218
- title: `Close ${formatKeys(getShortcutByCommand("exit_app"))}`,
3219
- style: { outline: "none", border: "none" },
3220
- tabIndex: -1
3221
- }
3222
- ),
3223
- /* @__PURE__ */ jsxRuntime.jsx(
3224
- "button",
3225
- {
3226
- className: "w-[12px] h-[12px] bg-[#FFC12F] rounded-full",
3227
- onClick: () => {
3228
- dispatch({
3229
- type: "TOGGLE_MINIMIZE",
3230
- payload: state.windowSize
3231
- });
3232
- if (app?.callback) {
3233
- app.callback("MINIMIZE_APP");
3108
+ ),
3109
+ /* @__PURE__ */ jsxRuntime.jsx(
3110
+ "button",
3111
+ {
3112
+ className: "w-[12px] h-[12px] bg-[#FFC12F] rounded-full",
3113
+ onClick: () => {
3114
+ dispatch({
3115
+ type: "TOGGLE_MINIMIZE",
3116
+ payload: state.windowSize
3117
+ });
3118
+ if (app?.callback) {
3119
+ app?.callback("MINIMIZE_APP");
3120
+ }
3121
+ },
3122
+ title: state.isMinimized ? "Restore" : `Minimize ${formatKeys(
3123
+ getShortcutByCommand("minimize_app")
3124
+ )}`,
3125
+ style: { outline: "none", border: "none" }
3234
3126
  }
3235
- },
3236
- title: state.isMinimized ? "Restore" : `Minimize ${formatKeys(
3237
- getShortcutByCommand("minimize_app")
3238
- )}`,
3239
- style: { outline: "none", border: "none" },
3240
- tabIndex: -1
3241
- }
3242
- ),
3243
- isResizable && app.windowSize.isAppWindowResizing && /* @__PURE__ */ jsxRuntime.jsx(
3244
- "button",
3245
- {
3246
- className: "w-[12px] h-[12px] bg-[#2ACB42] rounded-full",
3247
- onClick: () => {
3248
- dispatch({
3249
- type: "TOGGLE_MAXIMIZE",
3250
- payload: {
3251
- width: window.innerWidth,
3252
- height: window.innerHeight - TOP_BAR_HEIGHT2
3253
- }
3254
- });
3255
- },
3256
- title: state.isMaximized ? "Restore" : `Maximize ${formatKeys(
3257
- getShortcutByCommand("maximize_app")
3258
- )}`,
3259
- style: { outline: "none", border: "none" },
3260
- tabIndex: -1
3261
- }
3262
- )
3263
- ] }),
3264
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 max-w-[60%] truncate", children: /* @__PURE__ */ jsxRuntime.jsx(
3265
- Typography_default,
3266
- {
3267
- variant: "p",
3268
- className: "text-neutral-500 text-[15px] truncate",
3269
- children: app.name
3270
- }
3271
- ) })
3272
- ]
3273
- }
3274
- ),
3275
- !state.isMinimized && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 w-full bg-secondary overflow-y-auto min-h-0", children: React23.isValidElement(children) && typeof children.type !== "string" ? React23__namespace.default.cloneElement(children, {
3276
- windowSize: state.windowSize,
3277
- isAppWindowResizing: state.resizeStart !== null
3278
- }) : children }),
3279
- isResizable && !state.isMaximized && /* @__PURE__ */ jsxRuntime.jsx(
3280
- "div",
3281
- {
3282
- className: "absolute bottom-0 right-0 w-5 h-5 cursor-se-resize z-10",
3283
- style: {
3284
- borderBottomRightRadius: "10px"
3285
- },
3286
- onMouseDown: handleResizeStart
3287
- }
3288
- )
3289
- ] })
3127
+ ),
3128
+ isResizable && app.windowSize.isAppWindowResizing && /* @__PURE__ */ jsxRuntime.jsx(
3129
+ "button",
3130
+ {
3131
+ className: "w-[12px] h-[12px] bg-[#2ACB42] rounded-full",
3132
+ onClick: () => {
3133
+ dispatch({
3134
+ type: "TOGGLE_MAXIMIZE",
3135
+ payload: {
3136
+ width: window.innerWidth,
3137
+ height: window.innerHeight - 37
3138
+ }
3139
+ });
3140
+ },
3141
+ title: state.isMaximized ? "Restore" : `Maximize ${formatKeys(
3142
+ getShortcutByCommand("maximize_app")
3143
+ )}`,
3144
+ style: { outline: "none", border: "none" }
3145
+ }
3146
+ )
3147
+ ] }),
3148
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2", children: /* @__PURE__ */ jsxRuntime.jsx(Typography_default, { variant: "p", className: "text-neutral-500 text-[15px]", children: app.name }) })
3149
+ ]
3150
+ }
3151
+ ),
3152
+ !state.isMinimized && /* @__PURE__ */ jsxRuntime.jsx(
3153
+ "div",
3154
+ {
3155
+ className: "h-full w-full bg-secondary",
3156
+ style: {
3157
+ maxHeight: `${state.windowSize.height - 37}px`
3158
+ },
3159
+ children: React23.isValidElement(children) && typeof children.type !== "string" ? React23__namespace.default.cloneElement(children, {
3160
+ windowSize: state.windowSize,
3161
+ isAppWindowResizing: state.resizeStart !== null
3162
+ }) : children
3163
+ }
3164
+ ),
3165
+ isResizable && !state.isMaximized && /* @__PURE__ */ jsxRuntime.jsx(
3166
+ "div",
3167
+ {
3168
+ className: "absolute bottom-0 right-0 w-5 h-5 cursor-se-resize",
3169
+ style: {
3170
+ borderBottomRightRadius: "10px"
3171
+ },
3172
+ onMouseDown: handleResizeStart
3173
+ }
3174
+ )
3175
+ ]
3176
+ }
3177
+ )
3290
3178
  }
3291
3179
  );
3292
3180
  };