@shellui/core 0.6.1 → 0.7.0-alpha.1
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/README.md +1 -1
- package/package.json +2 -2
- package/schemas/shellui.config.schema.json +116 -72
- package/src/app.tsx +2 -0
- package/src/components/ContentView.tsx +2 -22
- package/src/components/iframeUrlSafety.spec.ts +67 -0
- package/src/components/iframeUrlSafety.ts +50 -0
- package/src/features/admin/AdminView.tsx +18 -4
- package/src/features/auth/AuthProvider.tsx +42 -2
- package/src/features/auth/appBackend/AppBackendSessionHost.tsx +58 -0
- package/src/features/auth/appBackend/appBackendSessions.spec.ts +195 -0
- package/src/features/auth/appBackend/appBackendSessions.ts +292 -0
- package/src/features/auth/appBackend/configSchema.spec.ts +41 -0
- package/src/features/auth/appBackend/frameAuth.ts +167 -0
- package/src/features/auth/appBackend/identity.spec.ts +201 -0
- package/src/features/auth/appBackend/identity.ts +173 -0
- package/src/features/auth/appBackend/silentSignIn.spec.ts +207 -0
- package/src/features/auth/appBackend/silentSignIn.ts +240 -0
- package/src/features/auth/backends/shellui.spec.ts +51 -19
- package/src/features/auth/backends/shellui.ts +20 -5
- package/src/features/auth/backends/types.ts +7 -2
- package/src/features/auth/components/LoginView.tsx +40 -18
- package/src/features/auth/components/OAuthCallbackView.tsx +29 -2
- package/src/features/auth/utils/authRequestError.ts +3 -0
- package/src/features/auth/utils/desktopSignIn.spec.ts +41 -0
- package/src/features/auth/utils/desktopSignIn.ts +38 -0
- package/src/features/auth/utils/index.ts +9 -0
- package/src/features/auth/utils/loginCancelTarget.spec.ts +73 -0
- package/src/features/auth/utils/loginCancelTarget.ts +45 -0
- package/src/features/auth/utils/loginPanelFrame.spec.ts +24 -0
- package/src/features/auth/utils/loginPanelFrame.ts +14 -0
- package/src/features/auth/utils/webPkce.spec.ts +96 -0
- package/src/features/auth/utils/webPkce.ts +152 -0
- package/src/features/chromeActions/ChromeActionsHost.tsx +7 -1
- package/src/features/chromeActions/computeActionInsets.ts +6 -0
- package/src/features/config/types.ts +41 -0
- package/src/features/layouts/appbar/AppBarLayout.tsx +39 -9
- package/src/features/layouts/chrome/ContentDragOverlay.tsx +14 -7
- package/src/features/layouts/chrome/DesktopChrome.tsx +3 -1
- package/src/features/layouts/floating/FloatingLayout.tsx +4 -1
- package/src/features/layouts/floating/FloatingSidebar.tsx +84 -28
- package/src/features/layouts/floating/computeFloatingInsets.spec.ts +19 -0
- package/src/features/layouts/floating/computeFloatingInsets.ts +40 -8
- package/src/features/layouts/floating/layoutChromeStore.ts +13 -0
- package/src/features/layouts/floating/useFloatingChrome.ts +11 -5
- package/src/features/layouts/fullscreen/FullscreenLayout.tsx +3 -0
- package/src/features/layouts/sidebar/SidebarInner.tsx +5 -0
- package/src/features/layouts/sidebar/SidebarLayout.tsx +1 -0
- package/src/features/layouts/windows/WindowsLayout.tsx +106 -46
- package/src/features/security/trustedFrames.spec.ts +17 -1
- package/src/features/security/trustedFrames.ts +31 -9
- package/src/features/settings/SettingsProvider.tsx +48 -32
- package/src/features/settings/utils/buildSettingsForPropagation.spec.ts +374 -0
- package/src/features/settings/utils/buildSettingsForPropagation.ts +70 -35
- package/src/i18n/translations/en/common.json +2 -0
- package/src/i18n/translations/fr/common.json +2 -0
- package/src/index.css +16 -1
- package/src/index.ts +1 -0
- package/src/lib/z-index.ts +5 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { createPkcePair } from './pkce';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* S256 PKCE for web sign-in (identity-service 0.9.0 and later).
|
|
5
|
+
*
|
|
6
|
+
* Each flow gets a random id. Only the id goes on `redirect_to` as
|
|
7
|
+
* `shellui_pkce_flow`, so the callback can find its own verifier and two
|
|
8
|
+
* sign-ins started in parallel do not overwrite each other. The verifier is
|
|
9
|
+
* never put in a URL.
|
|
10
|
+
*
|
|
11
|
+
* OAuth and SAML keep the verifier in `sessionStorage`: the callback lands in
|
|
12
|
+
* the tab that started the flow. A magic link opens from the email, often in a
|
|
13
|
+
* new tab with an empty `sessionStorage`, so that flow alone keeps the
|
|
14
|
+
* verifier in `localStorage`, keyed by the flow id, for 15 minutes. It is
|
|
15
|
+
* single use and removed on read, so the link only works in the browser that
|
|
16
|
+
* requested it.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
export const WEB_PKCE_FLOW_PARAM = 'shellui_pkce_flow';
|
|
20
|
+
const SESSION_PREFIX = 'shellui.auth.pkce.';
|
|
21
|
+
const MAGIC_LINK_PREFIX = 'shellui.auth.pkce.magic.';
|
|
22
|
+
/** A magic link only works for 15 minutes in the browser that requested it. */
|
|
23
|
+
const MAGIC_LINK_MAX_AGE_MS = 15 * 60 * 1000;
|
|
24
|
+
const OAUTH_MAX_AGE_MS = 30 * 60 * 1000;
|
|
25
|
+
/** Magic link flow ids start with `m`, OAuth and SAML ids with `o`. */
|
|
26
|
+
const MAGIC_LINK_FLOW_MARK = 'm';
|
|
27
|
+
const FLOW_ID_PATTERN = /^[mo][0-9a-f]{32}$/;
|
|
28
|
+
|
|
29
|
+
export type WebPkceFlowKind = 'oauth' | 'magic_link';
|
|
30
|
+
|
|
31
|
+
interface StoredVerifier {
|
|
32
|
+
verifier: string;
|
|
33
|
+
createdAt: number;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface PreparedWebPkce {
|
|
37
|
+
flowId: string;
|
|
38
|
+
challenge: string;
|
|
39
|
+
/** `redirectTo` with the flow id added. */
|
|
40
|
+
redirectTo: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function store(kind: 'session' | 'local'): Storage | null {
|
|
44
|
+
try {
|
|
45
|
+
const s = kind === 'session' ? globalThis.sessionStorage : globalThis.localStorage;
|
|
46
|
+
return s ?? null;
|
|
47
|
+
} catch {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function randomFlowId(kind: WebPkceFlowKind): string {
|
|
53
|
+
const bytes = new Uint8Array(16);
|
|
54
|
+
crypto.getRandomValues(bytes);
|
|
55
|
+
const mark = kind === 'magic_link' ? MAGIC_LINK_FLOW_MARK : 'o';
|
|
56
|
+
return mark + Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function write(s: Storage | null, key: string, value: StoredVerifier): boolean {
|
|
60
|
+
if (!s) return false;
|
|
61
|
+
try {
|
|
62
|
+
s.setItem(key, JSON.stringify(value));
|
|
63
|
+
return true;
|
|
64
|
+
} catch {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function readAndRemove(s: Storage | null, key: string, maxAgeMs: number): string | null {
|
|
70
|
+
if (!s) return null;
|
|
71
|
+
try {
|
|
72
|
+
const raw = s.getItem(key);
|
|
73
|
+
if (!raw) return null;
|
|
74
|
+
s.removeItem(key);
|
|
75
|
+
const parsed = JSON.parse(raw) as StoredVerifier;
|
|
76
|
+
if (typeof parsed?.verifier !== 'string' || typeof parsed.createdAt !== 'number') return null;
|
|
77
|
+
if (Date.now() - parsed.createdAt > maxAgeMs) return null;
|
|
78
|
+
return parsed.verifier;
|
|
79
|
+
} catch {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Drop expired magic link verifiers left by flows that were never finished. */
|
|
85
|
+
function pruneMagicLinkVerifiers(): void {
|
|
86
|
+
const s = store('local');
|
|
87
|
+
if (!s) return;
|
|
88
|
+
try {
|
|
89
|
+
for (let i = s.length - 1; i >= 0; i -= 1) {
|
|
90
|
+
const key = s.key(i);
|
|
91
|
+
if (!key?.startsWith(MAGIC_LINK_PREFIX)) continue;
|
|
92
|
+
try {
|
|
93
|
+
const parsed = JSON.parse(s.getItem(key) ?? '') as StoredVerifier;
|
|
94
|
+
if (Date.now() - parsed.createdAt <= MAGIC_LINK_MAX_AGE_MS) continue;
|
|
95
|
+
} catch {
|
|
96
|
+
// unreadable: remove
|
|
97
|
+
}
|
|
98
|
+
s.removeItem(key);
|
|
99
|
+
}
|
|
100
|
+
} catch {
|
|
101
|
+
// ignore
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export async function prepareWebPkce(
|
|
106
|
+
redirectTo: string,
|
|
107
|
+
kind: WebPkceFlowKind,
|
|
108
|
+
): Promise<PreparedWebPkce> {
|
|
109
|
+
const { verifier, challenge } = await createPkcePair();
|
|
110
|
+
const flowId = randomFlowId(kind);
|
|
111
|
+
const entry = { verifier, createdAt: Date.now() };
|
|
112
|
+
if (kind === 'magic_link') {
|
|
113
|
+
pruneMagicLinkVerifiers();
|
|
114
|
+
write(store('local'), MAGIC_LINK_PREFIX + flowId, entry);
|
|
115
|
+
} else {
|
|
116
|
+
write(store('session'), SESSION_PREFIX + flowId, entry);
|
|
117
|
+
}
|
|
118
|
+
const url = new URL(redirectTo);
|
|
119
|
+
url.searchParams.set(WEB_PKCE_FLOW_PARAM, flowId);
|
|
120
|
+
return { flowId, challenge, redirectTo: url.toString() };
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** Read the verifier for a callback and remove every stored copy. */
|
|
124
|
+
export function takeWebPkceVerifier(flowId: string | null | undefined): string | null {
|
|
125
|
+
const id = flowId?.trim();
|
|
126
|
+
if (!id || !FLOW_ID_PATTERN.test(id)) return null;
|
|
127
|
+
if (isMagicLinkFlowId(id)) {
|
|
128
|
+
return readAndRemove(store('local'), MAGIC_LINK_PREFIX + id, MAGIC_LINK_MAX_AGE_MS);
|
|
129
|
+
}
|
|
130
|
+
return readAndRemove(store('session'), SESSION_PREFIX + id, OAUTH_MAX_AGE_MS);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export function isMagicLinkFlowId(flowId: string | null | undefined): boolean {
|
|
134
|
+
return !!flowId && flowId.startsWith(MAGIC_LINK_FLOW_MARK) && FLOW_ID_PATTERN.test(flowId);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** Remove a flow's verifier, e.g. when starting it failed. */
|
|
138
|
+
export function clearWebPkce(flowId: string): void {
|
|
139
|
+
takeWebPkceVerifier(flowId);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export const WEB_PKCE_ERROR_CODES = [
|
|
143
|
+
'pkce_required',
|
|
144
|
+
'invalid_code_challenge',
|
|
145
|
+
'invalid_code_challenge_method',
|
|
146
|
+
'invalid_code_verifier',
|
|
147
|
+
'pkce_verification_failed',
|
|
148
|
+
] as const;
|
|
149
|
+
|
|
150
|
+
export function isWebPkceErrorCode(code: string | null | undefined): boolean {
|
|
151
|
+
return !!code && (WEB_PKCE_ERROR_CODES as readonly string[]).includes(code);
|
|
152
|
+
}
|
|
@@ -33,9 +33,11 @@ import {
|
|
|
33
33
|
} from '../../components/ui/tooltip';
|
|
34
34
|
import { cn } from '../../lib/utils';
|
|
35
35
|
import { useViewport } from '../../hooks/use-viewport';
|
|
36
|
+
import { isTauriRuntime } from '../layouts/chrome/runtime';
|
|
36
37
|
import { useSettings } from '../settings/hooks/useSettings';
|
|
37
38
|
import {
|
|
38
39
|
FLOATING_CHROME_MARGIN,
|
|
40
|
+
TAURI_FLOATING_ACTION_SIDEBAR_GAP_PX,
|
|
39
41
|
floatingTabBarBottomPadCss,
|
|
40
42
|
floatingTabBarHeight,
|
|
41
43
|
} from '../layouts/floating/computeFloatingInsets';
|
|
@@ -1039,7 +1041,11 @@ function TopActionBar({
|
|
|
1039
1041
|
? {
|
|
1040
1042
|
// One animated edge (inset + collapsed-chip clearance) so actions
|
|
1041
1043
|
// track the floating sidebar / layout resize instead of fighting it.
|
|
1042
|
-
left: `calc(var(--shellui-inset-left, 0px) + var(--shellui-chrome-actions-leading-extra, 0px)
|
|
1044
|
+
left: `calc(var(--shellui-inset-left, 0px) + var(--shellui-chrome-actions-leading-extra, 0px) + ${
|
|
1045
|
+
isTauriRuntime() && layout === 'floating' && sidebarExpanded
|
|
1046
|
+
? TAURI_FLOATING_ACTION_SIDEBAR_GAP_PX
|
|
1047
|
+
: 0
|
|
1048
|
+
}px)`,
|
|
1043
1049
|
right: 'var(--shellui-inset-right, 0px)',
|
|
1044
1050
|
// Match InsetMobileRadiusOverlay cutout so the bright scrim doesn’t
|
|
1045
1051
|
// square off the top card corners.
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { LayoutChromeInsets, LayoutChromeViewport } from '@shellui/sdk';
|
|
2
|
+
import { DESKTOP_TITLEBAR_HEIGHT_PX } from '../layouts/chrome/constants';
|
|
3
|
+
import { isTauriRuntime } from '../layouts/chrome/runtime';
|
|
2
4
|
import {
|
|
3
5
|
FLOATING_CHROME_MARGIN,
|
|
4
6
|
FLOATING_CONTENT_CLEARANCE,
|
|
@@ -93,6 +95,10 @@ export function chromeActionsTopMargin(
|
|
|
93
95
|
|
|
94
96
|
const { layout, viewport } = context;
|
|
95
97
|
if (layout === 'floating') {
|
|
98
|
+
if (isTauriRuntime() && viewport === 'desktop') {
|
|
99
|
+
// Center the row in the overlay titlebar, then nudge it off the window edge.
|
|
100
|
+
return Math.round((DESKTOP_TITLEBAR_HEIGHT_PX - chromeActionsTopBarHeight(viewport)) / 2) + 4;
|
|
101
|
+
}
|
|
96
102
|
return viewport === 'desktop' ? CHROME_ACTIONS_TOP_MARGIN_DESKTOP : CHROME_ACTIONS_TOP_MARGIN;
|
|
97
103
|
}
|
|
98
104
|
return CHROME_ACTIONS_TOP_MARGIN_MINIMAL;
|
|
@@ -62,6 +62,27 @@ export interface NavigationItem {
|
|
|
62
62
|
* - true: trusted, access token can be shared (opt-in)
|
|
63
63
|
*/
|
|
64
64
|
safeForAuthToken?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Identity server for this embedded app when it is not the shell `backend`.
|
|
67
|
+
* The shell keeps a separate session and sends this URL plus that session's
|
|
68
|
+
* access token. Omit to use the shell backend and token.
|
|
69
|
+
* The shell token is never sent when this server differs.
|
|
70
|
+
*/
|
|
71
|
+
backend?: AppBackendConfig;
|
|
72
|
+
/**
|
|
73
|
+
* Email service for this app. Omit to use the shell `email` when the app uses
|
|
74
|
+
* the shell identity server. When `backend` names a different server and this
|
|
75
|
+
* is omitted, the app receives no email URL.
|
|
76
|
+
*/
|
|
77
|
+
email?: EmailConfig;
|
|
78
|
+
/**
|
|
79
|
+
* Storage service for this app. Same fallback as `email`.
|
|
80
|
+
*/
|
|
81
|
+
storage?: StorageConfig;
|
|
82
|
+
/**
|
|
83
|
+
* Hosting service for this app. Same fallback as `email`.
|
|
84
|
+
*/
|
|
85
|
+
hosting?: HostingConfig;
|
|
65
86
|
}
|
|
66
87
|
|
|
67
88
|
export interface NavigationGroup {
|
|
@@ -216,6 +237,26 @@ export interface AuthConfig {
|
|
|
216
237
|
desktopScheme?: string;
|
|
217
238
|
}
|
|
218
239
|
|
|
240
|
+
/**
|
|
241
|
+
* Identity server for one embedded app when it differs from the shell `backend`.
|
|
242
|
+
* `type` defaults to the shell backend type. `companyId` is not copied from the shell.
|
|
243
|
+
*/
|
|
244
|
+
export interface AppBackendConfig {
|
|
245
|
+
/** `shellui` or `supabase`. When omitted, the shell backend type is used. */
|
|
246
|
+
type?: BackendType;
|
|
247
|
+
/** Base URL of this app's identity server. */
|
|
248
|
+
url: string;
|
|
249
|
+
/** Tenant id for this server. Not taken from the shell `backend.companyId`. */
|
|
250
|
+
companyId?: string | number;
|
|
251
|
+
/** Public key when `type` is `supabase`. */
|
|
252
|
+
publishableKey?: string;
|
|
253
|
+
/**
|
|
254
|
+
* OAuth provider for silent sign-in, such as `google`.
|
|
255
|
+
* When omitted, the shell uses the first `backend.login.oauthProviders` entry.
|
|
256
|
+
*/
|
|
257
|
+
provider?: string;
|
|
258
|
+
}
|
|
259
|
+
|
|
219
260
|
/** Backend API configuration. */
|
|
220
261
|
export interface BackendConfig {
|
|
221
262
|
/** Backend provider type. */
|
|
@@ -53,8 +53,13 @@ import {
|
|
|
53
53
|
} from '../chrome/SafeAreaTopbar';
|
|
54
54
|
import { useScrollHideChrome } from '../chrome/useScrollHideChrome';
|
|
55
55
|
import { InsetMobileRadiusOverlay } from '../chrome/InsetMobileRadiusOverlay';
|
|
56
|
+
import {
|
|
57
|
+
DESKTOP_TITLEBAR_HEIGHT_PX,
|
|
58
|
+
DESKTOP_TITLEBAR_PAD_TOP_PX,
|
|
59
|
+
MAC_TRAFFIC_LIGHTS_GAP_PX,
|
|
60
|
+
MAC_TRAFFIC_LIGHTS_WIDTH_PX,
|
|
61
|
+
} from '../chrome/constants';
|
|
56
62
|
import { useIsTauriRuntime, useMacOverlayChrome, useMacTrafficLights } from '../chrome/runtime';
|
|
57
|
-
import { MAC_TRAFFIC_LIGHTS_GAP_PX, MAC_TRAFFIC_LIGHTS_WIDTH_PX } from '../chrome/constants';
|
|
58
63
|
|
|
59
64
|
/** App-bar chrome height — taller than the 42px Tauri/sidebar title strip. */
|
|
60
65
|
const APP_BAR_HEIGHT_PX = 56;
|
|
@@ -509,10 +514,13 @@ function AppBarNav({
|
|
|
509
514
|
sections,
|
|
510
515
|
activePathPrefix,
|
|
511
516
|
currentLanguage,
|
|
517
|
+
windowDrag = false,
|
|
512
518
|
}: {
|
|
513
519
|
sections: NavSection[];
|
|
514
520
|
activePathPrefix: string | null;
|
|
515
521
|
currentLanguage: string;
|
|
522
|
+
/** Leftover space after the links drags the Tauri window. */
|
|
523
|
+
windowDrag?: boolean;
|
|
516
524
|
}) {
|
|
517
525
|
const { t } = useTranslation();
|
|
518
526
|
const entries = useMemo(() => sectionsToEntries(sections), [sections]);
|
|
@@ -580,7 +588,6 @@ function AppBarNav({
|
|
|
580
588
|
|
|
581
589
|
return (
|
|
582
590
|
<div
|
|
583
|
-
data-shellui-no-drag=""
|
|
584
591
|
ref={containerRef}
|
|
585
592
|
className="relative flex min-w-0 flex-1 items-center gap-0.5 overflow-hidden"
|
|
586
593
|
>
|
|
@@ -650,6 +657,14 @@ function AppBarNav({
|
|
|
650
657
|
currentLanguage={currentLanguage}
|
|
651
658
|
/>
|
|
652
659
|
) : null}
|
|
660
|
+
{windowDrag ? (
|
|
661
|
+
<div
|
|
662
|
+
aria-hidden
|
|
663
|
+
data-shellui-drag-region=""
|
|
664
|
+
data-tauri-drag-region=""
|
|
665
|
+
className="h-full min-h-8 min-w-2 flex-1 self-stretch"
|
|
666
|
+
/>
|
|
667
|
+
) : null}
|
|
653
668
|
</div>
|
|
654
669
|
);
|
|
655
670
|
}
|
|
@@ -764,10 +779,13 @@ export function AppBarLayout({
|
|
|
764
779
|
// Nested shell-in-iframe must not repeat the root safe-area top band.
|
|
765
780
|
const showSafeAreaTopbar = isShellUiRootWindow();
|
|
766
781
|
const scrollHideLayout = isInset ? 'app-bar-inset' : 'app-bar';
|
|
782
|
+
const titlebarAligned = isTauriRuntime && !isMobile;
|
|
783
|
+
const barHeightPx = titlebarAligned ? DESKTOP_TITLEBAR_HEIGHT_PX : APP_BAR_HEIGHT_PX;
|
|
784
|
+
const barPadTopPx = titlebarAligned ? DESKTOP_TITLEBAR_PAD_TOP_PX : APP_BAR_PAD_TOP_PX;
|
|
767
785
|
const { chromeVisible } = useScrollHideChrome({
|
|
768
786
|
enabled: isMobile,
|
|
769
787
|
layout: scrollHideLayout,
|
|
770
|
-
barHeightPx
|
|
788
|
+
barHeightPx,
|
|
771
789
|
includeSafeArea: showSafeAreaTopbar,
|
|
772
790
|
});
|
|
773
791
|
const authAwareNavigation = useMemo(
|
|
@@ -838,12 +856,12 @@ export function AppBarLayout({
|
|
|
838
856
|
paddingRight: isInset ? (isMobile ? 8 : insetFramePadPx + insetBarContentOffsetRightPx) : 8,
|
|
839
857
|
...(isMobile && showSafeAreaTopbar
|
|
840
858
|
? {
|
|
841
|
-
paddingTop: `calc(var(--shellui-safe-area-top) + ${
|
|
842
|
-
height: `calc(${
|
|
859
|
+
paddingTop: `calc(var(--shellui-safe-area-top) + ${barPadTopPx}px)`,
|
|
860
|
+
height: `calc(${barHeightPx}px + var(--shellui-safe-area-top))`,
|
|
843
861
|
}
|
|
844
862
|
: {
|
|
845
|
-
height:
|
|
846
|
-
paddingTop:
|
|
863
|
+
height: barHeightPx,
|
|
864
|
+
paddingTop: barPadTopPx,
|
|
847
865
|
}),
|
|
848
866
|
} as const;
|
|
849
867
|
|
|
@@ -902,9 +920,15 @@ export function AppBarLayout({
|
|
|
902
920
|
sections={startSections}
|
|
903
921
|
activePathPrefix={activePathPrefix}
|
|
904
922
|
currentLanguage={currentLanguage}
|
|
923
|
+
windowDrag={isTauriRuntime}
|
|
905
924
|
/>
|
|
906
925
|
) : (
|
|
907
|
-
<div
|
|
926
|
+
<div
|
|
927
|
+
className="min-w-0 flex-1 self-stretch"
|
|
928
|
+
{...(isTauriRuntime
|
|
929
|
+
? { 'data-shellui-drag-region': '', 'data-tauri-drag-region': '' }
|
|
930
|
+
: {})}
|
|
931
|
+
/>
|
|
908
932
|
)}
|
|
909
933
|
|
|
910
934
|
{isTauriRuntime ? (
|
|
@@ -982,9 +1006,15 @@ export function AppBarLayout({
|
|
|
982
1006
|
sections={startSections}
|
|
983
1007
|
activePathPrefix={activePathPrefix}
|
|
984
1008
|
currentLanguage={currentLanguage}
|
|
1009
|
+
windowDrag={isTauriRuntime}
|
|
985
1010
|
/>
|
|
986
1011
|
) : (
|
|
987
|
-
<div
|
|
1012
|
+
<div
|
|
1013
|
+
className="min-w-0 flex-1 self-stretch"
|
|
1014
|
+
{...(isTauriRuntime
|
|
1015
|
+
? { 'data-shellui-drag-region': '', 'data-tauri-drag-region': '' }
|
|
1016
|
+
: {})}
|
|
1017
|
+
/>
|
|
988
1018
|
)}
|
|
989
1019
|
|
|
990
1020
|
{isTauriRuntime ? (
|
|
@@ -1,19 +1,26 @@
|
|
|
1
|
-
import { DESKTOP_TITLEBAR_HEIGHT_PX } from './constants';
|
|
1
|
+
import { DESKTOP_TITLEBAR_HEIGHT_PX, MAC_TRAFFIC_LIGHTS_WIDTH_PX } from './constants';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Narrow left strip over the traffic-light band only.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* A full-width overlay used to sit on top of iframes and steal clicks from
|
|
7
|
+
* embedded content. Dragging the window still works from layout chrome
|
|
8
|
+
* (app bar, sidebar header, admin header, windows titlebar) and from this
|
|
9
|
+
* empty traffic-light spacer. Interactive iframe content to the right stays
|
|
10
|
+
* clickable.
|
|
11
|
+
*
|
|
12
|
+
* Requires `core:window:allow-start-dragging` in Tauri capabilities.
|
|
9
13
|
*/
|
|
10
14
|
export function ContentDragOverlay() {
|
|
11
15
|
return (
|
|
12
16
|
<div
|
|
13
17
|
aria-hidden
|
|
14
18
|
data-tauri-drag-region
|
|
15
|
-
className="fixed
|
|
16
|
-
style={{
|
|
19
|
+
className="fixed top-0 left-0 z-[45]"
|
|
20
|
+
style={{
|
|
21
|
+
height: DESKTOP_TITLEBAR_HEIGHT_PX,
|
|
22
|
+
width: MAC_TRAFFIC_LIGHTS_WIDTH_PX,
|
|
23
|
+
}}
|
|
17
24
|
/>
|
|
18
25
|
);
|
|
19
26
|
}
|
|
@@ -9,9 +9,11 @@ import {
|
|
|
9
9
|
} from './runtime';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* Global shell host chrome: document flags +
|
|
12
|
+
* Global shell host chrome: document flags + a narrow traffic-light drag strip.
|
|
13
13
|
* Mounted at the app root so it stays available on every page (layouts, login,
|
|
14
14
|
* settings, route error boundary, empty config) — including narrow/mobile widths.
|
|
15
|
+
* Full-width drag lives on layout chrome so iframe content under the titlebar
|
|
16
|
+
* band stays clickable.
|
|
15
17
|
*
|
|
16
18
|
* Sets `data-shellui-host` to `browser` | `pwa` | `tauri` so CSS / layout can
|
|
17
19
|
* distinguish Safari Home Screen PWAs (iOS 27 system status gradient) from
|
|
@@ -114,7 +114,7 @@ export function FloatingLayout({ title, appIcon, navigation = [] }: FloatingLayo
|
|
|
114
114
|
<SafeAreaTopbarOffset enabled={showSafeAreaTopbar} />
|
|
115
115
|
<FloatingStatusScrim enabled={showStatusScrim} />
|
|
116
116
|
|
|
117
|
-
{isTauriEnv ? (
|
|
117
|
+
{isTauriEnv && !(showSidebar && !sidebarCollapsed) ? (
|
|
118
118
|
<div
|
|
119
119
|
className="pointer-events-auto absolute top-0 left-0 z-[46] flex items-center"
|
|
120
120
|
style={{
|
|
@@ -122,6 +122,9 @@ export function FloatingLayout({ title, appIcon, navigation = [] }: FloatingLayo
|
|
|
122
122
|
paddingTop: DESKTOP_TITLEBAR_PAD_TOP_PX,
|
|
123
123
|
paddingLeft: trafficLights ? MAC_TRAFFIC_LIGHTS_WIDTH_PX : 8,
|
|
124
124
|
}}
|
|
125
|
+
{...(trafficLights
|
|
126
|
+
? { 'data-shellui-drag-region': '', 'data-tauri-drag-region': '' }
|
|
127
|
+
: {})}
|
|
125
128
|
>
|
|
126
129
|
<DesktopHistoryButtons />
|
|
127
130
|
</div>
|
|
@@ -15,10 +15,17 @@ import { NavIcon, ExternalLinkIcon } from '../sidebar/SidebarIcons';
|
|
|
15
15
|
import { AppBrandIcon } from '../branding/AppBrandIcon';
|
|
16
16
|
import { LoginButton } from '../../auth/components/LoginButton';
|
|
17
17
|
import { cn } from '../../../lib/utils';
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
18
|
+
import { DesktopHistoryButtons } from '../chrome/DesktopHistoryButtons';
|
|
19
|
+
import { useIsTauriClient, useIsTauriRuntime, useMacTrafficLights } from '../chrome/runtime';
|
|
20
|
+
import {
|
|
21
|
+
DESKTOP_TITLEBAR_HEIGHT_PX,
|
|
22
|
+
DESKTOP_TITLEBAR_PAD_TOP_PX,
|
|
23
|
+
MAC_TRAFFIC_LIGHTS_GAP_PX,
|
|
24
|
+
MAC_TRAFFIC_LIGHTS_WIDTH_PX,
|
|
25
|
+
} from '../chrome/constants';
|
|
20
26
|
import {
|
|
21
27
|
FLOATING_CHROME_MARGIN,
|
|
28
|
+
FLOATING_HISTORY_CLUSTER_PX,
|
|
22
29
|
FLOATING_SIDEBAR_TOGGLE_SIZE,
|
|
23
30
|
FLOATING_SIDEBAR_WIDTH,
|
|
24
31
|
} from './computeFloatingInsets';
|
|
@@ -100,9 +107,13 @@ export function FloatingSidebar({
|
|
|
100
107
|
const lang = i18n.language || 'en';
|
|
101
108
|
const trafficLights = useMacTrafficLights();
|
|
102
109
|
const isTauriEnv = useIsTauriClient();
|
|
103
|
-
const
|
|
104
|
-
/**
|
|
105
|
-
const
|
|
110
|
+
const tauriRuntime = useIsTauriRuntime();
|
|
111
|
+
/** Tauri drops the floating edge gap so this row shares the traffic-light band. */
|
|
112
|
+
const edgeMargin = tauriRuntime ? 0 : FLOATING_CHROME_MARGIN;
|
|
113
|
+
/** Collapsed chip clears the corner lights and the history cluster. */
|
|
114
|
+
const chipLeadingPx =
|
|
115
|
+
(trafficLights ? MAC_TRAFFIC_LIGHTS_WIDTH_PX : 0) +
|
|
116
|
+
(isTauriEnv ? FLOATING_HISTORY_CLUSTER_PX : 0);
|
|
106
117
|
|
|
107
118
|
const sidebarNav = useMemo(() => filterNavigationForSidebar(navigation), [navigation]);
|
|
108
119
|
const sections = useMemo(() => buildSections(sidebarNav), [sidebarNav]);
|
|
@@ -113,15 +124,23 @@ export function FloatingSidebar({
|
|
|
113
124
|
);
|
|
114
125
|
|
|
115
126
|
const sidebarEdgePad = {
|
|
116
|
-
paddingTop: `calc(${
|
|
117
|
-
paddingLeft: `calc(${
|
|
118
|
-
paddingBottom: `calc(${
|
|
127
|
+
paddingTop: `calc(${edgeMargin}px + var(--shellui-safe-area-top, 0px))`,
|
|
128
|
+
paddingLeft: `calc(${edgeMargin}px + var(--shellui-safe-area-left, 0px))`,
|
|
129
|
+
paddingBottom: `calc(${edgeMargin}px + var(--shellui-safe-area-bottom, 0px))`,
|
|
119
130
|
};
|
|
120
131
|
|
|
121
|
-
const chipEdgePad =
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
132
|
+
const chipEdgePad = tauriRuntime
|
|
133
|
+
? {
|
|
134
|
+
height: DESKTOP_TITLEBAR_HEIGHT_PX,
|
|
135
|
+
paddingTop: DESKTOP_TITLEBAR_PAD_TOP_PX,
|
|
136
|
+
paddingLeft: `calc(var(--shellui-safe-area-left, 0px) + ${chipLeadingPx}px)`,
|
|
137
|
+
boxSizing: 'border-box' as const,
|
|
138
|
+
alignItems: 'center',
|
|
139
|
+
}
|
|
140
|
+
: {
|
|
141
|
+
paddingTop: `calc(${FLOATING_CHROME_MARGIN}px + var(--shellui-safe-area-top, 0px))`,
|
|
142
|
+
paddingLeft: `calc(${FLOATING_CHROME_MARGIN}px + var(--shellui-safe-area-left, 0px) + ${chipLeadingPx}px)`,
|
|
143
|
+
};
|
|
125
144
|
|
|
126
145
|
const toggleLabel = collapsed
|
|
127
146
|
? t('develop.layout.showSidebar', { defaultValue: 'Show sidebar' })
|
|
@@ -247,6 +266,7 @@ export function FloatingSidebar({
|
|
|
247
266
|
aria-hidden={collapsed}
|
|
248
267
|
>
|
|
249
268
|
<nav
|
|
269
|
+
data-shellui-tauri-flush={tauriRuntime ? '' : undefined}
|
|
250
270
|
className={cn(
|
|
251
271
|
'shellui-floating-glass pointer-events-auto flex h-full flex-col overflow-hidden',
|
|
252
272
|
'origin-left will-change-transform',
|
|
@@ -258,25 +278,61 @@ export function FloatingSidebar({
|
|
|
258
278
|
style={{ width: FLOATING_SIDEBAR_WIDTH }}
|
|
259
279
|
aria-label={title || 'Navigation'}
|
|
260
280
|
>
|
|
261
|
-
<div
|
|
262
|
-
{
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
281
|
+
<div
|
|
282
|
+
className={cn(
|
|
283
|
+
'flex shrink-0 items-center border-b border-sidebar-border/80',
|
|
284
|
+
tauriRuntime ? 'pr-2.5' : 'gap-2 px-2.5 py-2.5',
|
|
285
|
+
)}
|
|
286
|
+
style={
|
|
287
|
+
tauriRuntime
|
|
288
|
+
? {
|
|
289
|
+
height: DESKTOP_TITLEBAR_HEIGHT_PX,
|
|
290
|
+
paddingTop: DESKTOP_TITLEBAR_PAD_TOP_PX,
|
|
291
|
+
}
|
|
292
|
+
: undefined
|
|
293
|
+
}
|
|
294
|
+
{...(tauriRuntime
|
|
295
|
+
? { 'data-shellui-drag-region': '', 'data-tauri-drag-region': '' }
|
|
296
|
+
: {})}
|
|
297
|
+
>
|
|
298
|
+
{trafficLights ? (
|
|
299
|
+
<div
|
|
300
|
+
className="h-full shrink-0"
|
|
301
|
+
style={{ width: MAC_TRAFFIC_LIGHTS_WIDTH_PX }}
|
|
302
|
+
aria-hidden
|
|
267
303
|
/>
|
|
268
304
|
) : null}
|
|
269
|
-
<
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
aria-label={toggleLabel}
|
|
275
|
-
aria-expanded={!collapsed}
|
|
276
|
-
onClick={onToggleCollapsed}
|
|
305
|
+
<div
|
|
306
|
+
className="flex h-full min-w-0 flex-1 items-center gap-1"
|
|
307
|
+
style={{
|
|
308
|
+
paddingLeft: trafficLights ? MAC_TRAFFIC_LIGHTS_GAP_PX : undefined,
|
|
309
|
+
}}
|
|
277
310
|
>
|
|
278
|
-
<
|
|
279
|
-
|
|
311
|
+
{isTauriEnv && !collapsed ? <DesktopHistoryButtons className="self-center" /> : null}
|
|
312
|
+
{appIcon ? (
|
|
313
|
+
<AppBrandIcon
|
|
314
|
+
appIcon={appIcon}
|
|
315
|
+
title={title}
|
|
316
|
+
className="size-7 shrink-0"
|
|
317
|
+
/>
|
|
318
|
+
) : null}
|
|
319
|
+
<span
|
|
320
|
+
className="min-h-full min-w-0 flex-1 self-stretch"
|
|
321
|
+
{...(tauriRuntime
|
|
322
|
+
? { 'data-shellui-drag-region': '', 'data-tauri-drag-region': '' }
|
|
323
|
+
: {})}
|
|
324
|
+
/>
|
|
325
|
+
<button
|
|
326
|
+
type="button"
|
|
327
|
+
tabIndex={collapsed ? -1 : 0}
|
|
328
|
+
className="shellui-floating-nav-control flex size-8 shrink-0 items-center justify-center text-sidebar-foreground transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"
|
|
329
|
+
aria-label={toggleLabel}
|
|
330
|
+
aria-expanded={!collapsed}
|
|
331
|
+
onClick={onToggleCollapsed}
|
|
332
|
+
>
|
|
333
|
+
<SidebarPanelIcon className="size-4" />
|
|
334
|
+
</button>
|
|
335
|
+
</div>
|
|
280
336
|
</div>
|
|
281
337
|
|
|
282
338
|
<div className="flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto p-2">
|
|
@@ -65,6 +65,25 @@ describe('computeFloatingInsets', () => {
|
|
|
65
65
|
});
|
|
66
66
|
});
|
|
67
67
|
|
|
68
|
+
it('drops the floating edge gap when edgeMargin is 0', () => {
|
|
69
|
+
expect(
|
|
70
|
+
computeFloatingInsets({
|
|
71
|
+
viewport: 'desktop',
|
|
72
|
+
chromeVisible: true,
|
|
73
|
+
safeArea: safe,
|
|
74
|
+
edgeMargin: 0,
|
|
75
|
+
}).left,
|
|
76
|
+
).toBe(3 + FLOATING_SIDEBAR_WIDTH + FLOATING_CONTENT_CLEARANCE);
|
|
77
|
+
expect(
|
|
78
|
+
computeFloatingInsets({
|
|
79
|
+
viewport: 'mobile',
|
|
80
|
+
chromeVisible: true,
|
|
81
|
+
safeArea: safe,
|
|
82
|
+
edgeMargin: 0,
|
|
83
|
+
}).bottom,
|
|
84
|
+
).toBe(20 / 2 + FLOATING_TAB_BAR_HEIGHT + FLOATING_CONTENT_CLEARANCE);
|
|
85
|
+
});
|
|
86
|
+
|
|
68
87
|
it('keeps content full-bleed when desktop sidebar is collapsed', () => {
|
|
69
88
|
expect(
|
|
70
89
|
computeFloatingInsets({
|