@tearleads/windowing 0.2.23 → 0.2.24

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 CHANGED
@@ -363,6 +363,66 @@ the browser paints and removes them on unmount; under a dark scheme,
363
363
  `tokens.css` sets `color-scheme: dark`. Tearleads sets its themes per host
364
364
  profile in `packages/app/src/host/AppHostConfig.ts`.
365
365
 
366
+ ## Wallpapers and Display Properties
367
+
368
+ A host offers its own desktop wallpapers. A `WallpaperDefinition` is
369
+ `{ id, label, tile?, base?, ink? }`: `tile` is one cell of a repeating
370
+ pattern, as SVG markup with its `width` and `height` in CSS pixels. The tile's
371
+ SVG is a mask rather than a picture: opaque shapes paint the ink, translucent
372
+ ones (`fill-opacity`) a share of it, and the base shows elsewhere. Unless a
373
+ wallpaper names its colors, they come from the theme, resolved on the
374
+ wallpaper's own element: the `--desktop-wallpaper-base` and
375
+ `--desktop-wallpaper-ink` tokens where a host sets them, else the desk color
376
+ (`--desktop-background`, then `--color-light`) under a faint wash of
377
+ `--color-dark`. So one tile suits every theme.
378
+ A wallpaper without a tile is its base alone.
379
+
380
+ The package ships quiet tessellations to choose from: `BLOCKS_WALLPAPER`,
381
+ `HONEYCOMB_WALLPAPER`, `TRIANGLES_WALLPAPER`, `HARLEQUIN_WALLPAPER`,
382
+ `CHEVRON_WALLPAPER`, and `PLAIN_WALLPAPER` (no pattern). List them with the
383
+ host's own in a `WallpaperProvider`, and render `DesktopWallpaper` as the
384
+ first child of the desktop surface, before `DesktopIcons`:
385
+
386
+ ```tsx
387
+ const BRICKS: WallpaperDefinition<"bricks"> = {
388
+ id: "bricks",
389
+ label: "Bricks",
390
+ tile: {
391
+ height: 24,
392
+ svg: `<svg xmlns="http://www.w3.org/2000/svg" width="48" height="24">…</svg>`,
393
+ width: 48,
394
+ },
395
+ };
396
+ const WALLPAPERS = [BRICKS, HONEYCOMB_WALLPAPER, PLAIN_WALLPAPER];
397
+
398
+ <WallpaperProvider
399
+ defaultWallpaper="bricks"
400
+ storageKey="notes.wallpaper"
401
+ wallpapers={WALLPAPERS}
402
+ >
403
+ <div style={{ position: "relative", isolation: "isolate", height: "100%" }}>
404
+ <DesktopWallpaper />
405
+ <DesktopIcons appIds={APP_IDS} />
406
+ {windows}
407
+ </div>
408
+ </WallpaperProvider>;
409
+ ```
410
+
411
+ The wallpaper paints on a layer below everything on the surface, including
412
+ content laid out in flow, so the surface must be a stacking context: give it
413
+ `isolation: isolate` beside its `position`. The wallpaper takes no pointer
414
+ input, so a right-click on it reaches the surface, where a host opens its
415
+ desktop menu. The choice persists under
416
+ `storageKey` like a theme's; `useWallpaper` and `useOptionalWallpaper` read
417
+ and set it. `DesktopWallpaper` paints its `wallpaper` prop instead when given
418
+ one, and nothing without a provider.
419
+
420
+ `DisplayProperties` is the content of a host's Display Properties mini-app: a
421
+ Background section listing the provider's wallpapers as previews, and a Theme
422
+ section listing the theme provider's themes. Each choice applies at once; a
423
+ section whose provider is missing, or a theme list of one, is left out. Both
424
+ Tearleads and a2f0.net open it from their desktop's context menu.
425
+
366
426
  ## Styles
367
427
 
368
428
  Each component imports its own stylesheet, so a bundler that handles CSS imports
@@ -0,0 +1,106 @@
1
+ /*
2
+ * Display Properties: a column of fieldsets. Each option is a labeled radio
3
+ * drawn as a card; the radio itself stays in the tab order and the
4
+ * accessibility tree but is visually hidden, and the card shows its focus and
5
+ * checked state.
6
+ */
7
+ .display-properties {
8
+ display: flex;
9
+ flex-direction: column;
10
+ gap: var(--space-md);
11
+ box-sizing: border-box;
12
+ padding: var(--space-md);
13
+ font-size: var(--font-size-sm);
14
+ }
15
+
16
+ .display-properties-section {
17
+ display: flex;
18
+ flex-direction: column;
19
+ gap: var(--space-sm);
20
+ min-width: 0;
21
+ margin: 0;
22
+ padding: 0;
23
+ border: 0;
24
+ }
25
+
26
+ .display-properties-section > legend {
27
+ margin-bottom: var(--space-sm);
28
+ padding: 0;
29
+ font-weight: 600;
30
+ }
31
+
32
+ .display-properties-wallpapers {
33
+ display: grid;
34
+ grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr));
35
+ gap: var(--space-sm);
36
+ }
37
+
38
+ .display-properties-themes {
39
+ display: flex;
40
+ flex-wrap: wrap;
41
+ gap: var(--space-sm);
42
+ }
43
+
44
+ .display-properties-wallpaper,
45
+ .display-properties-theme {
46
+ position: relative;
47
+ display: flex;
48
+ align-items: center;
49
+ gap: var(--space-xs);
50
+ box-sizing: border-box;
51
+ padding: var(--space-xs);
52
+ border: var(--border-width) solid var(--color-hairline);
53
+ border-radius: var(--app-radius-control);
54
+ cursor: pointer;
55
+ }
56
+
57
+ .display-properties-wallpaper {
58
+ flex-direction: column;
59
+ }
60
+
61
+ .display-properties-theme {
62
+ padding: var(--space-xs) var(--space-sm);
63
+ }
64
+
65
+ .display-properties-wallpaper:hover,
66
+ .display-properties-theme:hover {
67
+ background: var(--app-hover-surface);
68
+ }
69
+
70
+ .display-properties-wallpaper:has(:checked),
71
+ .display-properties-theme:has(:checked) {
72
+ border-color: var(--color-dark);
73
+ box-shadow: inset 0 0 0 1px var(--color-dark);
74
+ }
75
+
76
+ .display-properties-wallpaper:has(:focus-visible),
77
+ .display-properties-theme:has(:focus-visible) {
78
+ outline: 2px solid var(--color-dark);
79
+ outline-offset: 2px;
80
+ }
81
+
82
+ .display-properties-input {
83
+ position: absolute;
84
+ width: 1px;
85
+ height: 1px;
86
+ margin: 0;
87
+ overflow: hidden;
88
+ clip-path: inset(50%);
89
+ white-space: nowrap;
90
+ opacity: 0;
91
+ }
92
+
93
+ .display-properties-swatch {
94
+ position: relative;
95
+ width: 100%;
96
+ height: 3.5rem;
97
+ overflow: hidden;
98
+ border-radius: calc(var(--app-radius-control) - 2px);
99
+ box-shadow: inset 0 0 0 1px var(--color-hairline);
100
+ }
101
+
102
+ .display-properties-label {
103
+ overflow: hidden;
104
+ text-overflow: ellipsis;
105
+ white-space: nowrap;
106
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The display settings, for a host's Display Properties mini-app: the
3
+ * desktop's background, from the nearest {@link WallpaperProvider}, and the
4
+ * color theme, from the nearest {@link ThemeProvider}. Each choice applies at
5
+ * once. A section whose provider is missing, or that offers one option, is
6
+ * left out. It has no toolbar actions, so its window shows no toolbar row.
7
+ */
8
+ export declare function DisplayProperties(): import("react").JSX.Element;
@@ -0,0 +1,36 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useId } from "react";
3
+ import { useOptionalTheme } from "../theme/ThemeProvider.js";
4
+ import { useOptionalWallpaper } from "../wallpaper/WallpaperProvider.js";
5
+ import { wallpaperStyle } from "../wallpaper/wallpapers.js";
6
+ import { useSuppressWindowToolbar } from "../window/CurrentWindowContext.js";
7
+ import "../wallpaper/Wallpaper.css";
8
+ import "./DisplayProperties.css";
9
+ function BackgroundSection() {
10
+ const wallpaper = useOptionalWallpaper();
11
+ const name = useId();
12
+ if (!wallpaper) {
13
+ return null;
14
+ }
15
+ return (_jsxs("fieldset", { className: "display-properties-section", children: [_jsx("legend", { children: "Background" }), _jsx("div", { className: "display-properties-wallpapers", children: wallpaper.wallpapers.map((option) => (_jsxs("label", { className: "display-properties-wallpaper", children: [_jsx("input", { checked: option.id === wallpaper.activeWallpaper.id, className: "display-properties-input", name: name, onChange: () => wallpaper.setWallpaper(option.id), type: "radio", value: option.id }), _jsx("span", { "aria-hidden": "true", className: "display-properties-swatch wallpaper-pattern", "data-pattern": option.tile ? "" : undefined, style: wallpaperStyle(option) }), _jsx("span", { className: "display-properties-label", children: option.label })] }, option.id))) })] }));
16
+ }
17
+ function ThemeSection() {
18
+ const theme = useOptionalTheme();
19
+ const name = useId();
20
+ if (!theme || theme.themes.length < 2) {
21
+ return null;
22
+ }
23
+ return (_jsxs("fieldset", { className: "display-properties-section", children: [_jsx("legend", { children: "Theme" }), _jsx("div", { className: "display-properties-themes", children: theme.themes.map((option) => (_jsxs("label", { className: "display-properties-theme", children: [_jsx("input", { checked: option.id === theme.activeTheme.id, className: "display-properties-input", name: name, onChange: () => theme.setTheme(option.id), type: "radio", value: option.id }), _jsx("span", { className: "display-properties-label", children: option.label })] }, option.id))) })] }));
24
+ }
25
+ /**
26
+ * The display settings, for a host's Display Properties mini-app: the
27
+ * desktop's background, from the nearest {@link WallpaperProvider}, and the
28
+ * color theme, from the nearest {@link ThemeProvider}. Each choice applies at
29
+ * once. A section whose provider is missing, or that offers one option, is
30
+ * left out. It has no toolbar actions, so its window shows no toolbar row.
31
+ */
32
+ export function DisplayProperties() {
33
+ useSuppressWindowToolbar(true);
34
+ return (_jsxs("div", { className: "display-properties", children: [_jsx(BackgroundSection, {}), _jsx(ThemeSection, {})] }));
35
+ }
36
+ //# sourceMappingURL=DisplayProperties.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DisplayProperties.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/display/DisplayProperties.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,4BAA4B,CAAC;AACpC,OAAO,yBAAyB,CAAC;AAEjC,SAAS,iBAAiB;IACxB,MAAM,SAAS,GAAG,oBAAoB,EAAE,CAAC;IACzC,MAAM,IAAI,GAAG,KAAK,EAAE,CAAC;IACrB,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,CACL,oBAAU,SAAS,EAAC,4BAA4B,aAC9C,0CAA2B,EAC3B,cAAK,SAAS,EAAC,+BAA+B,YAC3C,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,MAAM,EA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AC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,EACzC,IAAI,EAAC,OAAO,EACZ,KAAK,EAAE,MAAM,CAAC,EAAE,GAChB,EACF,eAAM,SAAS,EAAC,0BAA0B,YAAE,MAAM,CAAC,KAAK,GAAQ,KATjB,MAAM,CAAC,EAAE,CAUlD,CACT,CAAC,GACE,IACG,CACZ,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB;IAC/B,wBAAwB,CAAC,IAAI,CAAC,CAAC;IAC/B,OAAO,CACL,eAAK,SAAS,EAAC,oBAAoB,aACjC,KAAC,iBAAiB,KAAG,EACrB,KAAC,YAAY,KAAG,IACZ,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { useId } from \"react\";\nimport { useOptionalTheme } from \"../theme/ThemeProvider\";\nimport { useOptionalWallpaper } from \"../wallpaper/WallpaperProvider\";\nimport { wallpaperStyle } from \"../wallpaper/wallpapers\";\nimport { useSuppressWindowToolbar } from \"../window/CurrentWindowContext\";\nimport \"../wallpaper/Wallpaper.css\";\nimport \"./DisplayProperties.css\";\n\nfunction BackgroundSection() {\n const wallpaper = useOptionalWallpaper();\n const name = useId();\n if (!wallpaper) {\n return null;\n }\n return (\n <fieldset className=\"display-properties-section\">\n <legend>Background</legend>\n <div className=\"display-properties-wallpapers\">\n {wallpaper.wallpapers.map((option) => (\n <label className=\"display-properties-wallpaper\" key={option.id}>\n <input\n checked={option.id === wallpaper.activeWallpaper.id}\n className=\"display-properties-input\"\n name={name}\n onChange={() => wallpaper.setWallpaper(option.id)}\n type=\"radio\"\n value={option.id}\n />\n <span\n aria-hidden=\"true\"\n className=\"display-properties-swatch wallpaper-pattern\"\n data-pattern={option.tile ? \"\" : undefined}\n style={wallpaperStyle(option)}\n />\n <span className=\"display-properties-label\">{option.label}</span>\n </label>\n ))}\n </div>\n </fieldset>\n );\n}\n\nfunction ThemeSection() {\n const theme = useOptionalTheme();\n const name = useId();\n if (!theme || theme.themes.length < 2) {\n return null;\n }\n return (\n <fieldset className=\"display-properties-section\">\n <legend>Theme</legend>\n <div className=\"display-properties-themes\">\n {theme.themes.map((option) => (\n <label className=\"display-properties-theme\" key={option.id}>\n <input\n checked={option.id === theme.activeTheme.id}\n className=\"display-properties-input\"\n name={name}\n onChange={() => theme.setTheme(option.id)}\n type=\"radio\"\n value={option.id}\n />\n <span className=\"display-properties-label\">{option.label}</span>\n </label>\n ))}\n </div>\n </fieldset>\n );\n}\n\n/**\n * The display settings, for a host's Display Properties mini-app: the\n * desktop's background, from the nearest {@link WallpaperProvider}, and the\n * color theme, from the nearest {@link ThemeProvider}. Each choice applies at\n * once. A section whose provider is missing, or that offers one option, is\n * left out. It has no toolbar actions, so its window shows no toolbar row.\n */\nexport function DisplayProperties() {\n useSuppressWindowToolbar(true);\n return (\n <div className=\"display-properties\">\n <BackgroundSection />\n <ThemeSection />\n </div>\n );\n}\n"]}
package/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export type { DesktopIconMenuItem } from "./desktop/DesktopIconMenu.js";
3
3
  export { DesktopIcons, type DesktopIconsProps, } from "./desktop/DesktopIcons.js";
