@shellui/core 0.5.0-beta.1 → 0.5.0-beta.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 (47) hide show
  1. package/package.json +2 -2
  2. package/schemas/shellui.config.schema.json +10 -2
  3. package/src/components/ContentView.tsx +12 -5
  4. package/src/components/ui/alert-dialog.tsx +1 -1
  5. package/src/components/ui/sidebar.tsx +60 -21
  6. package/src/features/admin/AdminView.tsx +31 -2
  7. package/src/features/auth/components/LoginButton.tsx +3 -3
  8. package/src/features/auth/components/LoginView.tsx +74 -28
  9. package/src/features/config/types.ts +16 -2
  10. package/src/features/layouts/AppLayout.tsx +30 -3
  11. package/src/features/layouts/OverlayShell.tsx +3 -1
  12. package/src/features/layouts/app-bar-inset/AppBarInsetLayout.tsx +22 -0
  13. package/src/features/layouts/appbar/AppBarLayout.tsx +98 -33
  14. package/src/features/layouts/chrome/CollapsedDesktopTitlebar.tsx +18 -10
  15. package/src/features/layouts/chrome/ContentDragOverlay.tsx +1 -1
  16. package/src/features/layouts/chrome/DesktopChrome.tsx +1 -1
  17. package/src/features/layouts/chrome/SafeAreaTopbar.tsx +48 -0
  18. package/src/features/layouts/chrome/constants.ts +7 -1
  19. package/src/features/layouts/chrome/index.ts +5 -0
  20. package/src/features/layouts/chrome/runtime.ts +157 -7
  21. package/src/features/layouts/floating/FloatingFadeMask.tsx +22 -0
  22. package/src/features/layouts/floating/FloatingLayout.tsx +142 -0
  23. package/src/features/layouts/floating/FloatingSidebar.tsx +327 -0
  24. package/src/features/layouts/floating/FloatingTabBar.tsx +437 -0
  25. package/src/features/layouts/floating/FloatingTabIndicator.tsx +216 -0
  26. package/src/features/layouts/floating/computeFloatingInsets.spec.ts +83 -0
  27. package/src/features/layouts/floating/computeFloatingInsets.ts +103 -0
  28. package/src/features/layouts/floating/isShellOwnedPath.spec.ts +23 -0
  29. package/src/features/layouts/floating/isShellOwnedPath.ts +16 -0
  30. package/src/features/layouts/floating/layoutChromeStore.ts +46 -0
  31. package/src/features/layouts/floating/scrollChrome.spec.ts +49 -0
  32. package/src/features/layouts/floating/useFloatingChrome.ts +216 -0
  33. package/src/features/layouts/fullscreen/FullscreenLayout.tsx +9 -4
  34. package/src/features/layouts/sidebar/SidebarInner.tsx +25 -29
  35. package/src/features/layouts/sidebar/SidebarLayout.tsx +41 -36
  36. package/src/features/layouts/sidebar/types.ts +4 -0
  37. package/src/features/layouts/sidebar-inset/SidebarInsetLayout.tsx +15 -0
  38. package/src/features/settings/SettingsProvider.tsx +7 -0
  39. package/src/features/settings/SettingsView.tsx +6 -6
  40. package/src/features/settings/components/Develop.tsx +31 -13
  41. package/src/features/settings/utils/buildSettingsForPropagation.ts +16 -0
  42. package/src/features/storage/StoragePickerContext.tsx +1 -0
  43. package/src/hooks/use-viewport.ts +40 -0
  44. package/src/i18n/translations/en/settings.json +8 -2
  45. package/src/i18n/translations/fr/settings.json +8 -2
  46. package/src/index.css +339 -15
  47. package/src/routes/components/RouteFallback.tsx +6 -2
@@ -46,17 +46,31 @@ import { useSettings } from '../../settings/hooks/useSettings';
46
46
  import { NavIcon } from '../sidebar/SidebarIcons';
47
47
  import { getExternalFaviconUrl } from '../sidebar/sidebarUtils';
48
48
  import { DesktopHistoryButtons } from '../chrome/DesktopHistoryButtons';
