@tearleads/windowing 0.2.36 → 0.2.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +1 -0
  2. package/desktop/DesktopIcons.js +1 -1
  3. package/desktop/DesktopIcons.js.map +1 -1
  4. package/docs/launcher.md +8 -0
  5. package/docs/publishing.md +2 -0
  6. package/docs/screensavers.md +74 -0
  7. package/index.d.ts +1 -0
  8. package/index.js +2 -1
  9. package/index.js.map +1 -1
  10. package/launcher/launcherDefinition.d.ts +6 -0
  11. package/launcher/launcherDefinition.js.map +1 -1
  12. package/package.json +1 -1
  13. package/routed/RoutedPaneNav.js +3 -1
  14. package/routed/RoutedPaneNav.js.map +1 -1
  15. package/screensaver/ScreensaverOverlay.d.ts +5 -0
  16. package/screensaver/ScreensaverOverlay.js +32 -0
  17. package/screensaver/ScreensaverOverlay.js.map +1 -0
  18. package/screensaver/ScreensaverProvider.d.ts +15 -0
  19. package/screensaver/ScreensaverProvider.js +13 -0
  20. package/screensaver/ScreensaverProvider.js.map +1 -0
  21. package/screensaver/screensaver.css +29 -0
  22. package/screensaver/screensaverHeldInput.d.ts +1 -0
  23. package/screensaver/screensaverHeldInput.js +76 -0
  24. package/screensaver/screensaverHeldInput.js.map +1 -0
  25. package/screensaver/screensaverInput.d.ts +2 -0
  26. package/screensaver/screensaverInput.js +105 -0
  27. package/screensaver/screensaverInput.js.map +1 -0
  28. package/screensaver/screensaverMachine.d.ts +34 -0
  29. package/screensaver/screensaverMachine.js +36 -0
  30. package/screensaver/screensaverMachine.js.map +1 -0
  31. package/screensaver/useScreensaverController.d.ts +6 -0
  32. package/screensaver/useScreensaverController.js +46 -0
  33. package/screensaver/useScreensaverController.js.map +1 -0
  34. package/screensaver/useScreensaverIsolation.d.ts +1 -0
  35. package/screensaver/useScreensaverIsolation.js +39 -0
  36. package/screensaver/useScreensaverIsolation.js.map +1 -0