4
4
  export type { DesktopIconPosition, DesktopState, } from "./desktop/desktopState.js";
5
5
  export { createMemoryDesktopStateStorage, createOpfsDesktopStateStorage, type DesktopStateStorage, type OpfsDesktopStateStorageOptions, } from "./desktop/desktopStateStorage.js";
6
+ export { DisplayProperties } from "./display/DisplayProperties.js";
6
7
  export { type WindowingIcons, WindowingIconsProvider, } from "./icons/WindowingIcons.js";
7
8
  export type { WindowingIcon, WindowingIconProps } from "./icons/windowingIcon.js";
8
9
  export { ROUTED_TABLET_BREAKPOINT_PX, ROUTED_TABLET_QUERY, WINDOWED_LAYOUT_MIN_WIDTH_PX, } from "./launcher/breakpoints.js";
@@ -32,6 +33,10 @@ export { SidebarResizeHandle, useSidebarResize } from "./sidebar/SidebarResize.j
32
33
  export { ThemeProvider, useOptionalTheme, useTheme, } from "./theme/ThemeProvider.js";
33
34
  export { ThemeSwitch } from "./theme/ThemeSwitch.js";
34
35
  export type { DefaultTheme, ThemeDefinition, ThemeScheme, } from "./theme/themes.js";
36
+ export { DesktopWallpaper, type DesktopWallpaperProps, } from "./wallpaper/DesktopWallpaper.js";
37
+ export { BLOCKS_WALLPAPER, CHEVRON_WALLPAPER, HARLEQUIN_WALLPAPER, HONEYCOMB_WALLPAPER, PLAIN_WALLPAPER, TRIANGLES_WALLPAPER, } from "./wallpaper/tessellations.js";
38
+ export { useOptionalWallpaper, useWallpaper, WallpaperProvider, } from "./wallpaper/WallpaperProvider.js";
39
+ export type { WallpaperDefinition, WallpaperTile, } from "./wallpaper/wallpapers.js";
35
40
  export { CurrentWindowProvider, useCurrentWindow, useSuppressWindowToolbar, useWindowBackground, useWindowContentSize, } from "./window/CurrentWindowContext.js";
36
41
  export { Window, type WindowContentBoundary } from "./window/Window.js";
37
42
  export { WindowTitleBarActionButtons } from "./window/WindowChromeActions.js";
package/index.js CHANGED
@@ -3,10 +3,12 @@ import "./tokens.css";
3
3
  // hooks, the menu and sidebar primitives the chrome renders with, a taskbar's
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
- // and desktop icons that open them, with a storage adapter for their layout.
6
+ // and desktop icons that open them, with a storage adapter for their layout,
7
+ // over a wallpaper chosen in Display Properties.
7
8
  export { createRequiredContext, } from "./createRequiredContext.js";
8
9
  export { DesktopIcons, } from "./desktop/DesktopIcons.js";
9
10
  export { createMemoryDesktopStateStorage, createOpfsDesktopStateStorage, } from "./desktop/desktopStateStorage.js";
11
+ export { DisplayProperties } from "./display/DisplayProperties.js";
10
12
  export { WindowingIconsProvider, } from "./icons/WindowingIcons.js";
11
13
  export { ROUTED_TABLET_BREAKPOINT_PX, ROUTED_TABLET_QUERY, WINDOWED_LAYOUT_MIN_WIDTH_PX, } from "./launcher/breakpoints.js";
12
14
  export { DEFAULT_MINI_APP_POSITION, LauncherNavigationProvider, useLauncherNavigationActions, useLauncherNavigationState, useMiniAppRouteSegments, useOptionalLauncherNavigationState, } from "./launcher/LauncherNavigationProvider.js";
@@ -33,6 +35,9 @@ export { RoutedPaneOverlayHostProvider, useRoutedPaneOverlayHost, } from "./rout
33
35
  export { SidebarResizeHandle, useSidebarResize } from "./sidebar/SidebarResize.js";
34
36
  export { ThemeProvider, useOptionalTheme, useTheme, } from "./theme/ThemeProvider.js";
35
37
  export { ThemeSwitch } from "./theme/ThemeSwitch.js";
38
+ export { DesktopWallpaper, } from "./wallpaper/DesktopWallpaper.js";
39
+ export { BLOCKS_WALLPAPER, CHEVRON_WALLPAPER, HARLEQUIN_WALLPAPER, HONEYCOMB_WALLPAPER, PLAIN_WALLPAPER, TRIANGLES_WALLPAPER, } from "./wallpaper/tessellations.js";
40
+ export { useOptionalWallpaper, useWallpaper, WallpaperProvider, } from "./wallpaper/WallpaperProvider.js";
36
41
  export { CurrentWindowProvider, useCurrentWindow, useSuppressWindowToolbar, useWindowBackground, useWindowContentSize, } from "./window/CurrentWindowContext.js";
37
42
  export { Window } from "./window/Window.js";
38
43
  export { WindowTitleBarActionButtons } from "./window/WindowChromeActions.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,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,EAEL,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,2BAA2B,EAC3B,mBAAmB,EACnB,4BAA4B,GAC7B,MA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pB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,UAAU,EAAwB,MAAM,qBAAqB,CAAC;AACvE,OAAO,EACL,6BAA6B,EAE7B,wBAAwB,GACzB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,QAAQ,GACT,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAMlD,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.\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 {\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 DEFAULT_MINI_APP_POSITION,\n type LauncherNavigationActions,\n LauncherNavigationProvider,\n type LauncherNavigationState,\n type OpenMiniAppRequest,\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 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 { 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 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,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,EACL,yBAAyB,EAEzB,0BAA0B,EAG1B,4BAA4B,EAC5B,0BAA0B,EAC1B,uBAAuB,EACvB,kCAAkC,GACnC,MAA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CAAgC,CAAC;AAExC,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,QAAQ,GACT,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAMlD,OAAO,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 DEFAULT_MINI_APP_POSITION,\n type LauncherNavigationActions,\n LauncherNavigationProvider,\n type LauncherNavigationState,\n type OpenMiniAppRequest,\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 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 { 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"]}
@@ -154,6 +154,7 @@ function useLauncherNavigationActionValue(runtimeRef, goBack, goForward, navigat
154
154
  appId,
155
155
  initialShowSidebar: app.initialShowSidebar,
156
156
  ...(pathSegments ? { pathSegments } : {}),
157
+ ...(app.windowSize ? { size: app.windowSize } : {}),
157
158
  });
158
159
  }, [navigateMiniAppRoute, runtimeRef]);
159
160
  const getMiniAppHref = useCallback(buildMiniAppPath, []);