49
- import { useIsTauriClient, useMacOverlayChrome, useMacTrafficLights } from '../chrome/runtime';
50
- import { MAC_TRAFFIC_LIGHTS_GAP_PX, MAC_TRAFFIC_LIGHTS_WIDTH_PX } from '../chrome/constants';
49
+ import {
50
+ isShellUiRootWindow,
51
+ SafeAreaTopbarOffset,
52
+ SafeAreaTopbarStrip,
53
+ } from '../chrome/SafeAreaTopbar';
54
+ import { useIsTauriRuntime, useMacOverlayChrome, useMacTrafficLights } from '../chrome/runtime';
55
+ import {
56
+ DESKTOP_TITLEBAR_HEIGHT_PX,
57
+ DESKTOP_TITLEBAR_PAD_TOP_PX,
58
+ MAC_TRAFFIC_LIGHTS_GAP_PX,
59
+ MAC_TRAFFIC_LIGHTS_WIDTH_PX,
60
+ } from '../chrome/constants';
51
61
 
52
- /** App-bar chrome height — taller than the 38px Tauri titlebar strip for easier hit targets. */
53
- const APP_BAR_HEIGHT_PX = 52;
62
+ /** App-bar chrome height — matches the Tauri / sidebar titlebar strip. */
63
+ const APP_BAR_HEIGHT_PX = DESKTOP_TITLEBAR_HEIGHT_PX;
64
+
65
+ export type AppBarChromeVariant = 'app-bar' | 'inset';
54
66
 
55
67
  interface AppBarLayoutProps {
56
68
  title?: string;
57
69
  appIcon?: ThemeAsset;
58
70
  logo?: ThemeAsset;
59
71
  navigation: (NavigationItem | NavigationGroup)[];
72
+ /** Visual chrome: default flush app-bar, or inset padded/rounded main frame. */
73
+ variant?: AppBarChromeVariant;
60
74
  }
61
75
 
62
76
  type NavSection =
