@tearleads/windowing 0.2.37 → 0.2.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/docs/screensavers.md +122 -0
- package/index.d.ts +3 -0
- package/index.js +3 -1
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/screensaver/LaserScreensaver.d.ts +2 -0
- package/screensaver/LaserScreensaver.js +17 -0
- package/screensaver/LaserScreensaver.js.map +1 -0
- package/screensaver/ScreensaverOverlay.d.ts +7 -0
- package/screensaver/ScreensaverOverlay.js +39 -0
- package/screensaver/ScreensaverOverlay.js.map +1 -0
- package/screensaver/ScreensaverProvider.d.ts +17 -0
- package/screensaver/ScreensaverProvider.js +15 -0
- package/screensaver/ScreensaverProvider.js.map +1 -0
- package/screensaver/ScreensaverUnlock.d.ts +6 -0
- package/screensaver/ScreensaverUnlock.js +19 -0
- package/screensaver/ScreensaverUnlock.js.map +1 -0
- package/screensaver/laserAnimation.d.ts +2 -0
- package/screensaver/laserAnimation.js +117 -0
- package/screensaver/laserAnimation.js.map +1 -0
- package/screensaver/screensaver.css +86 -0
- package/screensaver/screensaverHeldInput.d.ts +1 -0
- package/screensaver/screensaverHeldInput.js +76 -0
- package/screensaver/screensaverHeldInput.js.map +1 -0
- package/screensaver/screensaverInput.d.ts +2 -0
- package/screensaver/screensaverInput.js +126 -0
- package/screensaver/screensaverInput.js.map +1 -0
- package/screensaver/screensaverMachine.d.ts +59 -0
- package/screensaver/screensaverMachine.js +108 -0
- package/screensaver/screensaverMachine.js.map +1 -0
- package/screensaver/screensaverPinVerifier.d.ts +2 -0
- package/screensaver/screensaverPinVerifier.js +2 -0
- package/screensaver/screensaverPinVerifier.js.map +1 -0
- package/screensaver/useScreensaverController.d.ts +11 -0
- package/screensaver/useScreensaverController.js +96 -0
- package/screensaver/useScreensaverController.js.map +1 -0
- package/screensaver/useScreensaverIsolation.d.ts +1 -0
- package/screensaver/useScreensaverIsolation.js +39 -0
- 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, lasers, and PIN unlock](./docs/screensavers.md)
|
|
72
73
|
- [Publishing](./docs/publishing.md)
|
|
73
74
|
|
|
74
75
|
## Dependency compatibility
|
|
@@ -0,0 +1,122 @@
|
|
|
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. Use the bundled grayscale
|
|
7
|
+
`LaserScreensaver` or supply your own animation. The host supplies the control
|
|
8
|
+
that starts it; this package adds no idle timer, saved preference, or global
|
|
9
|
+
launch shortcut.
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import {
|
|
13
|
+
LaserScreensaver,
|
|
14
|
+
ScreensaverProvider,
|
|
15
|
+
useScreensaver,
|
|
16
|
+
} from "@tearleads/windowing";
|
|
17
|
+
|
|
18
|
+
function StartScreensaver() {
|
|
19
|
+
const { start } = useScreensaver();
|
|
20
|
+
return <button onClick={start}>Start screensaver</button>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
<ScreensaverProvider screensaver={LaserScreensaver}>
|
|
24
|
+
<Desktop />
|
|
25
|
+
<Taskbar />
|
|
26
|
+
<StartScreensaver />
|
|
27
|
+
</ScreensaverProvider>;
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
A custom animation is a React component with no required props. It mounts only
|
|
31
|
+
while active, inside a viewport-sized container; a canvas can use `width: 100%`
|
|
32
|
+
and `height: 100%`. It owns its animation and must cancel its work on unmount.
|
|
33
|
+
Replacing the component while active replaces only that animation, not the
|
|
34
|
+
session or grace timer. Styles are included by the public import.
|
|
35
|
+
|
|
36
|
+
`useScreensaver()` returns stable `start()` and `stop()` callbacks and an
|
|
37
|
+
`isActive` boolean (artwork or a PIN gate is visible). It throws outside the
|
|
38
|
+
provider. Repeated starts while active are ignored. Without a PIN, `stop()`
|
|
39
|
+
exits immediately and intentionally cancels input isolation, including a
|
|
40
|
+
pending release tail; reserve it for explicit host control or teardown, not an
|
|
41
|
+
effect watching `isActive`. With a PIN, `stop()` requests the PIN gate instead
|
|
42
|
+
and cannot bypass verification. Start and stop do not close, minimize, or
|
|
43
|
+
recreate the host's windows.
|
|
44
|
+
|
|
45
|
+
The optional `gracePeriodMs` defaults to `2000`. Input during that initial
|
|
46
|
+
period is consumed without dismissal; Escape always wakes it. After grace,
|
|
47
|
+
keyboard, pointer, mouse, touch, and wheel activity wake it. The dismissing
|
|
48
|
+
input and that discrete press's release/click tail are consumed so the desktop
|
|
49
|
+
does not receive an accidental click or shortcut. After that tail settles,
|
|
50
|
+
later presses are new host input, including a double-click's second press.
|
|
51
|
+
A new start during the isolated tail is ignored until
|
|
52
|
+
the gesture finishes. Idle listeners are passive and retain only modifiers,
|
|
53
|
+
not ordinary key presses. Meta release clears keys whose release the browser
|
|
54
|
+
omitted; losing focus or hiding the page clears the tail too. If a release is
|
|
55
|
+
lost while the page stays visible, press and release Escape to recover.
|
|
56
|
+
There is deliberately no deadline that unlocks under a still-held pointer:
|
|
57
|
+
that would allow its later release to click through. Escape is the explicit
|
|
58
|
+
recovery action, and its own release is consumed. Unmounting the provider
|
|
59
|
+
clears listeners and timers too. Isolation covers discrete releases/clicks,
|
|
60
|
+
not later trackpad momentum events after a wheel dismissal. Changing
|
|
61
|
+
`gracePeriodMs` during grace restarts the timer; `0` disables grace, so hosts
|
|
62
|
+
launching with a key should keep a positive grace period for that key's release.
|
|
63
|
+
|
|
64
|
+
The overlay is a native modal `dialog` in the document body, above windows and
|
|
65
|
+
the taskbar in the browser's top layer. It hides the cursor and makes the page
|
|
66
|
+
inert, including embedded frames. Native modal dialogs escape ancestor
|
|
67
|
+
inertness, per the [HTML modal dialog rules][modal-inertness]. Without a PIN,
|
|
68
|
+
the page remains inert through the waking press's tail even after the overlay
|
|
69
|
+
unmounts. A PIN-protected session keeps its overlay through the unlock prompt.
|
|
70
|
+
The animation is inert and hidden from assistive technology; the dialog
|
|
71
|
+
announces "Screensaver" and the exit or unlock instruction. Focus returns to the
|
|
72
|
+
previous connected element unless the host has moved it elsewhere. Existing
|
|
73
|
+
body inertness is restored, not unconditionally removed.
|
|
74
|
+
The PIN form receives normal DOM events. Host-level capture listeners must
|
|
75
|
+
ignore modal input or suspend global shortcuts while `isActive` is true;
|
|
76
|
+
page inertness does not disable document/window event listeners.
|
|
77
|
+
|
|
78
|
+
## PIN unlock
|
|
79
|
+
|
|
80
|
+
Pass `verifyPin` only when the host has a PIN configured:
|
|
81
|
+
|
|
82
|
+
```tsx
|
|
83
|
+
<ScreensaverProvider
|
|
84
|
+
screensaver={LaserScreensaver}
|
|
85
|
+
verifyPin={pinCodeEnabled ? verifyExistingPin : undefined}
|
|
86
|
+
>
|
|
87
|
+
<Desktop />
|
|
88
|
+
</ScreensaverProvider>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
`ScreensaverPinVerifier` is `(pin, signal) => Promise<boolean>`. It checks the
|
|
92
|
+
host's existing PIN without changing the host's session or keyring state;
|
|
93
|
+
only `true` removes the gate. Windowing never stores a PIN configuration or
|
|
94
|
+
verifies one itself. The verifier is captured for that session, so removing
|
|
95
|
+
the prop cannot bypass an already-started PIN gate. Keep the provider mounted
|
|
96
|
+
across host layout changes.
|
|
97
|
+
|
|
98
|
+
Wake input drains its release/click tail, then shows a full-screen unlock
|
|
99
|
+
surface with a focused password field. **Cancel** or **Escape** returns to the
|
|
100
|
+
animation, clears the entered PIN, and starts a fresh grace period after the
|
|
101
|
+
cancelling input has settled. Native dialog cancellation does the same;
|
|
102
|
+
native closure cannot reveal the desktop. Wrong PINs and verifier errors
|
|
103
|
+
retain the gate and allow another attempt.
|
|
104
|
+
|
|
105
|
+
Cancellation and unmount abort the verifier's `AbortSignal`. Verifiers should
|
|
106
|
+
honor it and must not unlock or otherwise mutate host state. Late results are
|
|
107
|
+
ignored even after another attempt starts. Successful verification drains any
|
|
108
|
+
still-held input before restoring the desktop. Rate limiting and credential
|
|
109
|
+
policy belong to the host.
|
|
110
|
+
|
|
111
|
+
The bundled lasers draw six grayscale trails, resize with the viewport, and
|
|
112
|
+
show a static composition with reduced motion. Their work stops on unmount.
|
|
113
|
+
|
|
114
|
+
Use a browser with native modal dialogs and `inert` support. This is a privacy
|
|
115
|
+
screen, not an OS lock or a security boundary: application data, editor state,
|
|
116
|
+
and sessions stay live underneath. It is not persisted across reloads. Use the
|
|
117
|
+
host's separate full Lock action when key/session teardown is required.
|
|
118
|
+
Host code should not open competing modal dialogs or change body inertness
|
|
119
|
+
during a session. Mount the provider only where screensaver behavior is wanted;
|
|
120
|
+
routed layouts need not include it.
|
|
121
|
+
|
|
122
|
+
[modal-inertness]: https://html.spec.whatwg.org/multipage/interaction.html#modal-dialogs-and-inert-subtrees
|
package/index.d.ts
CHANGED
|
@@ -31,6 +31,9 @@ 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 { LaserScreensaver } from "./screensaver/LaserScreensaver.js";
|
|
35
|
+
export { type ScreensaverControls, ScreensaverProvider, type ScreensaverProviderProps, useScreensaver, } from "./screensaver/ScreensaverProvider.js";
|
|
36
|
+
export type { ScreensaverPinVerifier } from "./screensaver/screensaverPinVerifier.js";
|
|
34
37
|
export { SidebarResizeHandle, useSidebarResize } from "./sidebar/SidebarResize.js";
|
|
35
38
|
export { ThemeProvider, useOptionalTheme, useTheme, } from "./theme/ThemeProvider.js";
|
|
36
39
|
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,8 @@ 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 { LaserScreensaver } from "./screensaver/LaserScreensaver.js";
|
|
38
|
+
export { ScreensaverProvider, useScreensaver, } from "./screensaver/ScreensaverProvider.js";
|
|
37
39
|
export { SidebarResizeHandle, useSidebarResize } from "./sidebar/SidebarResize.js";
|
|
38
40
|
export { ThemeProvider, useOptionalTheme, useTheme, } from "./theme/ThemeProvider.js";
|
|
39
41
|
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,
|
|
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,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,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EACL,wBAAwB,EAGxB,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,yB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B,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, 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 { LaserScreensaver } from \"./screensaver/LaserScreensaver\";\nexport {\n type ScreensaverControls,\n ScreensaverProvider,\n type ScreensaverProviderProps,\n useScreensaver,\n} from \"./screensaver/ScreensaverProvider\";\nexport type { ScreensaverPinVerifier } from \"./screensaver/screensaverPinVerifier\";\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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tearleads/windowing",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.39",
|
|
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": {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef } from "react";
|
|
3
|
+
import { startLaserAnimation } from "./laserAnimation.js";
|
|
4
|
+
/** Grayscale laser trails; ScreensaverProvider owns activation and input. */
|
|
5
|
+
export function LaserScreensaver() {
|
|
6
|
+
const canvas = useRef(null);
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
return canvas.current ? startLaserAnimation(canvas.current) : undefined;
|
|
9
|
+
}, []);
|
|
10
|
+
return (_jsx("canvas", { ref: canvas, className: "laser-screensaver", role: "img", "aria-label": "Grayscale laser trails", style: {
|
|
11
|
+
display: "block",
|
|
12
|
+
width: "100%",
|
|
13
|
+
height: "100%",
|
|
14
|
+
background: "black",
|
|
15
|
+
} }));
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=LaserScreensaver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LaserScreensaver.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/screensaver/LaserScreensaver.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,6EAA6E;AAC7E,MAAM,UAAU,gBAAgB;IAC9B,MAAM,MAAM,GAAG,MAAM,CAAoB,IAAI,CAAC,CAAC;IAC/C,SAAS,CAAC,GAAG,EAAE;QACb,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,mBAAmB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC1E,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CACL,iBACE,GAAG,EAAE,MAAM,EACX,SAAS,EAAC,mBAAmB,EAC7B,IAAI,EAAC,KAAK,gBACC,wBAAwB,EACnC,KAAK,EAAE;YACL,OAAO,EAAE,OAAO;YAChB,KAAK,EAAE,MAAM;YACb,MAAM,EAAE,MAAM;YACd,UAAU,EAAE,OAAO;SACpB,GACD,CACH,CAAC;AACJ,CAAC","sourcesContent":["import { useEffect, useRef } from \"react\";\n\nimport { startLaserAnimation } from \"./laserAnimation\";\n\n/** Grayscale laser trails; ScreensaverProvider owns activation and input. */\nexport function LaserScreensaver() {\n const canvas = useRef<HTMLCanvasElement>(null);\n useEffect(() => {\n return canvas.current ? startLaserAnimation(canvas.current) : undefined;\n }, []);\n\n return (\n <canvas\n ref={canvas}\n className=\"laser-screensaver\"\n role=\"img\"\n aria-label=\"Grayscale laser trails\"\n style={{\n display: \"block\",\n width: \"100%\",\n height: \"100%\",\n background: \"black\",\n }}\n />\n );\n}\n"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
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, locked, interactive, }) {
|
|
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
|
+
if (locked)
|
|
20
|
+
dialog.showModal();
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
dialog.addEventListener("cancel", cancel);
|
|
24
|
+
dialog.addEventListener("close", close);
|
|
25
|
+
dialog.showModal();
|
|
26
|
+
dialog.focus();
|
|
27
|
+
return () => {
|
|
28
|
+
dialog.removeEventListener("cancel", cancel);
|
|
29
|
+
dialog.removeEventListener("close", close);
|
|
30
|
+
dialog.close();
|
|
31
|
+
};
|
|
32
|
+
}, [onStop, locked]);
|
|
33
|
+
return createPortal(_jsx("dialog", { "aria-label": "Screensaver", "aria-description": interactive
|
|
34
|
+
? "Enter your PIN code to unlock, or cancel to return to the screensaver."
|
|
35
|
+
: locked
|
|
36
|
+
? "Press Escape to enter your PIN."
|
|
37
|
+
: "Press Escape to exit.", className: `screensaver-overlay${interactive ? " screensaver-overlay--unlock" : ""}`, ref: ref, children: interactive ? (children) : (_jsx("div", { "aria-hidden": "true", inert: true, className: "screensaver-content", children: children })) }), document.body);
|
|
38
|
+
}
|
|
39
|
+
//# 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,EACN,MAAM,EACN,WAAW,GAMZ;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;YACv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Ref } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport \"./screensaver.css\";\n\nexport function ScreensaverOverlay({\n children,\n onStop,\n locked,\n interactive,\n}: {\n children: ReactNode;\n onStop: () => void;\n locked: boolean;\n interactive: boolean;\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) {\n onStop();\n if (locked) dialog.showModal();\n }\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, locked]);\n return createPortal(\n <dialog\n aria-label=\"Screensaver\"\n aria-description={\n interactive\n ? \"Enter your PIN code to unlock, or cancel to return to the screensaver.\"\n : locked\n ? \"Press Escape to enter your PIN.\"\n : \"Press Escape to exit.\"\n }\n className={`screensaver-overlay${interactive ? \" screensaver-overlay--unlock\" : \"\"}`}\n ref={ref}\n >\n {interactive ? (\n children\n ) : (\n <div aria-hidden=\"true\" inert className=\"screensaver-content\">\n {children}\n </div>\n )}\n </dialog>,\n document.body,\n );\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ComponentType, type ReactNode } from "react";
|
|
2
|
+
import type { ScreensaverPinVerifier } from "./screensaverPinVerifier.js";
|
|
3
|
+
export interface ScreensaverControls {
|
|
4
|
+
start: () => void;
|
|
5
|
+
stop: () => void;
|
|
6
|
+
/** Artwork or PIN gate is visible; false can still consume a pending release. */
|
|
7
|
+
isActive: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface ScreensaverProviderProps {
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
screensaver: ComponentType;
|
|
12
|
+
gracePeriodMs?: number;
|
|
13
|
+
verifyPin?: ScreensaverPinVerifier | undefined;
|
|
14
|
+
}
|
|
15
|
+
declare const useScreensaver: () => ScreensaverControls;
|
|
16
|
+
export { useScreensaver };
|
|
17
|
+
export declare function ScreensaverProvider({ children, screensaver: Screensaver, gracePeriodMs, verifyPin, }: ScreensaverProviderProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
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 { ScreensaverUnlock } from "./ScreensaverUnlock.js";
|
|
6
|
+
import { useScreensaverController } from "./useScreensaverController.js";
|
|
7
|
+
const { context: ScreensaverContext, useRequired: useScreensaver } = createRequiredContext("useScreensaver requires ScreensaverProvider");
|
|
8
|
+
export { useScreensaver };
|
|
9
|
+
export function ScreensaverProvider({ children, screensaver: Screensaver, gracePeriodMs = 2000, verifyPin, }) {
|
|
10
|
+
const { isActive, start, stop, state, submit, cancel, dismiss } = useScreensaverController(gracePeriodMs, verifyPin);
|
|
11
|
+
const unlocking = state.status === "unlock" || state.status === "verifying";
|
|
12
|
+
const value = useMemo(() => ({ start, stop, isActive }), [start, stop, isActive]);
|
|
13
|
+
return (_jsxs(ScreensaverContext.Provider, { value: value, children: [children, isActive && (_jsx(ScreensaverOverlay, { onStop: dismiss, locked: state.locked === true, interactive: unlocking, children: unlocking ? (_jsx(ScreensaverUnlock, { busy: state.status === "verifying", error: state.status === "unlock" ? state.error : null, onSubmit: submit, onCancel: cancel })) : (_jsx(Screensaver, {})) }, state.session))] }));
|
|
14
|
+
}
|
|
15
|
+
//# 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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IAAI,EAAE,KAAK,CAAC,MAAM,KAAK,WAAW,EAClC,KAAK,EAAE,KAAK,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EACrD,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,GAChB,CACH,CAAC,CAAC,CAAC,CACF,KAAC,WAAW,KAAG,CAChB,IAdI,KAAK,CAAC,OAAO,CAeC,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 { ScreensaverUnlock } from \"./ScreensaverUnlock\";\nimport type { ScreensaverPinVerifier } from \"./screensaverPinVerifier\";\nimport { useScreensaverController } from \"./useScreensaverController\";\n\nexport interface ScreensaverControls {\n start: () => void;\n stop: () => void;\n /** Artwork or PIN gate is visible; false can still consume a pending release. */\n isActive: boolean;\n}\nexport interface ScreensaverProviderProps {\n children: ReactNode;\n screensaver: ComponentType;\n gracePeriodMs?: number;\n verifyPin?: ScreensaverPinVerifier | undefined;\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 verifyPin,\n}: ScreensaverProviderProps) {\n const { isActive, start, stop, state, submit, cancel, dismiss } =\n useScreensaverController(gracePeriodMs, verifyPin);\n const unlocking = state.status === \"unlock\" || state.status === \"verifying\";\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\n key={state.session}\n onStop={dismiss}\n locked={state.locked === true}\n interactive={unlocking}\n >\n {unlocking ? (\n <ScreensaverUnlock\n busy={state.status === \"verifying\"}\n error={state.status === \"unlock\" ? state.error : null}\n onSubmit={submit}\n onCancel={cancel}\n />\n ) : (\n <Screensaver />\n )}\n </ScreensaverOverlay>\n )}\n </ScreensaverContext.Provider>\n );\n}\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useId, useRef, useState } from "react";
|
|
3
|
+
export function ScreensaverUnlock({ busy, error, onSubmit, onCancel, }) {
|
|
4
|
+
const [pin, setPin] = useState("");
|
|
5
|
+
const input = useRef(null);
|
|
6
|
+
const errorId = useId();
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
if (!busy)
|
|
9
|
+
input.current?.focus();
|
|
10
|
+
}, [busy]);
|
|
11
|
+
return (_jsxs("form", { className: "screensaver-unlock", "aria-label": "Unlock screensaver", onKeyDown: (event) => event.stopPropagation(), onKeyUp: (event) => event.stopPropagation(), onSubmit: (event) => {
|
|
12
|
+
event.preventDefault();
|
|
13
|
+
if (busy || !pin)
|
|
14
|
+
return;
|
|
15
|
+
onSubmit(pin);
|
|
16
|
+
setPin("");
|
|
17
|
+
}, children: [_jsx("h2", { children: "Return to your session" }), _jsx("p", { children: "Enter your PIN code to return." }), _jsxs("label", { children: ["PIN code", _jsx("input", { ref: input, type: "password", inputMode: "numeric", autoComplete: "current-password", required: true, value: pin, disabled: busy, "aria-invalid": error !== null, "aria-describedby": error ? errorId : undefined, onChange: (event) => setPin(event.currentTarget.value) })] }), error && (_jsx("p", { id: errorId, role: "alert", children: error })), _jsx("button", { type: "submit", disabled: busy, children: busy ? "Unlocking…" : "Unlock" }), _jsx("button", { type: "button", onClick: onCancel, children: "Cancel" })] }));
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=ScreensaverUnlock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScreensaverUnlock.js","sourceRoot":"","sources":["../../../home/runner/work/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OAAO,CAAC,CAAC,CAAC,SAAS,EAC7C,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,GACtD,IACI,EACP,KAAK,IAAI,CACR,YAAG,EAAE,EAAE,OAAO,EAAE,IAAI,EAAC,OAAO,YACzB,KAAK,GACJ,CACL,EACD,iBAAQ,IAAI,EAAC,QAAQ,EAAC,QAAQ,EAAE,IAAI,YACjC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,QAAQ,GACxB,EACT,iBAAQ,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAE,QAAQ,uBAE9B,IACJ,CACR,CAAC;AACJ,CAAC","sourcesContent":["import { useEffect, useId, useRef, useState } from \"react\";\n\nexport function ScreensaverUnlock({\n busy,\n error,\n onSubmit,\n onCancel,\n}: {\n busy: boolean;\n error: string | null;\n onSubmit: (pin: string) => void;\n onCancel: () => void;\n}) {\n const [pin, setPin] = useState(\"\");\n const input = useRef<HTMLInputElement>(null);\n const errorId = useId();\n useEffect(() => {\n if (!busy) input.current?.focus();\n }, [busy]);\n return (\n <form\n className=\"screensaver-unlock\"\n aria-label=\"Unlock screensaver\"\n onKeyDown={(event) => event.stopPropagation()}\n onKeyUp={(event) => event.stopPropagation()}\n onSubmit={(event) => {\n event.preventDefault();\n if (busy || !pin) return;\n onSubmit(pin);\n setPin(\"\");\n }}\n >\n <h2>Return to your session</h2>\n <p>Enter your PIN code to return.</p>\n <label>\n PIN code\n <input\n ref={input}\n type=\"password\"\n inputMode=\"numeric\"\n autoComplete=\"current-password\"\n required\n value={pin}\n disabled={busy}\n aria-invalid={error !== null}\n aria-describedby={error ? errorId : undefined}\n onChange={(event) => setPin(event.currentTarget.value)}\n />\n </label>\n {error && (\n <p id={errorId} role=\"alert\">\n {error}\n </p>\n )}\n <button type=\"submit\" disabled={busy}>\n {busy ? \"Unlocking…\" : \"Unlock\"}\n </button>\n <button type=\"button\" onClick={onCancel}>\n Cancel\n </button>\n </form>\n );\n}\n"]}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
const SHADES = [
|
|
2
|
+
"#ffffff",
|
|
3
|
+
"#dddddd",
|
|
4
|
+
"#bbbbbb",
|
|
5
|
+
"#999999",
|
|
6
|
+
"#888888",
|
|
7
|
+
"#777777",
|
|
8
|
+
];
|
|
9
|
+
const TRAIL_LENGTH = 100;
|
|
10
|
+
function createBeams(width, height) {
|
|
11
|
+
return SHADES.map((color) => {
|
|
12
|
+
const angle = Math.random() * Math.PI * 2;
|
|
13
|
+
const speed = 3 + Math.random() * 3;
|
|
14
|
+
const x = Math.random() * width;
|
|
15
|
+
const y = Math.random() * height;
|
|
16
|
+
return {
|
|
17
|
+
x,
|
|
18
|
+
y,
|
|
19
|
+
dx: Math.cos(angle) * speed,
|
|
20
|
+
dy: Math.sin(angle) * speed,
|
|
21
|
+
color,
|
|
22
|
+
trail: [{ x, y }],
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
function advance(beam, width, height, step) {
|
|
27
|
+
beam.x += beam.dx * step;
|
|
28
|
+
beam.y += beam.dy * step;
|
|
29
|
+
if (beam.x <= 0 || beam.x >= width) {
|
|
30
|
+
beam.dx *= -1;
|
|
31
|
+
beam.x = Math.max(0, Math.min(width, beam.x));
|
|
32
|
+
}
|
|
33
|
+
if (beam.y <= 0 || beam.y >= height) {
|
|
34
|
+
beam.dy *= -1;
|
|
35
|
+
beam.y = Math.max(0, Math.min(height, beam.y));
|
|
36
|
+
}
|
|
37
|
+
beam.trail.push({ x: beam.x, y: beam.y });
|
|
38
|
+
if (beam.trail.length > TRAIL_LENGTH)
|
|
39
|
+
beam.trail.shift();
|
|
40
|
+
}
|
|
41
|
+
function draw(context, beams) {
|
|
42
|
+
context.lineWidth = 2;
|
|
43
|
+
context.lineCap = "round";
|
|
44
|
+
context.lineJoin = "round";
|
|
45
|
+
for (const beam of beams) {
|
|
46
|
+
context.strokeStyle = beam.color;
|
|
47
|
+
for (let index = 1; index < beam.trail.length; index += 1) {
|
|
48
|
+
const from = beam.trail[index - 1];
|
|
49
|
+
const to = beam.trail[index];
|
|
50
|
+
if (!from || !to)
|
|
51
|
+
continue;
|
|
52
|
+
context.globalAlpha = index / beam.trail.length;
|
|
53
|
+
context.beginPath();
|
|
54
|
+
context.moveTo(from.x, from.y);
|
|
55
|
+
context.lineTo(to.x, to.y);
|
|
56
|
+
context.stroke();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
context.globalAlpha = 1;
|
|
60
|
+
}
|
|
61
|
+
/** Owns only the artwork; windowing owns activation, input, and focus. */
|
|
62
|
+
export function startLaserAnimation(canvas) {
|
|
63
|
+
const context = canvas.getContext("2d");
|
|
64
|
+
if (!context)
|
|
65
|
+
return () => undefined;
|
|
66
|
+
let width = 0;
|
|
67
|
+
let height = 0;
|
|
68
|
+
let beams = [];
|
|
69
|
+
let frame = 0;
|
|
70
|
+
let previous = null;
|
|
71
|
+
const reducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
72
|
+
const resize = () => {
|
|
73
|
+
width = window.innerWidth;
|
|
74
|
+
height = window.innerHeight;
|
|
75
|
+
const scale = Math.min(window.devicePixelRatio || 1, 2);
|
|
76
|
+
canvas.width = Math.round(width * scale);
|
|
77
|
+
canvas.height = Math.round(height * scale);
|
|
78
|
+
context.setTransform(scale, 0, 0, scale, 0, 0);
|
|
79
|
+
context.fillStyle = "#000000";
|
|
80
|
+
context.fillRect(0, 0, width, height);
|
|
81
|
+
beams = createBeams(width, height);
|
|
82
|
+
if (reducedMotion.matches) {
|
|
83
|
+
for (let index = 0; index < TRAIL_LENGTH; index += 1) {
|
|
84
|
+
for (const beam of beams)
|
|
85
|
+
advance(beam, width, height, 1);
|
|
86
|
+
}
|
|
87
|
+
draw(context, beams);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
const animate = (timestamp) => {
|
|
91
|
+
// Keep motion independent of refresh rate without leaping after a hidden tab.
|
|
92
|
+
const step = previous === null ? 1 : Math.min((timestamp - previous) / (1000 / 60), 2);
|
|
93
|
+
previous = timestamp;
|
|
94
|
+
context.fillStyle = "rgba(0, 0, 0, 0.05)";
|
|
95
|
+
context.fillRect(0, 0, width, height);
|
|
96
|
+
for (const beam of beams)
|
|
97
|
+
advance(beam, width, height, step);
|
|
98
|
+
draw(context, beams);
|
|
99
|
+
frame = window.requestAnimationFrame(animate);
|
|
100
|
+
};
|
|
101
|
+
const restart = () => {
|
|
102
|
+
window.cancelAnimationFrame(frame);
|
|
103
|
+
previous = null;
|
|
104
|
+
resize();
|
|
105
|
+
if (!reducedMotion.matches)
|
|
106
|
+
animate(performance.now());
|
|
107
|
+
};
|
|
108
|
+
restart();
|
|
109
|
+
window.addEventListener("resize", resize);
|
|
110
|
+
reducedMotion.addEventListener("change", restart);
|
|
111
|
+
return () => {
|
|
112
|
+
window.cancelAnimationFrame(frame);
|
|
113
|
+
window.removeEventListener("resize", resize);
|
|
114
|
+
reducedMotion.removeEventListener("change", restart);
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=laserAnimation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"laserAnimation.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/screensaver/laserAnimation.ts"],"names":[],"mappings":"AAYA,MAAM,MAAM,GAAG;IACb,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;CACV,CAAC;AACF,MAAM,YAAY,GAAG,GAAG,CAAC;AAEzB,SAAS,WAAW,CAAC,KAAa,EAAE,MAAc;IAChD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QAC1B,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;QAC1C,MAAM,KAAK,GAAG,CAAC,GAAG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E,MAAM,CAAC,CAAC;IAC1C,aAAa,CAAC,gBAAgB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAClD,OAAO,GAAG,EAAE;QACV,MAAM,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;QACnC,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC7C,aAAa,CAAC,mBAAmB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC,CAAC;AACJ,CAAC","sourcesContent":["interface Point {\n x: number;\n y: number;\n}\n\ninterface Beam extends Point {\n dx: number;\n dy: number;\n color: string;\n trail: Point[];\n}\n\nconst SHADES = [\n \"#ffffff\",\n \"#dddddd\",\n \"#bbbbbb\",\n \"#999999\",\n \"#888888\",\n \"#777777\",\n];\nconst TRAIL_LENGTH = 100;\n\nfunction createBeams(width: number, height: number): Beam[] {\n return SHADES.map((color) => {\n const angle = Math.random() * Math.PI * 2;\n const speed = 3 + Math.random() * 3;\n const x = Math.random() * width;\n const y = Math.random() * height;\n return {\n x,\n y,\n dx: Math.cos(angle) * speed,\n dy: Math.sin(angle) * speed,\n color,\n trail: [{ x, y }],\n };\n });\n}\n\nfunction advance(beam: Beam, width: number, height: number, step: number) {\n beam.x += beam.dx * step;\n beam.y += beam.dy * step;\n if (beam.x <= 0 || beam.x >= width) {\n beam.dx *= -1;\n beam.x = Math.max(0, Math.min(width, beam.x));\n }\n if (beam.y <= 0 || beam.y >= height) {\n beam.dy *= -1;\n beam.y = Math.max(0, Math.min(height, beam.y));\n }\n beam.trail.push({ x: beam.x, y: beam.y });\n if (beam.trail.length > TRAIL_LENGTH) beam.trail.shift();\n}\n\nfunction draw(context: CanvasRenderingContext2D, beams: Beam[]) {\n context.lineWidth = 2;\n context.lineCap = \"round\";\n context.lineJoin = \"round\";\n for (const beam of beams) {\n context.strokeStyle = beam.color;\n for (let index = 1; index < beam.trail.length; index += 1) {\n const from = beam.trail[index - 1];\n const to = beam.trail[index];\n if (!from || !to) continue;\n context.globalAlpha = index / beam.trail.length;\n context.beginPath();\n context.moveTo(from.x, from.y);\n context.lineTo(to.x, to.y);\n context.stroke();\n }\n }\n context.globalAlpha = 1;\n}\n\n/** Owns only the artwork; windowing owns activation, input, and focus. */\nexport function startLaserAnimation(canvas: HTMLCanvasElement): () => void {\n const context = canvas.getContext(\"2d\");\n if (!context) return () => undefined;\n let width = 0;\n let height = 0;\n let beams: Beam[] = [];\n let frame = 0;\n let previous: number | null = null;\n const reducedMotion = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n\n const resize = () => {\n width = window.innerWidth;\n height = window.innerHeight;\n const scale = Math.min(window.devicePixelRatio || 1, 2);\n canvas.width = Math.round(width * scale);\n canvas.height = Math.round(height * scale);\n context.setTransform(scale, 0, 0, scale, 0, 0);\n context.fillStyle = \"#000000\";\n context.fillRect(0, 0, width, height);\n beams = createBeams(width, height);\n if (reducedMotion.matches) {\n for (let index = 0; index < TRAIL_LENGTH; index += 1) {\n for (const beam of beams) advance(beam, width, height, 1);\n }\n draw(context, beams);\n }\n };\n const animate = (timestamp: number) => {\n // Keep motion independent of refresh rate without leaping after a hidden tab.\n const step =\n previous === null ? 1 : Math.min((timestamp - previous) / (1000 / 60), 2);\n previous = timestamp;\n context.fillStyle = \"rgba(0, 0, 0, 0.05)\";\n context.fillRect(0, 0, width, height);\n for (const beam of beams) advance(beam, width, height, step);\n draw(context, beams);\n frame = window.requestAnimationFrame(animate);\n };\n\n const restart = () => {\n window.cancelAnimationFrame(frame);\n previous = null;\n resize();\n if (!reducedMotion.matches) animate(performance.now());\n };\n restart();\n window.addEventListener(\"resize\", resize);\n reducedMotion.addEventListener(\"change\", restart);\n return () => {\n window.cancelAnimationFrame(frame);\n window.removeEventListener(\"resize\", resize);\n reducedMotion.removeEventListener(\"change\", restart);\n };\n}\n"]}
|
|
@@ -0,0 +1,86 @@
|
|
|
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
|
+
}
|
|
30
|
+
|
|
31
|
+
.screensaver-overlay--unlock {
|
|
32
|
+
display: grid;
|
|
33
|
+
place-items: center;
|
|
34
|
+
padding: 1.5rem;
|
|
35
|
+
box-sizing: border-box;
|
|
36
|
+
overflow: auto;
|
|
37
|
+
cursor: auto;
|
|
38
|
+
touch-action: auto;
|
|
39
|
+
color: white;
|
|
40
|
+
font-family: system-ui, sans-serif;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.screensaver-unlock {
|
|
44
|
+
width: min(100%, 22rem);
|
|
45
|
+
padding: 1.5rem;
|
|
46
|
+
box-sizing: border-box;
|
|
47
|
+
border: 1px solid #666;
|
|
48
|
+
border-radius: 0.5rem;
|
|
49
|
+
background: #171717;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.screensaver-unlock h2 {
|
|
53
|
+
margin-top: 0;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.screensaver-unlock label {
|
|
57
|
+
display: grid;
|
|
58
|
+
gap: 0.5rem;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.screensaver-unlock input,
|
|
62
|
+
.screensaver-unlock button {
|
|
63
|
+
box-sizing: border-box;
|
|
64
|
+
width: 100%;
|
|
65
|
+
padding: 0.75rem;
|
|
66
|
+
border: 1px solid #888;
|
|
67
|
+
border-radius: 0.25rem;
|
|
68
|
+
font: inherit;
|
|
69
|
+
color: white;
|
|
70
|
+
background: #292929;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.screensaver-unlock button {
|
|
74
|
+
margin-top: 1rem;
|
|
75
|
+
cursor: pointer;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.screensaver-unlock :disabled {
|
|
79
|
+
opacity: 0.6;
|
|
80
|
+
cursor: wait;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.screensaver-unlock :focus-visible {
|
|
84
|
+
outline: 2px solid white;
|
|
85
|
+
outline-offset: 3px;
|
|
86
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function trackHeldScreensaverInput(held: Set<string>, event: Event, includePresses: boolean): void;
|