@shellui/core 0.5.0-beta.3 → 0.5.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 +5 -5
- package/package.json +3 -2
- package/schemas/shellui.config.schema.json +98 -33
- package/src/app.tsx +10 -4
- package/src/components/ContentView.tsx +3 -5
- package/src/components/contentIframeSandbox.spec.ts +25 -0
- package/src/components/contentIframeSandbox.ts +43 -0
- package/src/components/ui/dialog.tsx +5 -1
- package/src/components/ui/dropdown-menu.tsx +39 -4
- package/src/components/ui/sheet.tsx +1 -1
- package/src/components/ui/sidebar.tsx +3 -2
- package/src/components/ui/tabs.tsx +52 -0
- package/src/constants/urls.ts +1 -0
- package/src/features/auth/AuthProvider.tsx +169 -35
- package/src/features/auth/backends/index.ts +2 -0
- package/src/features/auth/backends/shellui.ts +43 -35
- package/src/features/auth/backends/supabase.ts +1 -0
- package/src/features/auth/backends/types.ts +5 -0
- package/src/features/auth/components/LoginView.tsx +5 -1
- package/src/features/auth/components/OAuthCallbackView.tsx +115 -44
- package/src/features/auth/constants/oauth.ts +2 -0
- package/src/features/auth/hooks/useAuth.tsx +4 -0
- package/src/features/auth/utils/authSessionPersistence.spec.ts +93 -0
- package/src/features/auth/utils/authSessionPersistence.ts +138 -0
- package/src/features/auth/utils/authStorageKeys.ts +8 -0
- package/src/features/auth/utils/bffAuthClient.ts +107 -0
- package/src/features/auth/utils/buildOAuthSessionRedirectTo.spec.ts +22 -0
- package/src/features/auth/utils/buildOAuthSessionRedirectTo.ts +17 -0
- package/src/features/auth/utils/buildSessionFromTokenPayload.spec.ts +29 -0
- package/src/features/auth/utils/buildSessionFromTokenPayload.ts +24 -0
- package/src/features/auth/utils/index.ts +18 -3
- package/src/features/auth/utils/isBffAuthEnabled.ts +12 -0
- package/src/features/chromeActions/ChromeActionIcons.tsx +261 -0
- package/src/features/chromeActions/ChromeActionsDemoView.tsx +149 -0
- package/src/features/chromeActions/ChromeActionsHost.tsx +1511 -0
- package/src/features/chromeActions/ChromeActionsProvider.tsx +141 -0
- package/src/features/chromeActions/chromeActionsStore.spec.ts +61 -0
- package/src/features/chromeActions/chromeActionsStore.ts +77 -0
- package/src/features/chromeActions/computeActionInsets.spec.ts +360 -0
- package/src/features/chromeActions/computeActionInsets.ts +326 -0
- package/src/features/chromeActions/index.ts +26 -0
- package/src/features/chromeActions/resolveUuidForRemoveIframe.spec.ts +49 -0
- package/src/features/config/types.ts +49 -2
- package/src/features/layouts/AppLayout.tsx +4 -4
- package/src/features/layouts/OverlayShell.tsx +60 -12
- package/src/features/layouts/app-bar-inset/AppBarInsetLayout.tsx +1 -1
- package/src/features/layouts/appbar/AppBarLayout.tsx +194 -89
- package/src/features/layouts/chrome/DesktopChrome.tsx +17 -3
- package/src/features/layouts/chrome/InsetMobileRadiusOverlay.tsx +18 -0
- package/src/features/layouts/chrome/index.ts +8 -0
- package/src/features/layouts/chrome/runtime.ts +73 -0
- package/src/features/layouts/chrome/useScrollHideChrome.ts +210 -0
- package/src/features/layouts/floating/FloatingBottomDock.tsx +410 -0
- package/src/features/layouts/floating/FloatingLayout.tsx +31 -21
- package/src/features/layouts/floating/FloatingStatusScrim.tsx +36 -0
- package/src/features/layouts/floating/computeFloatingInsets.spec.ts +5 -5
- package/src/features/layouts/floating/computeFloatingInsets.ts +64 -12
- package/src/features/layouts/floating/isShellOwnedPath.spec.ts +2 -0
- package/src/features/layouts/floating/isShellOwnedPath.ts +1 -0
- package/src/features/layouts/floating/layoutChromeStore.spec.ts +138 -0
- package/src/features/layouts/floating/layoutChromeStore.ts +169 -6
- package/src/features/layouts/floating/useFloatingChrome.ts +20 -30
- package/src/features/layouts/sidebar/SidebarLayout.tsx +87 -31
- package/src/features/layouts/sidebar-inset/SidebarInsetLayout.tsx +1 -1
- package/src/features/layouts/windows/WindowsLayout.tsx +240 -110
- package/src/features/messaging/MessagingSecurityBootstrap.tsx +19 -0
- package/src/features/messaging/deriveAllowedMessageOrigins.spec.ts +86 -0
- package/src/features/messaging/deriveAllowedMessageOrigins.ts +74 -0
- package/src/features/modal/ModalContext.spec.ts +13 -2
- package/src/features/modal/validateAndNormalizeUrl.ts +9 -23
- package/src/features/overlays/ResponsiveModal.tsx +201 -21
- package/src/features/overlays/overlaySize.spec.ts +18 -0
- package/src/features/overlays/overlaySize.ts +89 -0
- package/src/features/security/trustedFrames.spec.ts +129 -0
- package/src/features/security/trustedFrames.ts +79 -0
- package/src/features/security/urlAllowlist.spec.ts +99 -0
- package/src/features/security/urlAllowlist.ts +122 -0
- package/src/features/settings/SettingsProvider.tsx +38 -54
- package/src/features/settings/components/Develop.tsx +2 -0
- package/src/features/settings/components/develop/ChromeActionsTestButtons.tsx +63 -0
- package/src/features/settings/utils/buildSettingsForPropagation.spec.ts +23 -1
- package/src/features/settings/utils/buildSettingsForPropagation.ts +7 -0
- package/src/features/storage/StorageBridge.spec.ts +82 -0
- package/src/features/storage/StorageBridge.tsx +25 -3
- package/src/features/storage/StoragePickerContext.tsx +3 -4
- package/src/features/storage/uploads/uploadQueue.spec.ts +56 -1
- package/src/features/storage/uploads/uploadQueue.ts +44 -6
- package/src/features/theme/applyTheme.ts +23 -5
- package/src/hooks/use-mobile.tsx +21 -7
- package/src/i18n/translations/en/settings.json +9 -0
- package/src/i18n/translations/fr/settings.json +9 -0
- package/src/index.css +264 -124
- package/src/index.html +6 -4
- package/src/index.ts +8 -0
- package/src/routes/components/NavigationItemRoute.tsx +30 -15
- package/src/routes/components/RouteFallback.tsx +15 -0
- package/src/routes/routes.tsx +14 -0
- package/src/routes/utils/navigationRouteAccess.spec.ts +85 -0
- package/src/routes/utils/navigationRouteAccess.ts +43 -0
- package/src/features/auth/utils/clearStoredAuthSession.spec.ts +0 -23
- package/src/features/auth/utils/clearStoredAuthSession.ts +0 -10
- package/src/features/auth/utils/persistAuthSession.spec.ts +0 -35
- package/src/features/auth/utils/persistAuthSession.ts +0 -12
- package/src/features/auth/utils/readStoredAuthSession.spec.ts +0 -34
- package/src/features/auth/utils/readStoredAuthSession.ts +0 -14
- package/src/features/layouts/floating/FloatingFadeMask.tsx +0 -22
- package/src/features/layouts/floating/FloatingTabBar.tsx +0 -437
- package/src/features/layouts/floating/FloatingTabIndicator.tsx +0 -216
|
@@ -34,6 +34,8 @@ import { ExternalLinkIcon, NavIcon } from '../sidebar/SidebarIcons';
|
|
|
34
34
|
import { getExternalFaviconUrl, isAppIcon } from '../sidebar/sidebarUtils';
|
|
35
35
|
import { AppBrandIcon } from '../branding/AppBrandIcon';
|
|
36
36
|
import { useIsMobile } from '../../../hooks/use-mobile';
|
|
37
|
+
import { readSafeAreaInsetBottom, readSafeAreaInsetTop } from '../chrome/viewport';
|
|
38
|
+
import { WindowTitleBarActions } from '../../chromeActions';
|
|
37
39
|
|
|
38
40
|
interface WindowsLayoutProps {
|
|
39
41
|
title?: string;
|
|
@@ -88,31 +90,37 @@ const MIN_HEIGHT = 200;
|
|
|
88
90
|
const DEFAULT_WIDTH = 720;
|
|
89
91
|
const DEFAULT_HEIGHT = 480;
|
|
90
92
|
const TASKBAR_HEIGHT = 48;
|
|
93
|
+
/** Taskbar content row + home-indicator safe-area (CSS). */
|
|
94
|
+
const TASKBAR_SLOT_CSS = `calc(${TASKBAR_HEIGHT}px + var(--shellui-safe-area-bottom, 0px))`;
|
|
91
95
|
|
|
92
96
|
type WindowBounds = WindowState['bounds'];
|
|
93
97
|
|
|
94
98
|
function getDesktopSize(): { width: number; height: number } {
|
|
95
99
|
if (typeof window === 'undefined') return { width: 800, height: 600 };
|
|
100
|
+
const safeBottom = readSafeAreaInsetBottom();
|
|
96
101
|
return {
|
|
97
102
|
width: window.innerWidth,
|
|
98
|
-
height: Math.max(0, window.innerHeight - TASKBAR_HEIGHT),
|
|
103
|
+
height: Math.max(0, window.innerHeight - TASKBAR_HEIGHT - safeBottom),
|
|
99
104
|
};
|
|
100
105
|
}
|
|
101
106
|
|
|
102
107
|
function getMaximizedBounds(): WindowBounds {
|
|
103
108
|
const { width, height } = getDesktopSize();
|
|
104
|
-
|
|
109
|
+
const safeTop = readSafeAreaInsetTop();
|
|
110
|
+
return { x: 0, y: safeTop, w: width, h: Math.max(0, height - safeTop) };
|
|
105
111
|
}
|
|
106
112
|
|
|
107
113
|
/** Keep a window fully inside the desktop (never larger than the viewport). */
|
|
108
114
|
function clampBounds(bounds: WindowBounds): WindowBounds {
|
|
109
115
|
const { width: maxW, height: maxH } = getDesktopSize();
|
|
116
|
+
const safeTop = readSafeAreaInsetTop();
|
|
117
|
+
const usableH = Math.max(0, maxH - safeTop);
|
|
110
118
|
const minW = Math.min(MIN_WIDTH, maxW);
|
|
111
|
-
const minH = Math.min(MIN_HEIGHT,
|
|
119
|
+
const minH = Math.min(MIN_HEIGHT, usableH);
|
|
112
120
|
const w = Math.min(Math.max(bounds.w, minW), maxW);
|
|
113
|
-
const h = Math.min(Math.max(bounds.h, minH),
|
|
121
|
+
const h = Math.min(Math.max(bounds.h, minH), usableH);
|
|
114
122
|
const x = Math.min(Math.max(0, bounds.x), Math.max(0, maxW - w));
|
|
115
|
-
const y = Math.min(Math.max(
|
|
123
|
+
const y = Math.min(Math.max(safeTop, bounds.y), Math.max(safeTop, safeTop + usableH - h));
|
|
116
124
|
return { x, y, w, h };
|
|
117
125
|
}
|
|
118
126
|
|
|
@@ -136,6 +144,30 @@ function isCompactDesktop(): boolean {
|
|
|
136
144
|
return width < DEFAULT_WIDTH || height < DEFAULT_HEIGHT;
|
|
137
145
|
}
|
|
138
146
|
|
|
147
|
+
/**
|
|
148
|
+
* Phone-style windows chrome: width below md **or** a short/narrow desktop
|
|
149
|
+
* (iPhone landscape is often ≥768px wide but still too short for window mode).
|
|
150
|
+
*/
|
|
151
|
+
function useWindowsPhoneMode(): boolean {
|
|
152
|
+
const isMobile = useIsMobile();
|
|
153
|
+
const [isCompact, setIsCompact] = useState(() =>
|
|
154
|
+
typeof window !== 'undefined' ? isCompactDesktop() : false,
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
useEffect(() => {
|
|
158
|
+
const sync = () => setIsCompact(isCompactDesktop());
|
|
159
|
+
window.addEventListener('resize', sync);
|
|
160
|
+
window.addEventListener('orientationchange', sync);
|
|
161
|
+
sync();
|
|
162
|
+
return () => {
|
|
163
|
+
window.removeEventListener('resize', sync);
|
|
164
|
+
window.removeEventListener('orientationchange', sync);
|
|
165
|
+
};
|
|
166
|
+
}, []);
|
|
167
|
+
|
|
168
|
+
return isMobile || isCompact;
|
|
169
|
+
}
|
|
170
|
+
|
|
139
171
|
function buildFinalUrl(baseUrl: string, path: string, pathname: string): string {
|
|
140
172
|
const pathPrefix = getNavPathPrefix({ path } as NavigationItem);
|
|
141
173
|
const subPath = pathname.length > pathPrefix.length ? pathname.slice(pathPrefix.length + 1) : '';
|
|
@@ -144,7 +176,7 @@ function buildFinalUrl(baseUrl: string, path: string, pathname: string): string
|
|
|
144
176
|
return `${base}${subPath}`;
|
|
145
177
|
}
|
|
146
178
|
|
|
147
|
-
/** Single draggable/resizable window */
|
|
179
|
+
/** Single draggable/resizable window (fullscreen + locked on mobile). */
|
|
148
180
|
function AppWindow({
|
|
149
181
|
win,
|
|
150
182
|
navItem,
|
|
@@ -155,6 +187,8 @@ function AppWindow({
|
|
|
155
187
|
onBoundsChange,
|
|
156
188
|
maxZIndex,
|
|
157
189
|
zIndex,
|
|
190
|
+
mobileFullscreen,
|
|
191
|
+
cascadeIndex,
|
|
158
192
|
}: {
|
|
159
193
|
win: WindowState;
|
|
160
194
|
navItem: NavigationItem;
|
|
@@ -165,33 +199,38 @@ function AppWindow({
|
|
|
165
199
|
onBoundsChange: (bounds: WindowState['bounds']) => void;
|
|
166
200
|
maxZIndex: number;
|
|
167
201
|
zIndex: number;
|
|
202
|
+
/** Phone: fill desktop, no drag/resize/restore. */
|
|
203
|
+
mobileFullscreen: boolean;
|
|
204
|
+
/** Used to cascade normal size when leaving mobile. */
|
|
205
|
+
cascadeIndex: number;
|
|
168
206
|
}) {
|
|
169
207
|
const windowLabel = resolveNavLabel(navItem.label, currentLanguage);
|
|
208
|
+
const [frameUuid, setFrameUuid] = useState<string | null>(null);
|
|
170
209
|
const [isMaximized, setIsMaximized] = useState(() => {
|
|
171
|
-
if (isCompactDesktop()) return true;
|
|
172
|
-
const
|
|
210
|
+
if (mobileFullscreen || isCompactDesktop()) return true;
|
|
211
|
+
const maximized = getMaximizedBounds();
|
|
173
212
|
return (
|
|
174
|
-
win.bounds.x ===
|
|
175
|
-
win.bounds.y ===
|
|
176
|
-
win.bounds.w >=
|
|
177
|
-
win.bounds.h >=
|
|
213
|
+
win.bounds.x === maximized.x &&
|
|
214
|
+
win.bounds.y === maximized.y &&
|
|
215
|
+
win.bounds.w >= maximized.w &&
|
|
216
|
+
win.bounds.h >= maximized.h
|
|
178
217
|
);
|
|
179
218
|
});
|
|
180
219
|
const [bounds, setBounds] = useState(() => {
|
|
181
|
-
if (isCompactDesktop()) return getMaximizedBounds();
|
|
182
|
-
const
|
|
220
|
+
if (mobileFullscreen || isCompactDesktop()) return getMaximizedBounds();
|
|
221
|
+
const maximized = getMaximizedBounds();
|
|
183
222
|
if (
|
|
184
|
-
win.bounds.x ===
|
|
185
|
-
win.bounds.y ===
|
|
186
|
-
win.bounds.w >=
|
|
187
|
-
win.bounds.h >=
|
|
223
|
+
win.bounds.x === maximized.x &&
|
|
224
|
+
win.bounds.y === maximized.y &&
|
|
225
|
+
win.bounds.w >= maximized.w &&
|
|
226
|
+
win.bounds.h >= maximized.h
|
|
188
227
|
) {
|
|
189
228
|
return getMaximizedBounds();
|
|
190
229
|
}
|
|
191
230
|
return clampBounds(win.bounds);
|
|
192
231
|
});
|
|
193
232
|
const boundsBeforeMaximizeRef = useRef<WindowBounds>(
|
|
194
|
-
isCompactDesktop()
|
|
233
|
+
mobileFullscreen || isCompactDesktop()
|
|
195
234
|
? clampBounds({
|
|
196
235
|
x: 8,
|
|
197
236
|
y: 8,
|
|
@@ -215,6 +254,21 @@ function AppWindow({
|
|
|
215
254
|
startBounds: WindowBounds;
|
|
216
255
|
} | null>(null);
|
|
217
256
|
const resizeRafRef = useRef<number | null>(null);
|
|
257
|
+
|
|
258
|
+
// Resolve the content iframe UUID so title-bar actions can bind to this window.
|
|
259
|
+
useEffect(() => {
|
|
260
|
+
const sync = () => {
|
|
261
|
+
const iframe = containerRef.current?.querySelector('iframe');
|
|
262
|
+
if (!iframe) {
|
|
263
|
+
setFrameUuid(null);
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
setFrameUuid(shellui.getUuidByIframe(iframe.contentWindow) ?? null);
|
|
267
|
+
};
|
|
268
|
+
sync();
|
|
269
|
+
const id = window.setInterval(sync, 400);
|
|
270
|
+
return () => window.clearInterval(id);
|
|
271
|
+
}, [win.id, win.pathname]);
|
|
218
272
|
const pendingResizeBoundsRef = useRef<WindowBounds | null>(null);
|
|
219
273
|
|
|
220
274
|
// Use a ref for onBoundsChange to avoid it in effect deps (prevents infinite render loop).
|
|
@@ -228,19 +282,58 @@ function AppWindow({
|
|
|
228
282
|
onBoundsChangeRef.current(bounds);
|
|
229
283
|
}, [bounds]);
|
|
230
284
|
|
|
231
|
-
// Keep windows inside the viewport on browser / orientation resize
|
|
285
|
+
// Keep windows inside the viewport on browser / orientation resize.
|
|
286
|
+
// Use refs so iOS orientation (resize before React re-renders phone mode) still
|
|
287
|
+
// applies fullscreen when phone mode is active or about to be.
|
|
288
|
+
const mobileFullscreenRef = useRef(mobileFullscreen);
|
|
289
|
+
mobileFullscreenRef.current = mobileFullscreen;
|
|
290
|
+
const isMaximizedRef = useRef(isMaximized);
|
|
291
|
+
isMaximizedRef.current = isMaximized;
|
|
292
|
+
|
|
232
293
|
useEffect(() => {
|
|
233
294
|
const onResize = () => {
|
|
234
|
-
if (
|
|
295
|
+
if (mobileFullscreenRef.current) {
|
|
296
|
+
setIsMaximized(true);
|
|
297
|
+
setBounds(getMaximizedBounds());
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
if (isMaximizedRef.current) {
|
|
235
301
|
setBounds(getMaximizedBounds());
|
|
236
302
|
return;
|
|
237
303
|
}
|
|
238
304
|
setBounds((prev) => clampBounds(prev));
|
|
239
305
|
};
|
|
240
306
|
window.addEventListener('resize', onResize);
|
|
241
|
-
|
|
242
|
-
|
|
307
|
+
window.addEventListener('orientationchange', onResize);
|
|
308
|
+
return () => {
|
|
309
|
+
window.removeEventListener('resize', onResize);
|
|
310
|
+
window.removeEventListener('orientationchange', onResize);
|
|
311
|
+
};
|
|
312
|
+
}, []);
|
|
313
|
+
|
|
314
|
+
// Phone ↔ desktop: fullscreen stack on phone; restore a normal cascaded size on desktop.
|
|
315
|
+
// Accidental resize must not close windows — only change chrome / bounds.
|
|
316
|
+
const wasMobileFullscreenRef = useRef(mobileFullscreen);
|
|
317
|
+
useEffect(() => {
|
|
318
|
+
if (mobileFullscreen) {
|
|
319
|
+
setIsMaximized(true);
|
|
320
|
+
setBounds(getMaximizedBounds());
|
|
321
|
+
} else if (wasMobileFullscreenRef.current) {
|
|
322
|
+
// Only leave fullscreen when there is real room for window mode.
|
|
323
|
+
if (isCompactDesktop()) {
|
|
324
|
+
setIsMaximized(true);
|
|
325
|
+
setBounds(getMaximizedBounds());
|
|
326
|
+
} else {
|
|
327
|
+
const normal = getDefaultOpenBounds(cascadeIndex);
|
|
328
|
+
boundsBeforeMaximizeRef.current = normal;
|
|
329
|
+
setIsMaximized(false);
|
|
330
|
+
setBounds(normal);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
wasMobileFullscreenRef.current = mobileFullscreen;
|
|
334
|
+
}, [mobileFullscreen, cascadeIndex]);
|
|
243
335
|
|
|
336
|
+
const lockedChrome = mobileFullscreen || isMaximized;
|
|
244
337
|
const onPointerMove = useCallback((e: PointerEvent) => {
|
|
245
338
|
if (!dragRef.current) return;
|
|
246
339
|
const d = dragRef.current;
|
|
@@ -283,7 +376,7 @@ function AppWindow({
|
|
|
283
376
|
|
|
284
377
|
const handleTitlePointerDown = useCallback(
|
|
285
378
|
(e: ReactPointerEvent) => {
|
|
286
|
-
if (e.button !== 0 ||
|
|
379
|
+
if (e.button !== 0 || lockedChrome) return;
|
|
287
380
|
// Don't start drag when clicking a button (close, maximize) so their click handlers run
|
|
288
381
|
if ((e.target as Element).closest('button')) return;
|
|
289
382
|
e.preventDefault();
|
|
@@ -302,10 +395,11 @@ function AppWindow({
|
|
|
302
395
|
el.addEventListener('pointerup', onPointerUp as (e: Event) => void);
|
|
303
396
|
}
|
|
304
397
|
},
|
|
305
|
-
[bounds,
|
|
398
|
+
[bounds, lockedChrome, onFocus, onPointerMove, onPointerUp],
|
|
306
399
|
);
|
|
307
400
|
|
|
308
401
|
const handleMaximizeToggle = useCallback(() => {
|
|
402
|
+
if (mobileFullscreen) return;
|
|
309
403
|
if (isMaximized) {
|
|
310
404
|
setBounds(clampBounds(boundsBeforeMaximizeRef.current));
|
|
311
405
|
setIsMaximized(false);
|
|
@@ -314,7 +408,7 @@ function AppWindow({
|
|
|
314
408
|
setBounds(getMaximizedBounds());
|
|
315
409
|
setIsMaximized(true);
|
|
316
410
|
}
|
|
317
|
-
}, [isMaximized, bounds]);
|
|
411
|
+
}, [mobileFullscreen, isMaximized, bounds]);
|
|
318
412
|
|
|
319
413
|
const onResizePointerMove = useCallback((e: PointerEvent) => {
|
|
320
414
|
if (!resizeRef.current) return;
|
|
@@ -371,7 +465,7 @@ function AppWindow({
|
|
|
371
465
|
|
|
372
466
|
const handleResizePointerDown = useCallback(
|
|
373
467
|
(e: ReactPointerEvent, edge: string) => {
|
|
374
|
-
if (e.button !== 0) return;
|
|
468
|
+
if (e.button !== 0 || lockedChrome) return;
|
|
375
469
|
e.preventDefault();
|
|
376
470
|
e.stopPropagation();
|
|
377
471
|
onFocus();
|
|
@@ -390,7 +484,7 @@ function AppWindow({
|
|
|
390
484
|
el.addEventListener('pointerup', onResizePointerUp as (e: Event) => void);
|
|
391
485
|
}
|
|
392
486
|
},
|
|
393
|
-
[bounds, onFocus, onResizePointerMove, onResizePointerUp],
|
|
487
|
+
[bounds, lockedChrome, onFocus, onResizePointerMove, onResizePointerUp],
|
|
394
488
|
);
|
|
395
489
|
|
|
396
490
|
const finalUrl = useMemo(
|
|
@@ -403,7 +497,12 @@ function AppWindow({
|
|
|
403
497
|
return (
|
|
404
498
|
<div
|
|
405
499
|
ref={containerRef}
|
|
406
|
-
className=
|
|
500
|
+
className={cn(
|
|
501
|
+
'absolute flex flex-col overflow-hidden bg-card',
|
|
502
|
+
mobileFullscreen
|
|
503
|
+
? 'rounded-none border-0 shadow-none'
|
|
504
|
+
: 'rounded-lg border border-border shadow-lg',
|
|
505
|
+
)}
|
|
407
506
|
style={{
|
|
408
507
|
left: bounds.x,
|
|
409
508
|
top: bounds.y,
|
|
@@ -416,7 +515,10 @@ function AppWindow({
|
|
|
416
515
|
>
|
|
417
516
|
{/* Title bar: pointer capture so drag continues when cursor is over iframe or outside window */}
|
|
418
517
|
<div
|
|
419
|
-
className=
|
|
518
|
+
className={cn(
|
|
519
|
+
'flex items-center gap-2 pl-2 pr-1 py-1 bg-muted/80 border-b border-border select-none shrink-0',
|
|
520
|
+
lockedChrome ? 'cursor-default' : 'cursor-move',
|
|
521
|
+
)}
|
|
420
522
|
onPointerDown={handleTitlePointerDown}
|
|
421
523
|
>
|
|
422
524
|
{win.icon && (
|
|
@@ -429,18 +531,27 @@ function AppWindow({
|
|
|
429
531
|
)}
|
|
430
532
|
/>
|
|
431
533
|
)}
|
|
432
|
-
<
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
534
|
+
<WindowTitleBarActions
|
|
535
|
+
frameUuid={frameUuid}
|
|
536
|
+
fallbackTitle={windowLabel}
|
|
537
|
+
/>
|
|
538
|
+
{!mobileFullscreen && (
|
|
539
|
+
<button
|
|
540
|
+
type="button"
|
|
541
|
+
onClick={(e) => {
|
|
542
|
+
e.stopPropagation();
|
|
543
|
+
handleMaximizeToggle();
|
|
544
|
+
}}
|
|
545
|
+
className="p-1 rounded cursor-pointer text-muted-foreground hover:bg-sidebar-accent/50 hover:text-sidebar-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"
|
|
546
|
+
aria-label={isMaximized ? 'Restore' : 'Maximize'}
|
|
547
|
+
>
|
|
548
|
+
{isMaximized ? (
|
|
549
|
+
<RestoreIcon className="h-4 w-4" />
|
|
550
|
+
) : (
|
|
551
|
+
<MaximizeIcon className="h-4 w-4" />
|
|
552
|
+
)}
|
|
553
|
+
</button>
|
|
554
|
+
)}
|
|
444
555
|
<button
|
|
445
556
|
type="button"
|
|
446
557
|
onClick={(e) => {
|
|
@@ -474,8 +585,8 @@ function AppWindow({
|
|
|
474
585
|
navItem={navItem}
|
|
475
586
|
/>
|
|
476
587
|
</div>
|
|
477
|
-
{/* Resize handles (hidden when maximized) */}
|
|
478
|
-
{!
|
|
588
|
+
{/* Resize handles (hidden when maximized or mobile fullscreen) */}
|
|
589
|
+
{!lockedChrome &&
|
|
479
590
|
(['n', 's', 'e', 'w', 'ne', 'nw', 'se', 'sw'] as const).map((edge) => (
|
|
480
591
|
<div
|
|
481
592
|
key={edge}
|
|
@@ -618,7 +729,8 @@ export function WindowsLayout({ title, appIcon, logo: _logo, navigation }: Windo
|
|
|
618
729
|
const { i18n } = useTranslation();
|
|
619
730
|
const { isAuthenticated } = useAuth();
|
|
620
731
|
const { settings } = useSettings();
|
|
621
|
-
|
|
732
|
+
/** Fullscreen phone chrome — includes iPhone landscape (wide but short). */
|
|
733
|
+
const phoneMode = useWindowsPhoneMode();
|
|
622
734
|
const currentLanguage = i18n.language || 'en';
|
|
623
735
|
const hasCustomLoginNav = useMemo(() => hasLoginNavigationItem(navigation), [navigation]);
|
|
624
736
|
const authAwareNavigation = useMemo(
|
|
@@ -635,11 +747,11 @@ export function WindowsLayout({ title, appIcon, logo: _logo, navigation }: Windo
|
|
|
635
747
|
navigationItems: flattenNavigationItems(authAwareNavigation),
|
|
636
748
|
};
|
|
637
749
|
}, [authAwareNavigation]);
|
|
638
|
-
/** On
|
|
750
|
+
/** On phone, end (taskbar) links live in the start menu — the bar is too narrow. */
|
|
639
751
|
const menuSections = useMemo((): StartSection[] => {
|
|
640
|
-
if (!
|
|
752
|
+
if (!phoneMode || endNavItems.length === 0) return startSections;
|
|
641
753
|
return [...startSections, { type: 'items', items: endNavItems }];
|
|
642
|
-
}, [startSections, endNavItems,
|
|
754
|
+
}, [startSections, endNavItems, phoneMode]);
|
|
643
755
|
|
|
644
756
|
const [windows, setWindows] = useState<WindowState[]>([]);
|
|
645
757
|
/** Id of the window that is on top (first plan). Clicking a window or its taskbar button sets this. */
|
|
@@ -670,23 +782,22 @@ export function WindowsLayout({ title, appIcon, logo: _logo, navigation }: Windo
|
|
|
670
782
|
item.openIn === 'external' && !item.icon ? getExternalFaviconUrl(item.url) : null;
|
|
671
783
|
const icon = item.icon ?? faviconUrl ?? null;
|
|
672
784
|
const id = genId();
|
|
673
|
-
const bounds = getDefaultOpenBounds(windows.length);
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
]);
|
|
785
|
+
const bounds = phoneMode ? getMaximizedBounds() : getDefaultOpenBounds(windows.length);
|
|
786
|
+
const next: WindowState = {
|
|
787
|
+
id,
|
|
788
|
+
path: item.path,
|
|
789
|
+
pathname: getNavPathPrefix(item),
|
|
790
|
+
baseUrl: item.url,
|
|
791
|
+
label,
|
|
792
|
+
icon,
|
|
793
|
+
bounds,
|
|
794
|
+
};
|
|
795
|
+
// Phone: one page at a time — opening a new app closes the others.
|
|
796
|
+
setWindows((prev) => (phoneMode ? [next] : [...prev, next]));
|
|
686
797
|
setFrontWindowId(id);
|
|
687
798
|
setStartMenuOpen(false);
|
|
688
799
|
},
|
|
689
|
-
[currentLanguage, windows.length],
|
|
800
|
+
[currentLanguage, phoneMode, windows.length],
|
|
690
801
|
);
|
|
691
802
|
|
|
692
803
|
// On first load only: open a window for the current URL if it matches a nav item (no reaction to later URL changes)
|
|
@@ -760,20 +871,25 @@ export function WindowsLayout({ title, appIcon, logo: _logo, navigation }: Windo
|
|
|
760
871
|
}
|
|
761
872
|
const existing = windows.find((w) => w.path === item.path);
|
|
762
873
|
if (existing) {
|
|
874
|
+
// Phone navigate: keep only the chosen window (drop the stacked leftovers).
|
|
875
|
+
if (phoneMode) {
|
|
876
|
+
setWindows((prev) => prev.filter((w) => w.id === existing.id));
|
|
877
|
+
}
|
|
763
878
|
focusWindow(existing.id);
|
|
764
879
|
setStartMenuOpen(false);
|
|
765
880
|
return;
|
|
766
881
|
}
|
|
767
882
|
openWindow(item);
|
|
768
883
|
},
|
|
769
|
-
[openWindow, windows, focusWindow],
|
|
884
|
+
[openWindow, windows, focusWindow, phoneMode],
|
|
770
885
|
);
|
|
771
886
|
|
|
772
887
|
return (
|
|
773
888
|
<>
|
|
774
889
|
<div
|
|
890
|
+
data-shellui-windows-layout=""
|
|
775
891
|
className="fixed inset-0 overflow-hidden bg-background"
|
|
776
|
-
style={{ paddingBottom:
|
|
892
|
+
style={{ paddingBottom: TASKBAR_SLOT_CSS }}
|
|
777
893
|
>
|
|
778
894
|
{/* Organic primary wash behind windows — follows --primary with the active theme. */}
|
|
779
895
|
<div
|
|
@@ -808,6 +924,8 @@ export function WindowsLayout({ title, appIcon, logo: _logo, navigation }: Windo
|
|
|
808
924
|
onBoundsChange={(bounds) => updateWindowBounds(win.id, bounds)}
|
|
809
925
|
maxZIndex={maxZIndex}
|
|
810
926
|
zIndex={zIndex}
|
|
927
|
+
mobileFullscreen={phoneMode}
|
|
928
|
+
cascadeIndex={index}
|
|
811
929
|
/>
|
|
812
930
|
);
|
|
813
931
|
})}
|
|
@@ -817,10 +935,19 @@ export function WindowsLayout({ title, appIcon, logo: _logo, navigation }: Windo
|
|
|
817
935
|
<div
|
|
818
936
|
className="fixed left-0 right-0 bottom-0 flex items-center gap-1 px-2 border-t border-border bg-sidebar-background"
|
|
819
937
|
style={{
|
|
820
|
-
height:
|
|
938
|
+
height: TASKBAR_SLOT_CSS,
|
|
939
|
+
paddingBottom: 'var(--shellui-safe-area-bottom, 0px)',
|
|
821
940
|
zIndex: Z_INDEX.WINDOWS_TASKBAR,
|
|
822
941
|
}}
|
|
823
942
|
>
|
|
943
|
+
{/* Temporary: separate taskbar content from the home-indicator safe-area band on phone. */}
|
|
944
|
+
{phoneMode && (
|
|
945
|
+
<div
|
|
946
|
+
aria-hidden
|
|
947
|
+
className="pointer-events-none absolute left-0 right-0 border-b border-border"
|
|
948
|
+
style={{ bottom: 'var(--shellui-safe-area-bottom, 0px)' }}
|
|
949
|
+
/>
|
|
950
|
+
)}
|
|
824
951
|
{/* Start button */}
|
|
825
952
|
<div
|
|
826
953
|
className="relative shrink-0"
|
|
@@ -883,7 +1010,7 @@ export function WindowsLayout({ title, appIcon, logo: _logo, navigation }: Windo
|
|
|
883
1010
|
? resolveNavLabel(section.title, currentLanguage)
|
|
884
1011
|
: null;
|
|
885
1012
|
const isEndSection =
|
|
886
|
-
|
|
1013
|
+
phoneMode &&
|
|
887
1014
|
endNavItems.length > 0 &&
|
|
888
1015
|
sectionIndex === menuSections.length - 1 &&
|
|
889
1016
|
section.type === 'items' &&
|
|
@@ -975,51 +1102,54 @@ export function WindowsLayout({ title, appIcon, logo: _logo, navigation }: Windo
|
|
|
975
1102
|
)}
|
|
976
1103
|
</div>
|
|
977
1104
|
|
|
978
|
-
{/* Window list */}
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
e
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1105
|
+
{/* Window list — desktop only; phone switches via the start menu */}
|
|
1106
|
+
{!phoneMode && (
|
|
1107
|
+
<div className="flex-1 flex items-center gap-1 min-w-0 overflow-x-auto">
|
|
1108
|
+
{windows.map((win) => {
|
|
1109
|
+
const navItem = navigationItems.find((n) => n.path === win.path);
|
|
1110
|
+
const windowLabel = navItem
|
|
1111
|
+
? resolveNavLabel(navItem.label, currentLanguage)
|
|
1112
|
+
: win.label;
|
|
1113
|
+
const isFocused = win.id === frontWindowId;
|
|
1114
|
+
return (
|
|
1115
|
+
<button
|
|
1116
|
+
key={win.id}
|
|
1117
|
+
type="button"
|
|
1118
|
+
onClick={() => focusWindow(win.id)}
|
|
1119
|
+
onContextMenu={(e) => {
|
|
1120
|
+
e.preventDefault();
|
|
1121
|
+
closeWindow(win.id);
|
|
1122
|
+
}}
|
|
1123
|
+
className={cn(
|
|
1124
|
+
'flex items-center gap-2 h-8 px-2 rounded min-w-0 max-w-[140px] shrink-0 cursor-pointer transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',
|
|
1125
|
+
isFocused
|
|
1126
|
+
? 'bg-sidebar-accent text-sidebar-accent-foreground'
|
|
1127
|
+
: 'text-sidebar-foreground hover:bg-sidebar-accent/50 hover:text-sidebar-foreground',
|
|
1128
|
+
)}
|
|
1129
|
+
title={windowLabel}
|
|
1130
|
+
>
|
|
1131
|
+
{win.icon ? (
|
|
1132
|
+
<img
|
|
1133
|
+
src={win.icon}
|
|
1134
|
+
alt=""
|
|
1135
|
+
className={cn(
|
|
1136
|
+
'h-4 w-4 shrink-0 rounded-sm object-cover',
|
|
1137
|
+
isAppIcon(win.icon) && 'opacity-90 dark:opacity-100 dark:invert',
|
|
1138
|
+
)}
|
|
1139
|
+
/>
|
|
1140
|
+
) : (
|
|
1141
|
+
<span className="h-4 w-4 shrink-0 rounded-sm bg-muted" />
|
|
1142
|
+
)}
|
|
1143
|
+
<span className="text-xs truncate">{windowLabel}</span>
|
|
1144
|
+
</button>
|
|
1145
|
+
);
|
|
1146
|
+
})}
|
|
1147
|
+
</div>
|
|
1148
|
+
)}
|
|
1149
|
+
{phoneMode && <div className="flex-1 min-w-0" />}
|
|
1020
1150
|
|
|
1021
|
-
{/* End navigation items (right side of taskbar) — desktop only;
|
|
1022
|
-
{!
|
|
1151
|
+
{/* End navigation items (right side of taskbar) — desktop only; phone uses start menu */}
|
|
1152
|
+
{!phoneMode && endNavItems.length > 0 && (
|
|
1023
1153
|
<div className="flex items-center gap-0.5 shrink-0 border-l border-sidebar-border pl-2 ml-1">
|
|
1024
1154
|
{endNavItems.map((item) => {
|
|
1025
1155
|
const label =
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { shellui } from '@shellui/sdk';
|
|
3
|
+
import { useConfig } from '../config/useConfig';
|
|
4
|
+
import { deriveAllowedMessageOrigins } from './deriveAllowedMessageOrigins';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Applies config-derived companion origins to the SDK message security policy.
|
|
8
|
+
*/
|
|
9
|
+
export function MessagingSecurityBootstrap() {
|
|
10
|
+
const { config } = useConfig();
|
|
11
|
+
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
shellui.configureMessageSecurity({
|
|
14
|
+
allowedOrigins: deriveAllowedMessageOrigins(config),
|
|
15
|
+
});
|
|
16
|
+
}, [config]);
|
|
17
|
+
|
|
18
|
+
return null;
|
|
19
|
+
}
|