@tearleads/windowing 0.2.32 → 0.2.34
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/docs/launcher.md +31 -8
- package/index.d.ts +2 -1
- package/index.js +2 -1
- package/index.js.map +1 -1
- package/launcher/LauncherNavigationProvider.d.ts +8 -19
- package/launcher/LauncherNavigationProvider.js +18 -31
- package/launcher/LauncherNavigationProvider.js.map +1 -1
- package/launcher/launcherDefinition.d.ts +7 -5
- package/launcher/launcherDefinition.js.map +1 -1
- package/launcher/openMiniAppWindow.d.ts +54 -0
- package/launcher/openMiniAppWindow.js +37 -0
- package/launcher/openMiniAppWindow.js.map +1 -0
- package/launcher/useDefaultWindow.d.ts +4 -1
- package/launcher/useDefaultWindow.js +11 -4
- package/launcher/useDefaultWindow.js.map +1 -1
- package/package.json +1 -1
- package/routed/RoutedPaneAppBar.js +2 -1
- package/routed/RoutedPaneAppBar.js.map +1 -1
- package/routed/RoutedPaneNav.d.ts +1 -0
- package/routed/RoutedPaneNav.js +2 -1
- package/routed/RoutedPaneNav.js.map +1 -1
- package/routed/RoutedPaneSidebar.d.ts +1 -0
- package/routed/RoutedPaneSidebar.js +4 -2
- package/routed/RoutedPaneSidebar.js.map +1 -1
- package/routed/RoutedPaneTaskBar.js +2 -2
- package/routed/RoutedPaneTaskBar.js.map +1 -1
package/docs/launcher.md
CHANGED
|
@@ -39,7 +39,8 @@ and a `close` callback. Tearleads' footer does this in
|
|
|
39
39
|
A launcher application is a set of mini-apps, defined once and shown either in
|
|
40
40
|
windows on a desktop or one at a time in the routed shell. A
|
|
41
41
|
`LauncherDefinition` lists the apps by id, the order the launchers show them in,
|
|
42
|
-
and the app the routed shell shows at
|
|
42
|
+
the windows the desktop opens on entry, and the app the routed shell shows at
|
|
43
|
+
the root route:
|
|
43
44
|
|
|
44
45
|
```tsx
|
|
45
46
|
import type { LauncherDefinition } from "@tearleads/windowing";
|
|
@@ -58,7 +59,7 @@ const LAUNCHER: LauncherDefinition<"notes" | "contacts"> = {
|
|
|
58
59
|
title: "Notes",
|
|
59
60
|
},
|
|
60
61
|
},
|
|
61
|
-
|
|
62
|
+
defaultWindowAppIds: ["contacts", "notes"],
|
|
62
63
|
homeAppId: "notes",
|
|
63
64
|
order: ["notes", "contacts"],
|
|
64
65
|
};
|
|
@@ -72,12 +73,34 @@ or raises the one already open; in `routed` mode it pushes the app's route,
|
|
|
72
73
|
each window with `MiniAppWindow`, whose `AppBoundary` slot wraps the app (for
|
|
73
74
|
example in an error boundary).
|
|
74
75
|
|
|
75
|
-
Optional `
|
|
76
|
-
including mount
|
|
77
|
-
leaves it empty until the next mode entry. The
|
|
78
|
-
defers that entry while false (e.g. hidden
|
|
79
|
-
already initialized desktop preserves it,
|
|
80
|
-
manage startup yourself; `homeAppId` only sets
|
|
76
|
+
Optional `defaultWindowAppIds` open, in order, on entering an empty windowed
|
|
77
|
+
desktop, including mount, so the last opens in front. Minimized windows count
|
|
78
|
+
as open. Closing the last window leaves it empty until the next mode entry. The
|
|
79
|
+
provider's `defaultWindowEnabled` defers that entry while false (e.g. hidden
|
|
80
|
+
workspaces). Hiding and showing an already initialized desktop preserves it,
|
|
81
|
+
even if empty. Omit the list to manage startup yourself; `homeAppId` only sets
|
|
82
|
+
the routed home.
|
|
83
|
+
|
|
84
|
+
A new window opens at the request's `position`, or `DEFAULT_MINI_APP_POSITION`,
|
|
85
|
+
at the app's `windowSize`. A host that places its apps itself passes the
|
|
86
|
+
provider a `placeWindow` callback. It receives each request that opens a new
|
|
87
|
+
window and returns a `MiniAppWindowPlacement`: the window's `position`, in
|
|
88
|
+
viewport pixels like the request's, its `size`, and `fitToContent` to open it
|
|
89
|
+
fitted (see [Geometry and input](./windows.md#geometry-and-input)). A field it
|
|
90
|
+
leaves out keeps the default. Default windows, desktop icons, and every other
|
|
91
|
+
`openMiniApp` call open through it:
|
|
92
|
+
|
|
93
|
+
```tsx
|
|
94
|
+
<LauncherNavigationProvider
|
|
95
|
+
definition={LAUNCHER}
|
|
96
|
+
mode={mode}
|
|
97
|
+
placeWindow={({ appId }) =>
|
|
98
|
+
appId === "notes"
|
|
99
|
+
? { fitToContent: true, position: { x: 120, y: 40 } }
|
|
100
|
+
: {}
|
|
101
|
+
}
|
|
102
|
+
>
|
|
103
|
+
```
|
|
81
104
|
|
|
82
105
|
A mini-app reads and sets its own route with `useMiniAppRouteSegments(appId)`,
|
|
83
106
|
or `useMiniAppRouteState` for a parsed route: the browser route in the routed
|
package/index.d.ts
CHANGED
|
@@ -7,13 +7,14 @@ export { DisplayProperties } from "./display/DisplayProperties.js";
|
|
|
7
7
|
export { type WindowingIcons, WindowingIconsProvider, } from "./icons/WindowingIcons.js";
|
|
8
8
|
export type { WindowingIcon, WindowingIconProps } from "./icons/windowingIcon.js";
|
|
9
9
|
export { ROUTED_TABLET_BREAKPOINT_PX, ROUTED_TABLET_QUERY, WINDOWED_LAYOUT_MIN_WIDTH_PX, } from "./launcher/breakpoints.js";
|
|
10
|
-
export {
|
|
10
|
+
export { type LauncherNavigationActions, LauncherNavigationProvider, type LauncherNavigationState, useLauncherNavigationActions, useLauncherNavigationState, useMiniAppRouteSegments, useOptionalLauncherNavigationState, } from "./launcher/LauncherNavigationProvider.js";
|
|
11
11
|
export { isLauncherAppId, type LauncherDefinition, type MiniAppDefinition, resolveLauncherHomeAppId, resolveLauncherOrder, } from "./launcher/launcherDefinition.js";
|
|
12
12
|
export { MiniAppRouteSegmentsProvider, useMiniAppWindowRouteSegments, } from "./launcher/MiniAppRouteSegmentsContext.js";
|
|
13
13
|
export { type MiniAppBoundary, MiniAppWindow } from "./launcher/MiniAppWindow.js";
|
|
14
14
|
export { NavigationModeOverrideProvider, useNavigationModeOverride, useOptionalNavigationModeOverride, } from "./launcher/NavigationModeOverrideProvider.js";
|
|
15
15
|
export { NavigationModeSwitch } from "./launcher/NavigationModeSwitch.js";
|
|
16
16
|
export { isWindowedLayoutEligible, type NavigationEnvironment, type NavigationMode, readNavigationEnvironment, resolveNavigationMode, } from "./launcher/navigationMode.js";
|
|
17
|
+
export { DEFAULT_MINI_APP_POSITION, type MiniAppWindowPlacement, type OpenMiniAppRequest, type PlaceMiniAppWindow, } from "./launcher/openMiniAppWindow.js";
|
|
17
18
|
export { buildMiniAppPath, type LauncherRoute, parseLauncherRoute, } from "./launcher/routePaths.js";
|
|
18
19
|
export { resolveActiveLauncherRoute, useActiveLauncherRoute, } from "./launcher/useActiveLauncherRoute.js";
|
|
19
20
|
export { useCompactRoutedMode } from "./launcher/useCompactRoutedMode.js";
|
package/index.js
CHANGED
|
@@ -11,13 +11,14 @@ export { createMemoryDesktopStateStorage, createOpfsDesktopStateStorage, } from
|
|
|
11
11
|
export { DisplayProperties } from "./display/DisplayProperties.js";
|
|
12
12
|
export { WindowingIconsProvider, } from "./icons/WindowingIcons.js";
|
|
13
13
|
export { ROUTED_TABLET_BREAKPOINT_PX, ROUTED_TABLET_QUERY, WINDOWED_LAYOUT_MIN_WIDTH_PX, } from "./launcher/breakpoints.js";
|
|
14
|
-
export {
|
|
14
|
+
export { LauncherNavigationProvider, useLauncherNavigationActions, useLauncherNavigationState, useMiniAppRouteSegments, useOptionalLauncherNavigationState, } from "./launcher/LauncherNavigationProvider.js";
|
|
15
15
|
export { isLauncherAppId, resolveLauncherHomeAppId, resolveLauncherOrder, } from "./launcher/launcherDefinition.js";
|
|
16
16
|
export { MiniAppRouteSegmentsProvider, useMiniAppWindowRouteSegments, } from "./launcher/MiniAppRouteSegmentsContext.js";
|
|
17
17
|
export { MiniAppWindow } from "./launcher/MiniAppWindow.js";
|
|
18
18
|
export { NavigationModeOverrideProvider, useNavigationModeOverride, useOptionalNavigationModeOverride, } from "./launcher/NavigationModeOverrideProvider.js";
|
|
19
19
|
export { NavigationModeSwitch } from "./launcher/NavigationModeSwitch.js";
|
|
20
20
|
export { isWindowedLayoutEligible, readNavigationEnvironment, resolveNavigationMode, } from "./launcher/navigationMode.js";
|
|
21
|
+
export { DEFAULT_MINI_APP_POSITION, } from "./launcher/openMiniAppWindow.js";
|
|
21
22
|
export { buildMiniAppPath, parseLauncherRoute, } from "./launcher/routePaths.js";
|
|
22
23
|
export { resolveActiveLauncherRoute, useActiveLauncherRoute, } from "./launcher/useActiveLauncherRoute.js";
|
|
23
24
|
export { useCompactRoutedMode } from "./launcher/useCompactRoutedMode.js";
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../home/runner/work/tearleads/tearleads/packages/windowing/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AAEtB,6EAA6E;AAC7E,8EAA8E;AAC9E,yEAAyE;AACzE,8EAA8E;AAC9E,6EAA6E;AAC7E,iDAAiD;AACjD,OAAO,EACL,qBAAqB,GAEtB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,YAAY,GAEb,MAAM,wBAAwB,CAAC;AAKhC,OAAO,EACL,+BAA+B,EAC/B,6BAA6B,GAG9B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAEL,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,2BAA2B,EAC3B,mBAAmB,EACnB,4BAA4B,GAC7B,MAAM,wBAAwB,CAAC;AAChC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../home/runner/work/tearleads/tearleads/packages/windowing/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AAEtB,6EAA6E;AAC7E,8EAA8E;AAC9E,yEAAyE;AACzE,8EAA8E;AAC9E,6EAA6E;AAC7E,iDAAiD;AACjD,OAAO,EACL,qBAAqB,GAEtB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,YAAY,GAEb,MAAM,wBAAwB,CAAC;AAKhC,OAAO,EACL,+BAA+B,EAC/B,6BAA6B,GAG9B,MAAM,+BAA+B,CAAC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wB,EACxB,2BAA2B,EAC3B,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,gBAAgB,EAChB,0BAA0B,EAC1B,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAQlB,mBAAmB,GACpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC","sourcesContent":["import \"./tokens.css\";\n\n// The public windowing API: window state, window chrome and its registration\n// hooks, the menu and sidebar primitives the chrome renders with, a taskbar's\n// start menu and theme switch, the icons the chrome draws, a launcher of\n// mini-apps that shows them in windows or in the routed (iPad / phone) shell,\n// and desktop icons that open them, with a storage adapter for their layout,\n// over a wallpaper chosen in Display Properties.\nexport {\n createRequiredContext,\n type RequiredContext,\n} from \"./createRequiredContext\";\nexport type { DesktopIconMenuItem } from \"./desktop/DesktopIconMenu\";\nexport {\n DesktopIcons,\n type DesktopIconsProps,\n} from \"./desktop/DesktopIcons\";\nexport type {\n DesktopIconPosition,\n DesktopState,\n} from \"./desktop/desktopState\";\nexport {\n createMemoryDesktopStateStorage,\n createOpfsDesktopStateStorage,\n type DesktopStateStorage,\n type OpfsDesktopStateStorageOptions,\n} from \"./desktop/desktopStateStorage\";\nexport { DisplayProperties } from \"./display/DisplayProperties\";\nexport {\n type WindowingIcons,\n WindowingIconsProvider,\n} from \"./icons/WindowingIcons\";\nexport type { WindowingIcon, WindowingIconProps } from \"./icons/windowingIcon\";\nexport {\n ROUTED_TABLET_BREAKPOINT_PX,\n ROUTED_TABLET_QUERY,\n WINDOWED_LAYOUT_MIN_WIDTH_PX,\n} from \"./launcher/breakpoints\";\nexport {\n type LauncherNavigationActions,\n LauncherNavigationProvider,\n type LauncherNavigationState,\n useLauncherNavigationActions,\n useLauncherNavigationState,\n useMiniAppRouteSegments,\n useOptionalLauncherNavigationState,\n} from \"./launcher/LauncherNavigationProvider\";\nexport {\n isLauncherAppId,\n type LauncherDefinition,\n type MiniAppDefinition,\n resolveLauncherHomeAppId,\n resolveLauncherOrder,\n} from \"./launcher/launcherDefinition\";\nexport {\n MiniAppRouteSegmentsProvider,\n useMiniAppWindowRouteSegments,\n} from \"./launcher/MiniAppRouteSegmentsContext\";\nexport { type MiniAppBoundary, MiniAppWindow } from \"./launcher/MiniAppWindow\";\nexport {\n NavigationModeOverrideProvider,\n useNavigationModeOverride,\n useOptionalNavigationModeOverride,\n} from \"./launcher/NavigationModeOverrideProvider\";\nexport { NavigationModeSwitch } from \"./launcher/NavigationModeSwitch\";\nexport {\n isWindowedLayoutEligible,\n type NavigationEnvironment,\n type NavigationMode,\n readNavigationEnvironment,\n resolveNavigationMode,\n} from \"./launcher/navigationMode\";\nexport {\n DEFAULT_MINI_APP_POSITION,\n type MiniAppWindowPlacement,\n type OpenMiniAppRequest,\n type PlaceMiniAppWindow,\n} from \"./launcher/openMiniAppWindow\";\nexport {\n buildMiniAppPath,\n type LauncherRoute,\n parseLauncherRoute,\n} from \"./launcher/routePaths\";\nexport {\n resolveActiveLauncherRoute,\n useActiveLauncherRoute,\n} from \"./launcher/useActiveLauncherRoute\";\nexport { useCompactRoutedMode } from \"./launcher/useCompactRoutedMode\";\nexport {\n type MiniAppRouteSetOptions,\n useMiniAppRouteState,\n} from \"./launcher/useMiniAppRouteState\";\nexport { useNavigationMode } from \"./launcher/useNavigationMode\";\nexport { useNavigationModeDocumentAttribute } from \"./launcher/useNavigationModeDocumentAttribute\";\nexport {\n useRoutedLayoutActive,\n useWindowedLayoutActive,\n} from \"./launcher/useRoutedLayoutActive\";\nexport {\n type RoutedLayoutTier,\n useRoutedLayoutTier,\n} from \"./launcher/useRoutedLayoutTier\";\nexport { Menu, type MenuPosition } from \"./menu/Menu\";\nexport { MenuItem, type MenuItemProps } from \"./menu/MenuItem\";\nexport {\n StartMenu,\n type StartMenuItem,\n type StartMenuProps,\n} from \"./menu/StartMenu\";\nexport {\n type ContextMenuState,\n useContextMenuPositionState,\n useContextMenuState,\n} from \"./menu/useContextMenuState\";\nexport { useLongPress } from \"./menu/useLongPress\";\nexport { RoutedPane, type RoutedPaneProps } from \"./routed/RoutedPane\";\nexport {\n RoutedPaneOverlayHostProvider,\n type RoutedPaneOverlayHostValue,\n useRoutedPaneOverlayHost,\n} from \"./routed/RoutedPaneOverlayHost\";\nexport type { SubscribeKeyboardVisibility } from \"./routed/useMobileKeyboardVisible\";\nexport { SidebarResizeHandle, useSidebarResize } from \"./sidebar/SidebarResize\";\nexport {\n ThemeProvider,\n useOptionalTheme,\n useTheme,\n} from \"./theme/ThemeProvider\";\nexport { ThemeSwitch } from \"./theme/ThemeSwitch\";\nexport type {\n DefaultTheme,\n ThemeDefinition,\n ThemeScheme,\n} from \"./theme/themes\";\nexport {\n DesktopWallpaper,\n type DesktopWallpaperProps,\n} from \"./wallpaper/DesktopWallpaper\";\nexport {\n BLOCKS_WALLPAPER,\n CHEVRON_WALLPAPER,\n HARLEQUIN_WALLPAPER,\n HONEYCOMB_WALLPAPER,\n PLAIN_WALLPAPER,\n TRIANGLES_WALLPAPER,\n} from \"./wallpaper/tessellations\";\nexport {\n useOptionalWallpaper,\n useWallpaper,\n WallpaperProvider,\n} from \"./wallpaper/WallpaperProvider\";\nexport type {\n WallpaperDefinition,\n WallpaperTile,\n} from \"./wallpaper/wallpapers\";\nexport {\n CurrentWindowProvider,\n useCurrentWindow,\n useSuppressWindowToolbar,\n useWindowBackground,\n useWindowContentSize,\n} from \"./window/CurrentWindowContext\";\nexport { Window, type WindowContentBoundary } from \"./window/Window\";\nexport { WindowTitleBarActionButtons } from \"./window/WindowChromeActions\";\nexport { WindowCloseButton } from \"./window/WindowCloseButton\";\nexport {\n useWindowBackAction,\n useWindowBackActionValue,\n useWindowFileMenuItem,\n useWindowRefreshMenuItem,\n useWindowRefreshMenuItemValue,\n useWindowTitleBarAction,\n useWindowTitleBarActions,\n useWindowToolbarReservation,\n useWindowViewMenuItem,\n WindowMenuProvider,\n} from \"./window/WindowMenuContext\";\nexport {\n hasWindowSidebar,\n useRegisteredWindowSidebar,\n useWindowSidebar,\n WindowSidebarProvider,\n} from \"./window/WindowSidebarContext\";\nexport {\n findTopWindow,\n useWindowActions,\n useWindowStateData,\n type WindowCreateOptions,\n type WindowEntry,\n type WindowGeometry,\n type WindowPosition,\n type WindowSize,\n type WindowStateActions,\n type WindowStateData,\n WindowStateProvider,\n} from \"./window/WindowStateProvider\";\nexport { WindowToolBar } from \"./window/WindowToolBar\";\n"]}
|
|
@@ -2,24 +2,8 @@ import { type PropsWithChildren } from "react";
|
|
|
2
2
|
import type { LauncherDefinition } from "./launcherDefinition.js";
|
|
3
3
|
import { type NavigationHistoryAvailability } from "./navigationHistory.js";
|
|
4
4
|
import type { NavigationMode } from "./navigationMode.js";
|
|
5
|
+
import { type OpenMiniAppRequest, type PlaceMiniAppWindow } from "./openMiniAppWindow.js";
|
|
5
6
|
import { type LauncherRoute } from "./routePaths.js";
|
|
6
|
-
/** Where a new window opens when a request names no position. */
|
|
7
|
-
export declare const DEFAULT_MINI_APP_POSITION: {
|
|
8
|
-
x: number;
|
|
9
|
-
y: number;
|
|
10
|
-
};
|
|
11
|
-
/** A request to show an app: in a window, or as the routed shell's page. */
|
|
12
|
-
export interface OpenMiniAppRequest<AppId extends string = string> {
|
|
13
|
-
appId: AppId;
|
|
14
|
-
pathSegments?: ReadonlyArray<string> | undefined;
|
|
15
|
-
/** Where a new window opens. */
|
|
16
|
-
position?: {
|
|
17
|
-
x: number;
|
|
18
|
-
y: number;
|
|
19
|
-
} | undefined;
|
|
20
|
-
/** Raise the app's open window instead of opening another. Defaults to true. */
|
|
21
|
-
reuseExisting?: boolean | undefined;
|
|
22
|
-
}
|
|
23
7
|
export interface LauncherNavigationActions<AppId extends string = string> {
|
|
24
8
|
getMiniAppHref: (appId: AppId, pathSegments?: ReadonlyArray<string> | undefined) => string;
|
|
25
9
|
goBack: () => void;
|
|
@@ -41,10 +25,15 @@ export interface LauncherNavigationState<AppId extends string = string> {
|
|
|
41
25
|
route: LauncherRoute<AppId>;
|
|
42
26
|
}
|
|
43
27
|
interface LauncherNavigationProviderProps extends PropsWithChildren {
|
|
44
|
-
/** Defers the default
|
|
28
|
+
/** Defers the default windows while false, for example in a hidden workspace. */
|
|
45
29
|
defaultWindowEnabled?: boolean | undefined;
|
|
46
30
|
definition: LauncherDefinition;
|
|
47
31
|
mode: NavigationMode;
|
|
32
|
+
/**
|
|
33
|
+
* Places each new window, for a host that opens its apps at their own
|
|
34
|
+
* positions or sizes. Read when a window opens.
|
|
35
|
+
*/
|
|
36
|
+
placeWindow?: PlaceMiniAppWindow | undefined;
|
|
48
37
|
}
|
|
49
38
|
/**
|
|
50
39
|
* Navigation for a launcher's mini-apps, in either mode. In `windowed` mode,
|
|
@@ -52,7 +41,7 @@ interface LauncherNavigationProviderProps extends PropsWithChildren {
|
|
|
52
41
|
* {@link WindowStateProvider}); in `routed` mode it navigates the browser to
|
|
53
42
|
* the app's route, `/app/<app id>/…`, which the routed shell shows.
|
|
54
43
|
*/
|
|
55
|
-
export declare function LauncherNavigationProvider({ children, defaultWindowEnabled, definition, mode, }: LauncherNavigationProviderProps): import("react").JSX.Element;
|
|
44
|
+
export declare function LauncherNavigationProvider({ children, defaultWindowEnabled, definition, mode, placeWindow, }: LauncherNavigationProviderProps): import("react").JSX.Element;
|
|
56
45
|
export declare const useLauncherNavigationActions: () => LauncherNavigationActions<string>;
|
|
57
46
|
export declare const useLauncherNavigationState: () => LauncherNavigationState<string>;
|
|
58
47
|
export declare const useOptionalLauncherNavigationState: () => LauncherNavigationState<string> | null;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useEffect, useMemo, useRef, useState, } from "react";
|
|
3
3
|
import { createRequiredContext } from "../createRequiredContext.js";
|
|
4
|
-
import {
|
|
4
|
+
import { useWindowActions, useWindowStateData, } from "../window/WindowStateProvider/index.js";
|
|
5
5
|
import { useMiniAppWindowRouteSegments } from "./MiniAppRouteSegmentsContext.js";
|
|
6
6
|
import { DEFAULT_NAVIGATION_HISTORY_CURSOR, getNavigationHistoryAvailability, readNavigationHistoryCursor, } from "./navigationHistory.js";
|
|
7
|
+
import { openMiniAppWindow, } from "./openMiniAppWindow.js";
|
|
7
8
|
import { replaceWindowHistoryCursor, useRoutedPathNavigator, } from "./routedPathNavigator.js";
|
|
8
9
|
import { buildMiniAppPath, LAUNCHER_HOME_PATH, parseLauncherRoute, } from "./routePaths.js";
|
|
9
10
|
import { useDefaultWindow } from "./useDefaultWindow.js";
|
|
10
|
-
/** Where a new window opens when a request names no position. */
|
|
11
|
-
export const DEFAULT_MINI_APP_POSITION = { x: 200, y: 160 };
|
|
12
11
|
const launcherNavigationActionsContext = createRequiredContext("useLauncherNavigationActions requires LauncherNavigationProvider.");
|
|
13
12
|
const launcherNavigationStateContext = createRequiredContext("useLauncherNavigationState requires LauncherNavigationProvider.");
|
|
14
13
|
const EMPTY_ROUTE_SEGMENTS = [];
|
|
@@ -26,7 +25,7 @@ function ensureWindowHistoryCursor() {
|
|
|
26
25
|
}
|
|
27
26
|
return cursor;
|
|
28
27
|
}
|
|
29
|
-
function LauncherNavigationWindowRuntimeBridge({ defaultWindowEnabled, definition, mode, openMiniApp, runtimeRef, }) {
|
|
28
|
+
function LauncherNavigationWindowRuntimeBridge({ defaultWindowEnabled, definition, mode, openMiniApp, placeWindow, runtimeRef, }) {
|
|
30
29
|
const { bringToFront, create, restore, updateRoute } = useWindowActions();
|
|
31
30
|
const { windows } = useWindowStateData();
|
|
32
31
|
useEffect(() => {
|
|
@@ -34,6 +33,7 @@ function LauncherNavigationWindowRuntimeBridge({ defaultWindowEnabled, definitio
|
|
|
34
33
|
actions: { bringToFront, create, restore, updateRoute },
|
|
35
34
|
definition,
|
|
36
35
|
mode,
|
|
36
|
+
placeWindow,
|
|
37
37
|
windows,
|
|
38
38
|
};
|
|
39
39
|
}, [
|
|
@@ -41,6 +41,7 @@ function LauncherNavigationWindowRuntimeBridge({ defaultWindowEnabled, definitio
|
|
|
41
41
|
create,
|
|
42
42
|
definition,
|
|
43
43
|
mode,
|
|
44
|
+
placeWindow,
|
|
44
45
|
restore,
|
|
45
46
|
runtimeRef,
|
|
46
47
|
updateRoute,
|
|
@@ -127,34 +128,19 @@ function useLauncherRouteController({ definition, mode, runtimeRef, }) {
|
|
|
127
128
|
};
|
|
128
129
|
}
|
|
129
130
|
function useLauncherNavigationActionValue(runtimeRef, goBack, goForward, navigateHome, navigateMiniAppRoute) {
|
|
130
|
-
const openMiniApp = useCallback((
|
|
131
|
-
const { actions, definition, mode
|
|
132
|
-
if (
|
|
131
|
+
const openMiniApp = useCallback((request) => {
|
|
132
|
+
const { actions, definition, mode, placeWindow, windows } = runtimeRef.current;
|
|
133
|
+
if (mode === "routed") {
|
|
134
|
+
const { appId, pathSegments } = request;
|
|
133
135
|
navigateMiniAppRoute({ appId, pathSegments });
|
|
134
136
|
return null;
|
|
135
137
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
actions.restore(existingWindow.id);
|
|
143
|
-
actions.bringToFront(existingWindow.id);
|
|
144
|
-
if (pathSegments) {
|
|
145
|
-
actions.updateRoute(existingWindow.id, pathSegments);
|
|
146
|
-
}
|
|
147
|
-
return existingWindow.id;
|
|
148
|
-
}
|
|
149
|
-
const app = definition.apps[appId];
|
|
150
|
-
if (!app) {
|
|
151
|
-
throw new Error(`Unknown mini-app: ${appId}`);
|
|
152
|
-
}
|
|
153
|
-
return actions.create(app.title, position.x, position.y, app.createComponent(), {
|
|
154
|
-
appId,
|
|
155
|
-
initialShowSidebar: app.initialShowSidebar,
|
|
156
|
-
...(pathSegments ? { pathSegments } : {}),
|
|
157
|
-
...(app.windowSize ? { size: app.windowSize } : {}),
|
|
138
|
+
return openMiniAppWindow({
|
|
139
|
+
actions,
|
|
140
|
+
definition,
|
|
141
|
+
placeWindow,
|
|
142
|
+
request,
|
|
143
|
+
windows,
|
|
158
144
|
});
|
|
159
145
|
}, [navigateMiniAppRoute, runtimeRef]);
|
|
160
146
|
const getMiniAppHref = useCallback(buildMiniAppPath, []);
|
|
@@ -180,7 +166,7 @@ function useLauncherNavigationActionValue(runtimeRef, goBack, goForward, navigat
|
|
|
180
166
|
* {@link WindowStateProvider}); in `routed` mode it navigates the browser to
|
|
181
167
|
* the app's route, `/app/<app id>/…`, which the routed shell shows.
|
|
182
168
|
*/
|
|
183
|
-
export function LauncherNavigationProvider({ children, defaultWindowEnabled = true, definition, mode, }) {
|
|
169
|
+
export function LauncherNavigationProvider({ children, defaultWindowEnabled = true, definition, mode, placeWindow, }) {
|
|
184
170
|
const runtimeRef = useRef({
|
|
185
171
|
actions: {
|
|
186
172
|
bringToFront: () => { },
|
|
@@ -190,6 +176,7 @@ export function LauncherNavigationProvider({ children, defaultWindowEnabled = tr
|
|
|
190
176
|
},
|
|
191
177
|
definition,
|
|
192
178
|
mode,
|
|
179
|
+
placeWindow,
|
|
193
180
|
windows: [],
|
|
194
181
|
});
|
|
195
182
|
const { goBack, goForward, history, navigateHome, navigateMiniAppRoute, route, } = useLauncherRouteController({
|
|
@@ -199,7 +186,7 @@ export function LauncherNavigationProvider({ children, defaultWindowEnabled = tr
|
|
|
199
186
|
});
|
|
200
187
|
const actions = useLauncherNavigationActionValue(runtimeRef, goBack, goForward, navigateHome, navigateMiniAppRoute);
|
|
201
188
|
const state = useMemo(() => ({ definition, history, mode, route }), [definition, history, mode, route]);
|
|
202
|
-
return (_jsx(launcherNavigationActionsContext.context.Provider, { value: actions, children: _jsxs(launcherNavigationStateContext.context.Provider, { value: state, children: [_jsx(LauncherNavigationWindowRuntimeBridge, { defaultWindowEnabled: defaultWindowEnabled, definition: definition, mode: mode, openMiniApp: actions.openMiniApp, runtimeRef: runtimeRef }), children] }) }));
|
|
189
|
+
return (_jsx(launcherNavigationActionsContext.context.Provider, { value: actions, children: _jsxs(launcherNavigationStateContext.context.Provider, { value: state, children: [_jsx(LauncherNavigationWindowRuntimeBridge, { defaultWindowEnabled: defaultWindowEnabled, definition: definition, mode: mode, openMiniApp: actions.openMiniApp, placeWindow: placeWindow, runtimeRef: runtimeRef }), children] }) }));
|
|
203
190
|
}
|
|
204
191
|
// The context names apps by their string ids. The actions accept a host's own
|
|
205
192
|
// narrower id type as they are; a host narrows the route's id with
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LauncherNavigationProvider.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/launcher/LauncherNavigationProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAGL,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,kBAAkB,GAGnB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,6BAA6B,EAAE,MAAM,+BAA+B,CAAC;AAC9E,OAAO,EACL,iCAAiC,EACjC,gCAAgC,EAGhC,2BAA2B,GAC5B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAElB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,iEAAiE;AACjE,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC;AAsD5D,MAAM,gCAAgC,GACpC,qBAAqB,CACnB,mEAAmE,CACpE,CAAC;AACJ,MAAM,8BAA8B,GAClC,qBAAqB,CACnB,iEAA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,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;IACrD,CAAC,EACD,CAAC,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,qBAAqB,CAAC,CACxD,CAAC;IACF,6EAA6E;IAC7E,6EAA6E;IAC7E,0EAA0E;IAC1E,8EAA8E;IAC9E,kBAAkB;IAClB,MAAM,YAAY,GAAG,WAAW,EAAE,MAAM,CAAC;IACzC,MAAM,SAAS,GAAG,cAAc;QAC9B,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS;QACzB,CAAC,CAAC,CAAC,WAAW,EAAE,SAAS,IAAI,KAAK,CAAC,CAAC;IACtC,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,EAAE;QAC9B,IAAI,cAAc,EAAE,CAAC;YACnB,OAAO,EAAE,MAAM,EAAE,CAAC;YAClB,OAAO;QACT,CAAC;QAED,YAAY,EAAE,EAAE,CAAC;IACnB,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC,CAAC;IAE5C,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC;QACL,SAAS;QACT,MAAM;QACN,QAAQ;QACR,YAAY;QACZ,eAAe;KAChB,CAAC,EACF,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,eAAe,CAAC,CAC7D,CAAC;AACJ,CAAC","sourcesContent":["import {\n type MutableRefObject,\n type PropsWithChildren,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { createRequiredContext } from \"../createRequiredContext\";\nimport {\n findTopWindow,\n useWindowActions,\n useWindowStateData,\n type WindowStateActions,\n type WindowStateData,\n} from \"../window/WindowStateProvider\";\nimport type { LauncherDefinition } from \"./launcherDefinition\";\nimport { useMiniAppWindowRouteSegments } from \"./MiniAppRouteSegmentsContext\";\nimport {\n DEFAULT_NAVIGATION_HISTORY_CURSOR,\n getNavigationHistoryAvailability,\n type NavigationHistoryAvailability,\n type NavigationHistoryCursor,\n readNavigationHistoryCursor,\n} from \"./navigationHistory\";\nimport type { NavigationMode } from \"./navigationMode\";\nimport {\n replaceWindowHistoryCursor,\n useRoutedPathNavigator,\n} from \"./routedPathNavigator\";\nimport {\n buildMiniAppPath,\n LAUNCHER_HOME_PATH,\n type LauncherRoute,\n parseLauncherRoute,\n} from \"./routePaths\";\nimport { useDefaultWindow } from \"./useDefaultWindow\";\n\n/** Where a new window opens when a request names no position. */\nexport const DEFAULT_MINI_APP_POSITION = { x: 200, y: 160 };\n\n/** A request to show an app: in a window, or as the routed shell's page. */\nexport interface OpenMiniAppRequest<AppId extends string = string> {\n appId: AppId;\n pathSegments?: ReadonlyArray<string> | undefined;\n /** Where a new window opens. */\n position?: { x: number; y: number } | undefined;\n /** Raise the app's open window instead of opening another. Defaults to true. */\n reuseExisting?: boolean | undefined;\n}\n\nexport interface LauncherNavigationActions<AppId extends string = string> {\n getMiniAppHref: (\n appId: AppId,\n pathSegments?: ReadonlyArray<string> | undefined,\n ) => string;\n goBack: () => void;\n goForward: () => void;\n navigateMiniAppRoute: (input: {\n appId: AppId;\n pathSegments?: ReadonlyArray<string> | undefined;\n replace?: boolean | undefined;\n }) => void;\n navigateHome: (input?: { replace?: boolean | undefined }) => void;\n // Returns the window the app opened in or was raised to, or null when the\n // routed shell shows it instead.\n openMiniApp: (request: OpenMiniAppRequest<AppId>) => string | null;\n}\n\nexport interface LauncherNavigationState<AppId extends string = string> {\n definition: LauncherDefinition<AppId>;\n history: NavigationHistoryAvailability;\n mode: NavigationMode;\n route: LauncherRoute<AppId>;\n}\n\ninterface LauncherNavigationProviderProps extends PropsWithChildren {\n /** Defers the default window while false, for example in a hidden workspace. */\n defaultWindowEnabled?: boolean | undefined;\n definition: LauncherDefinition;\n mode: NavigationMode;\n}\n\ninterface LauncherNavigationRuntime {\n actions: Pick<\n WindowStateActions,\n \"bringToFront\" | \"create\" | \"restore\" | \"updateRoute\"\n >;\n definition: LauncherDefinition;\n mode: NavigationMode;\n windows: WindowStateData[\"windows\"];\n}\n\nconst launcherNavigationActionsContext =\n createRequiredContext<LauncherNavigationActions>(\n \"useLauncherNavigationActions requires LauncherNavigationProvider.\",\n );\nconst launcherNavigationStateContext =\n createRequiredContext<LauncherNavigationState>(\n \"useLauncherNavigationState requires LauncherNavigationProvider.\",\n );\nconst EMPTY_ROUTE_SEGMENTS: ReadonlyArray<string> = [];\n\nfunction readCurrentRoute(definition: LauncherDefinition): LauncherRoute {\n return parseLauncherRoute(window.location.pathname, definition);\n}\n\nfunction readWindowHistoryCursor(): NavigationHistoryCursor {\n return (\n readNavigationHistoryCursor(window.history.state) ??\n DEFAULT_NAVIGATION_HISTORY_CURSOR\n );\n}\n\nfunction ensureWindowHistoryCursor(): NavigationHistoryCursor {\n const cursor = readWindowHistoryCursor();\n if (readNavigationHistoryCursor(window.history.state) === null) {\n replaceWindowHistoryCursor(cursor);\n }\n\n return cursor;\n}\n\nfunction LauncherNavigationWindowRuntimeBridge({\n defaultWindowEnabled,\n definition,\n mode,\n openMiniApp,\n runtimeRef,\n}: {\n defaultWindowEnabled: boolean;\n definition: LauncherDefinition;\n mode: NavigationMode;\n openMiniApp: LauncherNavigationActions[\"openMiniApp\"];\n runtimeRef: MutableRefObject<LauncherNavigationRuntime>;\n}) {\n const { bringToFront, create, restore, updateRoute } = useWindowActions();\n const { windows } = useWindowStateData();\n\n useEffect(() => {\n runtimeRef.current = {\n actions: { bringToFront, create, restore, updateRoute },\n definition,\n mode,\n windows,\n };\n }, [\n bringToFront,\n create,\n definition,\n mode,\n restore,\n runtimeRef,\n updateRoute,\n windows,\n ]);\n\n useDefaultWindow({\n definition,\n enabled: defaultWindowEnabled,\n mode,\n openMiniApp,\n windowCount: windows.length,\n });\n\n return null;\n}\n\nfunction useLauncherRouteController({\n definition,\n mode,\n runtimeRef,\n}: {\n definition: LauncherDefinition;\n mode: NavigationMode;\n runtimeRef: MutableRefObject<LauncherNavigationRuntime>;\n}) {\n const [route, setRoute] = useState<LauncherRoute>(() =>\n readCurrentRoute(definition),\n );\n const [historyCursor, setHistoryCursorState] =\n useState<NavigationHistoryCursor>(readWindowHistoryCursor);\n const historyCursorRef = useRef(historyCursor);\n const setHistoryCursor = useCallback((cursor: NavigationHistoryCursor) => {\n historyCursorRef.current = cursor;\n setHistoryCursorState(cursor);\n }, []);\n const navigateRoutedPath = useRoutedPathNavigator({\n historyCursorRef,\n runtimeRef,\n setHistoryCursor,\n setRoute,\n });\n\n useEffect(() => {\n if (mode !== \"routed\") {\n return;\n }\n\n const handlePopState = (event: PopStateEvent) => {\n setHistoryCursor(\n readNavigationHistoryCursor(event.state) ??\n DEFAULT_NAVIGATION_HISTORY_CURSOR,\n );\n setRoute(readCurrentRoute(runtimeRef.current.definition));\n };\n\n setHistoryCursor(ensureWindowHistoryCursor());\n setRoute(readCurrentRoute(runtimeRef.current.definition));\n window.addEventListener(\"popstate\", handlePopState);\n return () => window.removeEventListener(\"popstate\", handlePopState);\n }, [mode, runtimeRef, setHistoryCursor]);\n\n const navigateMiniAppRoute = useCallback(\n ({\n appId,\n pathSegments = [],\n replace = false,\n }: {\n appId: string;\n pathSegments?: ReadonlyArray<string> | undefined;\n replace?: boolean | undefined;\n }) => {\n navigateRoutedPath({\n path: buildMiniAppPath(appId, pathSegments),\n replace,\n route: { appId, pathSegments: [...pathSegments] },\n });\n },\n [navigateRoutedPath],\n );\n const navigateHome = useCallback(\n ({ replace = false }: { replace?: boolean | undefined } = {}) => {\n navigateRoutedPath({\n path: LAUNCHER_HOME_PATH,\n replace,\n route: { appId: null, pathSegments: [] },\n });\n },\n [navigateRoutedPath],\n );\n\n const goBack = useCallback(() => {\n if (historyCursorRef.current.index > 0) {\n setHistoryCursor({\n ...historyCursorRef.current,\n index: historyCursorRef.current.index - 1,\n });\n window.history.back();\n }\n }, [setHistoryCursor]);\n const goForward = useCallback(() => {\n const { entries, index } = historyCursorRef.current;\n if (index < entries - 1) {\n setHistoryCursor({\n ...historyCursorRef.current,\n index: index + 1,\n });\n window.history.forward();\n }\n }, [setHistoryCursor]);\n const history = useMemo(\n () => getNavigationHistoryAvailability(historyCursor),\n [historyCursor],\n );\n\n return {\n goBack,\n goForward,\n history,\n navigateHome,\n navigateMiniAppRoute,\n route,\n };\n}\n\nfunction useLauncherNavigationActionValue(\n runtimeRef: MutableRefObject<LauncherNavigationRuntime>,\n goBack: LauncherNavigationActions[\"goBack\"],\n goForward: LauncherNavigationActions[\"goForward\"],\n navigateHome: LauncherNavigationActions[\"navigateHome\"],\n navigateMiniAppRoute: LauncherNavigationActions[\"navigateMiniAppRoute\"],\n): LauncherNavigationActions {\n const openMiniApp = useCallback(\n ({\n appId,\n pathSegments,\n position = DEFAULT_MINI_APP_POSITION,\n reuseExisting = true,\n }: OpenMiniAppRequest) => {\n const {\n actions,\n definition,\n mode: currentMode,\n windows: currentWindows,\n } = runtimeRef.current;\n\n if (currentMode === \"routed\") {\n navigateMiniAppRoute({ appId, pathSegments });\n return null;\n }\n\n const existingWindow = reuseExisting\n ? findTopWindow(currentWindows, (windowEntry) => {\n return windowEntry.appId === appId;\n })\n : null;\n if (existingWindow) {\n actions.restore(existingWindow.id);\n actions.bringToFront(existingWindow.id);\n if (pathSegments) {\n actions.updateRoute(existingWindow.id, pathSegments);\n }\n return existingWindow.id;\n }\n\n const app = definition.apps[appId];\n if (!app) {\n throw new Error(`Unknown mini-app: ${appId}`);\n }\n return actions.create(\n app.title,\n position.x,\n position.y,\n app.createComponent(),\n {\n appId,\n initialShowSidebar: app.initialShowSidebar,\n ...(pathSegments ? { pathSegments } : {}),\n ...(app.windowSize ? { size: app.windowSize } : {}),\n },\n );\n },\n [navigateMiniAppRoute, runtimeRef],\n );\n const getMiniAppHref = useCallback(buildMiniAppPath, []);\n return useMemo<LauncherNavigationActions>(\n () => ({\n getMiniAppHref,\n goBack,\n goForward,\n navigateHome,\n navigateMiniAppRoute,\n openMiniApp,\n }),\n [\n getMiniAppHref,\n goBack,\n goForward,\n navigateHome,\n navigateMiniAppRoute,\n openMiniApp,\n ],\n );\n}\n\n/**\n * Navigation for a launcher's mini-apps, in either mode. In `windowed` mode,\n * opening an app opens or raises its window (inside a\n * {@link WindowStateProvider}); in `routed` mode it navigates the browser to\n * the app's route, `/app/<app id>/…`, which the routed shell shows.\n */\nexport function LauncherNavigationProvider({\n children,\n defaultWindowEnabled = true,\n definition,\n mode,\n}: LauncherNavigationProviderProps) {\n const runtimeRef = useRef<LauncherNavigationRuntime>({\n actions: {\n bringToFront: () => {},\n create: () => \"\",\n restore: () => {},\n updateRoute: () => {},\n },\n definition,\n mode,\n windows: [],\n });\n const {\n goBack,\n goForward,\n history,\n navigateHome,\n navigateMiniAppRoute,\n route,\n } = useLauncherRouteController({\n definition,\n mode,\n runtimeRef,\n });\n const actions = useLauncherNavigationActionValue(\n runtimeRef,\n goBack,\n goForward,\n navigateHome,\n navigateMiniAppRoute,\n );\n const state = useMemo<LauncherNavigationState>(\n () => ({ definition, history, mode, route }),\n [definition, history, mode, route],\n );\n\n return (\n <launcherNavigationActionsContext.context.Provider value={actions}>\n <launcherNavigationStateContext.context.Provider value={state}>\n <LauncherNavigationWindowRuntimeBridge\n defaultWindowEnabled={defaultWindowEnabled}\n definition={definition}\n mode={mode}\n openMiniApp={actions.openMiniApp}\n runtimeRef={runtimeRef}\n />\n {children}\n </launcherNavigationStateContext.context.Provider>\n </launcherNavigationActionsContext.context.Provider>\n );\n}\n\n// The context names apps by their string ids. The actions accept a host's own\n// narrower id type as they are; a host narrows the route's id with\n// isLauncherAppId (or its own guard) to read it back as that type.\nexport const useLauncherNavigationActions =\n launcherNavigationActionsContext.useRequired;\n\nexport const useLauncherNavigationState =\n launcherNavigationStateContext.useRequired;\n\nexport const useOptionalLauncherNavigationState =\n launcherNavigationStateContext.useOptional;\n\n/**\n * The route of `appId` where it is hosted: the browser route in the routed\n * shell, or its window's own route and Back stack in a window. Mini-apps read\n * this rather than branching on navigation mode.\n */\nexport function useMiniAppRouteSegments(appId: string) {\n const actions = launcherNavigationActionsContext.useOptional();\n const state = launcherNavigationStateContext.useOptional();\n const windowRoute = useMiniAppWindowRouteSegments(appId);\n const isGlobalRouted = actions !== null && state?.mode === \"routed\";\n const isRouted = isGlobalRouted || windowRoute !== null;\n const pathSegments =\n isGlobalRouted && state.route.appId === appId\n ? state.route.pathSegments\n : (windowRoute?.pathSegments ?? EMPTY_ROUTE_SEGMENTS);\n const windowSetPathSegments = windowRoute?.setPathSegments;\n const setPathSegments = useCallback(\n (\n nextPathSegments: ReadonlyArray<string>,\n options: { replace?: boolean | undefined } = {},\n ) => {\n if (isGlobalRouted) {\n actions?.navigateMiniAppRoute({\n appId,\n pathSegments: nextPathSegments,\n ...(options.replace === undefined\n ? {}\n : { replace: options.replace }),\n });\n return;\n }\n\n windowSetPathSegments?.(nextPathSegments, options);\n },\n [actions, appId, isGlobalRouted, windowSetPathSegments],\n );\n // \"Can this mini-app step back where it is hosted?\" — browser history in the\n // routed shell, the window's own Back stack in a window. Mini-apps read this\n // rather than branching on navigation mode, so a detail surface that must\n // yield to a real Back affordance asks one question and gets the right answer\n // in both shells.\n const windowGoBack = windowRoute?.goBack;\n const canGoBack = isGlobalRouted\n ? state.history.canGoBack\n : (windowRoute?.canGoBack ?? false);\n const goBack = useCallback(() => {\n if (isGlobalRouted) {\n actions?.goBack();\n return;\n }\n\n windowGoBack?.();\n }, [actions, isGlobalRouted, windowGoBack]);\n\n return useMemo(\n () => ({\n canGoBack,\n goBack,\n isRouted,\n pathSegments,\n setPathSegments,\n }),\n [canGoBack, goBack, isRouted, pathSegments, setPathSegments],\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"LauncherNavigationProvider.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/launcher/LauncherNavigationProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAGL,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,qBAAqB,EAAE,MAAM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,SAAS,IAAI,KAAK,CAAC,CAAC;IACtC,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,EAAE;QAC9B,IAAI,cAAc,EAAE,CAAC;YACnB,OAAO,EAAE,MAAM,EAAE,CAAC;YAClB,OAAO;QACT,CAAC;QAED,YAAY,EAAE,EAAE,CAAC;IACnB,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC,CAAC;IAE5C,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC;QACL,SAAS;QACT,MAAM;QACN,QAAQ;QACR,YAAY;QACZ,eAAe;KAChB,CAAC,EACF,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,eAAe,CAAC,CAC7D,CAAC;AACJ,CAAC","sourcesContent":["import {\n type MutableRefObject,\n type PropsWithChildren,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { createRequiredContext } from \"../createRequiredContext\";\nimport {\n useWindowActions,\n useWindowStateData,\n type WindowStateActions,\n type WindowStateData,\n} from \"../window/WindowStateProvider\";\nimport type { LauncherDefinition } from \"./launcherDefinition\";\nimport { useMiniAppWindowRouteSegments } from \"./MiniAppRouteSegmentsContext\";\nimport {\n DEFAULT_NAVIGATION_HISTORY_CURSOR,\n getNavigationHistoryAvailability,\n type NavigationHistoryAvailability,\n type NavigationHistoryCursor,\n readNavigationHistoryCursor,\n} from \"./navigationHistory\";\nimport type { NavigationMode } from \"./navigationMode\";\nimport {\n type OpenMiniAppRequest,\n openMiniAppWindow,\n type PlaceMiniAppWindow,\n} from \"./openMiniAppWindow\";\nimport {\n replaceWindowHistoryCursor,\n useRoutedPathNavigator,\n} from \"./routedPathNavigator\";\nimport {\n buildMiniAppPath,\n LAUNCHER_HOME_PATH,\n type LauncherRoute,\n parseLauncherRoute,\n} from \"./routePaths\";\nimport { useDefaultWindow } from \"./useDefaultWindow\";\n\nexport interface LauncherNavigationActions<AppId extends string = string> {\n getMiniAppHref: (\n appId: AppId,\n pathSegments?: ReadonlyArray<string> | undefined,\n ) => string;\n goBack: () => void;\n goForward: () => void;\n navigateMiniAppRoute: (input: {\n appId: AppId;\n pathSegments?: ReadonlyArray<string> | undefined;\n replace?: boolean | undefined;\n }) => void;\n navigateHome: (input?: { replace?: boolean | undefined }) => void;\n // Returns the window the app opened in or was raised to, or null when the\n // routed shell shows it instead.\n openMiniApp: (request: OpenMiniAppRequest<AppId>) => string | null;\n}\n\nexport interface LauncherNavigationState<AppId extends string = string> {\n definition: LauncherDefinition<AppId>;\n history: NavigationHistoryAvailability;\n mode: NavigationMode;\n route: LauncherRoute<AppId>;\n}\n\ninterface LauncherNavigationProviderProps extends PropsWithChildren {\n /** Defers the default windows while false, for example in a hidden workspace. */\n defaultWindowEnabled?: boolean | undefined;\n definition: LauncherDefinition;\n mode: NavigationMode;\n /**\n * Places each new window, for a host that opens its apps at their own\n * positions or sizes. Read when a window opens.\n */\n placeWindow?: PlaceMiniAppWindow | undefined;\n}\n\ninterface LauncherNavigationRuntime {\n actions: Pick<\n WindowStateActions,\n \"bringToFront\" | \"create\" | \"restore\" | \"updateRoute\"\n >;\n definition: LauncherDefinition;\n mode: NavigationMode;\n placeWindow: PlaceMiniAppWindow | undefined;\n windows: WindowStateData[\"windows\"];\n}\n\nconst launcherNavigationActionsContext =\n createRequiredContext<LauncherNavigationActions>(\n \"useLauncherNavigationActions requires LauncherNavigationProvider.\",\n );\nconst launcherNavigationStateContext =\n createRequiredContext<LauncherNavigationState>(\n \"useLauncherNavigationState requires LauncherNavigationProvider.\",\n );\nconst EMPTY_ROUTE_SEGMENTS: ReadonlyArray<string> = [];\n\nfunction readCurrentRoute(definition: LauncherDefinition): LauncherRoute {\n return parseLauncherRoute(window.location.pathname, definition);\n}\n\nfunction readWindowHistoryCursor(): NavigationHistoryCursor {\n return (\n readNavigationHistoryCursor(window.history.state) ??\n DEFAULT_NAVIGATION_HISTORY_CURSOR\n );\n}\n\nfunction ensureWindowHistoryCursor(): NavigationHistoryCursor {\n const cursor = readWindowHistoryCursor();\n if (readNavigationHistoryCursor(window.history.state) === null) {\n replaceWindowHistoryCursor(cursor);\n }\n\n return cursor;\n}\n\nfunction LauncherNavigationWindowRuntimeBridge({\n defaultWindowEnabled,\n definition,\n mode,\n openMiniApp,\n placeWindow,\n runtimeRef,\n}: {\n defaultWindowEnabled: boolean;\n definition: LauncherDefinition;\n mode: NavigationMode;\n openMiniApp: LauncherNavigationActions[\"openMiniApp\"];\n placeWindow: PlaceMiniAppWindow | undefined;\n runtimeRef: MutableRefObject<LauncherNavigationRuntime>;\n}) {\n const { bringToFront, create, restore, updateRoute } = useWindowActions();\n const { windows } = useWindowStateData();\n\n useEffect(() => {\n runtimeRef.current = {\n actions: { bringToFront, create, restore, updateRoute },\n definition,\n mode,\n placeWindow,\n windows,\n };\n }, [\n bringToFront,\n create,\n definition,\n mode,\n placeWindow,\n restore,\n runtimeRef,\n updateRoute,\n windows,\n ]);\n\n useDefaultWindow({\n definition,\n enabled: defaultWindowEnabled,\n mode,\n openMiniApp,\n windowCount: windows.length,\n });\n\n return null;\n}\n\nfunction useLauncherRouteController({\n definition,\n mode,\n runtimeRef,\n}: {\n definition: LauncherDefinition;\n mode: NavigationMode;\n runtimeRef: MutableRefObject<LauncherNavigationRuntime>;\n}) {\n const [route, setRoute] = useState<LauncherRoute>(() =>\n readCurrentRoute(definition),\n );\n const [historyCursor, setHistoryCursorState] =\n useState<NavigationHistoryCursor>(readWindowHistoryCursor);\n const historyCursorRef = useRef(historyCursor);\n const setHistoryCursor = useCallback((cursor: NavigationHistoryCursor) => {\n historyCursorRef.current = cursor;\n setHistoryCursorState(cursor);\n }, []);\n const navigateRoutedPath = useRoutedPathNavigator({\n historyCursorRef,\n runtimeRef,\n setHistoryCursor,\n setRoute,\n });\n\n useEffect(() => {\n if (mode !== \"routed\") {\n return;\n }\n\n const handlePopState = (event: PopStateEvent) => {\n setHistoryCursor(\n readNavigationHistoryCursor(event.state) ??\n DEFAULT_NAVIGATION_HISTORY_CURSOR,\n );\n setRoute(readCurrentRoute(runtimeRef.current.definition));\n };\n\n setHistoryCursor(ensureWindowHistoryCursor());\n setRoute(readCurrentRoute(runtimeRef.current.definition));\n window.addEventListener(\"popstate\", handlePopState);\n return () => window.removeEventListener(\"popstate\", handlePopState);\n }, [mode, runtimeRef, setHistoryCursor]);\n\n const navigateMiniAppRoute = useCallback(\n ({\n appId,\n pathSegments = [],\n replace = false,\n }: {\n appId: string;\n pathSegments?: ReadonlyArray<string> | undefined;\n replace?: boolean | undefined;\n }) => {\n navigateRoutedPath({\n path: buildMiniAppPath(appId, pathSegments),\n replace,\n route: { appId, pathSegments: [...pathSegments] },\n });\n },\n [navigateRoutedPath],\n );\n const navigateHome = useCallback(\n ({ replace = false }: { replace?: boolean | undefined } = {}) => {\n navigateRoutedPath({\n path: LAUNCHER_HOME_PATH,\n replace,\n route: { appId: null, pathSegments: [] },\n });\n },\n [navigateRoutedPath],\n );\n\n const goBack = useCallback(() => {\n if (historyCursorRef.current.index > 0) {\n setHistoryCursor({\n ...historyCursorRef.current,\n index: historyCursorRef.current.index - 1,\n });\n window.history.back();\n }\n }, [setHistoryCursor]);\n const goForward = useCallback(() => {\n const { entries, index } = historyCursorRef.current;\n if (index < entries - 1) {\n setHistoryCursor({\n ...historyCursorRef.current,\n index: index + 1,\n });\n window.history.forward();\n }\n }, [setHistoryCursor]);\n const history = useMemo(\n () => getNavigationHistoryAvailability(historyCursor),\n [historyCursor],\n );\n\n return {\n goBack,\n goForward,\n history,\n navigateHome,\n navigateMiniAppRoute,\n route,\n };\n}\n\nfunction useLauncherNavigationActionValue(\n runtimeRef: MutableRefObject<LauncherNavigationRuntime>,\n goBack: LauncherNavigationActions[\"goBack\"],\n goForward: LauncherNavigationActions[\"goForward\"],\n navigateHome: LauncherNavigationActions[\"navigateHome\"],\n navigateMiniAppRoute: LauncherNavigationActions[\"navigateMiniAppRoute\"],\n): LauncherNavigationActions {\n const openMiniApp = useCallback(\n (request: OpenMiniAppRequest) => {\n const { actions, definition, mode, placeWindow, windows } =\n runtimeRef.current;\n if (mode === \"routed\") {\n const { appId, pathSegments } = request;\n navigateMiniAppRoute({ appId, pathSegments });\n return null;\n }\n return openMiniAppWindow({\n actions,\n definition,\n placeWindow,\n request,\n windows,\n });\n },\n [navigateMiniAppRoute, runtimeRef],\n );\n const getMiniAppHref = useCallback(buildMiniAppPath, []);\n return useMemo<LauncherNavigationActions>(\n () => ({\n getMiniAppHref,\n goBack,\n goForward,\n navigateHome,\n navigateMiniAppRoute,\n openMiniApp,\n }),\n [\n getMiniAppHref,\n goBack,\n goForward,\n navigateHome,\n navigateMiniAppRoute,\n openMiniApp,\n ],\n );\n}\n\n/**\n * Navigation for a launcher's mini-apps, in either mode. In `windowed` mode,\n * opening an app opens or raises its window (inside a\n * {@link WindowStateProvider}); in `routed` mode it navigates the browser to\n * the app's route, `/app/<app id>/…`, which the routed shell shows.\n */\nexport function LauncherNavigationProvider({\n children,\n defaultWindowEnabled = true,\n definition,\n mode,\n placeWindow,\n}: LauncherNavigationProviderProps) {\n const runtimeRef = useRef<LauncherNavigationRuntime>({\n actions: {\n bringToFront: () => {},\n create: () => \"\",\n restore: () => {},\n updateRoute: () => {},\n },\n definition,\n mode,\n placeWindow,\n windows: [],\n });\n const {\n goBack,\n goForward,\n history,\n navigateHome,\n navigateMiniAppRoute,\n route,\n } = useLauncherRouteController({\n definition,\n mode,\n runtimeRef,\n });\n const actions = useLauncherNavigationActionValue(\n runtimeRef,\n goBack,\n goForward,\n navigateHome,\n navigateMiniAppRoute,\n );\n const state = useMemo<LauncherNavigationState>(\n () => ({ definition, history, mode, route }),\n [definition, history, mode, route],\n );\n\n return (\n <launcherNavigationActionsContext.context.Provider value={actions}>\n <launcherNavigationStateContext.context.Provider value={state}>\n <LauncherNavigationWindowRuntimeBridge\n defaultWindowEnabled={defaultWindowEnabled}\n definition={definition}\n mode={mode}\n openMiniApp={actions.openMiniApp}\n placeWindow={placeWindow}\n runtimeRef={runtimeRef}\n />\n {children}\n </launcherNavigationStateContext.context.Provider>\n </launcherNavigationActionsContext.context.Provider>\n );\n}\n\n// The context names apps by their string ids. The actions accept a host's own\n// narrower id type as they are; a host narrows the route's id with\n// isLauncherAppId (or its own guard) to read it back as that type.\nexport const useLauncherNavigationActions =\n launcherNavigationActionsContext.useRequired;\n\nexport const useLauncherNavigationState =\n launcherNavigationStateContext.useRequired;\n\nexport const useOptionalLauncherNavigationState =\n launcherNavigationStateContext.useOptional;\n\n/**\n * The route of `appId` where it is hosted: the browser route in the routed\n * shell, or its window's own route and Back stack in a window. Mini-apps read\n * this rather than branching on navigation mode.\n */\nexport function useMiniAppRouteSegments(appId: string) {\n const actions = launcherNavigationActionsContext.useOptional();\n const state = launcherNavigationStateContext.useOptional();\n const windowRoute = useMiniAppWindowRouteSegments(appId);\n const isGlobalRouted = actions !== null && state?.mode === \"routed\";\n const isRouted = isGlobalRouted || windowRoute !== null;\n const pathSegments =\n isGlobalRouted && state.route.appId === appId\n ? state.route.pathSegments\n : (windowRoute?.pathSegments ?? EMPTY_ROUTE_SEGMENTS);\n const windowSetPathSegments = windowRoute?.setPathSegments;\n const setPathSegments = useCallback(\n (\n nextPathSegments: ReadonlyArray<string>,\n options: { replace?: boolean | undefined } = {},\n ) => {\n if (isGlobalRouted) {\n actions?.navigateMiniAppRoute({\n appId,\n pathSegments: nextPathSegments,\n ...(options.replace === undefined\n ? {}\n : { replace: options.replace }),\n });\n return;\n }\n\n windowSetPathSegments?.(nextPathSegments, options);\n },\n [actions, appId, isGlobalRouted, windowSetPathSegments],\n );\n // \"Can this mini-app step back where it is hosted?\" — browser history in the\n // routed shell, the window's own Back stack in a window. Mini-apps read this\n // rather than branching on navigation mode, so a detail surface that must\n // yield to a real Back affordance asks one question and gets the right answer\n // in both shells.\n const windowGoBack = windowRoute?.goBack;\n const canGoBack = isGlobalRouted\n ? state.history.canGoBack\n : (windowRoute?.canGoBack ?? false);\n const goBack = useCallback(() => {\n if (isGlobalRouted) {\n actions?.goBack();\n return;\n }\n\n windowGoBack?.();\n }, [actions, isGlobalRouted, windowGoBack]);\n\n return useMemo(\n () => ({\n canGoBack,\n goBack,\n isRouted,\n pathSegments,\n setPathSegments,\n }),\n [canGoBack, goBack, isRouted, pathSegments, setPathSegments],\n );\n}\n"]}
|
|
@@ -25,16 +25,18 @@ export interface MiniAppDefinition {
|
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* A launcher application: the mini-apps it can open, the order its launchers
|
|
28
|
-
* list them in,
|
|
28
|
+
* list them in, the ones the windowed desktop opens on entry, and the one the
|
|
29
|
+
* routed shell shows at the root route.
|
|
29
30
|
*/
|
|
30
31
|
export interface LauncherDefinition<AppId extends string = string> {
|
|
31
32
|
apps: Readonly<Record<AppId, MiniAppDefinition>>;
|
|
32
33
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
34
|
+
* Open, in this order, when entering windowed mode with no windows,
|
|
35
|
+
* including on mount, so the last opens in front. Closing the last window
|
|
36
|
+
* leaves the desktop empty until the next entry. Omit to leave window
|
|
37
|
+
* startup to the host. Unknown app ids are skipped.
|
|
36
38
|
*/
|
|
37
|
-
|
|
39
|
+
defaultWindowAppIds?: ReadonlyArray<AppId> | undefined;
|
|
38
40
|
/** Shown at the root route. Defaults to the first app in `order`. */
|
|
39
41
|
homeAppId?: AppId | undefined;
|
|
40
42
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"launcherDefinition.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/launcher/launcherDefinition.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"launcherDefinition.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/launcher/launcherDefinition.ts"],"names":[],"mappings":"AAkDA,sEAAsE;AACtE,MAAM,UAAU,eAAe,CAC7B,UAAqC,EACrC,KAAgC;IAEhC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAC5E,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,oBAAoB,CAClC,UAAqC;IAErC,MAAM,KAAK,GACT,UAAU,CAAC,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACnD,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,eAAe,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC;AACrE,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,wBAAwB,CACtC,UAAqC;IAErC,IACE,UAAU,CAAC,SAAS,KAAK,SAAS;QAClC,eAAe,CAAC,UAAU,EAAE,UAAU,CAAC,SAAS,CAAC,EACjD,CAAC;QACD,OAAO,UAAU,CAAC,SAAS,CAAC;IAC9B,CAAC;IACD,OAAO,oBAAoB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;AACrD,CAAC","sourcesContent":["import type { ComponentType } from \"react\";\nimport type { WindowingIcon } from \"../icons/windowingIcon\";\nimport type { WindowSize } from \"../window/WindowStateProvider\";\n\n/** One app a launcher opens: in a window, or as the routed shell's page. */\nexport interface MiniAppDefinition {\n /**\n * Builds the app's component. A window calls it when it opens, and the\n * routed shell when it shows the app, so each gets its own component.\n */\n createComponent: () => ComponentType;\n /** The app's glyph in the launchers and the taskbar. */\n icon?: WindowingIcon | undefined;\n /**\n * Whether the app's sidebar starts shown, in a new window and on the routed\n * shell's tablet tier. Defaults to shown. The phone tier always starts with\n * the sidebar hidden.\n */\n initialShowSidebar?: boolean | undefined;\n title: string;\n /**\n * The size a new window opens at, in CSS pixels. Defaults to the\n * stylesheet's window size.\n */\n windowSize?: WindowSize | undefined;\n}\n\n/**\n * A launcher application: the mini-apps it can open, the order its launchers\n * list them in, the ones the windowed desktop opens on entry, and the one the\n * routed shell shows at the root route.\n */\nexport interface LauncherDefinition<AppId extends string = string> {\n apps: Readonly<Record<AppId, MiniAppDefinition>>;\n /**\n * Open, in this order, when entering windowed mode with no windows,\n * including on mount, so the last opens in front. Closing the last window\n * leaves the desktop empty until the next entry. Omit to leave window\n * startup to the host. Unknown app ids are skipped.\n */\n defaultWindowAppIds?: ReadonlyArray<AppId> | undefined;\n /** Shown at the root route. Defaults to the first app in `order`. */\n homeAppId?: AppId | undefined;\n /**\n * The order the launchers list the apps in. Ids with no app in `apps` are\n * skipped. Defaults to the order of `apps`' keys.\n */\n order?: ReadonlyArray<AppId> | undefined;\n}\n\n/** Narrows an opaque window `appId` to one of the launcher's apps. */\nexport function isLauncherAppId<AppId extends string>(\n definition: LauncherDefinition<AppId>,\n value: string | null | undefined,\n): value is AppId {\n return typeof value === \"string\" && Object.hasOwn(definition.apps, value);\n}\n\n/** The launcher's apps in the order its launchers list them. */\nexport function resolveLauncherOrder<AppId extends string>(\n definition: LauncherDefinition<AppId>,\n): ReadonlyArray<AppId> {\n const order: ReadonlyArray<string> =\n definition.order ?? Object.keys(definition.apps);\n return order.filter((appId) => isLauncherAppId(definition, appId));\n}\n\n/** The app the routed shell shows at the root route, if the launcher has any. */\nexport function resolveLauncherHomeAppId<AppId extends string>(\n definition: LauncherDefinition<AppId>,\n): AppId | null {\n if (\n definition.homeAppId !== undefined &&\n isLauncherAppId(definition, definition.homeAppId)\n ) {\n return definition.homeAppId;\n }\n return resolveLauncherOrder(definition)[0] ?? null;\n}\n"]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { type WindowSize, type WindowStateActions, type WindowStateData } from "../window/WindowStateProvider/index.js";
|
|
2
|
+
import type { LauncherDefinition } from "./launcherDefinition.js";
|
|
3
|
+
/** Where a new window opens when a request names no position. */
|
|
4
|
+
export declare const DEFAULT_MINI_APP_POSITION: {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
};
|
|
8
|
+
/** A request to show an app: in a window, or as the routed shell's page. */
|
|
9
|
+
export interface OpenMiniAppRequest<AppId extends string = string> {
|
|
10
|
+
appId: AppId;
|
|
11
|
+
pathSegments?: ReadonlyArray<string> | undefined;
|
|
12
|
+
/** Where a new window opens. */
|
|
13
|
+
position?: {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
} | undefined;
|
|
17
|
+
/** Raise the app's open window instead of opening another. Defaults to true. */
|
|
18
|
+
reuseExisting?: boolean | undefined;
|
|
19
|
+
}
|
|
20
|
+
/** Where a host opens a new window for an app, and how. */
|
|
21
|
+
export interface MiniAppWindowPlacement {
|
|
22
|
+
/**
|
|
23
|
+
* Open the window fitted to its content, once the content has loaded, as
|
|
24
|
+
* `create`'s `fitToContent` does.
|
|
25
|
+
*/
|
|
26
|
+
fitToContent?: boolean | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Where the window opens, in viewport pixels like a request's `position`.
|
|
29
|
+
* Defaults to the request's position.
|
|
30
|
+
*/
|
|
31
|
+
position?: {
|
|
32
|
+
x: number;
|
|
33
|
+
y: number;
|
|
34
|
+
} | undefined;
|
|
35
|
+
/** The window's size. Defaults to the app's `windowSize`. */
|
|
36
|
+
size?: WindowSize | undefined;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Places a new window: the host's own geometry for the app a request opens,
|
|
40
|
+
* read when the window opens.
|
|
41
|
+
*/
|
|
42
|
+
export type PlaceMiniAppWindow = (request: OpenMiniAppRequest) => MiniAppWindowPlacement;
|
|
43
|
+
/**
|
|
44
|
+
* Raises the app's open window or opens a new one where `placeWindow` puts
|
|
45
|
+
* it, else at the request's position or {@link DEFAULT_MINI_APP_POSITION},
|
|
46
|
+
* sized by the app's `windowSize`. Returns the window's id.
|
|
47
|
+
*/
|
|
48
|
+
export declare function openMiniAppWindow({ actions, definition, placeWindow, request, windows, }: {
|
|
49
|
+
actions: Pick<WindowStateActions, "bringToFront" | "create" | "restore" | "updateRoute">;
|
|
50
|
+
definition: LauncherDefinition;
|
|
51
|
+
placeWindow: PlaceMiniAppWindow | undefined;
|
|
52
|
+
request: OpenMiniAppRequest;
|
|
53
|
+
windows: WindowStateData["windows"];
|
|
54
|
+
}): string;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { findTopWindow, } from "../window/WindowStateProvider/index.js";
|
|
2
|
+
/** Where a new window opens when a request names no position. */
|
|
3
|
+
export const DEFAULT_MINI_APP_POSITION = { x: 200, y: 160 };
|
|
4
|
+
/**
|
|
5
|
+
* Raises the app's open window or opens a new one where `placeWindow` puts
|
|
6
|
+
* it, else at the request's position or {@link DEFAULT_MINI_APP_POSITION},
|
|
7
|
+
* sized by the app's `windowSize`. Returns the window's id.
|
|
8
|
+
*/
|
|
9
|
+
export function openMiniAppWindow({ actions, definition, placeWindow, request, windows, }) {
|
|
10
|
+
const { appId, pathSegments, reuseExisting = true } = request;
|
|
11
|
+
const existingWindow = reuseExisting
|
|
12
|
+
? findTopWindow(windows, (windowEntry) => windowEntry.appId === appId)
|
|
13
|
+
: null;
|
|
14
|
+
if (existingWindow) {
|
|
15
|
+
actions.restore(existingWindow.id);
|
|
16
|
+
actions.bringToFront(existingWindow.id);
|
|
17
|
+
if (pathSegments) {
|
|
18
|
+
actions.updateRoute(existingWindow.id, pathSegments);
|
|
19
|
+
}
|
|
20
|
+
return existingWindow.id;
|
|
21
|
+
}
|
|
22
|
+
const app = definition.apps[appId];
|
|
23
|
+
if (!app) {
|
|
24
|
+
throw new Error(`Unknown mini-app: ${appId}`);
|
|
25
|
+
}
|
|
26
|
+
const placement = placeWindow?.(request) ?? {};
|
|
27
|
+
const position = placement.position ?? request.position ?? DEFAULT_MINI_APP_POSITION;
|
|
28
|
+
const size = placement.size ?? app.windowSize;
|
|
29
|
+
return actions.create(app.title, position.x, position.y, app.createComponent(), {
|
|
30
|
+
appId,
|
|
31
|
+
initialShowSidebar: app.initialShowSidebar,
|
|
32
|
+
...(placement.fitToContent ? { fitToContent: true } : {}),
|
|
33
|
+
...(pathSegments ? { pathSegments } : {}),
|
|
34
|
+
...(size ? { size } : {}),
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=openMiniAppWindow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openMiniAppWindow.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/launcher/openMiniAppWindow.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,GAId,MAAM,+BAA+B,CAAC;AAGvC,iEAAiE;AACjE,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC;AAoC5D;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAChC,OAAO,EACP,UAAU,EACV,WAAW,EACX,OAAO,EACP,OAAO,GAUR;IACC,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,aAAa,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IAC9D,MAAM,cAAc,GAAG,aAAa;QAClC,CAAC,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,KAAK,KAAK,KAAK,CAAC;QACtE,CAAC,CAAC,IAAI,CAAC;IACT,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;QACnC,OAAO,CAAC,YAAY,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;QACxC,IAAI,YAAY,EAAE,CAAC;YACjB,OAAO,CAAC,WAAW,CAAC,cAAc,CAAC,EAAE,EAAE,YAAY,CAAC,CAAC;QACvD,CAAC;QACD,OAAO,cAAc,CAAC,EAAE,CAAC;IAC3B,CAAC;IAED,MAAM,GAAG,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACnC,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CAAC,qBAAqB,KAAK,EAAE,CAAC,CAAC;IAChD,CAAC;IACD,MAAM,SAAS,GAAG,WAAW,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IAC/C,MAAM,QAAQ,GACZ,SAAS,CAAC,QAAQ,IAAI,OAAO,CAAC,QAAQ,IAAI,yBAAyB,CAAC;IACtE,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,IAAI,GAAG,CAAC,UAAU,CAAC;IAC9C,OAAO,OAAO,CAAC,MAAM,CACnB,GAAG,CAAC,KAAK,EACT,QAAQ,CAAC,CAAC,EACV,QAAQ,CAAC,CAAC,EACV,GAAG,CAAC,eAAe,EAAE,EACrB;QACE,KAAK;QACL,kBAAkB,EAAE,GAAG,CAAC,kBAAkB;QAC1C,GAAG,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzD,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC1B,CACF,CAAC;AACJ,CAAC","sourcesContent":["import {\n findTopWindow,\n type WindowSize,\n type WindowStateActions,\n type WindowStateData,\n} from \"../window/WindowStateProvider\";\nimport type { LauncherDefinition } from \"./launcherDefinition\";\n\n/** Where a new window opens when a request names no position. */\nexport const DEFAULT_MINI_APP_POSITION = { x: 200, y: 160 };\n\n/** A request to show an app: in a window, or as the routed shell's page. */\nexport interface OpenMiniAppRequest<AppId extends string = string> {\n appId: AppId;\n pathSegments?: ReadonlyArray<string> | undefined;\n /** Where a new window opens. */\n position?: { x: number; y: number } | undefined;\n /** Raise the app's open window instead of opening another. Defaults to true. */\n reuseExisting?: boolean | undefined;\n}\n\n/** Where a host opens a new window for an app, and how. */\nexport interface MiniAppWindowPlacement {\n /**\n * Open the window fitted to its content, once the content has loaded, as\n * `create`'s `fitToContent` does.\n */\n fitToContent?: boolean | undefined;\n /**\n * Where the window opens, in viewport pixels like a request's `position`.\n * Defaults to the request's position.\n */\n position?: { x: number; y: number } | undefined;\n /** The window's size. Defaults to the app's `windowSize`. */\n size?: WindowSize | undefined;\n}\n\n/**\n * Places a new window: the host's own geometry for the app a request opens,\n * read when the window opens.\n */\nexport type PlaceMiniAppWindow = (\n request: OpenMiniAppRequest,\n) => MiniAppWindowPlacement;\n\n/**\n * Raises the app's open window or opens a new one where `placeWindow` puts\n * it, else at the request's position or {@link DEFAULT_MINI_APP_POSITION},\n * sized by the app's `windowSize`. Returns the window's id.\n */\nexport function openMiniAppWindow({\n actions,\n definition,\n placeWindow,\n request,\n windows,\n}: {\n actions: Pick<\n WindowStateActions,\n \"bringToFront\" | \"create\" | \"restore\" | \"updateRoute\"\n >;\n definition: LauncherDefinition;\n placeWindow: PlaceMiniAppWindow | undefined;\n request: OpenMiniAppRequest;\n windows: WindowStateData[\"windows\"];\n}): string {\n const { appId, pathSegments, reuseExisting = true } = request;\n const existingWindow = reuseExisting\n ? findTopWindow(windows, (windowEntry) => windowEntry.appId === appId)\n : null;\n if (existingWindow) {\n actions.restore(existingWindow.id);\n actions.bringToFront(existingWindow.id);\n if (pathSegments) {\n actions.updateRoute(existingWindow.id, pathSegments);\n }\n return existingWindow.id;\n }\n\n const app = definition.apps[appId];\n if (!app) {\n throw new Error(`Unknown mini-app: ${appId}`);\n }\n const placement = placeWindow?.(request) ?? {};\n const position =\n placement.position ?? request.position ?? DEFAULT_MINI_APP_POSITION;\n const size = placement.size ?? app.windowSize;\n return actions.create(\n app.title,\n position.x,\n position.y,\n app.createComponent(),\n {\n appId,\n initialShowSidebar: app.initialShowSidebar,\n ...(placement.fitToContent ? { fitToContent: true } : {}),\n ...(pathSegments ? { pathSegments } : {}),\n ...(size ? { size } : {}),\n },\n );\n}\n"]}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { type LauncherDefinition } from "./launcherDefinition.js";
|
|
2
2
|
import type { NavigationMode } from "./navigationMode.js";
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Opens the host's default windows, in order so the last is in front, once
|
|
5
|
+
* per entry into an empty windowed desktop.
|
|
6
|
+
*/
|
|
4
7
|
export declare function useDefaultWindow({ definition, enabled, mode, openMiniApp, windowCount, }: {
|
|
5
8
|
definition: LauncherDefinition;
|
|
6
9
|
enabled: boolean;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { useEffect, useRef } from "react";
|
|
2
2
|
import { isLauncherAppId } from "./launcherDefinition.js";
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Opens the host's default windows, in order so the last is in front, once
|
|
5
|
+
* per entry into an empty windowed desktop.
|
|
6
|
+
*/
|
|
4
7
|
export function useDefaultWindow({ definition, enabled, mode, openMiniApp, windowCount, }) {
|
|
5
8
|
const handledWindowedEntry = useRef(false);
|
|
6
9
|
useEffect(() => {
|
|
@@ -12,9 +15,13 @@ export function useDefaultWindow({ definition, enabled, mode, openMiniApp, windo
|
|
|
12
15
|
return;
|
|
13
16
|
// Record the entry before opening, including across StrictMode effects.
|
|
14
17
|
handledWindowedEntry.current = true;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
if (windowCount > 0)
|
|
19
|
+
return;
|
|
20
|
+
// Each app once: the launcher's open requests within this pass cannot see
|
|
21
|
+
// the windows the earlier ones created.
|
|
22
|
+
for (const appId of new Set(definition.defaultWindowAppIds)) {
|
|
23
|
+
if (isLauncherAppId(definition, appId))
|
|
24
|
+
openMiniApp({ appId });
|
|
18
25
|
}
|
|
19
26
|
}, [definition, enabled, mode, openMiniApp, windowCount]);
|
|
20
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDefaultWindow.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/launcher/useDefaultWindow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,eAAe,EAA2B,MAAM,sBAAsB,CAAC;AAGhF
|
|
1
|
+
{"version":3,"file":"useDefaultWindow.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/launcher/useDefaultWindow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,eAAe,EAA2B,MAAM,sBAAsB,CAAC;AAGhF;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAC/B,UAAU,EACV,OAAO,EACP,IAAI,EACJ,WAAW,EACX,WAAW,GAOZ;IACC,MAAM,oBAAoB,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAE3C,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,IAAI,KAAK,UAAU,EAAE,CAAC;YACxB,oBAAoB,CAAC,OAAO,GAAG,KAAK,CAAC;YACrC,OAAO;QACT,CAAC;QACD,IAAI,CAAC,OAAO,IAAI,oBAAoB,CAAC,OAAO;YAAE,OAAO;QACrD,wEAAwE;QACxE,oBAAoB,CAAC,OAAO,GAAG,IAAI,CAAC;QACpC,IAAI,WAAW,GAAG,CAAC;YAAE,OAAO;QAC5B,0EAA0E;QAC1E,wCAAwC;QACxC,KAAK,MAAM,KAAK,IAAI,IAAI,GAAG,CAAC,UAAU,CAAC,mBAAmB,CAAC,EAAE,CAAC;YAC5D,IAAI,eAAe,CAAC,UAAU,EAAE,KAAK,CAAC;gBAAE,WAAW,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QACjE,CAAC;IACH,CAAC,EAAE,CAAC,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC;AAC5D,CAAC","sourcesContent":["import { useEffect, useRef } from \"react\";\nimport { isLauncherAppId, type LauncherDefinition } from \"./launcherDefinition\";\nimport type { NavigationMode } from \"./navigationMode\";\n\n/**\n * Opens the host's default windows, in order so the last is in front, once\n * per entry into an empty windowed desktop.\n */\nexport function useDefaultWindow({\n definition,\n enabled,\n mode,\n openMiniApp,\n windowCount,\n}: {\n definition: LauncherDefinition;\n enabled: boolean;\n mode: NavigationMode;\n openMiniApp: (request: { appId: string }) => string | null;\n windowCount: number;\n}) {\n const handledWindowedEntry = useRef(false);\n\n useEffect(() => {\n if (mode !== \"windowed\") {\n handledWindowedEntry.current = false;\n return;\n }\n if (!enabled || handledWindowedEntry.current) return;\n // Record the entry before opening, including across StrictMode effects.\n handledWindowedEntry.current = true;\n if (windowCount > 0) return;\n // Each app once: the launcher's open requests within this pass cannot see\n // the windows the earlier ones created.\n for (const appId of new Set(definition.defaultWindowAppIds)) {\n if (isLauncherAppId(definition, appId)) openMiniApp({ appId });\n }\n }, [definition, enabled, mode, openMiniApp, windowCount]);\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tearleads/windowing",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.34",
|
|
4
4
|
"description": "App-agnostic window management for React: window state, window chrome, and the menu and sidebar primitives it renders with.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|
|
@@ -6,6 +6,7 @@ import { useLauncherNavigationActions, useLauncherNavigationState, } from "../la
|
|
|
6
6
|
import { WindowTitleBarActionButtons } from "../window/WindowChromeActions.js";
|
|
7
7
|
import { useWindowBackActionValue, useWindowRefreshMenuItemValue, useWindowTitleBarActions, } from "../window/WindowMenuContext.js";
|
|
8
8
|
import { WindowRefreshButton } from "../window/WindowRefreshButton.js";
|
|
9
|
+
import { ROUTED_PANE_SIDEBAR_ID } from "./RoutedPaneSidebar.js";
|
|
9
10
|
export function RoutedPaneAppBar({ activeAppId, hasSidebar, onToggleSidebar, sidebarExpanded, tier, }) {
|
|
10
11
|
const { goBack, goForward } = useLauncherNavigationActions();
|
|
11
12
|
const { definition, history } = useLauncherNavigationState();
|
|
@@ -17,6 +18,6 @@ export function RoutedPaneAppBar({ activeAppId, hasSidebar, onToggleSidebar, sid
|
|
|
17
18
|
const canGoBack = backAction ? !backAction.disabled : history.canGoBack;
|
|
18
19
|
const sidebarLabel = sidebarExpanded ? "Hide Sidebar" : "Show Sidebar";
|
|
19
20
|
const showToolbar = toolbarActions.length > 0 || refreshItem !== null;
|
|
20
|
-
return (_jsxs("header", { className: "routed-pane-appbar", children: [_jsxs("div", { className: "routed-pane-appbar-primary", children: [_jsxs("div", { className: "routed-pane-history-controls", children: [_jsx("button", { "aria-label": backLabel, className: "routed-pane-iconbutton", disabled: !canGoBack, title: backLabel, type: "button", onClick: backAction?.onClick ?? goBack, children: _jsx(CaretLeftIcon, { "aria-hidden": true, size: 18 }) }), _jsx("button", { "aria-label": "Forward", className: "routed-pane-iconbutton", disabled: !history.canGoForward, title: "Forward", type: "button", onClick: goForward, children: _jsx(CaretRightIcon, { "aria-hidden": true, size: 18 }) })] }), hasSidebar && (_jsx("button", { "aria-controls":
|
|
21
|
+
return (_jsxs("header", { className: "routed-pane-appbar", children: [_jsxs("div", { className: "routed-pane-appbar-primary", children: [_jsxs("div", { className: "routed-pane-history-controls", children: [_jsx("button", { "aria-label": backLabel, className: "routed-pane-iconbutton", disabled: !canGoBack, title: backLabel, type: "button", onClick: backAction?.onClick ?? goBack, children: _jsx(CaretLeftIcon, { "aria-hidden": true, size: 18 }) }), _jsx("button", { "aria-label": "Forward", className: "routed-pane-iconbutton", disabled: !history.canGoForward, title: "Forward", type: "button", onClick: goForward, children: _jsx(CaretRightIcon, { "aria-hidden": true, size: 18 }) })] }), hasSidebar && (_jsx("button", { "aria-controls": ROUTED_PANE_SIDEBAR_ID, "aria-expanded": sidebarExpanded, "aria-label": sidebarLabel, className: "routed-pane-iconbutton", title: sidebarLabel, type: "button", onClick: onToggleSidebar, children: _jsx(SidebarSimpleIcon, { "aria-hidden": true, size: 18 }) })), tier !== "mobile" && (_jsx("div", { className: "routed-pane-title", children: definition.apps[activeAppId]?.title }))] }), _jsx("div", { className: "routed-pane-appbar-spacer" }), showToolbar && (_jsxs("div", { "aria-label": "Toolbar", className: "routed-pane-toolbar", role: "toolbar", children: [_jsx(WindowTitleBarActionButtons, { actions: toolbarActions, className: "routed-pane-iconbutton" }), refreshItem && (_jsx(WindowRefreshButton, { className: "routed-pane-iconbutton", item: refreshItem }))] }))] }));
|
|
21
22
|
}
|
|
22
23
|
//# sourceMappingURL=RoutedPaneAppBar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RoutedPaneAppBar.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/routed/RoutedPaneAppBar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,8CAA8C,CAAC;AACjF,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,GAC3B,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EACL,wBAAwB,EACxB,6BAA6B,EAC7B,wBAAwB,GACzB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"RoutedPaneAppBar.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/routed/RoutedPaneAppBar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,8CAA8C,C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S,EACpB,KAAK,EAAE,SAAS,EAChB,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,UAAU,EAAE,OAAO,IAAI,MAAM,YAEtC,KAAC,aAAa,yBAAa,IAAI,EAAE,EAAE,GAAI,GAChC,EACT,+BACa,SAAS,EACpB,SAAS,EAAC,wBAAwB,EAClC,QAAQ,EAAE,CAAC,OAAO,CAAC,YAAY,EAC/B,KAAK,EAAC,SAAS,EACf,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,SAAS,YAElB,KAAC,cAAc,yBAAa,IAAI,EAAE,EAAE,GAAI,GACjC,IACL,EACL,UAAU,IAAI,CACb,kCACiB,sBAAsB,mBACtB,eAAe,gBAClB,YAAY,EACxB,SAAS,EAAC,wBAAwB,EAClC,KAAK,EAAE,YAAY,EACnB,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,eAAe,YAExB,KAAC,iBAAiB,yBAAa,IAAI,EAAE,EAAE,GAAI,GACpC,CACV,EACA,IAAI,KAAK,QAAQ,IAAI,CACpB,cAAK,SAAS,EAAC,mBAAmB,YAC/B,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,KAAK,GAChC,CACP,IACG,EACN,cAAK,SAAS,EAAC,2BAA2B,GAAG,EAC5C,WAAW,IAAI,CACd,6BACa,SAAS,EACpB,SAAS,EAAC,qBAAqB,EAC/B,IAAI,EAAC,SAAS,aAEd,KAAC,2BAA2B,IAC1B,OAAO,EAAE,cAAc,EACvB,SAAS,EAAC,wBAAwB,GAClC,EACD,WAAW,IAAI,CACd,KAAC,mBAAmB,IAClB,SAAS,EAAC,wBAAwB,EAClC,IAAI,EAAE,WAAW,GACjB,CACH,IACG,CACP,IACM,CACV,CAAC;AACJ,CAAC","sourcesContent":["import { CaretLeftIcon } from \"@phosphor-icons/react/dist/csr/CaretLeft\";\nimport { CaretRightIcon } from \"@phosphor-icons/react/dist/csr/CaretRight\";\nimport { SidebarSimpleIcon } from \"@phosphor-icons/react/dist/csr/SidebarSimple\";\nimport {\n useLauncherNavigationActions,\n useLauncherNavigationState,\n} from \"../launcher/LauncherNavigationProvider\";\nimport type { RoutedLayoutTier } from \"../launcher/useRoutedLayoutTier\";\nimport { WindowTitleBarActionButtons } from \"../window/WindowChromeActions\";\nimport {\n useWindowBackActionValue,\n useWindowRefreshMenuItemValue,\n useWindowTitleBarActions,\n} from \"../window/WindowMenuContext\";\nimport { WindowRefreshButton } from \"../window/WindowRefreshButton\";\nimport { ROUTED_PANE_SIDEBAR_ID } from \"./RoutedPaneSidebar\";\n\nexport function RoutedPaneAppBar({\n activeAppId,\n hasSidebar,\n onToggleSidebar,\n sidebarExpanded,\n tier,\n}: {\n activeAppId: string;\n hasSidebar: boolean;\n onToggleSidebar: () => void;\n sidebarExpanded: boolean;\n tier: RoutedLayoutTier;\n}) {\n const { goBack, goForward } = useLauncherNavigationActions();\n const { definition, history } = useLauncherNavigationState();\n const backAction = useWindowBackActionValue();\n const toolbarActions = useWindowTitleBarActions();\n // Both hosts draw the same registered refresh action beside app actions.\n const refreshItem = useWindowRefreshMenuItemValue();\n const backLabel = backAction?.label ?? \"Back\";\n const canGoBack = backAction ? !backAction.disabled : history.canGoBack;\n const sidebarLabel = sidebarExpanded ? \"Hide Sidebar\" : \"Show Sidebar\";\n const showToolbar = toolbarActions.length > 0 || refreshItem !== null;\n\n return (\n <header className=\"routed-pane-appbar\">\n <div className=\"routed-pane-appbar-primary\">\n <div className=\"routed-pane-history-controls\">\n <button\n aria-label={backLabel}\n className=\"routed-pane-iconbutton\"\n disabled={!canGoBack}\n title={backLabel}\n type=\"button\"\n onClick={backAction?.onClick ?? goBack}\n >\n <CaretLeftIcon aria-hidden size={18} />\n </button>\n <button\n aria-label=\"Forward\"\n className=\"routed-pane-iconbutton\"\n disabled={!history.canGoForward}\n title=\"Forward\"\n type=\"button\"\n onClick={goForward}\n >\n <CaretRightIcon aria-hidden size={18} />\n </button>\n </div>\n {hasSidebar && (\n <button\n aria-controls={ROUTED_PANE_SIDEBAR_ID}\n aria-expanded={sidebarExpanded}\n aria-label={sidebarLabel}\n className=\"routed-pane-iconbutton\"\n title={sidebarLabel}\n type=\"button\"\n onClick={onToggleSidebar}\n >\n <SidebarSimpleIcon aria-hidden size={18} />\n </button>\n )}\n {tier !== \"mobile\" && (\n <div className=\"routed-pane-title\">\n {definition.apps[activeAppId]?.title}\n </div>\n )}\n </div>\n <div className=\"routed-pane-appbar-spacer\" />\n {showToolbar && (\n <div\n aria-label=\"Toolbar\"\n className=\"routed-pane-toolbar\"\n role=\"toolbar\"\n >\n <WindowTitleBarActionButtons\n actions={toolbarActions}\n className=\"routed-pane-iconbutton\"\n />\n {refreshItem && (\n <WindowRefreshButton\n className=\"routed-pane-iconbutton\"\n item={refreshItem}\n />\n )}\n </div>\n )}\n </header>\n );\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { RoutedLayoutTier } from "../launcher/useRoutedLayoutTier.js";
|
|
2
2
|
import type { LauncherPlacement } from "./launcherPlacement.js";
|
|
3
3
|
export declare const ROUTED_PANE_NAV_PANEL_ID = "routed-pane-nav-panel";
|
|
4
|
+
export declare const ROUTED_PANE_SHEET_ID = "routed-pane-sheet";
|
|
4
5
|
/**
|
|
5
6
|
* The navigation surface in its tier-appropriate container: a persistent
|
|
6
7
|
* `<aside>` rail in tablet side mode, or a bottom sheet of launcher tiles (plus
|
package/routed/RoutedPaneNav.js
CHANGED
|
@@ -7,6 +7,7 @@ import { RoutedPanePlacementButton } from "./RoutedPanePlacementButton.js";
|
|
|
7
7
|
import { useMobileSheetDrag } from "./useMobileSheetDrag.js";
|
|
8
8
|
import "./RoutedPaneNav.css";
|
|
9
9
|
export const ROUTED_PANE_NAV_PANEL_ID = "routed-pane-nav-panel";
|
|
10
|
+
export const ROUTED_PANE_SHEET_ID = "routed-pane-sheet";
|
|
10
11
|
// The launcher entries, in the order given, labeled from the definition.
|
|
11
12
|
function useRoutedPaneNavItems(appIds) {
|
|
12
13
|
const { definition } = useLauncherNavigationState();
|
|
@@ -99,7 +100,7 @@ export function RoutedPaneNav({ activeAppId, appIds, drawerOpen, launcherPlaceme
|
|
|
99
100
|
if (tier === "tablet" && launcherPlacement === "side") {
|
|
100
101
|
return (_jsxs("aside", { className: classNames("routed-pane-rail", !railExpanded && "routed-pane-rail--collapsed"), "data-state": railExpanded ? "open" : "closed", children: [_jsx(RoutedPaneRailToggle, { expanded: railExpanded, onToggle: onToggleRail }), railExpanded && (_jsx(RoutedPaneNavPanel, { activeAppId: activeAppId, appIds: appIds, id: ROUTED_PANE_NAV_PANEL_ID, onNavigate: onNavigateRail })), _jsx(RoutedPanePlacementButton, { launcherPlacement: launcherPlacement, onToggle: onToggleLauncherPlacement })] }));
|
|
101
102
|
}
|
|
102
|
-
return (_jsxs(_Fragment, { children: [drawerOpen && (_jsx("button", { "aria-label": "Close menu", className: "routed-pane-scrim", type: "button", onClick: onCloseDrawer })), _jsxs("aside", { "aria-hidden": !drawerOpen, className: "routed-pane-sheet", ref: sheetRef, "data-dragging": mobileSheetDrag.dragging ? "true" : "false", "data-open": drawerOpen ? "true" : "false", id:
|
|
103
|
+
return (_jsxs(_Fragment, { children: [drawerOpen && (_jsx("button", { "aria-label": "Close menu", className: "routed-pane-scrim", type: "button", onClick: onCloseDrawer })), _jsxs("aside", { "aria-hidden": !drawerOpen, className: "routed-pane-sheet", ref: sheetRef, "data-dragging": mobileSheetDrag.dragging ? "true" : "false", "data-open": drawerOpen ? "true" : "false", id: ROUTED_PANE_SHEET_ID, style: drawerOpen && mobileSheetDrag.dragOffset > 0
|
|
103
104
|
? { transform: `translateY(${mobileSheetDrag.dragOffset}px)` }
|
|
104
105
|
: undefined, children: [_jsxs("div", { className: "routed-pane-sheet-header", children: [_jsx(RoutedPaneMobileSheetHandle, { dragging: mobileSheetDrag.dragging, onClick: mobileSheetDrag.handleClick, onPointerDown: mobileSheetDrag.handlePointerDown }), tier === "tablet" && (_jsx(RoutedPanePlacementButton, { launcherPlacement: launcherPlacement, onToggle: onToggleLauncherPlacement }))] }), _jsx(RoutedPaneMobileNav, { activeAppId: activeAppId, appIds: appIds, onNavigate: onCloseDrawer })] })] }));
|
|
105
106
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RoutedPaneNav.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/routed/RoutedPaneNav.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,8CAA8C,CAAC;AACjF,OAAO,EAGL,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,GACP,MAAM,OAAO,CAAC;AAEf,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,GAC3B,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,qBAAqB,CAAC;AAE7B,MAAM,CAAC,MAAM,wBAAwB,GAAG,uBAAuB,CAAC;AAQhE,yEAAyE;AACzE,SAAS,qBAAqB,CAC5B,MAA6B;IAE7B,MAAM,EAAE,UAAU,EAAE,GAAG,0BAA0B,EAAE,CAAC;IACpD,OAAO,OAAO,CACZ,GAAG,EAAE,CACH,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QACvB,MAAM,GAAG,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACnC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAClE,CAAC,CAAC,EACJ,CAAC,MAAM,EAAE,UAAU,CAAC,CACrB,CAAC;AACJ,CAAC;AAED,sEAAsE;AACtE,4EAA4E;AA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EAAE,cAAc,GAC1B,CACH,EACD,KAAC,yBAAyB,IACxB,iBAAiB,EAAE,iBAAiB,EACpC,QAAQ,EAAE,yBAAyB,GACnC,IACI,CACT,CAAC;IACJ,CAAC;IAED,OAAO,CACL,8BACG,UAAU,IAAI,CACb,+BACa,YAAY,EACvB,SAAS,EAAC,mBAAmB,EAC7B,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,aAAa,GACtB,CACH,EACD,gCACe,CAAC,UAAU,EACxB,SAAS,EAAC,mBAAmB,EAC7B,GAAG,EAAE,QAAQ,mBACE,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,eAC/C,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EACxC,EAAE,EAAC,mBAAmB,EACtB,KAAK,EACH,UAAU,IAAI,eAAe,CAAC,UAAU,GAAG,CAAC;oBAC1C,CAAC,CAAC,EAAE,SAAS,EAAE,cAAc,eAAe,CAAC,UAAU,KAAK,EAAE;oBAC9D,CAAC,CAAC,SAAS,aAGf,eAAK,SAAS,EAAC,0BAA0B,aACvC,KAAC,2BAA2B,IAC1B,QAAQ,EAAE,eAAe,CAAC,QAAQ,EAClC,OAAO,EAAE,eAAe,CAAC,WAAW,EACpC,aAAa,EAAE,eAAe,CAAC,iBAAiB,GAChD,EACD,IAAI,KAAK,QAAQ,IAAI,CACpB,KAAC,yBAAyB,IACxB,iBAAiB,EAAE,iBAAiB,EACpC,QAAQ,EAAE,yBAAyB,GACnC,CACH,IACG,EACN,KAAC,mBAAmB,IAClB,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,aAAa,GACzB,IACI,IACP,CACJ,CAAC;AACJ,CAAC","sourcesContent":["import { SidebarSimpleIcon } from \"@phosphor-icons/react/dist/csr/SidebarSimple\";\nimport {\n type MouseEvent as ReactMouseEvent,\n type PointerEvent as ReactPointerEvent,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport type { WindowingIcon } from \"../icons/windowingIcon\";\nimport {\n useLauncherNavigationActions,\n useLauncherNavigationState,\n} from \"../launcher/LauncherNavigationProvider\";\nimport type { RoutedLayoutTier } from \"../launcher/useRoutedLayoutTier\";\nimport { classNames } from \"./classNames\";\nimport type { LauncherPlacement } from \"./launcherPlacement\";\nimport { RoutedPanePlacementButton } from \"./RoutedPanePlacementButton\";\nimport { useMobileSheetDrag } from \"./useMobileSheetDrag\";\nimport \"./RoutedPaneNav.css\";\n\nexport const ROUTED_PANE_NAV_PANEL_ID = \"routed-pane-nav-panel\";\n\ninterface RoutedPaneNavItem {\n appId: string;\n icon: WindowingIcon | undefined;\n label: string;\n}\n\n// The launcher entries, in the order given, labeled from the definition.\nfunction useRoutedPaneNavItems(\n appIds: ReadonlyArray<string>,\n): ReadonlyArray<RoutedPaneNavItem> {\n const { definition } = useLauncherNavigationState();\n return useMemo(\n () =>\n appIds.flatMap((appId) => {\n const app = definition.apps[appId];\n return app ? [{ appId, icon: app.icon, label: app.title }] : [];\n }),\n [appIds, definition],\n );\n}\n\n// Let the browser handle modified clicks (Cmd/Ctrl/Shift/Alt + click,\n// middle-click) so the href still opens in a new tab/window; only intercept\n// a plain left-click for in-app navigation.\nfunction isBrowserHandledNavClick(\n event: ReactMouseEvent<HTMLAnchorElement>,\n): boolean {\n return (\n event.button !== 0 ||\n event.metaKey ||\n event.ctrlKey ||\n event.shiftKey ||\n event.altKey\n );\n}\n\nfunction RoutedPaneNavLink({\n appId,\n activeAppId,\n icon: LinkIcon,\n label,\n onNavigate,\n}: {\n appId: string;\n activeAppId: string;\n icon: WindowingIcon | undefined;\n label: string;\n onNavigate: () => void;\n}) {\n const { getMiniAppHref, openMiniApp } = useLauncherNavigationActions();\n const handleClick = useCallback(\n (event: ReactMouseEvent<HTMLAnchorElement>) => {\n if (isBrowserHandledNavClick(event)) {\n return;\n }\n event.preventDefault();\n openMiniApp({ appId });\n onNavigate();\n },\n [appId, onNavigate, openMiniApp],\n );\n\n return (\n <a\n aria-current={activeAppId === appId ? \"page\" : undefined}\n className={classNames(\n \"routed-pane-nav-link\",\n activeAppId === appId && \"routed-pane-nav-link--active\",\n )}\n href={getMiniAppHref(appId)}\n onClick={handleClick}\n >\n {LinkIcon && <LinkIcon aria-hidden=\"true\" size={20} />}\n <span className=\"routed-pane-nav-link-label\">{label}</span>\n </a>\n );\n}\n\n/**\n * The tablet rail's navigation surface: an icon-and-label link per routed\n * mini-app. System commands and per-app file/view actions belong to the app bar\n * toolbar at the top of the shell.\n */\nfunction RoutedPaneNavPanel({\n activeAppId,\n appIds,\n id,\n onNavigate,\n}: {\n activeAppId: string;\n appIds: ReadonlyArray<string>;\n id: string;\n onNavigate: () => void;\n}) {\n const visibleNavItems = useRoutedPaneNavItems(appIds);\n return (\n <nav aria-label=\"Apps\" className=\"routed-pane-nav-panel\" id={id}>\n {visibleNavItems.map(({ appId, icon, label }) => (\n <RoutedPaneNavLink\n key={appId}\n activeAppId={activeAppId}\n appId={appId}\n icon={icon}\n label={label}\n onNavigate={onNavigate}\n />\n ))}\n </nav>\n );\n}\n\nfunction RoutedPaneRailToggle({\n expanded,\n onToggle,\n}: {\n expanded: boolean;\n onToggle: () => void;\n}) {\n const label = expanded\n ? \"Collapse navigation rail\"\n : \"Expand navigation rail\";\n\n return (\n <button\n aria-controls={expanded ? ROUTED_PANE_NAV_PANEL_ID : undefined}\n aria-expanded={expanded}\n aria-label={label}\n className=\"routed-pane-iconbutton routed-pane-rail-toggle\"\n title={label}\n type=\"button\"\n onClick={onToggle}\n >\n <SidebarSimpleIcon aria-hidden=\"true\" size={18} />\n </button>\n );\n}\n\nfunction RoutedPaneMobileNavTile({\n active,\n href,\n icon: TileIcon,\n label,\n onSelect,\n}: {\n active: boolean;\n href: string;\n icon: WindowingIcon | undefined;\n label: string;\n onSelect: () => void;\n}) {\n return (\n <a\n aria-current={active ? \"page\" : undefined}\n className={classNames(\n \"routed-pane-sheet-tile\",\n active && \"routed-pane-sheet-tile--active\",\n )}\n href={href}\n onClick={(event) => {\n if (isBrowserHandledNavClick(event)) {\n return;\n }\n event.preventDefault();\n onSelect();\n }}\n >\n {TileIcon && <TileIcon aria-hidden=\"true\" size={32} />}\n <span className=\"routed-pane-sheet-tile-label\">{label}</span>\n </a>\n );\n}\n\n/**\n * The bottom-sheet navigation: every routed mini-app as a grid of square\n * icon-and-label tiles (styled after Explorer's New Document screen). Like the\n * tablet rail it carries no per-app contextual actions. Selecting a tile\n * navigates and dismisses.\n */\nfunction RoutedPaneMobileNav({\n activeAppId,\n appIds,\n onNavigate,\n}: {\n activeAppId: string;\n appIds: ReadonlyArray<string>;\n onNavigate: () => void;\n}) {\n const { getMiniAppHref, openMiniApp } = useLauncherNavigationActions();\n const visibleNavItems = useRoutedPaneNavItems(appIds);\n\n return (\n <nav aria-label=\"Apps\" className=\"routed-pane-sheet-grid\">\n {visibleNavItems.map(({ appId, icon, label }) => (\n <RoutedPaneMobileNavTile\n key={appId}\n active={activeAppId === appId}\n href={getMiniAppHref(appId)}\n icon={icon}\n label={label}\n onSelect={() => {\n openMiniApp({ appId });\n onNavigate();\n }}\n />\n ))}\n </nav>\n );\n}\n\nfunction RoutedPaneMobileSheetHandle({\n dragging,\n onClick,\n onPointerDown,\n}: {\n dragging: boolean;\n onClick: (event: ReactMouseEvent<HTMLButtonElement>) => void;\n onPointerDown: (event: ReactPointerEvent<HTMLButtonElement>) => void;\n}) {\n return (\n <button\n aria-label=\"Dismiss menu\"\n className=\"routed-pane-sheet-handle\"\n data-dragging={dragging ? \"true\" : \"false\"}\n type=\"button\"\n onClick={onClick}\n onPointerDown={onPointerDown}\n >\n <span aria-hidden=\"true\" />\n </button>\n );\n}\n\n/**\n * The navigation surface in its tier-appropriate container: a persistent\n * `<aside>` rail in tablet side mode, or a bottom sheet of launcher tiles (plus\n * dismiss scrim) on mobile and in tablet bottom mode.\n */\nexport function RoutedPaneNav({\n activeAppId,\n appIds,\n drawerOpen,\n launcherPlacement,\n onCloseDrawer,\n onNavigateRail,\n onToggleLauncherPlacement,\n onToggleRail,\n railExpanded,\n tier,\n}: {\n activeAppId: string;\n appIds: ReadonlyArray<string>;\n drawerOpen: boolean;\n launcherPlacement: LauncherPlacement;\n onCloseDrawer: () => void;\n onNavigateRail: () => void;\n onToggleLauncherPlacement: () => void;\n onToggleRail: () => void;\n railExpanded: boolean;\n tier: RoutedLayoutTier;\n}) {\n const sheetRef = useRef<HTMLElement>(null);\n useEffect(() => {\n if (drawerOpen && (tier === \"mobile\" || launcherPlacement === \"bottom\")) {\n const sheet = sheetRef.current;\n const tile = sheet?.querySelector<HTMLElement>(\n '.routed-pane-sheet-tile[aria-current=\"page\"]',\n );\n (\n tile ?? sheet?.querySelector<HTMLElement>(\".routed-pane-sheet-tile\")\n )?.focus();\n }\n }, [drawerOpen, launcherPlacement, tier]);\n\n const mobileSheetDrag = useMobileSheetDrag({\n drawerOpen:\n (tier === \"mobile\" || launcherPlacement === \"bottom\") && drawerOpen,\n onClose: onCloseDrawer,\n });\n\n if (tier === \"tablet\" && launcherPlacement === \"side\") {\n return (\n <aside\n className={classNames(\n \"routed-pane-rail\",\n !railExpanded && \"routed-pane-rail--collapsed\",\n )}\n data-state={railExpanded ? \"open\" : \"closed\"}\n >\n <RoutedPaneRailToggle expanded={railExpanded} onToggle={onToggleRail} />\n {railExpanded && (\n <RoutedPaneNavPanel\n activeAppId={activeAppId}\n appIds={appIds}\n id={ROUTED_PANE_NAV_PANEL_ID}\n onNavigate={onNavigateRail}\n />\n )}\n <RoutedPanePlacementButton\n launcherPlacement={launcherPlacement}\n onToggle={onToggleLauncherPlacement}\n />\n </aside>\n );\n }\n\n return (\n <>\n {drawerOpen && (\n <button\n aria-label=\"Close menu\"\n className=\"routed-pane-scrim\"\n type=\"button\"\n onClick={onCloseDrawer}\n />\n )}\n <aside\n aria-hidden={!drawerOpen}\n className=\"routed-pane-sheet\"\n ref={sheetRef}\n data-dragging={mobileSheetDrag.dragging ? \"true\" : \"false\"}\n data-open={drawerOpen ? \"true\" : \"false\"}\n id=\"routed-pane-sheet\"\n style={\n drawerOpen && mobileSheetDrag.dragOffset > 0\n ? { transform: `translateY(${mobileSheetDrag.dragOffset}px)` }\n : undefined\n }\n >\n <div className=\"routed-pane-sheet-header\">\n <RoutedPaneMobileSheetHandle\n dragging={mobileSheetDrag.dragging}\n onClick={mobileSheetDrag.handleClick}\n onPointerDown={mobileSheetDrag.handlePointerDown}\n />\n {tier === \"tablet\" && (\n <RoutedPanePlacementButton\n launcherPlacement={launcherPlacement}\n onToggle={onToggleLauncherPlacement}\n />\n )}\n </div>\n <RoutedPaneMobileNav\n activeAppId={activeAppId}\n appIds={appIds}\n onNavigate={onCloseDrawer}\n />\n </aside>\n </>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"RoutedPaneNav.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/routed/RoutedPaneNav.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,8CAA8C,CAAC;AACjF,OAAO,EAGL,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,GACP,MAAM,OAAO,CAAC;AAEf,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,GAC3B,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,qBAAqB,CAAC;AAE7B,MAAM,CAAC,MAAM,wBAAwB,GAAG,uBAAuB,CAAC;AAChE,MAAM,CAAC,MAAM,oBAAoB,GAAG,mBAAmB,CAAC;AAQxD,yEAAyE;AACzE,SAAS,qBAAqB,CAC5B,MAA6B;IAE7B,MAAM,EAAE,UAAU,EAAE,GAAG,0BAA0B,EAAE,CAAC;IACpD,OAAO,OAAO,CACZ,GA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iBAAiB,GAChD,EACD,IAAI,KAAK,QAAQ,IAAI,CACpB,KAAC,yBAAyB,IACxB,iBAAiB,EAAE,iBAAiB,EACpC,QAAQ,EAAE,yBAAyB,GACnC,CACH,IACG,EACN,KAAC,mBAAmB,IAClB,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,aAAa,GACzB,IACI,IACP,CACJ,CAAC;AACJ,CAAC","sourcesContent":["import { SidebarSimpleIcon } from \"@phosphor-icons/react/dist/csr/SidebarSimple\";\nimport {\n type MouseEvent as ReactMouseEvent,\n type PointerEvent as ReactPointerEvent,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport type { WindowingIcon } from \"../icons/windowingIcon\";\nimport {\n useLauncherNavigationActions,\n useLauncherNavigationState,\n} from \"../launcher/LauncherNavigationProvider\";\nimport type { RoutedLayoutTier } from \"../launcher/useRoutedLayoutTier\";\nimport { classNames } from \"./classNames\";\nimport type { LauncherPlacement } from \"./launcherPlacement\";\nimport { RoutedPanePlacementButton } from \"./RoutedPanePlacementButton\";\nimport { useMobileSheetDrag } from \"./useMobileSheetDrag\";\nimport \"./RoutedPaneNav.css\";\n\nexport const ROUTED_PANE_NAV_PANEL_ID = \"routed-pane-nav-panel\";\nexport const ROUTED_PANE_SHEET_ID = \"routed-pane-sheet\";\n\ninterface RoutedPaneNavItem {\n appId: string;\n icon: WindowingIcon | undefined;\n label: string;\n}\n\n// The launcher entries, in the order given, labeled from the definition.\nfunction useRoutedPaneNavItems(\n appIds: ReadonlyArray<string>,\n): ReadonlyArray<RoutedPaneNavItem> {\n const { definition } = useLauncherNavigationState();\n return useMemo(\n () =>\n appIds.flatMap((appId) => {\n const app = definition.apps[appId];\n return app ? [{ appId, icon: app.icon, label: app.title }] : [];\n }),\n [appIds, definition],\n );\n}\n\n// Let the browser handle modified clicks (Cmd/Ctrl/Shift/Alt + click,\n// middle-click) so the href still opens in a new tab/window; only intercept\n// a plain left-click for in-app navigation.\nfunction isBrowserHandledNavClick(\n event: ReactMouseEvent<HTMLAnchorElement>,\n): boolean {\n return (\n event.button !== 0 ||\n event.metaKey ||\n event.ctrlKey ||\n event.shiftKey ||\n event.altKey\n );\n}\n\nfunction RoutedPaneNavLink({\n appId,\n activeAppId,\n icon: LinkIcon,\n label,\n onNavigate,\n}: {\n appId: string;\n activeAppId: string;\n icon: WindowingIcon | undefined;\n label: string;\n onNavigate: () => void;\n}) {\n const { getMiniAppHref, openMiniApp } = useLauncherNavigationActions();\n const handleClick = useCallback(\n (event: ReactMouseEvent<HTMLAnchorElement>) => {\n if (isBrowserHandledNavClick(event)) {\n return;\n }\n event.preventDefault();\n openMiniApp({ appId });\n onNavigate();\n },\n [appId, onNavigate, openMiniApp],\n );\n\n return (\n <a\n aria-current={activeAppId === appId ? \"page\" : undefined}\n className={classNames(\n \"routed-pane-nav-link\",\n activeAppId === appId && \"routed-pane-nav-link--active\",\n )}\n href={getMiniAppHref(appId)}\n onClick={handleClick}\n >\n {LinkIcon && <LinkIcon aria-hidden=\"true\" size={20} />}\n <span className=\"routed-pane-nav-link-label\">{label}</span>\n </a>\n );\n}\n\n/**\n * The tablet rail's navigation surface: an icon-and-label link per routed\n * mini-app. System commands and per-app file/view actions belong to the app bar\n * toolbar at the top of the shell.\n */\nfunction RoutedPaneNavPanel({\n activeAppId,\n appIds,\n id,\n onNavigate,\n}: {\n activeAppId: string;\n appIds: ReadonlyArray<string>;\n id: string;\n onNavigate: () => void;\n}) {\n const visibleNavItems = useRoutedPaneNavItems(appIds);\n return (\n <nav aria-label=\"Apps\" className=\"routed-pane-nav-panel\" id={id}>\n {visibleNavItems.map(({ appId, icon, label }) => (\n <RoutedPaneNavLink\n key={appId}\n activeAppId={activeAppId}\n appId={appId}\n icon={icon}\n label={label}\n onNavigate={onNavigate}\n />\n ))}\n </nav>\n );\n}\n\nfunction RoutedPaneRailToggle({\n expanded,\n onToggle,\n}: {\n expanded: boolean;\n onToggle: () => void;\n}) {\n const label = expanded\n ? \"Collapse navigation rail\"\n : \"Expand navigation rail\";\n\n return (\n <button\n aria-controls={expanded ? ROUTED_PANE_NAV_PANEL_ID : undefined}\n aria-expanded={expanded}\n aria-label={label}\n className=\"routed-pane-iconbutton routed-pane-rail-toggle\"\n title={label}\n type=\"button\"\n onClick={onToggle}\n >\n <SidebarSimpleIcon aria-hidden=\"true\" size={18} />\n </button>\n );\n}\n\nfunction RoutedPaneMobileNavTile({\n active,\n href,\n icon: TileIcon,\n label,\n onSelect,\n}: {\n active: boolean;\n href: string;\n icon: WindowingIcon | undefined;\n label: string;\n onSelect: () => void;\n}) {\n return (\n <a\n aria-current={active ? \"page\" : undefined}\n className={classNames(\n \"routed-pane-sheet-tile\",\n active && \"routed-pane-sheet-tile--active\",\n )}\n href={href}\n onClick={(event) => {\n if (isBrowserHandledNavClick(event)) {\n return;\n }\n event.preventDefault();\n onSelect();\n }}\n >\n {TileIcon && <TileIcon aria-hidden=\"true\" size={32} />}\n <span className=\"routed-pane-sheet-tile-label\">{label}</span>\n </a>\n );\n}\n\n/**\n * The bottom-sheet navigation: every routed mini-app as a grid of square\n * icon-and-label tiles (styled after Explorer's New Document screen). Like the\n * tablet rail it carries no per-app contextual actions. Selecting a tile\n * navigates and dismisses.\n */\nfunction RoutedPaneMobileNav({\n activeAppId,\n appIds,\n onNavigate,\n}: {\n activeAppId: string;\n appIds: ReadonlyArray<string>;\n onNavigate: () => void;\n}) {\n const { getMiniAppHref, openMiniApp } = useLauncherNavigationActions();\n const visibleNavItems = useRoutedPaneNavItems(appIds);\n\n return (\n <nav aria-label=\"Apps\" className=\"routed-pane-sheet-grid\">\n {visibleNavItems.map(({ appId, icon, label }) => (\n <RoutedPaneMobileNavTile\n key={appId}\n active={activeAppId === appId}\n href={getMiniAppHref(appId)}\n icon={icon}\n label={label}\n onSelect={() => {\n openMiniApp({ appId });\n onNavigate();\n }}\n />\n ))}\n </nav>\n );\n}\n\nfunction RoutedPaneMobileSheetHandle({\n dragging,\n onClick,\n onPointerDown,\n}: {\n dragging: boolean;\n onClick: (event: ReactMouseEvent<HTMLButtonElement>) => void;\n onPointerDown: (event: ReactPointerEvent<HTMLButtonElement>) => void;\n}) {\n return (\n <button\n aria-label=\"Dismiss menu\"\n className=\"routed-pane-sheet-handle\"\n data-dragging={dragging ? \"true\" : \"false\"}\n type=\"button\"\n onClick={onClick}\n onPointerDown={onPointerDown}\n >\n <span aria-hidden=\"true\" />\n </button>\n );\n}\n\n/**\n * The navigation surface in its tier-appropriate container: a persistent\n * `<aside>` rail in tablet side mode, or a bottom sheet of launcher tiles (plus\n * dismiss scrim) on mobile and in tablet bottom mode.\n */\nexport function RoutedPaneNav({\n activeAppId,\n appIds,\n drawerOpen,\n launcherPlacement,\n onCloseDrawer,\n onNavigateRail,\n onToggleLauncherPlacement,\n onToggleRail,\n railExpanded,\n tier,\n}: {\n activeAppId: string;\n appIds: ReadonlyArray<string>;\n drawerOpen: boolean;\n launcherPlacement: LauncherPlacement;\n onCloseDrawer: () => void;\n onNavigateRail: () => void;\n onToggleLauncherPlacement: () => void;\n onToggleRail: () => void;\n railExpanded: boolean;\n tier: RoutedLayoutTier;\n}) {\n const sheetRef = useRef<HTMLElement>(null);\n useEffect(() => {\n if (drawerOpen && (tier === \"mobile\" || launcherPlacement === \"bottom\")) {\n const sheet = sheetRef.current;\n const tile = sheet?.querySelector<HTMLElement>(\n '.routed-pane-sheet-tile[aria-current=\"page\"]',\n );\n (\n tile ?? sheet?.querySelector<HTMLElement>(\".routed-pane-sheet-tile\")\n )?.focus();\n }\n }, [drawerOpen, launcherPlacement, tier]);\n\n const mobileSheetDrag = useMobileSheetDrag({\n drawerOpen:\n (tier === \"mobile\" || launcherPlacement === \"bottom\") && drawerOpen,\n onClose: onCloseDrawer,\n });\n\n if (tier === \"tablet\" && launcherPlacement === \"side\") {\n return (\n <aside\n className={classNames(\n \"routed-pane-rail\",\n !railExpanded && \"routed-pane-rail--collapsed\",\n )}\n data-state={railExpanded ? \"open\" : \"closed\"}\n >\n <RoutedPaneRailToggle expanded={railExpanded} onToggle={onToggleRail} />\n {railExpanded && (\n <RoutedPaneNavPanel\n activeAppId={activeAppId}\n appIds={appIds}\n id={ROUTED_PANE_NAV_PANEL_ID}\n onNavigate={onNavigateRail}\n />\n )}\n <RoutedPanePlacementButton\n launcherPlacement={launcherPlacement}\n onToggle={onToggleLauncherPlacement}\n />\n </aside>\n );\n }\n\n return (\n <>\n {drawerOpen && (\n <button\n aria-label=\"Close menu\"\n className=\"routed-pane-scrim\"\n type=\"button\"\n onClick={onCloseDrawer}\n />\n )}\n <aside\n aria-hidden={!drawerOpen}\n className=\"routed-pane-sheet\"\n ref={sheetRef}\n data-dragging={mobileSheetDrag.dragging ? \"true\" : \"false\"}\n data-open={drawerOpen ? \"true\" : \"false\"}\n id={ROUTED_PANE_SHEET_ID}\n style={\n drawerOpen && mobileSheetDrag.dragOffset > 0\n ? { transform: `translateY(${mobileSheetDrag.dragOffset}px)` }\n : undefined\n }\n >\n <div className=\"routed-pane-sheet-header\">\n <RoutedPaneMobileSheetHandle\n dragging={mobileSheetDrag.dragging}\n onClick={mobileSheetDrag.handleClick}\n onPointerDown={mobileSheetDrag.handlePointerDown}\n />\n {tier === \"tablet\" && (\n <RoutedPanePlacementButton\n launcherPlacement={launcherPlacement}\n onToggle={onToggleLauncherPlacement}\n />\n )}\n </div>\n <RoutedPaneMobileNav\n activeAppId={activeAppId}\n appIds={appIds}\n onNavigate={onCloseDrawer}\n />\n </aside>\n </>\n );\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import type { RoutedLayoutTier } from "../launcher/useRoutedLayoutTier.js";
|
|
3
|
+
export declare const ROUTED_PANE_SIDEBAR_ID = "routed-pane-sidebar";
|
|
3
4
|
export declare function RoutedPaneSidebar({ children, onClose, tier, }: {
|
|
4
5
|
children: ReactNode;
|
|
5
6
|
onClose: () => void;
|
|
@@ -2,6 +2,8 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import { SidebarResizeHandle, useSidebarResize, } from "../sidebar/SidebarResize.js";
|
|
3
3
|
import "./RoutedPaneSidebar.css";
|
|
4
4
|
const DEFAULT_WIDTH = 224;
|
|
5
|
+
// The routed shell renders one sidebar per page; the app bar's toggle names it.
|
|
6
|
+
export const ROUTED_PANE_SIDEBAR_ID = "routed-pane-sidebar";
|
|
5
7
|
function getResizeContainer(sidebar) {
|
|
6
8
|
// The app bar spans sidebar + content in both launcher placements. Its width
|
|
7
9
|
// also changes when the side launcher expands, even if the viewport does not.
|
|
@@ -10,7 +12,7 @@ function getResizeContainer(sidebar) {
|
|
|
10
12
|
?.querySelector(".routed-pane-appbar") ?? null);
|
|
11
13
|
}
|
|
12
14
|
function RoutedPaneMobileSidebar({ children, onClose, }) {
|
|
13
|
-
return (_jsxs(_Fragment, { children: [_jsx("button", { "aria-label": "Close sidebar", className: "routed-pane-scrim", type: "button", onClick: onClose }), _jsx("div", { className: "routed-pane-sidebar", id:
|
|
15
|
+
return (_jsxs(_Fragment, { children: [_jsx("button", { "aria-label": "Close sidebar", className: "routed-pane-scrim", type: "button", onClick: onClose }), _jsx("div", { className: "routed-pane-sidebar", id: ROUTED_PANE_SIDEBAR_ID, role: "dialog", children: children })] }));
|
|
14
16
|
}
|
|
15
17
|
function RoutedPaneTabletSidebar({ children }) {
|
|
16
18
|
const resize = useSidebarResize({
|
|
@@ -18,7 +20,7 @@ function RoutedPaneTabletSidebar({ children }) {
|
|
|
18
20
|
initialWidth: null,
|
|
19
21
|
getResizeContainer,
|
|
20
22
|
});
|
|
21
|
-
return (_jsxs("div", { className: "routed-pane-sidebar-frame", children: [_jsx("div", { className: "routed-pane-sidebar", id:
|
|
23
|
+
return (_jsxs("div", { className: "routed-pane-sidebar-frame", children: [_jsx("div", { className: "routed-pane-sidebar", id: ROUTED_PANE_SIDEBAR_ID, ref: resize.sidebarRef, style: resize.width === null ? undefined : { width: resize.width }, children: children }), _jsx(SidebarResizeHandle, { className: "routed-pane-sidebar-resize-handle", controls: ROUTED_PANE_SIDEBAR_ID, currentWidth: resize.resolvedWidth, maxWidth: resize.maxWidth, onKeyDown: resize.handleKeyDown, onPointerDown: resize.handlePointerDown })] }));
|
|
22
24
|
}
|
|
23
25
|
export function RoutedPaneSidebar({ children, onClose, tier, }) {
|
|
24
26
|
return tier === "mobile" ? (_jsx(RoutedPaneMobileSidebar, { onClose: onClose, children: children })) : (_jsx(RoutedPaneTabletSidebar, { children: children }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RoutedPaneSidebar.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/routed/RoutedPaneSidebar.tsx"],"names":[],"mappings":";AAEA,OAAO,EACL,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,yBAAyB,CAAC;AAEjC,MAAM,aAAa,GAAG,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"RoutedPaneSidebar.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/routed/RoutedPaneSidebar.tsx"],"names":[],"mappings":";AAEA,OAAO,EACL,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,yBAAyB,CAAC;AAEjC,MAAM,aAAa,GAAG,GAAG,CAAC;AAC1B,gFAAgF;AAChF,MAAM,CAAC,MAAM,sBAAsB,GAAG,qBAAqB,CAAC;AAE5D,SAAS,kBAAkB,CAAC,OAAoB;IAC9C,6EAA6E;IAC7E,8EAA8E;IAC9E,OAAO,CACL,OAAO;SACJ,OAAO,CAAC,cAAc,CAAC;QACxB,EAAE,aAAa,CAAc,qBAAqB,CAAC,IAAI,IAAI,CAC9D,CAAC;AACJ,CAAC;AAED,SAAS,uBAAuB,CAAC,EAC/B,QAAQ,EACR,OAAO,GAIR;IACC,OAAO,CACL,8BACE,+BACa,eAAe,E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\nimport type { RoutedLayoutTier } from \"../launcher/useRoutedLayoutTier\";\nimport {\n SidebarResizeHandle,\n useSidebarResize,\n} from \"../sidebar/SidebarResize\";\nimport \"./RoutedPaneSidebar.css\";\n\nconst DEFAULT_WIDTH = 224;\n// The routed shell renders one sidebar per page; the app bar's toggle names it.\nexport const ROUTED_PANE_SIDEBAR_ID = \"routed-pane-sidebar\";\n\nfunction getResizeContainer(sidebar: HTMLElement) {\n // The app bar spans sidebar + content in both launcher placements. Its width\n // also changes when the side launcher expands, even if the viewport does not.\n return (\n sidebar\n .closest(\".routed-pane\")\n ?.querySelector<HTMLElement>(\".routed-pane-appbar\") ?? null\n );\n}\n\nfunction RoutedPaneMobileSidebar({\n children,\n onClose,\n}: {\n children: ReactNode;\n onClose: () => void;\n}) {\n return (\n <>\n <button\n aria-label=\"Close sidebar\"\n className=\"routed-pane-scrim\"\n type=\"button\"\n onClick={onClose}\n />\n <div\n className=\"routed-pane-sidebar\"\n id={ROUTED_PANE_SIDEBAR_ID}\n role=\"dialog\"\n >\n {children}\n </div>\n </>\n );\n}\n\nfunction RoutedPaneTabletSidebar({ children }: { children: ReactNode }) {\n const resize = useSidebarResize({\n defaultWidth: DEFAULT_WIDTH,\n initialWidth: null,\n getResizeContainer,\n });\n\n return (\n <div className=\"routed-pane-sidebar-frame\">\n <div\n className=\"routed-pane-sidebar\"\n id={ROUTED_PANE_SIDEBAR_ID}\n ref={resize.sidebarRef}\n style={resize.width === null ? undefined : { width: resize.width }}\n >\n {children}\n </div>\n <SidebarResizeHandle\n className=\"routed-pane-sidebar-resize-handle\"\n controls={ROUTED_PANE_SIDEBAR_ID}\n currentWidth={resize.resolvedWidth}\n maxWidth={resize.maxWidth}\n onKeyDown={resize.handleKeyDown}\n onPointerDown={resize.handlePointerDown}\n />\n </div>\n );\n}\n\nexport function RoutedPaneSidebar({\n children,\n onClose,\n tier,\n}: {\n children: ReactNode;\n onClose: () => void;\n tier: RoutedLayoutTier;\n}) {\n return tier === \"mobile\" ? (\n <RoutedPaneMobileSidebar onClose={onClose}>\n {children}\n </RoutedPaneMobileSidebar>\n ) : (\n <RoutedPaneTabletSidebar>{children}</RoutedPaneTabletSidebar>\n );\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { ROUTED_PANE_NAV_PANEL_ID } from "./RoutedPaneNav.js";
|
|
2
|
+
import { ROUTED_PANE_NAV_PANEL_ID, ROUTED_PANE_SHEET_ID, } from "./RoutedPaneNav.js";
|
|
3
3
|
/**
|
|
4
4
|
* The routed shell's bottom taskbar — the routed counterpart of a desktop's
|
|
5
5
|
* taskbar. Present in both tiers: the centered menu icon opens the launcher
|
|
@@ -15,7 +15,7 @@ export function RoutedPaneTaskBar({ drawerOpen, hidden, launcherPlacement, menuB
|
|
|
15
15
|
// nav panel only exists while expanded, so reference it only then (mirroring
|
|
16
16
|
// the rail toggle) rather than pointing aria-controls at an absent element.
|
|
17
17
|
const controls = usesSheet
|
|
18
|
-
?
|
|
18
|
+
? ROUTED_PANE_SHEET_ID
|
|
19
19
|
: expanded
|
|
20
20
|
? ROUTED_PANE_NAV_PANEL_ID
|
|
21
21
|
: undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RoutedPaneTaskBar.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/routed/RoutedPaneTaskBar.tsx"],"names":[],"mappings":";AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"RoutedPaneTaskBar.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/routed/RoutedPaneTaskBar.tsx"],"names":[],"mappings":";AAGA,OAAO,EACL,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AAezB;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAChC,UAAU,EACV,MAAM,EACN,iBAAiB,EACjB,aAAa,EACb,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,IAAI,EACJ,IAAI,GACmB;IACvB,MAAM,SAAS,GAAG,IAAI,KAAK,QAAQ,IAAI,iBAAiB,KAAK,QAAQ,CAAC;IACtE,MAAM,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC;IACvD,yEAAyE;IACzE,iEAAiE;IACjE,6EAA6E;IAC7E,4EAA4E;IAC5E,MAAM,QAAQ,GAAG,SAAS;QACxB,CAAC,CAAC,oBAAoB;QACtB,CAAC,CAAC,QAAQ;YACR,CAAC,CAAC,wBAAwB;YAC1B,CAAC,CAAC,SAAS,CAAC;IAEhB,OAAO,CACL,kBAAQ,SAAS,EAAC,qBAAqB,EAAC,MAAM,EAAE,MAAM,aACpD,kCACiB,QAAQ,mBACR,QAAQ,gBACZ,MAAM,EACjB,SAAS,EAAC,iCAAiC,EAC3C,GAAG,EAAE,aAAa,EAClB,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,YAAY,YAEjD,QAAQ,GACF,EACT,cAAK,SAAS,EAAC,yBAAyB,YAAE,IAAI,GAAO,IAC9C,CACV,CAAC;AACJ,CAAC","sourcesContent":["import type { ReactNode, RefObject } from \"react\";\nimport type { RoutedLayoutTier } from \"../launcher/useRoutedLayoutTier\";\nimport type { LauncherPlacement } from \"./launcherPlacement\";\nimport {\n ROUTED_PANE_NAV_PANEL_ID,\n ROUTED_PANE_SHEET_ID,\n} from \"./RoutedPaneNav\";\n\ninterface RoutedPaneTaskBarProps {\n drawerOpen: boolean;\n hidden: boolean;\n launcherPlacement: LauncherPlacement;\n menuButtonRef: RefObject<HTMLButtonElement | null>;\n menuIcon: ReactNode;\n onToggleDrawer: () => void;\n onToggleRail: () => void;\n railExpanded: boolean;\n tier: RoutedLayoutTier;\n tray: ReactNode;\n}\n\n/**\n * The routed shell's bottom taskbar — the routed counterpart of a desktop's\n * taskbar. Present in both tiers: the centered menu icon opens the launcher\n * sheet on mobile or in bottom mode, and reveals the rail in tablet side mode.\n * The corner hosts the tray. On mobile it hides while a text-editing control\n * has focus to leave room for the software keyboard.\n */\nexport function RoutedPaneTaskBar({\n drawerOpen,\n hidden,\n launcherPlacement,\n menuButtonRef,\n menuIcon,\n onToggleDrawer,\n onToggleRail,\n railExpanded,\n tier,\n tray,\n}: RoutedPaneTaskBarProps) {\n const usesSheet = tier === \"mobile\" || launcherPlacement === \"bottom\";\n const expanded = usesSheet ? drawerOpen : railExpanded;\n // The launcher sheet stays mounted (just hidden), so keep its disclosure\n // relationship wired regardless of open state. The tablet rail's\n // nav panel only exists while expanded, so reference it only then (mirroring\n // the rail toggle) rather than pointing aria-controls at an absent element.\n const controls = usesSheet\n ? ROUTED_PANE_SHEET_ID\n : expanded\n ? ROUTED_PANE_NAV_PANEL_ID\n : undefined;\n\n return (\n <footer className=\"routed-pane-taskbar\" hidden={hidden}>\n <button\n aria-controls={controls}\n aria-expanded={expanded}\n aria-label=\"Menu\"\n className=\"routed-pane-taskbar-menu-button\"\n ref={menuButtonRef}\n type=\"button\"\n onClick={usesSheet ? onToggleDrawer : onToggleRail}\n >\n {menuIcon}\n </button>\n <div className=\"routed-pane-taskbar-end\">{tray}</div>\n </footer>\n );\n}\n"]}
|