@@ -203,19 +217,19 @@ function AppBarItemIcon({ item, label }: { item: NavigationItem; label: string }
203
217
  if (iconSrc) {
204
218
  return (
205
219
  <span
206
- className="flex size-7 shrink-0 items-center justify-center rounded-md bg-muted/60"
220
+ className="flex size-5 shrink-0 items-center justify-center rounded-md bg-muted/60 p-0.5"
207
221
  aria-hidden
208
222
  >
209
223
  <NavIcon
210
224
  src={iconSrc}
211
- className="size-5"
225
+ className="size-3"
212
226
  />
213
227
  </span>
214
228
  );
215
229
  }
216
230
  return (
217
231
  <span
218
- className="flex size-7 shrink-0 items-center justify-center rounded-md bg-muted text-[11px] font-semibold leading-none text-muted-foreground"
232
+ className="flex size-5 shrink-0 items-center justify-center rounded-md bg-muted p-0.5 text-[9px] font-semibold leading-none text-muted-foreground"
219
233
  aria-hidden
220
234
  >
221
235
  {firstLetter}
@@ -225,11 +239,12 @@ function AppBarItemIcon({ item, label }: { item: NavigationItem; label: string }
225
239
 
226
240
  const navTriggerClass = (active: boolean) =>
227
241
  cn(
228
- 'inline-flex h-9 shrink-0 items-center gap-2 rounded-md px-2.5 pr-3 text-sm font-medium transition-colors',
242
+ // h-7 leaves air in the 42px chrome after the 2px top pad.
243
+ 'inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md px-2 text-xs font-medium transition-colors',
229
244
  'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',
230
245
  active
231
246
  ? 'bg-sidebar-accent text-sidebar-accent-foreground'
232
- : 'text-sidebar-foreground/85 hover:bg-sidebar-accent/50 hover:text-sidebar-foreground',
247
+ : 'text-sidebar-foreground/85 hover:bg-sidebar-accent hover:text-sidebar-foreground',
233
248
  );
234
249
 
235
250
  /** Text link / action used in the bar (not inside a dropdown). */
@@ -355,11 +370,11 @@ function AppBarNavCategory({
355
370
  type="button"
356
371
  variant="ghost"
357
372
  size="sm"
358
- className={cn(navTriggerClass(active), 'hover:bg-sidebar-accent/50')}
373
+ className={cn(navTriggerClass(active))}
359
374
  aria-expanded={open}
360
375
  >
361
376
  <span className="truncate">{label}</span>
362
- <CaretDownIcon className="size-3.5 shrink-0 opacity-70" />
377
+ <CaretDownIcon className="size-3 shrink-0 opacity-70" />
363
378
  </Button>
364
379
  </DropdownMenuTrigger>
365
380
  <DropdownMenuContent
@@ -407,12 +422,12 @@ function AppBarNavMore({
407
422
  type="button"
408
423
  variant="ghost"
409
424
  size="sm"
410
- className={cn(navTriggerClass(moreActive), 'hover:bg-sidebar-accent/50')}
425
+ className={cn(navTriggerClass(moreActive))}
411
426
  aria-label={t('desktopChrome.more')}
412
427
  aria-expanded={open}
413
428
  >
414
429
  <span>{t('desktopChrome.more')}</span>
415
- <CaretDownIcon className="size-3.5 shrink-0 opacity-70" />
430
+ <CaretDownIcon className="size-3 shrink-0 opacity-70" />
416
431
  </Button>
417
432
  </DropdownMenuTrigger>
418
433
  <DropdownMenuContent
@@ -478,12 +493,12 @@ function AppBarNavMeasureChip({
478
493
  >
479
494
  {withIcon ? (
480
495
  <span
481
- className="size-7 shrink-0"
496
+ className="size-5 shrink-0"
482
497
  aria-hidden
483
498
  />
484
499
  ) : null}
485
500
  {label}
486
- {withCaret ? <CaretDownIcon className="size-3.5 shrink-0 opacity-70" /> : null}
501
+ {withCaret ? <CaretDownIcon className="size-3 shrink-0 opacity-70" /> : null}
487
502
  </span>
488
503
  );
489
504
  }
@@ -662,11 +677,11 @@ function TopBarEndItem({
662
677
  const iconEl = iconSrc ? (
663
678
  <NavIcon
664
679
  src={iconSrc}
665
- className="size-4"
680
+ className="size-3.5"
666
681
  />
667
682
  ) : (
668
683
  <span
669
- className="flex size-5 shrink-0 items-center justify-center rounded-md bg-muted text-[10px] font-semibold text-muted-foreground"
684
+ className="flex size-4 shrink-0 items-center justify-center rounded-md bg-muted text-[9px] font-semibold text-muted-foreground"
670
685
  aria-hidden
671
686
  >
672
687
  {firstLetter}
@@ -674,10 +689,10 @@ function TopBarEndItem({
674
689
  );
675
690
 
676
691
  const buttonClass = cn(
677
- 'flex size-9 items-center justify-center rounded-md transition-colors cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',
692
+ 'flex size-7 items-center justify-center rounded-md transition-colors cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',
678
693
  isActive
679
694
  ? 'bg-sidebar-accent text-sidebar-accent-foreground'
680
- : 'text-muted-foreground hover:bg-sidebar-accent/50 hover:text-sidebar-foreground',
695
+ : 'text-muted-foreground hover:bg-sidebar-accent hover:text-sidebar-foreground',
681
696
  );
682
697
 
683
698
  const wrap = (node: ReactNode) => <AppBarTooltip label={label}>{node}</AppBarTooltip>;
@@ -730,16 +745,22 @@ function TopBarEndItem({
730
745
  );
731
746
  }
732
747
 
733
- export function AppBarLayout({ title, appIcon, navigation }: AppBarLayoutProps) {
748
+ export function AppBarLayout({
749
+ title,
750
+ appIcon,
751
+ navigation,
752
+ variant = 'app-bar',
753
+ }: AppBarLayoutProps) {
734
754
  const { i18n } = useTranslation();
735
755
  const { isAuthenticated } = useAuth();
736
756
  const { settings } = useSettings();
737
757
  const location = useLocation();
738
758
  const isMobile = useIsMobile();
739
- const isTauriEnv = useIsTauriClient();
759
+ const isTauriRuntime = useIsTauriRuntime();
740
760
  const overlay = useMacOverlayChrome();
741
761
  const trafficLights = useMacTrafficLights();
742
762
  const currentLanguage = i18n.language || 'en';
763
+ const isInset = variant === 'inset';
743
764
  const hasCustomLoginNav = useMemo(() => hasLoginNavigationItem(navigation), [navigation]);
744
765
  const authAwareNavigation = useMemo(
745
766
  () =>
@@ -787,19 +808,55 @@ export function AppBarLayout({ title, appIcon, navigation }: AppBarLayoutProps)
787
808
  : undefined;
788
809
 
789
810
  const hasStartNav = startSections.some((s) => s.items.length > 0);
811
+ // Nested shell-in-iframe must not repeat the root safe-area top band.
812
+ const showSafeAreaTopbar = isShellUiRootWindow();
813
+ // Keep in sync with <main> `md:mx-3` — bar content aligns to the inset card border.
814
+ // Extra inset from the frame edge: 20px left (brand/nav), 10px right (end links already have control padding).
815
+ const insetFramePadPx = 12;
816
+ const insetBarContentOffsetLeftPx = 20;
817
+ const insetBarContentOffsetRightPx = 10;
818
+ // md+: strip owns the inset; mobile pads the header into the status band.
819
+ const headerStyle = {
820
+ paddingLeft: isInset
821
+ ? (chromeInset ?? insetFramePadPx) + insetBarContentOffsetLeftPx
822
+ : (chromeInset ?? 12),
823
+ paddingRight: isInset ? insetFramePadPx + insetBarContentOffsetRightPx : 8,
824
+ ...(isMobile && showSafeAreaTopbar
825
+ ? {
826
+ paddingTop: `calc(var(--shellui-safe-area-top) + ${DESKTOP_TITLEBAR_PAD_TOP_PX}px)`,
827
+ height: `calc(${APP_BAR_HEIGHT_PX}px + var(--shellui-safe-area-top))`,
828
+ }
829
+ : {
830
+ height: APP_BAR_HEIGHT_PX,
831
+ paddingTop: DESKTOP_TITLEBAR_PAD_TOP_PX,
832
+ }),
833
+ } as const;
790
834
 
791
835
  return (
792
- <div className="flex h-full max-h-full flex-col overflow-hidden bg-background">
793
- {/* Header background extends into the status-bar band; controls sit below it. */}
836
+ <div
837
+ data-shellui-app-bar-layout=""
838
+ data-shellui-layout-variant={variant}
839
+ className={cn(
840
+ 'flex h-full max-h-full flex-col overflow-hidden',
841
+ isInset ? 'bg-shellui-inset-chrome' : 'bg-background',
842
+ )}
843
+ >
844
+ <SafeAreaTopbarOffset enabled={showSafeAreaTopbar} />
845
+ <SafeAreaTopbarStrip
846
+ enabled={showSafeAreaTopbar}
847
+ className={
848
+ isInset ? '[&>div]:border-transparent [&>div]:bg-shellui-inset-chrome' : undefined
849
+ }
850
+ />
794
851
  <header
795
- className="relative z-[46] flex w-full shrink-0 items-center gap-1.5 border-b border-sidebar-border bg-sidebar text-sidebar-foreground select-none"
796
- style={{
797
- paddingTop: 'var(--shellui-safe-area-top)',
798
- height: `calc(${APP_BAR_HEIGHT_PX}px + var(--shellui-safe-area-top))`,
799
- paddingLeft: chromeInset ?? 12,
800
- paddingRight: 8,
801
- }}
802
- data-layout="app-bar"
852
+ className={cn(
853
+ 'relative z-[46] flex w-full shrink-0 items-center gap-1.5 text-sidebar-foreground select-none',
854
+ isInset
855
+ ? 'border-b border-transparent bg-transparent'
856
+ : 'border-b border-sidebar-border bg-sidebar',
857
+ )}
858
+ style={headerStyle}
859
+ data-layout={isInset ? 'app-bar-inset' : 'app-bar'}
803
860
  {...(trafficLights ? { 'data-shellui-drag-region': '', 'data-tauri-drag-region': '' } : {})}
804
861
  >
805
862
  {appIcon ? (
@@ -822,7 +879,7 @@ export function AppBarLayout({ title, appIcon, navigation }: AppBarLayoutProps)
822
879
  <div className="min-w-0 flex-1" />
823
880
  )}
824
881
 
825
- {isTauriEnv ? (
882
+ {isTauriRuntime ? (
826
883
  <div
827
884
  data-shellui-no-drag=""
828
885
  className="shrink-0"
@@ -867,7 +924,15 @@ export function AppBarLayout({ title, appIcon, navigation }: AppBarLayoutProps)
867
924
  </div>
868
925
  </header>
869
926
 
870
- <main className="flex min-h-0 flex-1 flex-col overflow-hidden">
927
+ <main
928
+ className={cn(
929
+ 'flex min-h-0 flex-1 flex-col overflow-hidden',
930
+ // Desktop inset: float the content frame on the chrome tray (same as sidebar-inset).
931
+ // `md:mx-3` (12px) must match `insetFramePadPx` on the header above.
932
+ isInset &&
933
+ 'bg-background md:mx-3 md:mb-3 md:rounded-2xl md:border md:border-border md:shadow-sm',
934
+ )}
935
+ >
871
936
  <Outlet />
872
937
  </main>
873
938
  </div>
@@ -3,17 +3,20 @@ import { cn } from '../../../lib/utils';
3
3
  import { DesktopHistoryButtons } from './DesktopHistoryButtons';
4
4
  import {
5
5
  DESKTOP_TITLEBAR_HEIGHT_PX,
6
+ DESKTOP_TITLEBAR_PAD_TOP_PX,
6
7
  MAC_TRAFFIC_LIGHTS_GAP_PX,
7
8
  MAC_TRAFFIC_LIGHTS_WIDTH_PX,
8
9
  } from './constants';
9
- import { useIsTauriClient, useMacOverlayChrome } from './runtime';
10
+ import { useIsTauriClient, useMacOverlayChrome, useMacTrafficLights } from './runtime';
10
11
 
11
12
  /**
12
- * Full-width 38px chrome when the sidebar is collapsed in a Tauri overlay window.
13
+ * Full-width 42px chrome when the sidebar is collapsed in a Tauri overlay window.
13
14
  * Open-sidebar first, then Back; room for more controls later.
15
+ * Stays visible in native fullscreen (no traffic-light spacer there).
14
16
  */
15
17
  export function CollapsedDesktopTitlebar({ className }: { className?: string }) {
16
18
  const overlay = useMacOverlayChrome();
19
+ const trafficLights = useMacTrafficLights();
17
20
  const isTauriEnv = useIsTauriClient();
18
21
  const { state, isMobile } = useSidebar();
19
22
  const collapsed = state === 'collapsed' && !isMobile;
@@ -29,19 +32,24 @@ export function CollapsedDesktopTitlebar({ className }: { className?: string })
29
32
  'fixed inset-x-0 top-0 z-[47] flex w-full items-center border-b border-sidebar-border bg-sidebar text-sidebar-foreground select-none',
30
33
  className,
31
34
  )}
32
- style={{ height: DESKTOP_TITLEBAR_HEIGHT_PX }}
35
+ style={{
36
+ height: DESKTOP_TITLEBAR_HEIGHT_PX,
37
+ paddingTop: DESKTOP_TITLEBAR_PAD_TOP_PX,
38
+ }}
33
39
  >
34
- <div
35
- className="h-full shrink-0"
36
- style={{ width: MAC_TRAFFIC_LIGHTS_WIDTH_PX }}
37
- aria-hidden
38
- />
40
+ {trafficLights ? (
41
+ <div
42
+ className="h-full shrink-0"
43
+ style={{ width: MAC_TRAFFIC_LIGHTS_WIDTH_PX }}
44
+ aria-hidden
45
+ />
46
+ ) : null}
39
47
  <div
40
48
  data-shellui-no-drag=""
41
49
  className="flex h-full items-center gap-0.5"
42
- style={{ paddingLeft: MAC_TRAFFIC_LIGHTS_GAP_PX }}
50
+ style={{ paddingLeft: trafficLights ? MAC_TRAFFIC_LIGHTS_GAP_PX : 8 }}
43
51
  >
44
- <SidebarTrigger className="size-8 touch-manipulation" />
52
+ <SidebarTrigger className="size-7 touch-manipulation" />
45
53
  {isTauriEnv ? <DesktopHistoryButtons /> : null}
46
54
  </div>
47
55
  </div>
@@ -1,7 +1,7 @@
1
1
  import { DESKTOP_TITLEBAR_HEIGHT_PX } from './constants';
2
2
 
3
3
  /**
4
- * Full-width invisible 38px strip at the top of the Tauri window.
4
+ * Full-width invisible 42px strip at the top of the Tauri window.
5
5
  *
6
6
  * Uses Tauri's official `data-tauri-drag-region` (requires
7
7
  * `core:window:allow-start-dragging` in capabilities). Shell controls must sit
@@ -3,7 +3,7 @@ import { ContentDragOverlay } from './ContentDragOverlay';
3
3
  import { useIsTauriClient, useMacTrafficLights } from './runtime';
4
4
 
5
5
  /**
6
- * Global Tauri desktop chrome: document flags + the 38px top drag strip.
6
+ * Global Tauri desktop chrome: document flags + the 42px top drag strip.
7
7
  * Mounted at the app root so it stays available on every page (layouts, login,
8
8
  * settings, route error boundary, empty config) — including narrow/mobile widths.
9
9
  */
@@ -0,0 +1,48 @@
1
+ import { useEffect } from 'react';
2
+ import { cn } from '../../../lib/utils';
3
+
4
+ /** True when this window is the outermost shell (not nested in an iframe). */
5
+ export function isShellUiRootWindow(): boolean {
6
+ return typeof window !== 'undefined' && window.parent === window;
7
+ }
8
+
9
+ /**
10
+ * Root shell only: advertise the safe-area topbar on <html> so fixed chrome
11
+ * (sidebar, drawers) can clear it. Nested iframe shells skip this.
12
+ */
13
+ export function SafeAreaTopbarOffset({ enabled }: { enabled: boolean }) {
14
+ useEffect(() => {
15
+ if (!enabled) return;
16
+ const root = document.documentElement;
17
+ root.setAttribute('data-shellui-safe-area-topbar', '');
18
+ return () => root.removeAttribute('data-shellui-safe-area-topbar');
19
+ }, [enabled]);
20
+
21
+ return null;
22
+ }
23
+
24
+ /**
25
+ * Tablet / desktop band for top safe-area. Height is 0 when the inset is 0;
26
+ * overflow clips the border so no stray hairline. Hidden below md — mobile
27
+ * headers pad into the status band instead.
28
+ */
29
+ export function SafeAreaTopbarStrip({
30
+ enabled,
31
+ className,
32
+ }: {
33
+ enabled: boolean;
34
+ /** Outer strip classes (defaults match sidebar chrome). */
35
+ className?: string;
36
+ }) {
37
+ if (!enabled) return null;
38
+ return (
39
+ <div
40
+ aria-hidden
41
+ data-slot="shellui-safe-area-top"
42
+ className={cn('relative z-0 hidden shrink-0 overflow-hidden md:block', className)}
43
+ style={{ height: 'var(--shellui-safe-area-top)' }}
44
+ >
45
+ <div className="box-border h-full border-b border-sidebar-border bg-sidebar" />
46
+ </div>
47
+ );
48
+ }
@@ -1,5 +1,11 @@
1
1
  /** Height of the macOS overlay titlebar / traffic-light row. */
2
- export const DESKTOP_TITLEBAR_HEIGHT_PX = 38;
2
+ export const DESKTOP_TITLEBAR_HEIGHT_PX = 42;
3
+
4
+ /**
5
+ * Top inset inside the titlebar so web controls optically match macOS traffic lights
6
+ * (lights stay vertically centered in the full height).
7
+ */
8
+ export const DESKTOP_TITLEBAR_PAD_TOP_PX = 2;
3
9
 
4
10
  /** Width reserved for macOS traffic lights (close / minimize / zoom). */
5
11
  export const MAC_TRAFFIC_LIGHTS_WIDTH_PX = 78;
@@ -1,5 +1,6 @@
1
1
  export {
2
2
  DESKTOP_TITLEBAR_HEIGHT_PX,
3
+ DESKTOP_TITLEBAR_PAD_TOP_PX,
3
4
  IFRAME_FOREIGN_ATTR,
4
5
  MAC_TRAFFIC_LIGHTS_GAP_PX,
5
6
  MAC_TRAFFIC_LIGHTS_WIDTH_PX,
@@ -14,9 +15,12 @@ export {
14
15
  } from './goDesktopBack';
15
16
  export {
16
17
  useIsTauriClient,
18
+ useIsTauriRuntime,
19
+ useIsTauriFullscreen,
17
20
  useMacOverlayChrome,
18
21
  useMacTrafficLights,
19
22
  isMacOSDesktop,
23
+ isTauriRuntime,
20
24
  } from './runtime';
21
25
  export { DesktopBackButton } from './DesktopBackButton';
22
26
  export { DesktopForwardButton } from './DesktopForwardButton';
@@ -24,3 +28,4 @@ export { DesktopHistoryButtons } from './DesktopHistoryButtons';
24
28
  export { ContentDragOverlay } from './ContentDragOverlay';
25
29
  export { DesktopChrome } from './DesktopChrome';
26
30
  export { CollapsedDesktopTitlebar } from './CollapsedDesktopTitlebar';
31
+ export { isShellUiRootWindow, SafeAreaTopbarOffset, SafeAreaTopbarStrip } from './SafeAreaTopbar';
@@ -10,6 +10,84 @@ export function isMacOSDesktop(): boolean {
10
10
  return platform.startsWith('Mac') && !touchIpad;
11
11
  }
12
12
 
13
+ type TauriInternals = {
14
+ invoke: (cmd: string, args?: Record<string, unknown>) => Promise<unknown>;
15
+ transformCallback: (callback: (data: unknown) => void, once: boolean) => number;
16
+ unregisterCallback?: (id: number) => void;
17
+ metadata?: { currentWindow?: { label?: string } };
18
+ };
19
+
20
+ function getTauriInternals(): TauriInternals | null {
21
+ if (typeof window === 'undefined') return null;
22
+ return (window as Window & { __TAURI_INTERNALS__?: TauriInternals }).__TAURI_INTERNALS__ ?? null;
23
+ }
24
+
25
+ /**
26
+ * True only inside a real Tauri webview (`__TAURI__` / `__TAURI_INTERNALS__`).
27
+ * Unlike `isTauri()`, this ignores the CLI `--target tauri` build flag
28
+ * (`__SHELLUI_TAURI__`) so a browser tab opened against the same URL does not
29
+ * get traffic-light padding.
30
+ */
31
+ export function isTauriRuntime(): boolean {
32
+ if (typeof window === 'undefined') return false;
33
+ const w = window as Window & {
34
+ __TAURI__?: unknown;
35
+ __TAURI_INTERNALS__?: unknown;
36
+ };
37
+ return !!(w.__TAURI__ ?? w.__TAURI_INTERNALS__);
38
+ }
39
+
40
+ function currentWindowLabel(internals: TauriInternals): string {
41
+ return internals.metadata?.currentWindow?.label || 'main';
42
+ }
43
+
44
+ /** Native macOS / OS fullscreen via Tauri window plugin (no npm import required). */
45
+ async function readTauriFullscreen(): Promise<boolean> {
46
+ const internals = getTauriInternals();
47
+ if (!internals?.invoke) return false;
48
+ try {
49
+ return Boolean(
50
+ await internals.invoke('plugin:window|is_fullscreen', {
51
+ label: currentWindowLabel(internals),
52
+ }),
53
+ );
54
+ } catch {
55
+ return false;
56
+ }
57
+ }
58
+
59
+ /**
60
+ * Listen for window resize (includes fullscreen transitions on macOS).
61
+ * Uses Tauri event IPC when available; falls back to DOM `resize`.
62
+ */
63
+ async function listenTauriWindowResized(handler: () => void): Promise<() => void> {
64
+ const internals = getTauriInternals();
65
+ if (internals?.invoke && internals.transformCallback) {
66
+ const label = currentWindowLabel(internals);
67
+ const callbackId = internals.transformCallback(() => {
68
+ handler();
69
+ }, false);
70
+ try {
71
+ const eventId = (await internals.invoke('plugin:event|listen', {
72
+ event: 'tauri://resize',
73
+ target: { kind: 'Window', label },
74
+ handler: callbackId,
75
+ })) as number;
76
+ return () => {
77
+ internals.unregisterCallback?.(callbackId);
78
+ void internals
79
+ .invoke('plugin:event|unlisten', { event: 'tauri://resize', eventId })
80
+ .catch(() => undefined);
81
+ };
82
+ } catch {
83
+ internals.unregisterCallback?.(callbackId);
84
+ }
85
+ }
86
+
87
+ window.addEventListener('resize', handler);
88
+ return () => window.removeEventListener('resize', handler);
89
+ }
90
+
13
91
  export function useIsTauriClient(): boolean {
14
92
  const [value, setValue] = useState(() => isTauri());
15
93
 
@@ -22,24 +100,96 @@ export function useIsTauriClient(): boolean {
22
100
  return value;
23
101
  }
24
102
 
25
- /** Overlay titlebar chrome: Tauri on macOS, desktop (non-mobile) viewport. */
103
+ /** Live Tauri webview (not merely a tauri-targeted web build). */
104
+ export function useIsTauriRuntime(): boolean {
105
+ const [value, setValue] = useState(() => isTauriRuntime());
106
+
107
+ useEffect(() => {
108
+ setValue(isTauriRuntime());
109
+ // __TAURI_INTERNALS__ can appear slightly after first paint in dev.
110
+ const timer = window.setTimeout(() => setValue(isTauriRuntime()), 200);
111
+ return () => window.clearTimeout(timer);
112
+ }, []);
113
+
114
+ return value;
115
+ }
116
+
117
+ /**
118
+ * Native window fullscreen (Tauri `is_fullscreen` + resize listener).
119
+ * Resize can fire before macOS updates fullscreen state, so we re-check after a short delay.
120
+ * @see https://v2.tauri.app/reference/javascript/api/namespacewindow/#isfullscreen
121
+ */
122
+ export function useIsTauriFullscreen(): boolean {
123
+ const tauriRuntime = useIsTauriRuntime();
124
+ const [fullscreen, setFullscreen] = useState(false);
125
+
126
+ useEffect(() => {
127
+ if (!tauriRuntime) {
128
+ setFullscreen(false);
129
+ return;
130
+ }
131
+
132
+ let cancelled = false;
133
+ let unlisten: (() => void) | undefined;
134
+ let debounceTimer: number | undefined;
135
+
136
+ const sync = async () => {
137
+ const next = await readTauriFullscreen();
138
+ if (!cancelled) setFullscreen(next);
139
+ };
140
+
141
+ void (async () => {
142
+ await sync();
143
+ unlisten = await listenTauriWindowResized(() => {
144
+ void sync();
145
+ window.clearTimeout(debounceTimer);
146
+ // macOS often flips isFullscreen after the resize notification.
147
+ debounceTimer = window.setTimeout(() => {
148
+ void sync();
149
+ }, 400);
150
+ });
151
+ })();
152
+
153
+ return () => {
154
+ cancelled = true;
155
+ window.clearTimeout(debounceTimer);
156
+ unlisten?.();
157
+ };
158
+ }, [tauriRuntime]);
159
+
160
+ return fullscreen;
161
+ }
162
+
163
+ /**
164
+ * macOS Tauri desktop chrome (history buttons, collapsed titlebar, drag regions).
165
+ * Desktop viewport only — narrow/mobile layouts use the sheet / top header instead.
166
+ * Stays on in native fullscreen; only the traffic-light *inset* goes away there.
167
+ */
26
168
  export function useMacOverlayChrome(): boolean {
27
- const trafficLights = useMacTrafficLights();
169
+ const tauriRuntime = useIsTauriRuntime();
28
170
  const isMobile = useIsMobile();
29
- return trafficLights && !isMobile;
171
+ const [isMac, setIsMac] = useState(false);
172
+
173
+ useEffect(() => {
174
+ setIsMac(isMacOSDesktop());
175
+ }, []);
176
+
177
+ return tauriRuntime && isMac && !isMobile;
30
178
  }
31
179
 
32
180
  /**
33
- * Native macOS traffic lights are on the window (Tauri macOS), including
34
- * narrow / mobile layouts where overlay chrome is otherwise disabled.
181
+ * Native macOS traffic lights that need chrome inset: live Tauri webview on
182
+ * macOS, windowed (not native fullscreen — lights are hidden there).
183
+ * Applies at any viewport width (narrow window / mobile layout included).
35
184
  */
36
185
  export function useMacTrafficLights(): boolean {
37
- const tauri = useIsTauriClient();
186
+ const tauriRuntime = useIsTauriRuntime();
187
+ const fullscreen = useIsTauriFullscreen();
38
188
  const [isMac, setIsMac] = useState(false);
39
189
 
40
190
  useEffect(() => {
41
191
  setIsMac(isMacOSDesktop());
42
192
  }, []);
43
193
 
44
- return tauri && isMac;
194
+ return tauriRuntime && isMac && !fullscreen;
45
195
  }
@@ -0,0 +1,22 @@
1
+ /** Soft edge fades — mask-tapered blur so scrolling content softens toward chrome. */
2
+ export function FloatingFadeMask({
3
+ placement,
4
+ visible,
5
+ }: {
6
+ placement: 'top' | 'bottom';
7
+ /** False at the matching scroll edge (top/bottom) or when content does not overflow. */
8
+ visible: boolean;
9
+ }) {
10
+ return (
11
+ <div
12
+ aria-hidden
13
+ data-shellui-floating-fade={placement}
14
+ data-visible={visible ? 'true' : 'false'}
15
+ className={
16
+ placement === 'top'
17
+ ? 'shellui-floating-fade shellui-floating-fade-top'
18
+ : 'shellui-floating-fade shellui-floating-fade-bottom'
19
+ }
20
+ />
21
+ );
22
+ }