package/README.md CHANGED
@@ -69,6 +69,7 @@ desktop surface must be a positioned container.
69
69
  - [Themes](./docs/appearance.md#themes)
70
70
  - [Wallpapers and Display Properties](./docs/appearance.md#wallpapers-and-display-properties)
71
71
  - [Styles](./docs/appearance.md#styles)
72
+ - [Pluggable screensavers](./docs/screensavers.md)
72
73
  - [Publishing](./docs/publishing.md)
73
74
 
74
75
  ## Dependency compatibility
@@ -37,7 +37,7 @@ export function DesktopIcons({ appIds, label = "Desktop", menuItems, onOpen, sto
37
37
  return (_jsxs("div", { "aria-label": label, "aria-orientation": "vertical", className: "desktop-icons", ref: setLayer, role: "listbox", children: [shownIds.map((appId) => {
38
38
  const app = definition.apps[appId];
39
39
  const position = positions[appId];
40
- return app && position ? (_jsx(DesktopIcon, { appId: appId, clamp: clamp, icon: app.icon, onContextMenu: (event) => openContextMenu(event, appId), onMove: (next) => moveIcon(appId, next), onOpen: () => open(appId), onSelect: () => setSelected(appId), onStep: (direction) => step(appId, direction), position: position, selected: selected === appId, tabbable: tabbableId === appId, title: app.title }, appId)) : null;
40
+ return app && position ? (_jsx(DesktopIcon, { appId: appId, clamp: clamp, icon: app.icon, onContextMenu: (event) => openContextMenu(event, appId), onMove: (next) => moveIcon(appId, next), onOpen: () => open(appId), onSelect: () => setSelected(appId), onStep: (direction) => step(appId, direction), position: position, selected: selected === appId, tabbable: tabbableId === appId, title: app.iconLabel ?? app.title }, appId)) : null;
41
41
  }), contextMenu && menuAppId !== undefined && menuApp && (_jsx(DesktopIconMenu, { icon: menuApp.icon, items: menuItems?.(menuAppId) ?? NO_MENU_ITEMS, onClose: closeContextMenu, onOpen: () => open(menuAppId), position: contextMenu.position }))] }));
42
42
  }
43
43
  //# sourceMappingURL=DesktopIcons.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DesktopIcons.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/desktop/DesktopIcons.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,M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AS,CAAC,KAAK,CAAC,CAAC;gBAClC,OAAO,GAAG,IAAI,QAAQ,CAAC,CAAC,CAAC,CACvB,KAAC,WAAW,IACV,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,GAAG,CAAC,IAAI,EAEd,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,EACvD,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,EACvC,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EACzB,QAAQ,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,EAClC,MAAM,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,EAC7C,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,KAAK,KAAK,EAC5B,QAAQ,EAAE,UAAU,KAAK,KAAK,EAC9B,KAAK,EAAE,GAAG,CAAC,KAAK,IATX,KAAK,CAUV,CACH,CAAC,CAAC,CAAC,IAAI,CAAC;YACX,CAAC,CAAC,EACD,WAAW,IAAI,SAAS,KAAK,SAAS,IAAI,OAAO,IAAI,CACpD,KAAC,eAAe,IACd,IAAI,EAAE,OAAO,CAAC,IAAI,EAClB,KAAK,EAAE,SAAS,EAAE,CAAC,SAAS,CAAC,IAAI,aAAa,EAC9C,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,EAC7B,QAAQ,EAAE,WAAW,CAAC,QAAQ,GAC9B,CACH,IACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useMemo, useState } from \"react\";\nimport {\n useLauncherNavigationActions,\n useLauncherNavigationState,\n} from \"../launcher/LauncherNavigationProvider\";\nimport { isLauncherAppId } from \"../launcher/launcherDefinition\";\nimport { useContextMenuState } from \"../menu/useContextMenuState\";\nimport { DesktopIcon } from \"./DesktopIcon\";\nimport { DesktopIconMenu, type DesktopIconMenuItem } from \"./DesktopIconMenu\";\nimport { resolveDesktopIconPositions } from \"./desktopState\";\nimport {\n createMemoryDesktopStateStorage,\n type DesktopStateStorage,\n} from \"./desktopStateStorage\";\nimport { useDesktopIconSelection } from \"./useDesktopIconSelection\";\nimport { useDesktopIconState } from \"./useDesktopIconState\";\nimport { useDesktopSurface } from \"./useDesktopSurface\";\nimport \"./DesktopIcons.css\";\n\nexport interface DesktopIconsProps<AppId extends string = string> {\n /** The launcher apps to show, in their default grid order. */\n appIds: ReadonlyArray<AppId>;\n /** The icon list's accessible name. Defaults to \"Desktop\". */\n label?: string | undefined;\n /** Extra context-menu items for an icon, shown below Open. */\n menuItems?:\n | ((appId: AppId) => ReadonlyArray<DesktopIconMenuItem>)\n | undefined;\n /** Opens an app. Defaults to the launcher's `openMiniApp`. */\n onOpen?: ((appId: AppId) => void) | undefined;\n /**\n * Where the icon positions persist. Without one they last as long as the\n * component. Keep the adapter stable: a new one reloads the layout.\n */\n storage?: DesktopStateStorage | undefined;\n}\n\nconst NO_MENU_ITEMS: ReadonlyArray<DesktopIconMenuItem> = [];\n\n/**\n * Launcher apps as icons on the windowed desktop, behind its windows. Drag an\n * icon to move it; double-click it, or press Enter, to open its app;\n * right-click it for its menu. Positions persist through `storage`.\n *\n * Render it inside a {@link LauncherNavigationProvider}, as the first child of\n * the positioned surface the windows lay out on.\n */\nexport function DesktopIcons<AppId extends string>({\n appIds,\n label = \"Desktop\",\n menuItems,\n onOpen,\n storage,\n}: DesktopIconsProps<AppId>) {\n const { definition } = useLauncherNavigationState();\n const { openMiniApp } = useLauncherNavigationActions();\n const [memoryStorage] = useState(createMemoryDesktopStateStorage);\n const { icons, moveIcon } = useDesktopIconState(storage ?? memoryStorage);\n const [layer, setLayer] = useState<HTMLDivElement | null>(null);\n const { clamp, surface } = useDesktopSurface(layer);\n const shownIds = useMemo(\n () => appIds.filter((appId) => isLauncherAppId(definition, appId)),\n [appIds, definition],\n );\n const { selected, setSelected, step, tabbableId } = useDesktopIconSelection(\n layer,\n shownIds,\n );\n const { closeContextMenu, contextMenu, openContextMenu } =\n useContextMenuState<AppId>({ onOpen: setSelected });\n const positions = useMemo(\n () => resolveDesktopIconPositions(shownIds, icons, surface),\n [icons, shownIds, surface],\n );\n const open = useCallback(\n (appId: AppId) => (onOpen ? onOpen(appId) : openMiniApp({ appId })),\n [onOpen, openMiniApp],\n );\n\n const menuAppId = contextMenu?.id;\n const menuApp = menuAppId === undefined ? null : definition.apps[menuAppId];\n return (\n <div\n aria-label={label}\n aria-orientation=\"vertical\"\n className=\"desktop-icons\"\n ref={setLayer}\n role=\"listbox\"\n >\n {shownIds.map((appId) => {\n const app = definition.apps[appId];\n const position = positions[appId];\n return app && position ? (\n <DesktopIcon\n appId={appId}\n clamp={clamp}\n icon={app.icon}\n key={appId}\n onContextMenu={(event) => openContextMenu(event, appId)}\n onMove={(next) => moveIcon(appId, next)}\n onOpen={() => open(appId)}\n onSelect={() => setSelected(appId)}\n onStep={(direction) => step(appId, direction)}\n position={position}\n selected={selected === appId}\n tabbable={tabbableId === appId}\n title={app.title}\n />\n ) : null;\n })}\n {contextMenu && menuAppId !== undefined && menuApp && (\n <DesktopIconMenu\n icon={menuApp.icon}\n items={menuItems?.(menuAppId) ?? NO_MENU_ITEMS}\n onClose={closeContextMenu}\n onOpen={() => open(menuAppId)}\n position={contextMenu.position}\n />\n )}\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"DesktopIcons.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/desktop/DesktopIcons.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,GAC3B,MAAM,wCAAwC,CAAC;AAChD,OA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W,IACV,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,GAAG,CAAC,IAAI,EAEd,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,EACvD,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,EACvC,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EACzB,QAAQ,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,EAClC,MAAM,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,EAC7C,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,KAAK,KAAK,EAC5B,QAAQ,EAAE,UAAU,KAAK,KAAK,EAC9B,KAAK,EAAE,GAAG,CAAC,SAAS,IAAI,GAAG,CAAC,KAAK,IAT5B,KAAK,CAUV,CACH,CAAC,CAAC,CAAC,IAAI,CAAC;YACX,CAAC,CAAC,EACD,WAAW,IAAI,SAAS,KAAK,SAAS,IAAI,OAAO,IAAI,CACpD,KAAC,eAAe,IACd,IAAI,EAAE,OAAO,CAAC,IAAI,EAClB,KAAK,EAAE,SAAS,EAAE,CAAC,SAAS,CAAC,IAAI,aAAa,EAC9C,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,EAC7B,QAAQ,EAAE,WAAW,CAAC,QAAQ,GAC9B,CACH,IACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useMemo, useState } from \"react\";\nimport {\n useLauncherNavigationActions,\n useLauncherNavigationState,\n} from \"../launcher/LauncherNavigationProvider\";\nimport { isLauncherAppId } from \"../launcher/launcherDefinition\";\nimport { useContextMenuState } from \"../menu/useContextMenuState\";\nimport { DesktopIcon } from \"./DesktopIcon\";\nimport { DesktopIconMenu, type DesktopIconMenuItem } from \"./DesktopIconMenu\";\nimport { resolveDesktopIconPositions } from \"./desktopState\";\nimport {\n createMemoryDesktopStateStorage,\n type DesktopStateStorage,\n} from \"./desktopStateStorage\";\nimport { useDesktopIconSelection } from \"./useDesktopIconSelection\";\nimport { useDesktopIconState } from \"./useDesktopIconState\";\nimport { useDesktopSurface } from \"./useDesktopSurface\";\nimport \"./DesktopIcons.css\";\n\nexport interface DesktopIconsProps<AppId extends string = string> {\n /** The launcher apps to show, in their default grid order. */\n appIds: ReadonlyArray<AppId>;\n /** The icon list's accessible name. Defaults to \"Desktop\". */\n label?: string | undefined;\n /** Extra context-menu items for an icon, shown below Open. */\n menuItems?:\n | ((appId: AppId) => ReadonlyArray<DesktopIconMenuItem>)\n | undefined;\n /** Opens an app. Defaults to the launcher's `openMiniApp`. */\n onOpen?: ((appId: AppId) => void) | undefined;\n /**\n * Where the icon positions persist. Without one they last as long as the\n * component. Keep the adapter stable: a new one reloads the layout.\n */\n storage?: DesktopStateStorage | undefined;\n}\n\nconst NO_MENU_ITEMS: ReadonlyArray<DesktopIconMenuItem> = [];\n\n/**\n * Launcher apps as icons on the windowed desktop, behind its windows. Drag an\n * icon to move it; double-click it, or press Enter, to open its app;\n * right-click it for its menu. Positions persist through `storage`.\n *\n * Render it inside a {@link LauncherNavigationProvider}, as the first child of\n * the positioned surface the windows lay out on.\n */\nexport function DesktopIcons<AppId extends string>({\n appIds,\n label = \"Desktop\",\n menuItems,\n onOpen,\n storage,\n}: DesktopIconsProps<AppId>) {\n const { definition } = useLauncherNavigationState();\n const { openMiniApp } = useLauncherNavigationActions();\n const [memoryStorage] = useState(createMemoryDesktopStateStorage);\n const { icons, moveIcon } = useDesktopIconState(storage ?? memoryStorage);\n const [layer, setLayer] = useState<HTMLDivElement | null>(null);\n const { clamp, surface } = useDesktopSurface(layer);\n const shownIds = useMemo(\n () => appIds.filter((appId) => isLauncherAppId(definition, appId)),\n [appIds, definition],\n );\n const { selected, setSelected, step, tabbableId } = useDesktopIconSelection(\n layer,\n shownIds,\n );\n const { closeContextMenu, contextMenu, openContextMenu } =\n useContextMenuState<AppId>({ onOpen: setSelected });\n const positions = useMemo(\n () => resolveDesktopIconPositions(shownIds, icons, surface),\n [icons, shownIds, surface],\n );\n const open = useCallback(\n (appId: AppId) => (onOpen ? onOpen(appId) : openMiniApp({ appId })),\n [onOpen, openMiniApp],\n );\n\n const menuAppId = contextMenu?.id;\n const menuApp = menuAppId === undefined ? null : definition.apps[menuAppId];\n return (\n <div\n aria-label={label}\n aria-orientation=\"vertical\"\n className=\"desktop-icons\"\n ref={setLayer}\n role=\"listbox\"\n >\n {shownIds.map((appId) => {\n const app = definition.apps[appId];\n const position = positions[appId];\n return app && position ? (\n <DesktopIcon\n appId={appId}\n clamp={clamp}\n icon={app.icon}\n key={appId}\n onContextMenu={(event) => openContextMenu(event, appId)}\n onMove={(next) => moveIcon(appId, next)}\n onOpen={() => open(appId)}\n onSelect={() => setSelected(appId)}\n onStep={(direction) => step(appId, direction)}\n position={position}\n selected={selected === appId}\n tabbable={tabbableId === appId}\n title={app.iconLabel ?? app.title}\n />\n ) : null;\n })}\n {contextMenu && menuAppId !== undefined && menuApp && (\n <DesktopIconMenu\n icon={menuApp.icon}\n items={menuItems?.(menuAppId) ?? NO_MENU_ITEMS}\n onClose={closeContextMenu}\n onOpen={() => open(menuAppId)}\n position={contextMenu.position}\n />\n )}\n </div>\n );\n}\n"]}
package/docs/launcher.md CHANGED
@@ -55,6 +55,7 @@ const LAUNCHER: LauncherDefinition<"notes" | "contacts"> = {
55
55
  notes: {
56
56
  createComponent: () => NotesApp,
57
57
  icon: NoteIcon,
58
+ iconLabel: "Quick notes",
58
59
  initialShowSidebar: false,
59
60
  title: "Notes",
60
61
  },
@@ -65,6 +66,13 @@ const LAUNCHER: LauncherDefinition<"notes" | "contacts"> = {
65
66
  };
66
67
  ```
67
68
 
69
+ Each app's optional `iconLabel` labels its desktop icon and routed launcher
70
+ entries (both the tablet rail and mobile sheet). Omit it to use `title`.
71
+ Window chrome and the routed content heading always keep `title`; app ids,
72
+ routes, and stored desktop positions do not change. Hosts building a start
73
+ menu from the definition should use `app.iconLabel ?? app.title` for each
74
+ item's `label`, as Tearleads' start and desktop context menus do.
75
+
68
76
  `LauncherNavigationProvider` takes the definition and a `NavigationMode`, and
69
77
  goes inside a `WindowStateProvider`. In `windowed` mode
70
78
  `useLauncherNavigationActions().openMiniApp({ appId })` opens the app's window,
@@ -24,6 +24,8 @@ The declarations drop the stylesheet imports tsc keeps
24
24
  in them, which a consumer's typecheck could not resolve. The smoke script
25
25
  installs the lowest React the peer range admits, typechecks against the
26
26
  declarations with TypeScript's defaults, and bundles a named import with webpack.
27
+ It also consumes `MiniAppDefinition.iconLabel` through the packed declarations
28
+ and opens a labeled desktop icon, checking that the window keeps its own title.
27
29
 
28
30
  Merging to `main` publishes. When [`packages/windowing`][windowing-source] changes
29
31
  there, [`.github/workflows/windowing-publish.yml`][windowing-publish] publishes
@@ -0,0 +1,74 @@
1
+ # Screensavers
2
+
3
+ Part of [@tearleads/windowing](../README.md).
4
+
5
+ Mount one `ScreensaverProvider` around the host's desktop and taskbar. It needs
6
+ no window-state or launcher provider. The host supplies the animation and the
7
+ control that starts it; this package adds no animation, idle timer, saved
8
+ preference, or global launch shortcut.
9
+
10
+ ```tsx
11
+ import { ScreensaverProvider, useScreensaver } from "@tearleads/windowing";
12
+
13
+ function StartScreensaver() {
14
+ const { start } = useScreensaver();
15
+ return <button onClick={start}>Start screensaver</button>;
16
+ }
17
+
18
+ <ScreensaverProvider screensaver={MyAnimation}>
19
+ <Desktop />
20
+ <Taskbar />
21
+ <StartScreensaver />
22
+ </ScreensaverProvider>;
23
+ ```
24
+
25
+ `MyAnimation` is a React component with no required props. It mounts only while
26
+ active, inside a viewport-sized container; a canvas can use `width: 100%` and
27
+ `height: 100%`. It owns its animation and must cancel its work on unmount.
28
+ Replacing the component while active replaces only that animation, not the
29
+ session or grace timer. Styles are included by the public import.
30
+
31
+ `useScreensaver()` returns stable `start()` and `stop()` callbacks and an
32
+ `isActive` boolean. It throws outside the provider. Repeated starts while active
33
+ are ignored. `stop()` exits immediately and intentionally cancels input
34
+ isolation, including a pending release tail; reserve it for explicit host
35
+ control or teardown, not an effect watching `isActive`. Start and stop do not
36
+ close, minimize, or recreate the host's windows.
37
+
38
+ The optional `gracePeriodMs` defaults to `2000`. Input during that initial
39
+ period is consumed without dismissal; Escape always exits. After grace,
40
+ keyboard, pointer, mouse, touch, and wheel activity dismiss. The dismissing
41
+ input and that discrete press's release/click tail are consumed so the desktop
42
+ does not receive an accidental click or shortcut. After that tail settles,
43
+ later presses are new host input, including a double-click's second press.
44
+ A new start during the isolated tail is ignored until
45
+ the gesture finishes. Idle listeners are passive and retain only modifiers,
46
+ not ordinary key presses. Meta release clears keys whose release the browser
47
+ omitted; losing focus or hiding the page clears the tail too. If a release is
48
+ lost while the page stays visible, press and release Escape to recover.
49
+ There is deliberately no deadline that unlocks under a still-held pointer:
50
+ that would allow its later release to click through. Escape is the explicit
51
+ recovery action, and its own release is consumed. Unmounting the provider
52
+ clears listeners and timers too. Isolation covers discrete releases/clicks,
53
+ not later trackpad momentum events after a wheel dismissal. Changing
54
+ `gracePeriodMs` during grace restarts the timer; `0` disables grace, so hosts
55
+ launching with a key should keep a positive grace period for that key's release.
56
+
57
+ The overlay is a native modal `dialog` in the document body, above windows and
58
+ the taskbar in the browser's top layer. It hides the cursor and makes the page
59
+ inert, including embedded frames. Native modal dialogs escape ancestor
60
+ inertness, per the [HTML modal dialog rules][modal-inertness]. The page
61
+ remains inert while a dismissing
62
+ press finishes, even though the animation and overlay have unmounted. The
63
+ animation itself is inert and hidden from assistive technology; the dialog
64
+ announces "Screensaver" and the Escape instruction. Focus returns to the
65
+ previous connected element unless the host has moved it elsewhere. Existing
66
+ body inertness is restored, not unconditionally removed.
67
+
68
+ Use a browser with native modal dialogs and `inert` support. This is a visual
69
+ screensaver, not an authentication lock or security boundary. Host code should
70
+ not open competing modal dialogs or change body inertness during a session.
71
+ Mount the provider only in layouts where the host wants screensaver behavior;
72
+ routed layouts need not include it.
73
+
74
+ [modal-inertness]: https://html.spec.whatwg.org/multipage/interaction.html#modal-dialogs-and-inert-subtrees
package/index.d.ts CHANGED
@@ -31,6 +31,7 @@ export { useLongPress } from "./menu/useLongPress.js";
31
31
  export { RoutedPane, type RoutedPaneProps } from "./routed/RoutedPane.js";
32
32
  export { RoutedPaneOverlayHostProvider, type RoutedPaneOverlayHostValue, useRoutedPaneOverlayHost, } from "./routed/RoutedPaneOverlayHost.js";
33
33
  export type { SubscribeKeyboardVisibility } from "./routed/useMobileKeyboardVisible.js";
34
+ export { type ScreensaverControls, ScreensaverProvider, type ScreensaverProviderProps, useScreensaver, } from "./screensaver/ScreensaverProvider.js";
34
35
  export { SidebarResizeHandle, useSidebarResize } from "./sidebar/SidebarResize.js";
35
36
  export { ThemeProvider, useOptionalTheme, useTheme, } from "./theme/ThemeProvider.js";
36
37
  export { ThemeSwitch } from "./theme/ThemeSwitch.js";
package/index.js CHANGED
@@ -4,7 +4,7 @@ import "./tokens.css";
4
4
  // start menu and theme switch, the icons the chrome draws, a launcher of
5
5
  // mini-apps that shows them in windows or in the routed (iPad / phone) shell,
6
6
  // and desktop icons that open them, with a storage adapter for their layout,
7
- // over a wallpaper chosen in Display Properties.
7
+ // over a wallpaper chosen in Display Properties, plus a host-supplied screensaver.
8
8
  export { createRequiredContext, } from "./createRequiredContext.js";
9
9
  export { DesktopIcons, } from "./desktop/DesktopIcons.js";
10
10
  export { createMemoryDesktopStateStorage, createOpfsDesktopStateStorage, } from "./desktop/desktopStateStorage.js";
@@ -34,6 +34,7 @@ export { useContextMenuPositionState, useContextMenuState, } from "./menu/useCon
34
34
  export { useLongPress } from "./menu/useLongPress.js";
35
35
  export { RoutedPane } from "./routed/RoutedPane.js";
36
36
  export { RoutedPaneOverlayHostProvider, useRoutedPaneOverlayHost, } from "./routed/RoutedPaneOverlayHost.js";
37
+ export { ScreensaverProvider, useScreensaver, } from "./screensaver/ScreensaverProvider.js";
37
38
  export { SidebarResizeHandle, useSidebarResize } from "./sidebar/SidebarResize.js";
38
39
  export { ThemeProvider, useOptionalTheme, useTheme, } from "./theme/ThemeProvider.js";
39
40
  export { ThemeSwitch } from "./theme/ThemeSwitch.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,EAEL,0BAA0B,EAE1B,4BAA4B,EAC5B,0BAA0B,EAC1B,uBAAuB,EACvB,kCAAkC,GACnC,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACL,eAAe,EAGf,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,4BAA4B,EAC5B,6BAA6B,GAC9B,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAwB,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EACL,8BAA8B,EAC9B,yBAAyB,EACzB,iCAAiC,GAClC,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAE,oBAAo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EACL,gBAAgB,GAEjB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,mBAAmB,GACpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,GAClB,MAAM,+BAA+B,CAAC;AAKvC,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,wBAAwB,EACxB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,MAAM,EAA8B,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,qBAAqB,EACrB,wBAAwB,EACxB,6BAA6B,EAC7B,uBAAuB,EACvB,wBAAwB,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"]}
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,mFAAmF;AACnF,OAAO,EACL,qBAAqB,GAEtB,MAAM,yBAAyB,CAAC;AAEjC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8BAA8B,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,qBAAqB,EACrB,wBAAwB,EACxB,6BAA6B,EAC7B,uBAAuB,EACvB,wBAAwB,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, plus a host-supplied screensaver.\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 {\n type ScreensaverControls,\n ScreensaverProvider,\n type ScreensaverProviderProps,\n useScreensaver,\n} from \"./screensaver/ScreensaverProvider\";\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"]}
@@ -10,12 +10,18 @@ export interface MiniAppDefinition {
10
10
  createComponent: () => ComponentType;
11
11
  /** The app's glyph in the launchers and the taskbar. */
12
12
  icon?: WindowingIcon | undefined;
13
+ /**
14
+ * Label for desktop icons and launcher navigation. Defaults to `title`.
15
+ * Does not change window titles, routed headings, app ids, or routes.
16
+ */
17
+ iconLabel?: string | undefined;
13
18
  /**
14
19
  * Whether the app's sidebar starts shown, in a new window and on the routed
15
20
  * shell's tablet tier. Defaults to shown. The phone tier always starts with
16
21
  * the sidebar hidden.
17
22
  */
18
23
  initialShowSidebar?: boolean | undefined;
24
+ /** The window title and routed content heading. */
19
25
  title: string;
20
26
  /**
21
27
  * The size a new window opens at, in CSS pixels. Defaults to the
@@ -1 +1 @@
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"]}
1
+ {"version":3,"file":"launcherDefinition.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/launcher/launcherDefinition.ts"],"names":[],"mappings":"AAwDA,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 * Label for desktop icons and launcher navigation. Defaults to `title`.\n * Does not change window titles, routed headings, app ids, or routes.\n */\n iconLabel?: string | 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 /** The window title and routed content heading. */\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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tearleads/windowing",
3
- "version": "0.2.36",
3
+ "version": "0.2.38",
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": {
@@ -13,7 +13,9 @@ function useRoutedPaneNavItems(appIds) {
13
13
  const { definition } = useLauncherNavigationState();
14
14
  return useMemo(() => appIds.flatMap((appId) => {
15
15
  const app = definition.apps[appId];
16
- return app ? [{ appId, icon: app.icon, label: app.title }] : [];
16
+ return app
17
+ ? [{ appId, icon: app.icon, label: app.iconLabel ?? app.title }]
18
+ : [];
17
19
  }), [appIds, definition]);
18
20
  }
19
21
  // Let the browser handle modified clicks (Cmd/Ctrl/Shift/Alt + click,
@@ -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;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,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,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xB,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
+ {"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;AAC1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e,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\";\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\n ? [{ appId, icon: app.icon, label: app.iconLabel ?? app.title }]\n : [];\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"]}
@@ -0,0 +1,5 @@
1
+ import { type ReactNode } from "react";
2
+ export declare function ScreensaverOverlay({ children, onStop, }: {
3
+ children: ReactNode;
4
+ onStop: () => void;
5
+ }): import("react").ReactPortal;
@@ -0,0 +1,32 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useLayoutEffect, useRef } from "react";
3
+ import { createPortal } from "react-dom";
4
+ import "./screensaver.css";
5
+ export function ScreensaverOverlay({ children, onStop, }) {
6
+ const ref = useRef(null);
7
+ useLayoutEffect(() => {
8
+ const dialog = ref.current;
9
+ if (!dialog)
10
+ return;
11
+ const cancel = (event) => {
12
+ event.preventDefault();
13
+ event.stopImmediatePropagation();
14
+ onStop();
15
+ };
16
+ const close = () => {
17
+ if (!dialog.open)
18
+ onStop();
19
+ };
20
+ dialog.addEventListener("cancel", cancel);
21
+ dialog.addEventListener("close", close);
22
+ dialog.showModal();
23
+ dialog.focus();
24
+ return () => {
25
+ dialog.removeEventListener("cancel", cancel);
26
+ dialog.removeEventListener("close", close);
27
+ dialog.close();
28
+ };
29
+ }, [onStop]);
30
+ return createPortal(_jsx("dialog", { "aria-label": "Screensaver", "aria-description": "Press Escape to exit.", className: "screensaver-overlay", ref: ref, children: _jsx("div", { "aria-hidden": "true", inert: true, className: "screensaver-content", children: children }) }), document.body);
31
+ }
32
+ //# sourceMappingURL=ScreensaverOverlay.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScreensaverOverlay.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/screensaver/ScreensaverOverlay.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkB,eAAe,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,mBAAmB,CAAC;AAE3B,MAAM,UAAU,kBAAkB,CAAC,EACjC,QAAQ,EACR,MAAM,GAIP;IACC,MAAM,GAAG,GAAG,MAAM,CAAoB,IAAI,CAAC,CAAC;IAC5C,eAAe,CAAC,GAAG,EAAE;QACnB,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC;QAC3B,IAAI,CAAC,MAAM;YAAE,OAAO;QACpB,MAAM,MAAM,GAAG,CAAC,KAAY,EAAE,EAAE;YAC9B,KAAK,CAAC,cAAc,EAAE,CAAC;YACvB,KAAK,CAAC,wBAAwB,EAAE,CAAC;YACjC,MAAM,EAAE,CAAC;QACX,CAAC,CAAC;QACF,MAAM,KAAK,GAAG,GAAG,EAAE;YACjB,IAAI,CAAC,MAAM,CAAC,IAAI;gBAAE,MAAM,EAAE,CAAC;QAC7B,CAAC,CAAC;QACF,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC1C,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QACxC,MAAM,CAAC,SAAS,EAAE,CAAC;QACnB,MAAM,CAAC,KAAK,EAAE,CAAC;QACf,OAAO,GAAG,EAAE;YACV,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YAC7C,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAC3C,MAAM,CAAC,KAAK,EAAE,CAAC;QACjB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IACb,OAAO,YAAY,CACjB,+BACa,aAAa,sBACP,uBAAuB,EACxC,SAAS,EAAC,qBAAqB,EAC/B,GAAG,EAAE,GAAG,YAER,6BAAiB,MAAM,EAAC,KAAK,QAAC,SAAS,EAAC,qBAAqB,YAC1D,QAAQ,GACL,GACC,EACT,QAAQ,CAAC,IAAI,CACd,CAAC;AACJ,CAAC","sourcesContent":["import { type ReactNode, useLayoutEffect, useRef } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport \"./screensaver.css\";\n\nexport function ScreensaverOverlay({\n children,\n onStop,\n}: {\n children: ReactNode;\n onStop: () => void;\n}) {\n const ref = useRef<HTMLDialogElement>(null);\n useLayoutEffect(() => {\n const dialog = ref.current;\n if (!dialog) return;\n const cancel = (event: Event) => {\n event.preventDefault();\n event.stopImmediatePropagation();\n onStop();\n };\n const close = () => {\n if (!dialog.open) onStop();\n };\n dialog.addEventListener(\"cancel\", cancel);\n dialog.addEventListener(\"close\", close);\n dialog.showModal();\n dialog.focus();\n return () => {\n dialog.removeEventListener(\"cancel\", cancel);\n dialog.removeEventListener(\"close\", close);\n dialog.close();\n };\n }, [onStop]);\n return createPortal(\n <dialog\n aria-label=\"Screensaver\"\n aria-description=\"Press Escape to exit.\"\n className=\"screensaver-overlay\"\n ref={ref}\n >\n <div aria-hidden=\"true\" inert className=\"screensaver-content\">\n {children}\n </div>\n </dialog>,\n document.body,\n );\n}\n"]}
@@ -0,0 +1,15 @@
1
+ import { type ComponentType, type ReactNode } from "react";
2
+ export interface ScreensaverControls {
3
+ start: () => void;
4
+ stop: () => void;
5
+ /** The animation is mounted; false can still consume a pending release. */
6
+ isActive: boolean;
7
+ }
8
+ export interface ScreensaverProviderProps {
9
+ children: ReactNode;
10
+ screensaver: ComponentType;
11
+ gracePeriodMs?: number;
12
+ }
13
+ declare const useScreensaver: () => ScreensaverControls;
14
+ export { useScreensaver };
15
+ export declare function ScreensaverProvider({ children, screensaver: Screensaver, gracePeriodMs, }: ScreensaverProviderProps): import("react").JSX.Element;
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useMemo } from "react";
3
+ import { createRequiredContext } from "../createRequiredContext.js";
4
+ import { ScreensaverOverlay } from "./ScreensaverOverlay.js";
5
+ import { useScreensaverController } from "./useScreensaverController.js";
6
+ const { context: ScreensaverContext, useRequired: useScreensaver } = createRequiredContext("useScreensaver requires ScreensaverProvider");
7
+ export { useScreensaver };
8
+ export function ScreensaverProvider({ children, screensaver: Screensaver, gracePeriodMs = 2000, }) {
9
+ const { isActive, start, stop, session } = useScreensaverController(gracePeriodMs);
10
+ const value = useMemo(() => ({ start, stop, isActive }), [start, stop, isActive]);
11
+ return (_jsxs(ScreensaverContext.Provider, { value: value, children: [children, isActive && (_jsx(ScreensaverOverlay, { onStop: stop, children: _jsx(Screensaver, {}) }, session))] }));
12
+ }
13
+ //# sourceMappingURL=ScreensaverProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScreensaverProvider.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/screensaver/ScreensaverProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAsC,OAAO,EAAE,MAAM,OAAO,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAatE,MAAM,EAAE,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,cAAc,EAAE,GAChE,qBAAqB,CACnB,6CAA6C,CAC9C,CAAC;AAEJ,OAAO,EAAE,cAAc,EAAE,CAAC;AAE1B,MAAM,UAAU,mBAAmB,CAAC,EAClC,QAAQ,EACR,WAAW,EAAE,WAAW,EACxB,aAAa,GAAG,IAAI,GACK;IACzB,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,GACtC,wBAAwB,CAAC,aAAa,CAAC,CAAC;IAC1C,MAAM,KAAK,GAAG,OAAO,CACnB,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,EACjC,CAAC,KAAK,EAAE,IAAI,EAAE,QAAQ,CAAC,CACxB,CAAC;IACF,OAAO,CACL,MAAC,kBAAkB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,aACtC,QAAQ,EACR,QAAQ,IAAI,CACX,KAAC,kBAAkB,IAAe,MAAM,EAAE,IAAI,YAC5C,KAAC,WAAW,KAAG,IADQ,OAAO,CAEX,CACtB,IAC2B,CAC/B,CAAC;AACJ,CAAC","sourcesContent":["import { type ComponentType, type ReactNode, useMemo } from \"react\";\nimport { createRequiredContext } from \"../createRequiredContext\";\nimport { ScreensaverOverlay } from \"./ScreensaverOverlay\";\nimport { useScreensaverController } from \"./useScreensaverController\";\n\nexport interface ScreensaverControls {\n start: () => void;\n stop: () => void;\n /** The animation is mounted; false can still consume a pending release. */\n isActive: boolean;\n}\nexport interface ScreensaverProviderProps {\n children: ReactNode;\n screensaver: ComponentType;\n gracePeriodMs?: number;\n}\nconst { context: ScreensaverContext, useRequired: useScreensaver } =\n createRequiredContext<ScreensaverControls>(\n \"useScreensaver requires ScreensaverProvider\",\n );\n\nexport { useScreensaver };\n\nexport function ScreensaverProvider({\n children,\n screensaver: Screensaver,\n gracePeriodMs = 2000,\n}: ScreensaverProviderProps) {\n const { isActive, start, stop, session } =\n useScreensaverController(gracePeriodMs);\n const value = useMemo(\n () => ({ start, stop, isActive }),\n [start, stop, isActive],\n );\n return (\n <ScreensaverContext.Provider value={value}>\n {children}\n {isActive && (\n <ScreensaverOverlay key={session} onStop={stop}>\n <Screensaver />\n </ScreensaverOverlay>\n )}\n </ScreensaverContext.Provider>\n );\n}\n"]}
@@ -0,0 +1,29 @@
1
+ .screensaver-overlay {
2
+ position: fixed;
3
+ inset: 0;
4
+ width: 100%;
5
+ height: 100%;
6
+ max-width: none;
7
+ max-height: none;
8
+ margin: 0;
9
+ padding: 0;
10
+ border: 0;
11
+ overflow: hidden;
12
+ background: black;
13
+ cursor: none;
14
+ outline: none;
15
+ touch-action: none;
16
+ overscroll-behavior: none;
17
+ }
18
+
19
+ .screensaver-overlay::backdrop {
20
+ background: black;
21
+ cursor: none;
22
+ }
23
+
24
+ .screensaver-content {
25
+ width: 100%;
26
+ height: 100%;
27
+ pointer-events: none;
28
+ user-select: none;
29
+ }
@@ -0,0 +1 @@
1
+ export declare function trackHeldScreensaverInput(held: Set<string>, event: Event, includePresses: boolean): void;
@@ -0,0 +1,76 @@
1
+ // Raw input inventory, independent of screensaver lifecycle. Observe idle
2
+ // input too, since a modifier may already be down when the host starts it.
3
+ function trackModifiers(held, event) {
4
+ // Input first held in an iframe cannot be observed by the parent. The next
5
+ // key/pointer event carries its modifier flags across the focus change.
6
+ const modifiers = {
7
+ Alt: event.altKey,
8
+ Control: event.ctrlKey,
9
+ Meta: event.metaKey,
10
+ Shift: event.shiftKey,
11
+ };
12
+ for (const [name, pressed] of Object.entries(modifiers)) {
13
+ const id = `modifier:${name}`;
14
+ if (pressed)
15
+ held.add(id);
16
+ else
17
+ held.delete(id);
18
+ }
19
+ }
20
+ function trackKey(held, event, includePresses) {
21
+ // Meta combinations may omit ordinary releases on macOS, but Escape's
22
+ // explicit recovery gesture must still consume its own keyup.
23
+ if (event.type === "keyup" && event.key === "Meta") {
24
+ for (const key of held)
25
+ if (key.startsWith("key:") && key !== "key:Escape")
26
+ held.delete(key);
27
+ }
28
+ if (!includePresses &&
29
+ !["Alt", "Control", "Meta", "Shift"].includes(event.key))
30
+ return;
31
+ const key = `key:${event.code || event.key}`;
32
+ if (event.type === "keydown")
33
+ held.add(key);
34
+ if (event.type === "keyup")
35
+ held.delete(key);
36
+ }
37
+ export function trackHeldScreensaverInput(held, event, includePresses) {
38
+ if (event instanceof KeyboardEvent || event instanceof MouseEvent) {
39
+ trackModifiers(held, event);
40
+ }
41
+ if (event instanceof KeyboardEvent) {
42
+ trackKey(held, event, includePresses);
43
+ return;
44
+ }
45
+ if (!includePresses)
46
+ return;
47
+ const pointer = event instanceof PointerEvent ? event.pointerId : 0;
48
+ const button = event instanceof MouseEvent ? event.button : 0;
49
+ switch (event.type) {
50
+ case "pointerdown":
51
+ held.add(`pointer:${pointer}`);
52
+ break;
53
+ case "pointerup":
54
+ case "pointercancel":
55
+ held.delete(`pointer:${pointer}`);
56
+ break;
57
+ case "mousedown":
58
+ held.add(`mouse:${button}`);
59
+ break;
60
+ case "mouseup":
61
+ held.delete(`mouse:${button}`);
62
+ break;
63
+ case "touchstart":
64
+ held.add("touch");
65
+ break;
66
+ case "touchend":
67
+ case "touchcancel":
68
+ if (typeof TouchEvent === "undefined" ||
69
+ !(event instanceof TouchEvent) ||
70
+ event.touches.length === 0) {
71
+ held.delete("touch");
72
+ }
73
+ break;
74
+ }
75
+ }
76
+ //# sourceMappingURL=screensaverHeldInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"screensaverHeldInput.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/screensaver/screensaverHeldInput.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,2EAA2E;AAC3E,SAAS,cAAc,CAAC,IAAiB,EAAE,KAAiC;IAC1E,2EAA2E;IAC3E,wEAAwE;IACxE,MAAM,SAAS,GAAG;QAChB,GAAG,EAAE,KAAK,CAAC,MAAM;QACjB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,IAAI,EAAE,KAAK,CAAC,OAAO;QACnB,KAAK,EAAE,KAAK,CAAC,QAAQ;KACtB,CAAC;IACF,KAAK,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;QACxD,MAAM,EAAE,GAAG,YAAY,IAAI,EAAE,CAAC;QAC9B,IAAI,OAAO;YAAE,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;;YACrB,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACvB,CAAC;AACH,CAAC;AAED,SAAS,QAAQ,CACf,IAAiB,EACjB,KAAoB,EACpB,cAAuB;IAEvB,sEAAsE;IACtE,8DAA8D;IAC9D,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,IAAI,KAAK,CAAC,GAAG,KAAK,MAAM,EAAE,CAAC;QACnD,KAAK,MAAM,GAAG,IAAI,IAAI;YACpB,IAAI,GAAG,CAAC,UAAU,CAAC,MAAM,CAA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CAAC;QACjB,KAAK,eAAe;YAClB,IAAI,CAAC,MAAM,CAAC,WAAW,OAAO,EAAE,CAAC,CAAC;YAClC,MAAM;QACR,KAAK,WAAW;YACd,IAAI,CAAC,GAAG,CAAC,SAAS,MAAM,EAAE,CAAC,CAAC;YAC5B,MAAM;QACR,KAAK,SAAS;YACZ,IAAI,CAAC,MAAM,CAAC,SAAS,MAAM,EAAE,CAAC,CAAC;YAC/B,MAAM;QACR,KAAK,YAAY;YACf,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAClB,MAAM;QACR,KAAK,UAAU,CAAC;QAChB,KAAK,aAAa;YAChB,IACE,OAAO,UAAU,KAAK,WAAW;gBACjC,CAAC,CAAC,KAAK,YAAY,UAAU,CAAC;gBAC9B,KAAK,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAC1B,CAAC;gBACD,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YACvB,CAAC;YACD,MAAM;IACV,CAAC;AACH,CAAC","sourcesContent":["// Raw input inventory, independent of screensaver lifecycle. Observe idle\n// input too, since a modifier may already be down when the host starts it.\nfunction trackModifiers(held: Set<string>, event: KeyboardEvent | MouseEvent) {\n // Input first held in an iframe cannot be observed by the parent. The next\n // key/pointer event carries its modifier flags across the focus change.\n const modifiers = {\n Alt: event.altKey,\n Control: event.ctrlKey,\n Meta: event.metaKey,\n Shift: event.shiftKey,\n };\n for (const [name, pressed] of Object.entries(modifiers)) {\n const id = `modifier:${name}`;\n if (pressed) held.add(id);\n else held.delete(id);\n }\n}\n\nfunction trackKey(\n held: Set<string>,\n event: KeyboardEvent,\n includePresses: boolean,\n) {\n // Meta combinations may omit ordinary releases on macOS, but Escape's\n // explicit recovery gesture must still consume its own keyup.\n if (event.type === \"keyup\" && event.key === \"Meta\") {\n for (const key of held)\n if (key.startsWith(\"key:\") && key !== \"key:Escape\") held.delete(key);\n }\n if (\n !includePresses &&\n ![\"Alt\", \"Control\", \"Meta\", \"Shift\"].includes(event.key)\n )\n return;\n const key = `key:${event.code || event.key}`;\n if (event.type === \"keydown\") held.add(key);\n if (event.type === \"keyup\") held.delete(key);\n}\n\nexport function trackHeldScreensaverInput(\n held: Set<string>,\n event: Event,\n includePresses: boolean,\n) {\n if (event instanceof KeyboardEvent || event instanceof MouseEvent) {\n trackModifiers(held, event);\n }\n if (event instanceof KeyboardEvent) {\n trackKey(held, event, includePresses);\n return;\n }\n if (!includePresses) return;\n const pointer = event instanceof PointerEvent ? event.pointerId : 0;\n const button = event instanceof MouseEvent ? event.button : 0;\n switch (event.type) {\n case \"pointerdown\":\n held.add(`pointer:${pointer}`);\n break;\n case \"pointerup\":\n case \"pointercancel\":\n held.delete(`pointer:${pointer}`);\n break;\n case \"mousedown\":\n held.add(`mouse:${button}`);\n break;\n case \"mouseup\":\n held.delete(`mouse:${button}`);\n break;\n case \"touchstart\":\n held.add(\"touch\");\n break;\n case \"touchend\":\n case \"touchcancel\":\n if (\n typeof TouchEvent === \"undefined\" ||\n !(event instanceof TouchEvent) ||\n event.touches.length === 0\n ) {\n held.delete(\"touch\");\n }\n break;\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import type { ScreensaverEvent, ScreensaverState } from "./screensaverMachine.js";
2
+ export declare function captureScreensaverInput(readState: () => ScreensaverState, send: (event: ScreensaverEvent) => void, held: Set<string>, engaged: boolean): () => void;
@@ -0,0 +1,105 @@
1
+ import { trackHeldScreensaverInput } from "./screensaverHeldInput.js";
2
+ const pointerReleases = [
3
+ "pointerup",
4
+ "mouseup",
5
+ "touchend",
6
+ "touchcancel",
7
+ "pointercancel",
8
+ ];
9
+ function dismissEvent(event, hasHeldInput) {
10
+ return {
11
+ type: "dismiss",
12
+ escape: event instanceof KeyboardEvent && event.key === "Escape",
13
+ drain: hasHeldInput ||
14
+ pointerReleases.includes(event.type) ||
15
+ ["keydown", "pointerdown", "mousedown", "touchstart"].includes(event.type) ||
16
+ (event instanceof MouseEvent && event.buttons !== 0),
17
+ };
18
+ }
19
+ function drainReleased(event, held) {
20
+ // Escape is an explicit recovery gesture even if a previous release was
21
+ // lost. Keep its own keyup isolated before restoring the page.
22
+ if (event instanceof KeyboardEvent && event.key === "Escape") {
23
+ if (event.type === "keydown" || event.type === "keyup")
24
+ held.clear();
25
+ if (event.type === "keydown")
26
+ held.add(`key:${event.code || event.key}`);
27
+ return event.type === "keyup";
28
+ }
29
+ return (held.size === 0 &&
30
+ [
31
+ "keyup",
32
+ "pointerup",
33
+ "mouseup",
34
+ "touchend",
35
+ "touchcancel",
36
+ "pointercancel",
37
+ "click",
38
+ "contextmenu",
39
+ ].includes(event.type));
40
+ }
41
+ export function captureScreensaverInput(readState, send, held, engaged) {
42
+ const consume = (event) => {
43
+ const { status } = readState();
44
+ trackHeldScreensaverInput(held, event, status !== "idle");
45
+ if (status === "idle")
46
+ return;
47
+ event.preventDefault();
48
+ event.stopImmediatePropagation();
49
+ if (status === "settling")
50
+ return;
51
+ if (status === "draining") {
52
+ if (drainReleased(event, held))
53
+ send({ type: "released" });
54
+ return;
55
+ }
56
+ send(dismissEvent(event, held.size > 0));
57
+ // A press can start during grace and first dismiss on its release. Keep
58
+ // isolation through the following click, even when nothing remains held.
59
+ if (held.size === 0 && pointerReleases.includes(event.type))
60
+ send({ type: "released" });
61
+ };
62
+ const events = [
63
+ "click",
64
+ "dblclick",
65
+ "auxclick",
66
+ "contextmenu",
67
+ "keydown",
68
+ "keyup",
69
+ "keypress",
70
+ "pointerdown",
71
+ "pointerup",
72
+ "pointermove",
73
+ "pointercancel",
74
+ "mousedown",
75
+ "mouseup",
76
+ "mousemove",
77
+ "touchstart",
78
+ "touchend",
79
+ "touchmove",
80
+ "touchcancel",
81
+ "wheel",
82
+ ];
83
+ for (const type of events)
84
+ window.addEventListener(type, consume, {
85
+ capture: true,
86
+ passive: !engaged,
87
+ });
88
+ const blur = () => {
89
+ held.clear();
90
+ send({ type: "released" });
91
+ };
92
+ const visibility = () => {
93
+ if (document.visibilityState === "hidden")
94
+ blur();
95
+ };
96
+ document.addEventListener("visibilitychange", visibility);
97
+ window.addEventListener("blur", blur);
98
+ return () => {
99
+ document.removeEventListener("visibilitychange", visibility);
100
+ window.removeEventListener("blur", blur);
101
+ for (const type of events)
102
+ window.removeEventListener(type, consume, true);
103
+ };
104
+ }
105
+ //# sourceMappingURL=screensaverInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"screensaverInput.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/screensaver/screensaverInput.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAGnE,MAAM,eAAe,GAAG;IACtB,WAAW;IACX,SAAS;IACT,UAAU;IACV,aAAa;IACb,eAAe;CAChB,CAAC;AAEF,SAAS,YAAY,CAAC,KAAY,EAAE,YAAqB;IACvD,OAAO;QACL,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,KAAK,YAAY,aAAa,IAAI,KAAK,CAAC,GAAG,KAAK,QAAQ;QAChE,KAAK,EACH,YAAY;YACZ,eAAe,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC;YACpC,CAAC,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC,QAAQ,CAC5D,KAAK,CAAC,IAAI,CACX;YACD,CAAC,KAAK,YAAY,UAAU,IAAI,KAAK,CAAC,OAAO,KAAK,CAAC,CAAC;KACvD,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,KAAY,EAAE,IAAiB;IACpD,wEAAwE;IACxE,+DAA+D;IAC/D,IAAI,KAAK,YAAY,aAAa,IAAI,KAAK,CAAC,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC7D,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO;YAAE,IAAI,CAAC,KAAK,EAAE,CAAC;QACrE,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS;YAAE,IAAI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B,CAAC,CAAC;IACF,MAAM,MAAM,GAAG;QACb,OAAO;QACP,UAAU;QACV,UAAU;QACV,aAAa;QACb,SAAS;QACT,OAAO;QACP,UAAU;QACV,aAAa;QACb,WAAW;QACX,aAAa;QACb,eAAe;QACf,WAAW;QACX,SAAS;QACT,WAAW;QACX,YAAY;QACZ,UAAU;QACV,WAAW;QACX,aAAa;QACb,OAAO;KACR,CAAC;IACF,KAAK,MAAM,IAAI,IAAI,MAAM;QACvB,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,OAAO,EAAE;YACrC,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,CAAC,OAAO;SAClB,CAAC,CAAC;IACL,MAAM,IAAI,GAAG,GAAG,EAAE;QAChB,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,IAAI,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC;IAC7B,CAAC,CAAC;IACF,MAAM,UAAU,GAAG,GAAG,EAAE;QACtB,IAAI,QAAQ,CAAC,eAAe,KAAK,QAAQ;YAAE,IAAI,EAAE,CAAC;IACpD,CAAC,CAAC;IACF,QAAQ,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,UAAU,CAAC,CAAC;IAC1D,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACtC,OAAO,GAAG,EAAE;QACV,QAAQ,CAAC,mBAAmB,CAAC,kBAAkB,EAAE,UAAU,CAAC,CAAC;QAC7D,MAAM,CAAC,mBAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACzC,KAAK,MAAM,IAAI,IAAI,MAAM;YAAE,MAAM,CAAC,mBAAmB,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IAC7E,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { trackHeldScreensaverInput } from \"./screensaverHeldInput\";\nimport type { ScreensaverEvent, ScreensaverState } from \"./screensaverMachine\";\n\nconst pointerReleases = [\n \"pointerup\",\n \"mouseup\",\n \"touchend\",\n \"touchcancel\",\n \"pointercancel\",\n];\n\nfunction dismissEvent(event: Event, hasHeldInput: boolean): ScreensaverEvent {\n return {\n type: \"dismiss\",\n escape: event instanceof KeyboardEvent && event.key === \"Escape\",\n drain:\n hasHeldInput ||\n pointerReleases.includes(event.type) ||\n [\"keydown\", \"pointerdown\", \"mousedown\", \"touchstart\"].includes(\n event.type,\n ) ||\n (event instanceof MouseEvent && event.buttons !== 0),\n };\n}\n\nfunction drainReleased(event: Event, held: Set<string>) {\n // Escape is an explicit recovery gesture even if a previous release was\n // lost. Keep its own keyup isolated before restoring the page.\n if (event instanceof KeyboardEvent && event.key === \"Escape\") {\n if (event.type === \"keydown\" || event.type === \"keyup\") held.clear();\n if (event.type === \"keydown\") held.add(`key:${event.code || event.key}`);\n return event.type === \"keyup\";\n }\n return (\n held.size === 0 &&\n [\n \"keyup\",\n \"pointerup\",\n \"mouseup\",\n \"touchend\",\n \"touchcancel\",\n \"pointercancel\",\n \"click\",\n \"contextmenu\",\n ].includes(event.type)\n );\n}\n\nexport function captureScreensaverInput(\n readState: () => ScreensaverState,\n send: (event: ScreensaverEvent) => void,\n held: Set<string>,\n engaged: boolean,\n) {\n const consume = (event: Event) => {\n const { status } = readState();\n trackHeldScreensaverInput(held, event, status !== \"idle\");\n if (status === \"idle\") return;\n event.preventDefault();\n event.stopImmediatePropagation();\n if (status === \"settling\") return;\n if (status === \"draining\") {\n if (drainReleased(event, held)) send({ type: \"released\" });\n return;\n }\n send(dismissEvent(event, held.size > 0));\n // A press can start during grace and first dismiss on its release. Keep\n // isolation through the following click, even when nothing remains held.\n if (held.size === 0 && pointerReleases.includes(event.type))\n send({ type: \"released\" });\n };\n const events = [\n \"click\",\n \"dblclick\",\n \"auxclick\",\n \"contextmenu\",\n \"keydown\",\n \"keyup\",\n \"keypress\",\n \"pointerdown\",\n \"pointerup\",\n \"pointermove\",\n \"pointercancel\",\n \"mousedown\",\n \"mouseup\",\n \"mousemove\",\n \"touchstart\",\n \"touchend\",\n \"touchmove\",\n \"touchcancel\",\n \"wheel\",\n ];\n for (const type of events)\n window.addEventListener(type, consume, {\n capture: true,\n passive: !engaged,\n });\n const blur = () => {\n held.clear();\n send({ type: \"released\" });\n };\n const visibility = () => {\n if (document.visibilityState === \"hidden\") blur();\n };\n document.addEventListener(\"visibilitychange\", visibility);\n window.addEventListener(\"blur\", blur);\n return () => {\n document.removeEventListener(\"visibilitychange\", visibility);\n window.removeEventListener(\"blur\", blur);\n for (const type of events) window.removeEventListener(type, consume, true);\n };\n}\n"]}
@@ -0,0 +1,34 @@
1
+ export type ScreensaverState = {
2
+ status: "idle";
3
+ session: number;
4
+ } | {
5
+ status: "grace";
6
+ session: number;
7
+ } | {
8
+ status: "armed";
9
+ session: number;
10
+ } | {
11
+ status: "draining";
12
+ session: number;
13
+ } | {
14
+ status: "settling";
15
+ session: number;
16
+ };
17
+ export type ScreensaverEvent = {
18
+ type: "start";
19
+ } | {
20
+ type: "stop";
21
+ } | {
22
+ type: "dismiss";
23
+ escape: boolean;
24
+ drain: boolean;
25
+ } | {
26
+ type: "released";
27
+ } | {
28
+ type: "settled";
29
+ session: number;
30
+ } | {
31
+ type: "graceElapsed";
32
+ session: number;
33
+ };
34
+ export declare function transitionScreensaver(state: ScreensaverState, event: ScreensaverEvent): ScreensaverState;
@@ -0,0 +1,36 @@
1
+ function dismiss(state, isEscape, drain) {
2
+ if (state.status !== "armed" && !(state.status === "grace" && isEscape))
3
+ return state;
4
+ return { status: drain ? "draining" : "idle", session: state.session };
5
+ }
6
+ export function transitionScreensaver(state, event) {
7
+ switch (event.type) {
8
+ case "start":
9
+ return state.status === "idle"
10
+ ? { status: "grace", session: state.session + 1 }
11
+ : state;
12
+ case "dismiss":
13
+ return dismiss(state, event.escape, event.drain);
14
+ case "released":
15
+ return state.status === "draining"
16
+ ? { status: "settling", session: state.session }
17
+ : state;
18
+ case "settled":
19
+ return state.status === "settling" && state.session === event.session
20
+ ? { status: "idle", session: state.session }
21
+ : state;
22
+ case "stop":
23
+ return state.status === "idle"
24
+ ? state
25
+ : { status: "idle", session: state.session };
26
+ case "graceElapsed":
27
+ return state.status === "grace" && state.session === event.session
28
+ ? { status: "armed", session: state.session }
29
+ : state;
30
+ default: {
31
+ const exhaustive = event;
32
+ return exhaustive;
33
+ }
34
+ }
35
+ }
36
+ //# sourceMappingURL=screensaverMachine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"screensaverMachine.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/screensaver/screensaverMachine.ts"],"names":[],"mappings":"AAcA,SAAS,OAAO,CACd,KAAuB,EACvB,QAAiB,EACjB,KAAc;IAEd,IAAI,KAAK,CAAC,MAAM,KAAK,OAAO,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,KAAK,OAAO,IAAI,QAAQ,CAAC;QACrE,OAAO,KAAK,CAAC;IACf,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;AACzE,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,KAAuB,EACvB,KAAuB;IAEvB,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,OAAO;YACV,OAAO,KAAK,CAAC,MAAM,KAAK,MAAM;gBAC5B,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,GAAG,CAAC,EAAE;gBACjD,CAAC,CAAC,KAAK,CAAC;QACZ,KAAK,SAAS;YACZ,OAAO,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;QACnD,KAAK,UAAU;YACb,OAAO,KAAK,CAAC,MAAM,KAAK,UAAU;gBAChC,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE;gBAChD,CAAC,CAAC,KAAK,CAAC;QACZ,KAAK,SAAS;YACZ,OAAO,KAAK,CAAC,MAAM,KAAK,UAAU,IAAI,KAAK,CAAC,OAAO,KAAK,KAAK,CAAC,OAAO;gBACnE,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE;gBAC5C,CAAC,CAAC,KAAK,CAAC;QACZ,KAAK,MAAM;YACT,OAAO,KAAK,CAAC,MAAM,KAAK,MAAM;gBAC5B,CAAC,CAAC,KAAK;gBACP,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;QACjD,KAAK,cAAc;YACjB,OAAO,KAAK,CAAC,MAAM,KAAK,OAAO,IAAI,KAAK,CAAC,OAAO,KAAK,KAAK,CAAC,OAAO;gBAChE,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE;gBAC7C,CAAC,CAAC,KAAK,CAAC;QACZ,OAAO,CAAC,CAAC,CAAC;YACR,MAAM,UAAU,GAAU,KAAK,CAAC;YAChC,OAAO,UAAU,CAAC;QACpB,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["export type ScreensaverState =\n | { status: \"idle\"; session: number }\n | { status: \"grace\"; session: number }\n | { status: \"armed\"; session: number }\n | { status: \"draining\"; session: number }\n | { status: \"settling\"; session: number };\nexport type ScreensaverEvent =\n | { type: \"start\" }\n | { type: \"stop\" }\n | { type: \"dismiss\"; escape: boolean; drain: boolean }\n | { type: \"released\" }\n | { type: \"settled\"; session: number }\n | { type: \"graceElapsed\"; session: number };\n\nfunction dismiss(\n state: ScreensaverState,\n isEscape: boolean,\n drain: boolean,\n): ScreensaverState {\n if (state.status !== \"armed\" && !(state.status === \"grace\" && isEscape))\n return state;\n return { status: drain ? \"draining\" : \"idle\", session: state.session };\n}\n\nexport function transitionScreensaver(\n state: ScreensaverState,\n event: ScreensaverEvent,\n): ScreensaverState {\n switch (event.type) {\n case \"start\":\n return state.status === \"idle\"\n ? { status: \"grace\", session: state.session + 1 }\n : state;\n case \"dismiss\":\n return dismiss(state, event.escape, event.drain);\n case \"released\":\n return state.status === \"draining\"\n ? { status: \"settling\", session: state.session }\n : state;\n case \"settled\":\n return state.status === \"settling\" && state.session === event.session\n ? { status: \"idle\", session: state.session }\n : state;\n case \"stop\":\n return state.status === \"idle\"\n ? state\n : { status: \"idle\", session: state.session };\n case \"graceElapsed\":\n return state.status === \"grace\" && state.session === event.session\n ? { status: \"armed\", session: state.session }\n : state;\n default: {\n const exhaustive: never = event;\n return exhaustive;\n }\n }\n}\n"]}
@@ -0,0 +1,6 @@
1
+ export declare function useScreensaverController(gracePeriodMs: number): {
2
+ isActive: boolean;
3
+ session: number;
4
+ start: () => void;
5
+ stop: () => void;
6
+ };
@@ -0,0 +1,46 @@
1
+ import { useCallback, useEffect, useLayoutEffect, useRef, useState, } from "react";
2
+ import { captureScreensaverInput } from "./screensaverInput.js";
3
+ import { transitionScreensaver, } from "./screensaverMachine.js";
4
+ import { useScreensaverIsolation } from "./useScreensaverIsolation.js";
5
+ export function useScreensaverController(gracePeriodMs) {
6
+ const [state, setState] = useState({
7
+ status: "idle",
8
+ session: 0,
9
+ });
10
+ const live = useRef(state);
11
+ const held = useRef(new Set());
12
+ const engaged = state.status !== "idle";
13
+ const send = useCallback((event) => {
14
+ const next = transitionScreensaver(live.current, event);
15
+ live.current = next;
16
+ setState(next);
17
+ }, []);
18
+ const rememberFocus = useScreensaverIsolation(state.status !== "idle");
19
+ const start = useCallback(() => {
20
+ if (live.current.status === "idle")
21
+ rememberFocus();
22
+ send({ type: "start" });
23
+ }, [send, rememberFocus]);
24
+ const stop = useCallback(() => send({ type: "stop" }), [send]);
25
+ useEffect(() => {
26
+ if (state.status !== "grace" && state.status !== "settling")
27
+ return;
28
+ const timer = setTimeout(() => send({
29
+ type: state.status === "grace" ? "graceElapsed" : "settled",
30
+ session: state.session,
31
+ }), state.status === "grace" ? gracePeriodMs : 0);
32
+ return () => clearTimeout(timer);
33
+ }, [state, gracePeriodMs, send]);
34
+ useLayoutEffect(() => {
35
+ if (!engaged)
36
+ held.current.clear();
37
+ return captureScreensaverInput(() => live.current, send, held.current, engaged);
38
+ }, [engaged, send]);
39
+ return {
40
+ isActive: state.status === "grace" || state.status === "armed",
41
+ session: state.session,
42
+ start,
43
+ stop,
44
+ };
45
+ }
46
+ //# sourceMappingURL=useScreensaverController.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useScreensaverController.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/screensaver/useScreensaverController.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,SAAS,EACT,eAAe,EACf,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAGL,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,MAAM,UAAU,wBAAwB,CAAC,aAAqB;IAC5D,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAmB;QACnD,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,CAAC;KACX,CAAC,CAAC;IACH,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3B,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,GAAG,EAAU,CAAC,CAAC;IACvC,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC;IACxC,MAAM,IAAI,GAAG,WAAW,CAAC,CAAC,KAAuB,EAAE,EAAE;QACnD,MAAM,IAAI,GAAG,qBAAqB,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QACxD,IAAI,CAAC,OAA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O,uBAAuB,CAC5B,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,EAClB,IAAI,EACJ,IAAI,CAAC,OAAO,EACZ,OAAO,CACR,CAAC;IACJ,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;IACpB,OAAO;QACL,QAAQ,EAAE,KAAK,CAAC,MAAM,KAAK,OAAO,IAAI,KAAK,CAAC,MAAM,KAAK,OAAO;QAC9D,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,KAAK;QACL,IAAI;KACL,CAAC;AACJ,CAAC","sourcesContent":["import {\n useCallback,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from \"react\";\nimport { captureScreensaverInput } from \"./screensaverInput\";\nimport {\n type ScreensaverEvent,\n type ScreensaverState,\n transitionScreensaver,\n} from \"./screensaverMachine\";\nimport { useScreensaverIsolation } from \"./useScreensaverIsolation\";\n\nexport function useScreensaverController(gracePeriodMs: number) {\n const [state, setState] = useState<ScreensaverState>({\n status: \"idle\",\n session: 0,\n });\n const live = useRef(state);\n const held = useRef(new Set<string>());\n const engaged = state.status !== \"idle\";\n const send = useCallback((event: ScreensaverEvent) => {\n const next = transitionScreensaver(live.current, event);\n live.current = next;\n setState(next);\n }, []);\n const rememberFocus = useScreensaverIsolation(state.status !== \"idle\");\n const start = useCallback(() => {\n if (live.current.status === \"idle\") rememberFocus();\n send({ type: \"start\" });\n }, [send, rememberFocus]);\n const stop = useCallback(() => send({ type: \"stop\" }), [send]);\n useEffect(() => {\n if (state.status !== \"grace\" && state.status !== \"settling\") return;\n const timer = setTimeout(\n () =>\n send({\n type: state.status === \"grace\" ? \"graceElapsed\" : \"settled\",\n session: state.session,\n }),\n state.status === \"grace\" ? gracePeriodMs : 0,\n );\n return () => clearTimeout(timer);\n }, [state, gracePeriodMs, send]);\n useLayoutEffect(() => {\n if (!engaged) held.current.clear();\n return captureScreensaverInput(\n () => live.current,\n send,\n held.current,\n engaged,\n );\n }, [engaged, send]);\n return {\n isActive: state.status === \"grace\" || state.status === \"armed\",\n session: state.session,\n start,\n stop,\n };\n}\n"]}
@@ -0,0 +1 @@
1
+ export declare function useScreensaverIsolation(engaged: boolean): () => void;
@@ -0,0 +1,39 @@
1
+ import { useCallback, useEffect, useLayoutEffect, useRef } from "react";
2
+ // The modal isolates the page while visible. Keep that isolation through the
3
+ // release/click tail too: iframe events cannot be intercepted by their host.
4
+ // Per HTML 6.3.1, a showModal() dialog escapes ancestor inertness; only inert
5
+ // on the dialog itself would hide it. Keep the body lock across modal removal.
6
+ export function useScreensaverIsolation(engaged) {
7
+ const previousFocus = useRef(null);
8
+ const rememberFocus = useCallback(() => {
9
+ const focus = document.activeElement;
10
+ if (!focus?.closest("dialog.screensaver-overlay"))
11
+ previousFocus.current = focus;
12
+ }, []);
13
+ useLayoutEffect(() => {
14
+ if (!engaged)
15
+ return;
16
+ const body = document.body;
17
+ const wasInert = body.inert;
18
+ body.inert = true;
19
+ return () => {
20
+ body.inert = wasInert;
21
+ };
22
+ }, [engaged]);
23
+ // Restore after React's commit-time selection restoration, not in the layout
24
+ // cleanup which runs before it. A host that moved focus elsewhere keeps it.
25
+ useEffect(() => {
26
+ if (!engaged)
27
+ return;
28
+ const focus = previousFocus.current;
29
+ return () => {
30
+ if (document.activeElement !== document.body)
31
+ return;
32
+ if (focus instanceof HTMLElement && focus.isConnected) {
33
+ focus.focus({ preventScroll: true });
34
+ }
35
+ };
36
+ }, [engaged]);
37
+ return rememberFocus;
38
+ }
39
+ //# sourceMappingURL=useScreensaverIsolation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useScreensaverIsolation.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/screensaver/useScreensaverIsolation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAExE,6EAA6E;AAC7E,6EAA6E;AAC7E,8EAA8E;AAC9E,+EAA+E;AAC/E,MAAM,UAAU,uBAAuB,CAAC,OAAgB;IACtD,MAAM,aAAa,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IACnD,MAAM,aAAa,GAAG,WAAW,CAAC,GAAG,EAAE;QACrC,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC;QACrC,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,4BAA4B,CAAC;YAC/C,aAAa,CAAC,OAAO,GAAG,KAAK,CAAC;IAClC,CAAC,EAAE,EAAE,CAAC,CAAC;IACP,eAAe,CAAC,GAAG,EAAE;QACnB,IAAI,CAAC,OAAO;YAAE,OAAO;QACrB,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC;QAC3B,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC;QAC5B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,OAAO,GAAG,EAAE;YACV,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC;QACxB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IACd,6EAA6E;IAC7E,4EAA4E;IAC5E,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,OAAO;YAAE,OAAO;QACrB,MAAM,KAAK,GAAG,aAAa,CAAC,OAAO,CAAC;QACpC,OAAO,GAAG,EAAE;YACV,IAAI,QAAQ,CAAC,aAAa,KAAK,QAAQ,CAAC,IAAI;gBAAE,OAAO;YACrD,IAAI,KAAK,YAAY,WAAW,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC;gBACtD,KAAK,CAAC,KAAK,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;YACvC,CAAC;QACH,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IACd,OAAO,aAAa,CAAC;AACvB,CAAC","sourcesContent":["import { useCallback, useEffect, useLayoutEffect, useRef } from \"react\";\n\n// The modal isolates the page while visible. Keep that isolation through the\n// release/click tail too: iframe events cannot be intercepted by their host.\n// Per HTML 6.3.1, a showModal() dialog escapes ancestor inertness; only inert\n// on the dialog itself would hide it. Keep the body lock across modal removal.\nexport function useScreensaverIsolation(engaged: boolean) {\n const previousFocus = useRef<Element | null>(null);\n const rememberFocus = useCallback(() => {\n const focus = document.activeElement;\n if (!focus?.closest(\"dialog.screensaver-overlay\"))\n previousFocus.current = focus;\n }, []);\n useLayoutEffect(() => {\n if (!engaged) return;\n const body = document.body;\n const wasInert = body.inert;\n body.inert = true;\n return () => {\n body.inert = wasInert;\n };\n }, [engaged]);\n // Restore after React's commit-time selection restoration, not in the layout\n // cleanup which runs before it. A host that moved focus elsewhere keeps it.\n useEffect(() => {\n if (!engaged) return;\n const focus = previousFocus.current;\n return () => {\n if (document.activeElement !== document.body) return;\n if (focus instanceof HTMLElement && focus.isConnected) {\n focus.focus({ preventScroll: true });\n }\n };\n }, [engaged]);\n return rememberFocus;\n}\n"]}