@@ -1 +1 @@
1
- {"version":3,"file":"LauncherNavigationProvider.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/launcher/LauncherNavigationProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAGL,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,kBAAkB,GAGnB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,6BAA6B,EAAE,MAAM,+BAA+B,CAAC;AAC9E,OAAO,EACL,iCAAiC,EACjC,gCAAgC,EAGhC,2BAA2B,GAC5B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAElB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,iEAAiE;AACjE,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC;AAsD5D,MAAM,gCAAgC,GACpC,qBAAqB,CACnB,mEAAmE,CACpE,CAAC;AACJ,MAAM,8BAA8B,GAClC,qBAAqB,CACnB,iEAAiE,CAClE,CAAC;AACJ,MAAM,oBAAoB,GAA0B,EAAE,CAAC;AAEvD,SAAS,gBAAgB,CAAC,UAA8B;IACtD,OAAO,kBAAkB,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;AAClE,CAAC;AAED,SAAS,uBAAuB;I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zB,CAAC,CAAC,CAAC,WAAW,EAAE,SAAS,IAAI,KAAK,CAAC,CAAC;IACtC,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,EAAE;QAC9B,IAAI,cAAc,EAAE,CAAC;YACnB,OAAO,EAAE,MAAM,EAAE,CAAC;YAClB,OAAO;QACT,CAAC;QAED,YAAY,EAAE,EAAE,CAAC;IACnB,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC,CAAC;IAE5C,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC;QACL,SAAS;QACT,MAAM;QACN,QAAQ;QACR,YAAY;QACZ,eAAe;KAChB,CAAC,EACF,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,eAAe,CAAC,CAC7D,CAAC;AACJ,CAAC","sourcesContent":["import {\n type MutableRefObject,\n type PropsWithChildren,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { createRequiredContext } from \"../createRequiredContext\";\nimport {\n findTopWindow,\n useWindowActions,\n useWindowStateData,\n type WindowStateActions,\n type WindowStateData,\n} from \"../window/WindowStateProvider\";\nimport type { LauncherDefinition } from \"./launcherDefinition\";\nimport { useMiniAppWindowRouteSegments } from \"./MiniAppRouteSegmentsContext\";\nimport {\n DEFAULT_NAVIGATION_HISTORY_CURSOR,\n getNavigationHistoryAvailability,\n type NavigationHistoryAvailability,\n type NavigationHistoryCursor,\n readNavigationHistoryCursor,\n} from \"./navigationHistory\";\nimport type { NavigationMode } from \"./navigationMode\";\nimport {\n replaceWindowHistoryCursor,\n useRoutedPathNavigator,\n} from \"./routedPathNavigator\";\nimport {\n buildMiniAppPath,\n LAUNCHER_HOME_PATH,\n type LauncherRoute,\n parseLauncherRoute,\n} from \"./routePaths\";\nimport { useDefaultWindow } from \"./useDefaultWindow\";\n\n/** Where a new window opens when a request names no position. */\nexport const DEFAULT_MINI_APP_POSITION = { x: 200, y: 160 };\n\n/** A request to show an app: in a window, or as the routed shell's page. */\nexport interface OpenMiniAppRequest<AppId extends string = string> {\n appId: AppId;\n pathSegments?: ReadonlyArray<string> | undefined;\n /** Where a new window opens. */\n position?: { x: number; y: number } | undefined;\n /** Raise the app's open window instead of opening another. Defaults to true. */\n reuseExisting?: boolean | undefined;\n}\n\nexport interface LauncherNavigationActions<AppId extends string = string> {\n getMiniAppHref: (\n appId: AppId,\n pathSegments?: ReadonlyArray<string> | undefined,\n ) => string;\n goBack: () => void;\n goForward: () => void;\n navigateMiniAppRoute: (input: {\n appId: AppId;\n pathSegments?: ReadonlyArray<string> | undefined;\n replace?: boolean | undefined;\n }) => void;\n navigateHome: (input?: { replace?: boolean | undefined }) => void;\n // Returns the window the app opened in or was raised to, or null when the\n // routed shell shows it instead.\n openMiniApp: (request: OpenMiniAppRequest<AppId>) => string | null;\n}\n\nexport interface LauncherNavigationState<AppId extends string = string> {\n definition: LauncherDefinition<AppId>;\n history: NavigationHistoryAvailability;\n mode: NavigationMode;\n route: LauncherRoute<AppId>;\n}\n\ninterface LauncherNavigationProviderProps extends PropsWithChildren {\n /** Defers the default window while false, for example in a hidden workspace. */\n defaultWindowEnabled?: boolean | undefined;\n definition: LauncherDefinition;\n mode: NavigationMode;\n}\n\ninterface LauncherNavigationRuntime {\n actions: Pick<\n WindowStateActions,\n \"bringToFront\" | \"create\" | \"restore\" | \"updateRoute\"\n >;\n definition: LauncherDefinition;\n mode: NavigationMode;\n windows: WindowStateData[\"windows\"];\n}\n\nconst launcherNavigationActionsContext =\n createRequiredContext<LauncherNavigationActions>(\n \"useLauncherNavigationActions requires LauncherNavigationProvider.\",\n );\nconst launcherNavigationStateContext =\n createRequiredContext<LauncherNavigationState>(\n \"useLauncherNavigationState requires LauncherNavigationProvider.\",\n );\nconst EMPTY_ROUTE_SEGMENTS: ReadonlyArray<string> = [];\n\nfunction readCurrentRoute(definition: LauncherDefinition): LauncherRoute {\n return parseLauncherRoute(window.location.pathname, definition);\n}\n\nfunction readWindowHistoryCursor(): NavigationHistoryCursor {\n return (\n readNavigationHistoryCursor(window.history.state) ??\n DEFAULT_NAVIGATION_HISTORY_CURSOR\n );\n}\n\nfunction ensureWindowHistoryCursor(): NavigationHistoryCursor {\n const cursor = readWindowHistoryCursor();\n if (readNavigationHistoryCursor(window.history.state) === null) {\n replaceWindowHistoryCursor(cursor);\n }\n\n return cursor;\n}\n\nfunction LauncherNavigationWindowRuntimeBridge({\n defaultWindowEnabled,\n definition,\n mode,\n openMiniApp,\n runtimeRef,\n}: {\n defaultWindowEnabled: boolean;\n definition: LauncherDefinition;\n mode: NavigationMode;\n openMiniApp: LauncherNavigationActions[\"openMiniApp\"];\n runtimeRef: MutableRefObject<LauncherNavigationRuntime>;\n}) {\n const { bringToFront, create, restore, updateRoute } = useWindowActions();\n const { windows } = useWindowStateData();\n\n useEffect(() => {\n runtimeRef.current = {\n actions: { bringToFront, create, restore, updateRoute },\n definition,\n mode,\n windows,\n };\n }, [\n bringToFront,\n create,\n definition,\n mode,\n restore,\n runtimeRef,\n updateRoute,\n windows,\n ]);\n\n useDefaultWindow({\n definition,\n enabled: defaultWindowEnabled,\n mode,\n openMiniApp,\n windowCount: windows.length,\n });\n\n return null;\n}\n\nfunction useLauncherRouteController({\n definition,\n mode,\n runtimeRef,\n}: {\n definition: LauncherDefinition;\n mode: NavigationMode;\n runtimeRef: MutableRefObject<LauncherNavigationRuntime>;\n}) {\n const [route, setRoute] = useState<LauncherRoute>(() =>\n readCurrentRoute(definition),\n );\n const [historyCursor, setHistoryCursorState] =\n useState<NavigationHistoryCursor>(readWindowHistoryCursor);\n const historyCursorRef = useRef(historyCursor);\n const setHistoryCursor = useCallback((cursor: NavigationHistoryCursor) => {\n historyCursorRef.current = cursor;\n setHistoryCursorState(cursor);\n }, []);\n const navigateRoutedPath = useRoutedPathNavigator({\n historyCursorRef,\n runtimeRef,\n setHistoryCursor,\n setRoute,\n });\n\n useEffect(() => {\n if (mode !== \"routed\") {\n return;\n }\n\n const handlePopState = (event: PopStateEvent) => {\n setHistoryCursor(\n readNavigationHistoryCursor(event.state) ??\n DEFAULT_NAVIGATION_HISTORY_CURSOR,\n );\n setRoute(readCurrentRoute(runtimeRef.current.definition));\n };\n\n setHistoryCursor(ensureWindowHistoryCursor());\n setRoute(readCurrentRoute(runtimeRef.current.definition));\n window.addEventListener(\"popstate\", handlePopState);\n return () => window.removeEventListener(\"popstate\", handlePopState);\n }, [mode, runtimeRef, setHistoryCursor]);\n\n const navigateMiniAppRoute = useCallback(\n ({\n appId,\n pathSegments = [],\n replace = false,\n }: {\n appId: string;\n pathSegments?: ReadonlyArray<string> | undefined;\n replace?: boolean | undefined;\n }) => {\n navigateRoutedPath({\n path: buildMiniAppPath(appId, pathSegments),\n replace,\n route: { appId, pathSegments: [...pathSegments] },\n });\n },\n [navigateRoutedPath],\n );\n const navigateHome = useCallback(\n ({ replace = false }: { replace?: boolean | undefined } = {}) => {\n navigateRoutedPath({\n path: LAUNCHER_HOME_PATH,\n replace,\n route: { appId: null, pathSegments: [] },\n });\n },\n [navigateRoutedPath],\n );\n\n const goBack = useCallback(() => {\n if (historyCursorRef.current.index > 0) {\n setHistoryCursor({\n ...historyCursorRef.current,\n index: historyCursorRef.current.index - 1,\n });\n window.history.back();\n }\n }, [setHistoryCursor]);\n const goForward = useCallback(() => {\n const { entries, index } = historyCursorRef.current;\n if (index < entries - 1) {\n setHistoryCursor({\n ...historyCursorRef.current,\n index: index + 1,\n });\n window.history.forward();\n }\n }, [setHistoryCursor]);\n const history = useMemo(\n () => getNavigationHistoryAvailability(historyCursor),\n [historyCursor],\n );\n\n return {\n goBack,\n goForward,\n history,\n navigateHome,\n navigateMiniAppRoute,\n route,\n };\n}\n\nfunction useLauncherNavigationActionValue(\n runtimeRef: MutableRefObject<LauncherNavigationRuntime>,\n goBack: LauncherNavigationActions[\"goBack\"],\n goForward: LauncherNavigationActions[\"goForward\"],\n navigateHome: LauncherNavigationActions[\"navigateHome\"],\n navigateMiniAppRoute: LauncherNavigationActions[\"navigateMiniAppRoute\"],\n): LauncherNavigationActions {\n const openMiniApp = useCallback(\n ({\n appId,\n pathSegments,\n position = DEFAULT_MINI_APP_POSITION,\n reuseExisting = true,\n }: OpenMiniAppRequest) => {\n const {\n actions,\n definition,\n mode: currentMode,\n windows: currentWindows,\n } = runtimeRef.current;\n\n if (currentMode === \"routed\") {\n navigateMiniAppRoute({ appId, pathSegments });\n return null;\n }\n\n const existingWindow = reuseExisting\n ? findTopWindow(currentWindows, (windowEntry) => {\n return windowEntry.appId === appId;\n })\n : null;\n if (existingWindow) {\n actions.restore(existingWindow.id);\n actions.bringToFront(existingWindow.id);\n if (pathSegments) {\n actions.updateRoute(existingWindow.id, pathSegments);\n }\n return existingWindow.id;\n }\n\n const app = definition.apps[appId];\n if (!app) {\n throw new Error(`Unknown mini-app: ${appId}`);\n }\n return actions.create(\n app.title,\n position.x,\n position.y,\n app.createComponent(),\n {\n appId,\n initialShowSidebar: app.initialShowSidebar,\n ...(pathSegments ? { pathSegments } : {}),\n },\n );\n },\n [navigateMiniAppRoute, runtimeRef],\n );\n const getMiniAppHref = useCallback(buildMiniAppPath, []);\n return useMemo<LauncherNavigationActions>(\n () => ({\n getMiniAppHref,\n goBack,\n goForward,\n navigateHome,\n navigateMiniAppRoute,\n openMiniApp,\n }),\n [\n getMiniAppHref,\n goBack,\n goForward,\n navigateHome,\n navigateMiniAppRoute,\n openMiniApp,\n ],\n );\n}\n\n/**\n * Navigation for a launcher's mini-apps, in either mode. In `windowed` mode,\n * opening an app opens or raises its window (inside a\n * {@link WindowStateProvider}); in `routed` mode it navigates the browser to\n * the app's route, `/app/<app id>/…`, which the routed shell shows.\n */\nexport function LauncherNavigationProvider({\n children,\n defaultWindowEnabled = true,\n definition,\n mode,\n}: LauncherNavigationProviderProps) {\n const runtimeRef = useRef<LauncherNavigationRuntime>({\n actions: {\n bringToFront: () => {},\n create: () => \"\",\n restore: () => {},\n updateRoute: () => {},\n },\n definition,\n mode,\n windows: [],\n });\n const {\n goBack,\n goForward,\n history,\n navigateHome,\n navigateMiniAppRoute,\n route,\n } = useLauncherRouteController({\n definition,\n mode,\n runtimeRef,\n });\n const actions = useLauncherNavigationActionValue(\n runtimeRef,\n goBack,\n goForward,\n navigateHome,\n navigateMiniAppRoute,\n );\n const state = useMemo<LauncherNavigationState>(\n () => ({ definition, history, mode, route }),\n [definition, history, mode, route],\n );\n\n return (\n <launcherNavigationActionsContext.context.Provider value={actions}>\n <launcherNavigationStateContext.context.Provider value={state}>\n <LauncherNavigationWindowRuntimeBridge\n defaultWindowEnabled={defaultWindowEnabled}\n definition={definition}\n mode={mode}\n openMiniApp={actions.openMiniApp}\n runtimeRef={runtimeRef}\n />\n {children}\n </launcherNavigationStateContext.context.Provider>\n </launcherNavigationActionsContext.context.Provider>\n );\n}\n\n// The context names apps by their string ids. The actions accept a host's own\n// narrower id type as they are; a host narrows the route's id with\n// isLauncherAppId (or its own guard) to read it back as that type.\nexport const useLauncherNavigationActions =\n launcherNavigationActionsContext.useRequired;\n\nexport const useLauncherNavigationState =\n launcherNavigationStateContext.useRequired;\n\nexport const useOptionalLauncherNavigationState =\n launcherNavigationStateContext.useOptional;\n\n/**\n * The route of `appId` where it is hosted: the browser route in the routed\n * shell, or its window's own route and Back stack in a window. Mini-apps read\n * this rather than branching on navigation mode.\n */\nexport function useMiniAppRouteSegments(appId: string) {\n const actions = launcherNavigationActionsContext.useOptional();\n const state = launcherNavigationStateContext.useOptional();\n const windowRoute = useMiniAppWindowRouteSegments(appId);\n const isGlobalRouted = actions !== null && state?.mode === \"routed\";\n const isRouted = isGlobalRouted || windowRoute !== null;\n const pathSegments =\n isGlobalRouted && state.route.appId === appId\n ? state.route.pathSegments\n : (windowRoute?.pathSegments ?? EMPTY_ROUTE_SEGMENTS);\n const windowSetPathSegments = windowRoute?.setPathSegments;\n const setPathSegments = useCallback(\n (\n nextPathSegments: ReadonlyArray<string>,\n options: { replace?: boolean | undefined } = {},\n ) => {\n if (isGlobalRouted) {\n actions?.navigateMiniAppRoute({\n appId,\n pathSegments: nextPathSegments,\n ...(options.replace === undefined\n ? {}\n : { replace: options.replace }),\n });\n return;\n }\n\n windowSetPathSegments?.(nextPathSegments, options);\n },\n [actions, appId, isGlobalRouted, windowSetPathSegments],\n );\n // \"Can this mini-app step back where it is hosted?\" — browser history in the\n // routed shell, the window's own Back stack in a window. Mini-apps read this\n // rather than branching on navigation mode, so a detail surface that must\n // yield to a real Back affordance asks one question and gets the right answer\n // in both shells.\n const windowGoBack = windowRoute?.goBack;\n const canGoBack = isGlobalRouted\n ? state.history.canGoBack\n : (windowRoute?.canGoBack ?? false);\n const goBack = useCallback(() => {\n if (isGlobalRouted) {\n actions?.goBack();\n return;\n }\n\n windowGoBack?.();\n }, [actions, isGlobalRouted, windowGoBack]);\n\n return useMemo(\n () => ({\n canGoBack,\n goBack,\n isRouted,\n pathSegments,\n setPathSegments,\n }),\n [canGoBack, goBack, isRouted, pathSegments, setPathSegments],\n );\n}\n"]}
1
+ {"version":3,"file":"LauncherNavigationProvider.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/launcher/LauncherNavigationProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAGL,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,kBAAkB,GAGnB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,6BAA6B,EAAE,MAAM,+BAA+B,CAAC;AAC9E,OAAO,EACL,iCAAiC,EACjC,gCAAgC,EAGhC,2BAA2B,GAC5B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAElB,kBAAkB,GACnB,MAAM,cA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AAE,CAAC;YACnB,OAAO,EAAE,oBAAoB,CAAC;gBAC5B,KAAK;gBACL,YAAY,EAAE,gBAAgB;gBAC9B,GAAG,CAAC,OAAO,CAAC,OAAO,KAAK,SAAS;oBAC/B,CAAC,CAAC,EAAE;oBACJ,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC;aAClC,CAAC,CAAC;YACH,OAAO;QACT,CAAC;QAED,qBAAqB,EAAE,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;IACrD,CAAC,EACD,CAAC,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,qBAAqB,CAAC,CACxD,CAAC;IACF,6EAA6E;IAC7E,6EAA6E;IAC7E,0EAA0E;IAC1E,8EAA8E;IAC9E,kBAAkB;IAClB,MAAM,YAAY,GAAG,WAAW,EAAE,MAAM,CAAC;IACzC,MAAM,SAAS,GAAG,cAAc;QAC9B,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS;QACzB,CAAC,CAAC,CAAC,WAAW,EAAE,SAAS,IAAI,KAAK,CAAC,CAAC;IACtC,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,EAAE;QAC9B,IAAI,cAAc,EAAE,CAAC;YACnB,OAAO,EAAE,MAAM,EAAE,CAAC;YAClB,OAAO;QACT,CAAC;QAED,YAAY,EAAE,EAAE,CAAC;IACnB,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC,CAAC;IAE5C,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC;QACL,SAAS;QACT,MAAM;QACN,QAAQ;QACR,YAAY;QACZ,eAAe;KAChB,CAAC,EACF,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,eAAe,CAAC,CAC7D,CAAC;AACJ,CAAC","sourcesContent":["import {\n type MutableRefObject,\n type PropsWithChildren,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { createRequiredContext } from \"../createRequiredContext\";\nimport {\n findTopWindow,\n useWindowActions,\n useWindowStateData,\n type WindowStateActions,\n type WindowStateData,\n} from \"../window/WindowStateProvider\";\nimport type { LauncherDefinition } from \"./launcherDefinition\";\nimport { useMiniAppWindowRouteSegments } from \"./MiniAppRouteSegmentsContext\";\nimport {\n DEFAULT_NAVIGATION_HISTORY_CURSOR,\n getNavigationHistoryAvailability,\n type NavigationHistoryAvailability,\n type NavigationHistoryCursor,\n readNavigationHistoryCursor,\n} from \"./navigationHistory\";\nimport type { NavigationMode } from \"./navigationMode\";\nimport {\n replaceWindowHistoryCursor,\n useRoutedPathNavigator,\n} from \"./routedPathNavigator\";\nimport {\n buildMiniAppPath,\n LAUNCHER_HOME_PATH,\n type LauncherRoute,\n parseLauncherRoute,\n} from \"./routePaths\";\nimport { useDefaultWindow } from \"./useDefaultWindow\";\n\n/** Where a new window opens when a request names no position. */\nexport const DEFAULT_MINI_APP_POSITION = { x: 200, y: 160 };\n\n/** A request to show an app: in a window, or as the routed shell's page. */\nexport interface OpenMiniAppRequest<AppId extends string = string> {\n appId: AppId;\n pathSegments?: ReadonlyArray<string> | undefined;\n /** Where a new window opens. */\n position?: { x: number; y: number } | undefined;\n /** Raise the app's open window instead of opening another. Defaults to true. */\n reuseExisting?: boolean | undefined;\n}\n\nexport interface LauncherNavigationActions<AppId extends string = string> {\n getMiniAppHref: (\n appId: AppId,\n pathSegments?: ReadonlyArray<string> | undefined,\n ) => string;\n goBack: () => void;\n goForward: () => void;\n navigateMiniAppRoute: (input: {\n appId: AppId;\n pathSegments?: ReadonlyArray<string> | undefined;\n replace?: boolean | undefined;\n }) => void;\n navigateHome: (input?: { replace?: boolean | undefined }) => void;\n // Returns the window the app opened in or was raised to, or null when the\n // routed shell shows it instead.\n openMiniApp: (request: OpenMiniAppRequest<AppId>) => string | null;\n}\n\nexport interface LauncherNavigationState<AppId extends string = string> {\n definition: LauncherDefinition<AppId>;\n history: NavigationHistoryAvailability;\n mode: NavigationMode;\n route: LauncherRoute<AppId>;\n}\n\ninterface LauncherNavigationProviderProps extends PropsWithChildren {\n /** Defers the default window while false, for example in a hidden workspace. */\n defaultWindowEnabled?: boolean | undefined;\n definition: LauncherDefinition;\n mode: NavigationMode;\n}\n\ninterface LauncherNavigationRuntime {\n actions: Pick<\n WindowStateActions,\n \"bringToFront\" | \"create\" | \"restore\" | \"updateRoute\"\n >;\n definition: LauncherDefinition;\n mode: NavigationMode;\n windows: WindowStateData[\"windows\"];\n}\n\nconst launcherNavigationActionsContext =\n createRequiredContext<LauncherNavigationActions>(\n \"useLauncherNavigationActions requires LauncherNavigationProvider.\",\n );\nconst launcherNavigationStateContext =\n createRequiredContext<LauncherNavigationState>(\n \"useLauncherNavigationState requires LauncherNavigationProvider.\",\n );\nconst EMPTY_ROUTE_SEGMENTS: ReadonlyArray<string> = [];\n\nfunction readCurrentRoute(definition: LauncherDefinition): LauncherRoute {\n return parseLauncherRoute(window.location.pathname, definition);\n}\n\nfunction readWindowHistoryCursor(): NavigationHistoryCursor {\n return (\n readNavigationHistoryCursor(window.history.state) ??\n DEFAULT_NAVIGATION_HISTORY_CURSOR\n );\n}\n\nfunction ensureWindowHistoryCursor(): NavigationHistoryCursor {\n const cursor = readWindowHistoryCursor();\n if (readNavigationHistoryCursor(window.history.state) === null) {\n replaceWindowHistoryCursor(cursor);\n }\n\n return cursor;\n}\n\nfunction LauncherNavigationWindowRuntimeBridge({\n defaultWindowEnabled,\n definition,\n mode,\n openMiniApp,\n runtimeRef,\n}: {\n defaultWindowEnabled: boolean;\n definition: LauncherDefinition;\n mode: NavigationMode;\n openMiniApp: LauncherNavigationActions[\"openMiniApp\"];\n runtimeRef: MutableRefObject<LauncherNavigationRuntime>;\n}) {\n const { bringToFront, create, restore, updateRoute } = useWindowActions();\n const { windows } = useWindowStateData();\n\n useEffect(() => {\n runtimeRef.current = {\n actions: { bringToFront, create, restore, updateRoute },\n definition,\n mode,\n windows,\n };\n }, [\n bringToFront,\n create,\n definition,\n mode,\n restore,\n runtimeRef,\n updateRoute,\n windows,\n ]);\n\n useDefaultWindow({\n definition,\n enabled: defaultWindowEnabled,\n mode,\n openMiniApp,\n windowCount: windows.length,\n });\n\n return null;\n}\n\nfunction useLauncherRouteController({\n definition,\n mode,\n runtimeRef,\n}: {\n definition: LauncherDefinition;\n mode: NavigationMode;\n runtimeRef: MutableRefObject<LauncherNavigationRuntime>;\n}) {\n const [route, setRoute] = useState<LauncherRoute>(() =>\n readCurrentRoute(definition),\n );\n const [historyCursor, setHistoryCursorState] =\n useState<NavigationHistoryCursor>(readWindowHistoryCursor);\n const historyCursorRef = useRef(historyCursor);\n const setHistoryCursor = useCallback((cursor: NavigationHistoryCursor) => {\n historyCursorRef.current = cursor;\n setHistoryCursorState(cursor);\n }, []);\n const navigateRoutedPath = useRoutedPathNavigator({\n historyCursorRef,\n runtimeRef,\n setHistoryCursor,\n setRoute,\n });\n\n useEffect(() => {\n if (mode !== \"routed\") {\n return;\n }\n\n const handlePopState = (event: PopStateEvent) => {\n setHistoryCursor(\n readNavigationHistoryCursor(event.state) ??\n DEFAULT_NAVIGATION_HISTORY_CURSOR,\n );\n setRoute(readCurrentRoute(runtimeRef.current.definition));\n };\n\n setHistoryCursor(ensureWindowHistoryCursor());\n setRoute(readCurrentRoute(runtimeRef.current.definition));\n window.addEventListener(\"popstate\", handlePopState);\n return () => window.removeEventListener(\"popstate\", handlePopState);\n }, [mode, runtimeRef, setHistoryCursor]);\n\n const navigateMiniAppRoute = useCallback(\n ({\n appId,\n pathSegments = [],\n replace = false,\n }: {\n appId: string;\n pathSegments?: ReadonlyArray<string> | undefined;\n replace?: boolean | undefined;\n }) => {\n navigateRoutedPath({\n path: buildMiniAppPath(appId, pathSegments),\n replace,\n route: { appId, pathSegments: [...pathSegments] },\n });\n },\n [navigateRoutedPath],\n );\n const navigateHome = useCallback(\n ({ replace = false }: { replace?: boolean | undefined } = {}) => {\n navigateRoutedPath({\n path: LAUNCHER_HOME_PATH,\n replace,\n route: { appId: null, pathSegments: [] },\n });\n },\n [navigateRoutedPath],\n );\n\n const goBack = useCallback(() => {\n if (historyCursorRef.current.index > 0) {\n setHistoryCursor({\n ...historyCursorRef.current,\n index: historyCursorRef.current.index - 1,\n });\n window.history.back();\n }\n }, [setHistoryCursor]);\n const goForward = useCallback(() => {\n const { entries, index } = historyCursorRef.current;\n if (index < entries - 1) {\n setHistoryCursor({\n ...historyCursorRef.current,\n index: index + 1,\n });\n window.history.forward();\n }\n }, [setHistoryCursor]);\n const history = useMemo(\n () => getNavigationHistoryAvailability(historyCursor),\n [historyCursor],\n );\n\n return {\n goBack,\n goForward,\n history,\n navigateHome,\n navigateMiniAppRoute,\n route,\n };\n}\n\nfunction useLauncherNavigationActionValue(\n runtimeRef: MutableRefObject<LauncherNavigationRuntime>,\n goBack: LauncherNavigationActions[\"goBack\"],\n goForward: LauncherNavigationActions[\"goForward\"],\n navigateHome: LauncherNavigationActions[\"navigateHome\"],\n navigateMiniAppRoute: LauncherNavigationActions[\"navigateMiniAppRoute\"],\n): LauncherNavigationActions {\n const openMiniApp = useCallback(\n ({\n appId,\n pathSegments,\n position = DEFAULT_MINI_APP_POSITION,\n reuseExisting = true,\n }: OpenMiniAppRequest) => {\n const {\n actions,\n definition,\n mode: currentMode,\n windows: currentWindows,\n } = runtimeRef.current;\n\n if (currentMode === \"routed\") {\n navigateMiniAppRoute({ appId, pathSegments });\n return null;\n }\n\n const existingWindow = reuseExisting\n ? findTopWindow(currentWindows, (windowEntry) => {\n return windowEntry.appId === appId;\n })\n : null;\n if (existingWindow) {\n actions.restore(existingWindow.id);\n actions.bringToFront(existingWindow.id);\n if (pathSegments) {\n actions.updateRoute(existingWindow.id, pathSegments);\n }\n return existingWindow.id;\n }\n\n const app = definition.apps[appId];\n if (!app) {\n throw new Error(`Unknown mini-app: ${appId}`);\n }\n return actions.create(\n app.title,\n position.x,\n position.y,\n app.createComponent(),\n {\n appId,\n initialShowSidebar: app.initialShowSidebar,\n ...(pathSegments ? { pathSegments } : {}),\n ...(app.windowSize ? { size: app.windowSize } : {}),\n },\n );\n },\n [navigateMiniAppRoute, runtimeRef],\n );\n const getMiniAppHref = useCallback(buildMiniAppPath, []);\n return useMemo<LauncherNavigationActions>(\n () => ({\n getMiniAppHref,\n goBack,\n goForward,\n navigateHome,\n navigateMiniAppRoute,\n openMiniApp,\n }),\n [\n getMiniAppHref,\n goBack,\n goForward,\n navigateHome,\n navigateMiniAppRoute,\n openMiniApp,\n ],\n );\n}\n\n/**\n * Navigation for a launcher's mini-apps, in either mode. In `windowed` mode,\n * opening an app opens or raises its window (inside a\n * {@link WindowStateProvider}); in `routed` mode it navigates the browser to\n * the app's route, `/app/<app id>/…`, which the routed shell shows.\n */\nexport function LauncherNavigationProvider({\n children,\n defaultWindowEnabled = true,\n definition,\n mode,\n}: LauncherNavigationProviderProps) {\n const runtimeRef = useRef<LauncherNavigationRuntime>({\n actions: {\n bringToFront: () => {},\n create: () => \"\",\n restore: () => {},\n updateRoute: () => {},\n },\n definition,\n mode,\n windows: [],\n });\n const {\n goBack,\n goForward,\n history,\n navigateHome,\n navigateMiniAppRoute,\n route,\n } = useLauncherRouteController({\n definition,\n mode,\n runtimeRef,\n });\n const actions = useLauncherNavigationActionValue(\n runtimeRef,\n goBack,\n goForward,\n navigateHome,\n navigateMiniAppRoute,\n );\n const state = useMemo<LauncherNavigationState>(\n () => ({ definition, history, mode, route }),\n [definition, history, mode, route],\n );\n\n return (\n <launcherNavigationActionsContext.context.Provider value={actions}>\n <launcherNavigationStateContext.context.Provider value={state}>\n <LauncherNavigationWindowRuntimeBridge\n defaultWindowEnabled={defaultWindowEnabled}\n definition={definition}\n mode={mode}\n openMiniApp={actions.openMiniApp}\n runtimeRef={runtimeRef}\n />\n {children}\n </launcherNavigationStateContext.context.Provider>\n </launcherNavigationActionsContext.context.Provider>\n );\n}\n\n// The context names apps by their string ids. The actions accept a host's own\n// narrower id type as they are; a host narrows the route's id with\n// isLauncherAppId (or its own guard) to read it back as that type.\nexport const useLauncherNavigationActions =\n launcherNavigationActionsContext.useRequired;\n\nexport const useLauncherNavigationState =\n launcherNavigationStateContext.useRequired;\n\nexport const useOptionalLauncherNavigationState =\n launcherNavigationStateContext.useOptional;\n\n/**\n * The route of `appId` where it is hosted: the browser route in the routed\n * shell, or its window's own route and Back stack in a window. Mini-apps read\n * this rather than branching on navigation mode.\n */\nexport function useMiniAppRouteSegments(appId: string) {\n const actions = launcherNavigationActionsContext.useOptional();\n const state = launcherNavigationStateContext.useOptional();\n const windowRoute = useMiniAppWindowRouteSegments(appId);\n const isGlobalRouted = actions !== null && state?.mode === \"routed\";\n const isRouted = isGlobalRouted || windowRoute !== null;\n const pathSegments =\n isGlobalRouted && state.route.appId === appId\n ? state.route.pathSegments\n : (windowRoute?.pathSegments ?? EMPTY_ROUTE_SEGMENTS);\n const windowSetPathSegments = windowRoute?.setPathSegments;\n const setPathSegments = useCallback(\n (\n nextPathSegments: ReadonlyArray<string>,\n options: { replace?: boolean | undefined } = {},\n ) => {\n if (isGlobalRouted) {\n actions?.navigateMiniAppRoute({\n appId,\n pathSegments: nextPathSegments,\n ...(options.replace === undefined\n ? {}\n : { replace: options.replace }),\n });\n return;\n }\n\n windowSetPathSegments?.(nextPathSegments, options);\n },\n [actions, appId, isGlobalRouted, windowSetPathSegments],\n );\n // \"Can this mini-app step back where it is hosted?\" — browser history in the\n // routed shell, the window's own Back stack in a window. Mini-apps read this\n // rather than branching on navigation mode, so a detail surface that must\n // yield to a real Back affordance asks one question and gets the right answer\n // in both shells.\n const windowGoBack = windowRoute?.goBack;\n const canGoBack = isGlobalRouted\n ? state.history.canGoBack\n : (windowRoute?.canGoBack ?? false);\n const goBack = useCallback(() => {\n if (isGlobalRouted) {\n actions?.goBack();\n return;\n }\n\n windowGoBack?.();\n }, [actions, isGlobalRouted, windowGoBack]);\n\n return useMemo(\n () => ({\n canGoBack,\n goBack,\n isRouted,\n pathSegments,\n setPathSegments,\n }),\n [canGoBack, goBack, isRouted, pathSegments, setPathSegments],\n );\n}\n"]}
@@ -1,5 +1,6 @@
1
1
  import type { ComponentType } from "react";
2
2
  import type { WindowingIcon } from "../icons/windowingIcon.js";
3
+ import type { WindowSize } from "../window/WindowStateProvider/index.js";
3
4
  /** One app a launcher opens: in a window, or as the routed shell's page. */
4
5
  export interface MiniAppDefinition {
5
6
  /**
@@ -16,6 +17,11 @@ export interface MiniAppDefinition {
16
17
  */
17
18
  initialShowSidebar?: boolean | undefined;
18
19
  title: string;
20
+ /**
21
+ * The size a new window opens at, in CSS pixels. Defaults to the
22
+ * stylesheet's window size.
23
+ */
24
+ windowSize?: WindowSize | undefined;
19
25
  }
20
26
  /**
21
27
  * A launcher application: the mini-apps it can open, the order its launchers
@@ -1 +1 @@
1
- {"version":3,"file":"launcherDefinition.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/launcher/launcherDefinition.ts"],"names":[],"mappings":"AA0CA,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\";\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\n/**\n * A launcher application: the mini-apps it can open, the order its launchers\n * list them in, and the one the routed shell shows at the root route.\n */\nexport interface LauncherDefinition<AppId extends string = string> {\n apps: Readonly<Record<AppId, MiniAppDefinition>>;\n /**\n * Opens when entering windowed mode with no windows, including on mount.\n * Closing the last window leaves the desktop empty until the next entry.\n * Omit to leave window startup to the host. Unknown app ids are ignored.\n */\n defaultWindowAppId?: 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":"AAgDA,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, and the one the routed shell shows at the root route.\n */\nexport interface LauncherDefinition<AppId extends string = string> {\n apps: Readonly<Record<AppId, MiniAppDefinition>>;\n /**\n * Opens when entering windowed mode with no windows, including on mount.\n * Closing the last window leaves the desktop empty until the next entry.\n * Omit to leave window startup to the host. Unknown app ids are ignored.\n */\n defaultWindowAppId?: 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.23",
3
+ "version": "0.2.24",
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,15 @@
1
+ import { type WallpaperDefinition } from "./wallpapers.js";
2
+ export interface DesktopWallpaperProps {
3
+ /** Paints this wallpaper instead of the nearest provider's choice. */
4
+ wallpaper?: WallpaperDefinition | undefined;
5
+ }
6
+ /**
7
+ * The wallpaper behind the desktop's icons and windows: the nearest
8
+ * {@link WallpaperProvider}'s choice, or `wallpaper`. Render it as the first
9
+ * child of the positioned surface the windows lay out on, before
10
+ * `DesktopIcons`, and make that surface a stacking context (`isolation:
11
+ * isolate`): the wallpaper sits on a layer below the surface's content. It
12
+ * takes no pointer input, so presses reach the surface. Without a provider or
13
+ * a `wallpaper` it renders nothing.
14
+ */
15
+ export declare function DesktopWallpaper({ wallpaper }: DesktopWallpaperProps): import("react").JSX.Element | null;
@@ -0,0 +1,22 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useOptionalWallpaper } from "./WallpaperProvider.js";
3
+ import { wallpaperStyle } from "./wallpapers.js";
4
+ import "./Wallpaper.css";
5
+ /**
6
+ * The wallpaper behind the desktop's icons and windows: the nearest
7
+ * {@link WallpaperProvider}'s choice, or `wallpaper`. Render it as the first
8
+ * child of the positioned surface the windows lay out on, before
9
+ * `DesktopIcons`, and make that surface a stacking context (`isolation:
10
+ * isolate`): the wallpaper sits on a layer below the surface's content. It
11
+ * takes no pointer input, so presses reach the surface. Without a provider or
12
+ * a `wallpaper` it renders nothing.
13
+ */
14
+ export function DesktopWallpaper({ wallpaper }) {
15
+ const context = useOptionalWallpaper();
16
+ const shown = wallpaper ?? context?.activeWallpaper;
17
+ if (!shown) {
18
+ return null;
19
+ }
20
+ return (_jsx("div", { "aria-hidden": "true", className: "desktop-wallpaper wallpaper-pattern", "data-pattern": shown.tile ? "" : undefined, "data-wallpaper": shown.id, style: wallpaperStyle(shown) }));
21
+ }
22
+ //# sourceMappingURL=DesktopWallpaper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DesktopWallpaper.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/wallpaper/DesktopWallpaper.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAA4B,cAAc,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,iBAAiB,CAAC;AAOzB;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAAE,SAAS,EAAyB;IACnE,MAAM,OAAO,GAAG,oBAAoB,EAAE,CAAC;IACvC,MAAM,KAAK,GAAG,SAAS,IAAI,OAAO,EAAE,eAAe,CAAC;IACpD,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,CACL,6BACc,MAAM,EAClB,SAAS,EAAC,qCAAqC,kBACjC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,oBACzB,KAAK,CAAC,EAAE,EACxB,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,GAC5B,CACH,CAAC;AACJ,CAAC","sourcesContent":["import { useOptionalWallpaper } from \"./WallpaperProvider\";\nimport { type WallpaperDefinition, wallpaperStyle } from \"./wallpapers\";\nimport \"./Wallpaper.css\";\n\nexport interface DesktopWallpaperProps {\n /** Paints this wallpaper instead of the nearest provider's choice. */\n wallpaper?: WallpaperDefinition | undefined;\n}\n\n/**\n * The wallpaper behind the desktop's icons and windows: the nearest\n * {@link WallpaperProvider}'s choice, or `wallpaper`. Render it as the first\n * child of the positioned surface the windows lay out on, before\n * `DesktopIcons`, and make that surface a stacking context (`isolation:\n * isolate`): the wallpaper sits on a layer below the surface's content. It\n * takes no pointer input, so presses reach the surface. Without a provider or\n * a `wallpaper` it renders nothing.\n */\nexport function DesktopWallpaper({ wallpaper }: DesktopWallpaperProps) {\n const context = useOptionalWallpaper();\n const shown = wallpaper ?? context?.activeWallpaper;\n if (!shown) {\n return null;\n }\n return (\n <div\n aria-hidden=\"true\"\n className=\"desktop-wallpaper wallpaper-pattern\"\n data-pattern={shown.tile ? \"\" : undefined}\n data-wallpaper={shown.id}\n style={wallpaperStyle(shown)}\n />\n );\n}\n"]}
@@ -0,0 +1,34 @@
1
+ /*
2
+ * A wallpaper paints from the custom properties wallpaperStyle() sets: the
3
+ * base color fills the element, and a layer of ink above it shows through the
4
+ * tile's mask, repeated at the tile's size. A wallpaper with no tile has no
5
+ * data-pattern, and so no ink layer.
6
+ */
7
+ .wallpaper-pattern {
8
+ background: var(--wallpaper-base);
9
+ }
10
+
11
+ .wallpaper-pattern[data-pattern]::before {
12
+ content: "";
13
+ position: absolute;
14
+ inset: 0;
15
+ background: var(--wallpaper-ink);
16
+ -webkit-mask-image: var(--wallpaper-mask);
17
+ mask-image: var(--wallpaper-mask);
18
+ -webkit-mask-repeat: repeat;
19
+ mask-repeat: repeat;
20
+ -webkit-mask-size: var(--wallpaper-size);
21
+ mask-size: var(--wallpaper-size);
22
+ }
23
+
24
+ /* The desktop's wallpaper fills the window surface beneath everything on it,
25
+ positioned or not (icons, windows, and content laid out in flow, such as a
26
+ pinned panel), and lets presses through to the surface. Its negative layer
27
+ needs the surface to be a stacking context (`isolation: isolate`), or it
28
+ falls behind the surface's own background. */
29
+ .desktop-wallpaper {
30
+ position: absolute;
31
+ inset: 0;
32
+ z-index: -1;
33
+ pointer-events: none;
34
+ }
@@ -0,0 +1,33 @@
1
+ import { type PropsWithChildren } from "react";
2
+ import { type WallpaperDefinition } from "./wallpapers.js";
3
+ interface WallpaperContextValue {
4
+ /** The wallpaper showing: the user's choice, or the host's default. */
5
+ activeWallpaper: WallpaperDefinition;
6
+ /** Records a wallpaper the host offers as the user's choice. */
7
+ setWallpaper: (id: string) => void;
8
+ /** Every wallpaper the host offers, in order. */
9
+ wallpapers: readonly WallpaperDefinition[];
10
+ }
11
+ interface WallpaperProviderProps<Id extends string> extends PropsWithChildren {
12
+ /** The wallpaper until the user picks one. Defaults to the first. */
13
+ defaultWallpaper?: NoInfer<Id> | undefined;
14
+ /** Where the user's choice persists in localStorage. */
15
+ storageKey: string;
16
+ /**
17
+ * The wallpapers the host offers, in the order Display Properties lists
18
+ * them. Define the list once, outside render.
19
+ */
20
+ wallpapers: readonly WallpaperDefinition<Id>[];
21
+ }
22
+ /**
23
+ * Owns the desktop wallpaper: the host's `wallpapers` and the user's choice
24
+ * among them, which {@link DesktopWallpaper} paints and Display Properties
25
+ * changes. Mount one above every desktop that shares the choice.
26
+ *
27
+ * Only an explicit choice persists. A stored id the host no longer offers
28
+ * counts as no choice, so the default shows.
29
+ */
30
+ export declare function WallpaperProvider<Id extends string>({ children, defaultWallpaper, storageKey, wallpapers, }: WallpaperProviderProps<Id>): import("react").JSX.Element;
31
+ export declare const useWallpaper: () => WallpaperContextValue;
32
+ export declare const useOptionalWallpaper: () => WallpaperContextValue | null;
33
+ export {};
@@ -0,0 +1,37 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useCallback, useMemo, useState } from "react";
3
+ import { createRequiredContext } from "../createRequiredContext.js";
4
+ import { loadStoredPreference, saveStoredPreference, } from "../launcher/storedPreference.js";
5
+ import { findWallpaper } from "./wallpapers.js";
6
+ const wallpaperContext = createRequiredContext("useWallpaper must be used within a WallpaperProvider");
7
+ /**
8
+ * Owns the desktop wallpaper: the host's `wallpapers` and the user's choice
9
+ * among them, which {@link DesktopWallpaper} paints and Display Properties
10
+ * changes. Mount one above every desktop that shares the choice.
11
+ *
12
+ * Only an explicit choice persists. A stored id the host no longer offers
13
+ * counts as no choice, so the default shows.
14
+ */
15
+ export function WallpaperProvider({ children, defaultWallpaper, storageKey, wallpapers, }) {
16
+ const [choice, setChoice] = useState(() => loadStoredPreference(storageKey, (stored) => stored));
17
+ const activeWallpaper = findWallpaper(wallpapers, choice) ??
18
+ findWallpaper(wallpapers, defaultWallpaper) ??
19
+ wallpapers[0];
20
+ if (!activeWallpaper) {
21
+ throw new Error("WallpaperProvider needs at least one wallpaper");
22
+ }
23
+ const setWallpaper = useCallback((id) => {
24
+ if (!findWallpaper(wallpapers, id)) {
25
+ return;
26
+ }
27
+ setChoice(id);
28
+ saveStoredPreference(storageKey, id);
29
+ }, [storageKey, wallpapers]);
30
+ const value = useMemo(() => ({ activeWallpaper, setWallpaper, wallpapers }), [activeWallpaper, setWallpaper, wallpapers]);
31
+ return (_jsx(wallpaperContext.context.Provider, { value: value, children: children }));
32
+ }
33
+ export const useWallpaper = wallpaperContext.useRequired;
34
+ // Non-throwing accessor: a desktop rendered without a provider shows no
35
+ // wallpaper, and Display Properties leaves out its Background section.
36
+ export const useOptionalWallpaper = wallpaperContext.useOptional;
37
+ //# sourceMappingURL=WallpaperProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WallpaperProvider.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/wallpaper/WallpaperProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAA0B,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC/E,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACL,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,aAAa,EAA4B,MAAM,cAAc,CAAC;AAWvE,MAAM,gBAAgB,GAAG,qBAAqB,CAC5C,sDAAsD,CACvD,CAAC;AAcF;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAAoB,EACnD,QAAQ,EACR,gBAAgB,EAChB,UAAU,EACV,UAAU,GACiB;IAC3B,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,CACxC,oBAAoB,CAAC,UAAU,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,CACrD,CAAC;IACF,MAAM,eAAe,GACnB,aAAa,CAAC,UAAU,EAAE,MAAM,CAAC;QACjC,aAAa,CAAC,UAAU,EAAE,gBAAgB,CAAC;QAC3C,UAAU,CAAC,CAAC,CAAC,CAAC;IAChB,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;IACpE,CAAC;IAED,MAAM,YAAY,GAAG,WAAW,CAC9B,CAAC,EAAU,EAAE,EAAE;QACb,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,EAAE,CAAC,EAAE,CAAC;YACnC,OAAO;QACT,CAAC;QACD,SAAS,CAAC,EAAE,CAAC,CAAC;QACd,oBAAoB,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IACvC,CAAC,EACD,CAAC,UAAU,EAAE,UAAU,CAAC,CACzB,CAAC;IAEF,MAAM,KAAK,GAAG,OAAO,CACnB,GAAG,EAAE,CAAC,CAAC,EAAE,eAAe,EAAE,YAAY,EAAE,UAAU,EAAE,CAAC,EACrD,CAAC,eAAe,EAAE,YAAY,EAAE,UAAU,CAAC,CAC5C,CAAC;IAEF,OAAO,CACL,KAAC,gBAAgB,CAAC,OAAO,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAC5C,QAAQ,GACyB,CACrC,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,gBAAgB,CAAC,WAAW,CAAC;AAEzD,wEAAwE;AACxE,uEAAuE;AACvE,MAAM,CAAC,MAAM,oBAAoB,GAAG,gBAAgB,CAAC,WAAW,CAAC","sourcesContent":["import { type PropsWithChildren, useCallback, useMemo, useState } from \"react\";\nimport { createRequiredContext } from \"../createRequiredContext\";\nimport {\n loadStoredPreference,\n saveStoredPreference,\n} from \"../launcher/storedPreference\";\nimport { findWallpaper, type WallpaperDefinition } from \"./wallpapers\";\n\ninterface WallpaperContextValue {\n /** The wallpaper showing: the user's choice, or the host's default. */\n activeWallpaper: WallpaperDefinition;\n /** Records a wallpaper the host offers as the user's choice. */\n setWallpaper: (id: string) => void;\n /** Every wallpaper the host offers, in order. */\n wallpapers: readonly WallpaperDefinition[];\n}\n\nconst wallpaperContext = createRequiredContext<WallpaperContextValue>(\n \"useWallpaper must be used within a WallpaperProvider\",\n);\n\ninterface WallpaperProviderProps<Id extends string> extends PropsWithChildren {\n /** The wallpaper until the user picks one. Defaults to the first. */\n defaultWallpaper?: NoInfer<Id> | undefined;\n /** Where the user's choice persists in localStorage. */\n storageKey: string;\n /**\n * The wallpapers the host offers, in the order Display Properties lists\n * them. Define the list once, outside render.\n */\n wallpapers: readonly WallpaperDefinition<Id>[];\n}\n\n/**\n * Owns the desktop wallpaper: the host's `wallpapers` and the user's choice\n * among them, which {@link DesktopWallpaper} paints and Display Properties\n * changes. Mount one above every desktop that shares the choice.\n *\n * Only an explicit choice persists. A stored id the host no longer offers\n * counts as no choice, so the default shows.\n */\nexport function WallpaperProvider<Id extends string>({\n children,\n defaultWallpaper,\n storageKey,\n wallpapers,\n}: WallpaperProviderProps<Id>) {\n const [choice, setChoice] = useState(() =>\n loadStoredPreference(storageKey, (stored) => stored),\n );\n const activeWallpaper =\n findWallpaper(wallpapers, choice) ??\n findWallpaper(wallpapers, defaultWallpaper) ??\n wallpapers[0];\n if (!activeWallpaper) {\n throw new Error(\"WallpaperProvider needs at least one wallpaper\");\n }\n\n const setWallpaper = useCallback(\n (id: string) => {\n if (!findWallpaper(wallpapers, id)) {\n return;\n }\n setChoice(id);\n saveStoredPreference(storageKey, id);\n },\n [storageKey, wallpapers],\n );\n\n const value = useMemo<WallpaperContextValue>(\n () => ({ activeWallpaper, setWallpaper, wallpapers }),\n [activeWallpaper, setWallpaper, wallpapers],\n );\n\n return (\n <wallpaperContext.context.Provider value={value}>\n {children}\n </wallpaperContext.context.Provider>\n );\n}\n\nexport const useWallpaper = wallpaperContext.useRequired;\n\n// Non-throwing accessor: a desktop rendered without a provider shows no\n// wallpaper, and Display Properties leaves out its Background section.\nexport const useOptionalWallpaper = wallpaperContext.useOptional;\n"]}
@@ -0,0 +1,13 @@
1
+ import type { WallpaperDefinition } from "./wallpapers.js";
2
+ /** Cubes seen corner-on, each in three shades: the tumbling-blocks quilt. */
3
+ export declare const BLOCKS_WALLPAPER: WallpaperDefinition<"blocks">;
4
+ /** Outlined hexagons, as a honeycomb. */
5
+ export declare const HONEYCOMB_WALLPAPER: WallpaperDefinition<"honeycomb">;
6
+ /** Equilateral triangles, alternately dark and light. */
7
+ export declare const TRIANGLES_WALLPAPER: WallpaperDefinition<"triangles">;
8
+ /** Diamonds on a lighter ground, as a harlequin's coat. */
9
+ export declare const HARLEQUIN_WALLPAPER: WallpaperDefinition<"harlequin">;
10
+ /** Zigzag bands. */
11
+ export declare const CHEVRON_WALLPAPER: WallpaperDefinition<"chevron">;
12
+ /** No pattern: the theme's desk color alone. */
13
+ export declare const PLAIN_WALLPAPER: WallpaperDefinition<"plain">;
@@ -0,0 +1,151 @@
1
+ // Ready-made wallpapers: quiet tessellations of the plane, each one tile of
2
+ // SVG repeated edge to edge. A host lists the ones it offers, alongside its
3
+ // own, in its WallpaperProvider. Shapes that cross a tile's edge are drawn in
4
+ // full from every neighboring cell, so the clipped halves meet seamlessly.
5
+ const SQRT3 = Math.sqrt(3);
6
+ function round(value) {
7
+ return String(Math.round(value * 100) / 100);
8
+ }
9
+ function tile(width, height, body) {
10
+ const w = round(width);
11
+ const h = round(height);
12
+ return {
13
+ height: Number(h),
14
+ svg: `<svg xmlns="http://www.w3.org/2000/svg" width="${w}" height="${h}" viewBox="0 0 ${w} ${h}">${body}</svg>`,
15
+ width: Number(w),
16
+ };
17
+ }
18
+ function polygon(points, opacity = 1) {
19
+ const list = points.map(([x, y]) => `${round(x)},${round(y)}`).join(" ");
20
+ const fill = opacity === 1 ? "" : ` fill-opacity="${opacity}"`;
21
+ return `<polygon points="${list}"${fill}/>`;
22
+ }
23
+ // The whole tile at one shade, beneath the shapes drawn over it.
24
+ function ground(width, height, opacity) {
25
+ return `<rect width="${round(width)}" height="${round(height)}" fill-opacity="${opacity}"/>`;
26
+ }
27
+ // A pointy-topped hexagon's corners, clockwise from the top.
28
+ function hexagon([cx, cy], radius) {
29
+ const half = (radius * SQRT3) / 2;
30
+ return [
31
+ [cx, cy - radius],
32
+ [cx + half, cy - radius / 2],
33
+ [cx + half, cy + radius / 2],
34
+ [cx, cy + radius],
35
+ [cx - half, cy + radius / 2],
36
+ [cx - half, cy - radius / 2],
37
+ ];
38
+ }
39
+ // Hexagon centers covering one w-by-3r cell of a pointy-topped hex grid,
40
+ // including every neighbor whose outline reaches into the cell.
41
+ function hexCenters(width, radius) {
42
+ const rows = [
43
+ [0, [0, width]],
44
+ [1.5 * radius, [-width / 2, width / 2, 1.5 * width]],
45
+ [3 * radius, [0, width]],
46
+ ];
47
+ return rows.flatMap(([y, xs]) => xs.map((x) => [x, y]));
48
+ }
49
+ /** Cubes seen corner-on, each in three shades: the tumbling-blocks quilt. */
50
+ export const BLOCKS_WALLPAPER = (() => {
51
+ const radius = 18;
52
+ const width = radius * SQRT3;
53
+ const centers = [
54
+ [width / 2, radius],
55
+ [0, 2.5 * radius],
56
+ [width, 2.5 * radius],
57
+ [0, -0.5 * radius],
58
+ [width, -0.5 * radius],
59
+ ];
60
+ // The ground is the darkest face's shade, so faces never meet over a gap
61
+ // of bare base where their antialiased edges would show as seams.
62
+ const faces = centers
63
+ .map((center) => {
64
+ const [top, upperRight, , bottom, lowerLeft, upperLeft] = hexagon(center, radius);
65
+ return [
66
+ polygon([top, upperRight, center, upperLeft], 1),
67
+ polygon([upperLeft, center, bottom, lowerLeft], 0.55),
68
+ ].join("");
69
+ })
70
+ .join("");
71
+ const height = 3 * radius;
72
+ return {
73
+ id: "blocks",
74
+ label: "Blocks",
75
+ tile: tile(width, height, `${ground(width, height, 0.2)}${faces}`),
76
+ };
77
+ })();
78
+ /** Outlined hexagons, as a honeycomb. */
79
+ export const HONEYCOMB_WALLPAPER = (() => {
80
+ const radius = 16;
81
+ const width = radius * SQRT3;
82
+ const body = hexCenters(width, radius)
83
+ .map((center) => polygon(hexagon(center, radius)))
84
+ .join("");
85
+ return {
86
+ id: "honeycomb",
87
+ label: "Honeycomb",
88
+ tile: tile(width, 3 * radius, `<g fill="none" stroke="#000" stroke-width="1.5">${body}</g>`),
89
+ };
90
+ })();
91
+ /** Equilateral triangles, alternately dark and light. */
92
+ export const TRIANGLES_WALLPAPER = (() => {
93
+ const side = 36;
94
+ const height = (side * SQRT3) / 2;
95
+ const half = side / 2;
96
+ // Inverted triangles are the lighter ground between the upright ones.
97
+ const upright = [
98
+ // The first row's upright triangle.
99
+ polygon([
100
+ [0, height],
101
+ [side, height],
102
+ [half, 0],
103
+ ]),
104
+ // The second row's, offset by half a side.
105
+ polygon([
106
+ [0, height],
107
+ [-half, 2 * height],
108
+ [half, 2 * height],
109
+ ]),
110
+ polygon([
111
+ [side, height],
112
+ [half, 2 * height],
113
+ [side + half, 2 * height],
114
+ ]),
115
+ ].join("");
116
+ return {
117
+ id: "triangles",
118
+ label: "Triangles",
119
+ tile: tile(side, 2 * height, `${ground(side, 2 * height, 0.4)}${upright}`),
120
+ };
121
+ })();
122
+ /** Diamonds on a lighter ground, as a harlequin's coat. */
123
+ export const HARLEQUIN_WALLPAPER = {
124
+ id: "harlequin",
125
+ label: "Harlequin",
126
+ tile: tile(32, 48, `${ground(32, 48, 0.35)}${polygon([
127
+ [16, 0],
128
+ [32, 24],
129
+ [16, 48],
130
+ [0, 24],
131
+ ])}`),
132
+ };
133
+ /** Zigzag bands. */
134
+ export const CHEVRON_WALLPAPER = {
135
+ id: "chevron",
136
+ label: "Chevron",
137
+ tile: tile(40, 20, polygon([
138
+ [0, 0],
139
+ [20, 10],
140
+ [40, 0],
141
+ [40, 10],
142
+ [20, 20],
143
+ [0, 10],
144
+ ])),
145
+ };
146
+ /** No pattern: the theme's desk color alone. */
147
+ export const PLAIN_WALLPAPER = {
148
+ id: "plain",
149
+ label: "None",
150
+ };
151
+ //# sourceMappingURL=tessellations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tessellations.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/wallpaper/tessellations.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,4EAA4E;AAC5E,8EAA8E;AAC9E,2EAA2E;AAM3E,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAE3B,SAAS,KAAK,CAAC,KAAa;IAC1B,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC;AAC/C,CAAC;AAED,SAAS,IAAI,CAAC,KAAa,EAAE,MAAc,EAAE,IAAY;IACvD,MAAM,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;IACvB,MAAM,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IACxB,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;QACjB,GAAG,EAAE,kDAAkD,CAAC,aAAa,CAAC,kBAAkB,CAAC,IAAI,CAAC,KAAK,IAAI,QAAQ;QAC/G,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;KACjB,CAAC;AACJ,CAAC;AAED,SAAS,OAAO,CAAC,MAA4B,EAAE,OAAO,GAAG,CAAC;IACxD,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzE,MAAM,IAAI,GAAG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C,EAAE,CAAC,CAAC;QACN,CAAC,EAAE,EAAE,EAAE,CAAC;QACR,CAAC,EAAE,EAAE,CAAC,CAAC;QACP,CAAC,EAAE,EAAE,EAAE,CAAC;QACR,CAAC,EAAE,EAAE,EAAE,CAAC;QACR,CAAC,CAAC,EAAE,EAAE,CAAC;KACR,CAAC,CACH;CACF,CAAC;AAEF,gDAAgD;AAChD,MAAM,CAAC,MAAM,eAAe,GAAiC;IAC3D,EAAE,EAAE,OAAO;IACX,KAAK,EAAE,MAAM;CACd,CAAC","sourcesContent":["// Ready-made wallpapers: quiet tessellations of the plane, each one tile of\n// SVG repeated edge to edge. A host lists the ones it offers, alongside its\n// own, in its WallpaperProvider. Shapes that cross a tile's edge are drawn in\n// full from every neighboring cell, so the clipped halves meet seamlessly.\n\nimport type { WallpaperDefinition, WallpaperTile } from \"./wallpapers\";\n\ntype Point = readonly [x: number, y: number];\n\nconst SQRT3 = Math.sqrt(3);\n\nfunction round(value: number): string {\n return String(Math.round(value * 100) / 100);\n}\n\nfunction tile(width: number, height: number, body: string): WallpaperTile {\n const w = round(width);\n const h = round(height);\n return {\n height: Number(h),\n svg: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${w}\" height=\"${h}\" viewBox=\"0 0 ${w} ${h}\">${body}</svg>`,\n width: Number(w),\n };\n}\n\nfunction polygon(points: ReadonlyArray<Point>, opacity = 1): string {\n const list = points.map(([x, y]) => `${round(x)},${round(y)}`).join(\" \");\n const fill = opacity === 1 ? \"\" : ` fill-opacity=\"${opacity}\"`;\n return `<polygon points=\"${list}\"${fill}/>`;\n}\n\n// The whole tile at one shade, beneath the shapes drawn over it.\nfunction ground(width: number, height: number, opacity: number): string {\n return `<rect width=\"${round(width)}\" height=\"${round(height)}\" fill-opacity=\"${opacity}\"/>`;\n}\n\ntype Hexagon = readonly [Point, Point, Point, Point, Point, Point];\n\n// A pointy-topped hexagon's corners, clockwise from the top.\nfunction hexagon([cx, cy]: Point, radius: number): Hexagon {\n const half = (radius * SQRT3) / 2;\n return [\n [cx, cy - radius],\n [cx + half, cy - radius / 2],\n [cx + half, cy + radius / 2],\n [cx, cy + radius],\n [cx - half, cy + radius / 2],\n [cx - half, cy - radius / 2],\n ];\n}\n\n// Hexagon centers covering one w-by-3r cell of a pointy-topped hex grid,\n// including every neighbor whose outline reaches into the cell.\nfunction hexCenters(width: number, radius: number): Point[] {\n const rows: ReadonlyArray<readonly [y: number, xs: number[]]> = [\n [0, [0, width]],\n [1.5 * radius, [-width / 2, width / 2, 1.5 * width]],\n [3 * radius, [0, width]],\n ];\n return rows.flatMap(([y, xs]) => xs.map((x): Point => [x, y]));\n}\n\n/** Cubes seen corner-on, each in three shades: the tumbling-blocks quilt. */\nexport const BLOCKS_WALLPAPER: WallpaperDefinition<\"blocks\"> = (() => {\n const radius = 18;\n const width = radius * SQRT3;\n const centers: Point[] = [\n [width / 2, radius],\n [0, 2.5 * radius],\n [width, 2.5 * radius],\n [0, -0.5 * radius],\n [width, -0.5 * radius],\n ];\n // The ground is the darkest face's shade, so faces never meet over a gap\n // of bare base where their antialiased edges would show as seams.\n const faces = centers\n .map((center) => {\n const [top, upperRight, , bottom, lowerLeft, upperLeft] = hexagon(\n center,\n radius,\n );\n return [\n polygon([top, upperRight, center, upperLeft], 1),\n polygon([upperLeft, center, bottom, lowerLeft], 0.55),\n ].join(\"\");\n })\n .join(\"\");\n const height = 3 * radius;\n return {\n id: \"blocks\",\n label: \"Blocks\",\n tile: tile(width, height, `${ground(width, height, 0.2)}${faces}`),\n };\n})();\n\n/** Outlined hexagons, as a honeycomb. */\nexport const HONEYCOMB_WALLPAPER: WallpaperDefinition<\"honeycomb\"> = (() => {\n const radius = 16;\n const width = radius * SQRT3;\n const body = hexCenters(width, radius)\n .map((center) => polygon(hexagon(center, radius)))\n .join(\"\");\n return {\n id: \"honeycomb\",\n label: \"Honeycomb\",\n tile: tile(\n width,\n 3 * radius,\n `<g fill=\"none\" stroke=\"#000\" stroke-width=\"1.5\">${body}</g>`,\n ),\n };\n})();\n\n/** Equilateral triangles, alternately dark and light. */\nexport const TRIANGLES_WALLPAPER: WallpaperDefinition<\"triangles\"> = (() => {\n const side = 36;\n const height = (side * SQRT3) / 2;\n const half = side / 2;\n // Inverted triangles are the lighter ground between the upright ones.\n const upright = [\n // The first row's upright triangle.\n polygon([\n [0, height],\n [side, height],\n [half, 0],\n ]),\n // The second row's, offset by half a side.\n polygon([\n [0, height],\n [-half, 2 * height],\n [half, 2 * height],\n ]),\n polygon([\n [side, height],\n [half, 2 * height],\n [side + half, 2 * height],\n ]),\n ].join(\"\");\n return {\n id: \"triangles\",\n label: \"Triangles\",\n tile: tile(side, 2 * height, `${ground(side, 2 * height, 0.4)}${upright}`),\n };\n})();\n\n/** Diamonds on a lighter ground, as a harlequin's coat. */\nexport const HARLEQUIN_WALLPAPER: WallpaperDefinition<\"harlequin\"> = {\n id: \"harlequin\",\n label: \"Harlequin\",\n tile: tile(\n 32,\n 48,\n `${ground(32, 48, 0.35)}${polygon([\n [16, 0],\n [32, 24],\n [16, 48],\n [0, 24],\n ])}`,\n ),\n};\n\n/** Zigzag bands. */\nexport const CHEVRON_WALLPAPER: WallpaperDefinition<\"chevron\"> = {\n id: \"chevron\",\n label: \"Chevron\",\n tile: tile(\n 40,\n 20,\n polygon([\n [0, 0],\n [20, 10],\n [40, 0],\n [40, 10],\n [20, 20],\n [0, 10],\n ]),\n ),\n};\n\n/** No pattern: the theme's desk color alone. */\nexport const PLAIN_WALLPAPER: WallpaperDefinition<\"plain\"> = {\n id: \"plain\",\n label: \"None\",\n};\n"]}
@@ -0,0 +1,52 @@
1
+ import type { CSSProperties } from "react";
2
+ /**
3
+ * One tile of a repeating wallpaper pattern. The tile's SVG is a mask, not a
4
+ * picture: where its shapes are opaque the wallpaper paints its ink, where
5
+ * they are translucent (`fill-opacity`, `stroke-opacity`) it paints that share
6
+ * of the ink, and elsewhere the base shows. The markup's own colors are
7
+ * ignored, so one tile follows every theme.
8
+ */
9
+ export interface WallpaperTile {
10
+ /** The tile's height in CSS pixels; the pattern repeats at this size. */
11
+ readonly height: number;
12
+ /**
13
+ * The tile as a standalone SVG document (with its `xmlns`), drawn edge to
14
+ * edge across `width` by `height` so neighboring tiles meet seamlessly.
15
+ */
16
+ readonly svg: string;
17
+ /** The tile's width in CSS pixels. */
18
+ readonly width: number;
19
+ }
20
+ /**
21
+ * A desktop wallpaper a host offers: a base color and, optionally, a pattern
22
+ * repeated over it in an ink color. Unless it names its own, the colors come
23
+ * from the theme: the `--desktop-wallpaper-base` and `--desktop-wallpaper-ink`
24
+ * tokens where a host sets them, else the desk color (`--desktop-background`,
25
+ * then `--color-light`) under a faint wash of `--color-dark`.
26
+ */
27
+ export interface WallpaperDefinition<Id extends string = string> {
28
+ /** A CSS color under the pattern. */
29
+ readonly base?: string | undefined;
30
+ readonly id: Id;
31
+ /** A CSS color the pattern paints in. */
32
+ readonly ink?: string | undefined;
33
+ /** The wallpaper's name, as Display Properties lists it. */
34
+ readonly label: string;
35
+ /** The repeating pattern. Without one the wallpaper is its base alone. */
36
+ readonly tile?: WallpaperTile | undefined;
37
+ }
38
+ type WallpaperStyle = CSSProperties & {
39
+ "--wallpaper-base": string;
40
+ "--wallpaper-ink": string;
41
+ "--wallpaper-mask"?: string;
42
+ "--wallpaper-size"?: string;
43
+ };
44
+ /** The tile's SVG as a `url()` value. */
45
+ export declare function wallpaperTileUrl(tile: WallpaperTile): string;
46
+ /**
47
+ * The custom properties a `.wallpaper-pattern` element paints a wallpaper
48
+ * from: its colors, and its tile as a mask repeated at the tile's size.
49
+ */
50
+ export declare function wallpaperStyle(wallpaper: WallpaperDefinition): WallpaperStyle;
51
+ export declare function findWallpaper<Id extends string>(wallpapers: readonly WallpaperDefinition<Id>[], id: string | null | undefined): WallpaperDefinition<Id> | undefined;
52
+ export {};
@@ -0,0 +1,28 @@
1
+ // The theme's colors, resolved on the wallpaper's own element, so a theme
2
+ // scoped below the document root reaches the desktop and the previews alike.
3
+ const THEME_BASE = "var(--desktop-wallpaper-base, var(--desktop-background, var(--color-light)))";
4
+ const THEME_INK = "var(--desktop-wallpaper-ink, color-mix(in srgb, var(--color-dark) 12%, transparent))";
5
+ /** The tile's SVG as a `url()` value. */
6
+ export function wallpaperTileUrl(tile) {
7
+ return `url("data:image/svg+xml,${encodeURIComponent(tile.svg)}")`;
8
+ }
9
+ /**
10
+ * The custom properties a `.wallpaper-pattern` element paints a wallpaper
11
+ * from: its colors, and its tile as a mask repeated at the tile's size.
12
+ */
13
+ export function wallpaperStyle(wallpaper) {
14
+ const style = {
15
+ "--wallpaper-base": wallpaper.base ?? THEME_BASE,
16
+ "--wallpaper-ink": wallpaper.ink ?? THEME_INK,
17
+ };
18
+ if (wallpaper.tile) {
19
+ style["--wallpaper-mask"] = wallpaperTileUrl(wallpaper.tile);
20
+ style["--wallpaper-size"] =
21
+ `${wallpaper.tile.width}px ${wallpaper.tile.height}px`;
22
+ }
23
+ return style;
24
+ }
25
+ export function findWallpaper(wallpapers, id) {
26
+ return wallpapers.find((wallpaper) => wallpaper.id === id);
27
+ }
28
+ //# sourceMappingURL=wallpapers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wallpapers.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/wallpaper/wallpapers.ts"],"names":[],"mappings":"AAwCA,0EAA0E;AAC1E,6EAA6E;AAC7E,MAAM,UAAU,GACd,8EAA8E,CAAC;AACjF,MAAM,SAAS,GACb,sFAAsF,CAAC;AASzF,yCAAyC;AACzC,MAAM,UAAU,gBAAgB,CAAC,IAAmB;IAClD,OAAO,2BAA2B,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;AACrE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,SAA8B;IAC3D,MAAM,KAAK,GAAmB;QAC5B,kBAAkB,EAAE,SAAS,CAAC,IAAI,IAAI,UAAU;QAChD,iBAAiB,EAAE,SAAS,CAAC,GAAG,IAAI,SAAS;KAC9C,CAAC;IACF,IAAI,SAAS,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,CAAC,kBAAkB,CAAC,GAAG,gBAAgB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAC7D,KAAK,CAAC,kBAAkB,CAAC;YACvB,GAAG,SAAS,CAAC,IAAI,CAAC,KAAK,MAAM,SAAS,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC;IAC3D,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,UAA8C,EAC9C,EAA6B;IAE7B,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;AAC7D,CAAC","sourcesContent":["import type { CSSProperties } from \"react\";\n\n/**\n * One tile of a repeating wallpaper pattern. The tile's SVG is a mask, not a\n * picture: where its shapes are opaque the wallpaper paints its ink, where\n * they are translucent (`fill-opacity`, `stroke-opacity`) it paints that share\n * of the ink, and elsewhere the base shows. The markup's own colors are\n * ignored, so one tile follows every theme.\n */\nexport interface WallpaperTile {\n /** The tile's height in CSS pixels; the pattern repeats at this size. */\n readonly height: number;\n /**\n * The tile as a standalone SVG document (with its `xmlns`), drawn edge to\n * edge across `width` by `height` so neighboring tiles meet seamlessly.\n */\n readonly svg: string;\n /** The tile's width in CSS pixels. */\n readonly width: number;\n}\n\n/**\n * A desktop wallpaper a host offers: a base color and, optionally, a pattern\n * repeated over it in an ink color. Unless it names its own, the colors come\n * from the theme: the `--desktop-wallpaper-base` and `--desktop-wallpaper-ink`\n * tokens where a host sets them, else the desk color (`--desktop-background`,\n * then `--color-light`) under a faint wash of `--color-dark`.\n */\nexport interface WallpaperDefinition<Id extends string = string> {\n /** A CSS color under the pattern. */\n readonly base?: string | undefined;\n readonly id: Id;\n /** A CSS color the pattern paints in. */\n readonly ink?: string | undefined;\n /** The wallpaper's name, as Display Properties lists it. */\n readonly label: string;\n /** The repeating pattern. Without one the wallpaper is its base alone. */\n readonly tile?: WallpaperTile | undefined;\n}\n\n// The theme's colors, resolved on the wallpaper's own element, so a theme\n// scoped below the document root reaches the desktop and the previews alike.\nconst THEME_BASE =\n \"var(--desktop-wallpaper-base, var(--desktop-background, var(--color-light)))\";\nconst THEME_INK =\n \"var(--desktop-wallpaper-ink, color-mix(in srgb, var(--color-dark) 12%, transparent))\";\n\ntype WallpaperStyle = CSSProperties & {\n \"--wallpaper-base\": string;\n \"--wallpaper-ink\": string;\n \"--wallpaper-mask\"?: string;\n \"--wallpaper-size\"?: string;\n};\n\n/** The tile's SVG as a `url()` value. */\nexport function wallpaperTileUrl(tile: WallpaperTile): string {\n return `url(\"data:image/svg+xml,${encodeURIComponent(tile.svg)}\")`;\n}\n\n/**\n * The custom properties a `.wallpaper-pattern` element paints a wallpaper\n * from: its colors, and its tile as a mask repeated at the tile's size.\n */\nexport function wallpaperStyle(wallpaper: WallpaperDefinition): WallpaperStyle {\n const style: WallpaperStyle = {\n \"--wallpaper-base\": wallpaper.base ?? THEME_BASE,\n \"--wallpaper-ink\": wallpaper.ink ?? THEME_INK,\n };\n if (wallpaper.tile) {\n style[\"--wallpaper-mask\"] = wallpaperTileUrl(wallpaper.tile);\n style[\"--wallpaper-size\"] =\n `${wallpaper.tile.width}px ${wallpaper.tile.height}px`;\n }\n return style;\n}\n\nexport function findWallpaper<Id extends string>(\n wallpapers: readonly WallpaperDefinition<Id>[],\n id: string | null | undefined,\n): WallpaperDefinition<Id> | undefined {\n return wallpapers.find((wallpaper) => wallpaper.id === id);\n}\n"]}