@liberation-data/desk 0.42.0 → 0.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. package/README.md +312 -5
  2. package/dist/core/hosted.d.ts +222 -0
  3. package/dist/core/hosted.d.ts.map +1 -0
  4. package/dist/core/hosted.js +166 -0
  5. package/dist/core/hosted.js.map +1 -0
  6. package/dist/core/index.d.ts +10 -0
  7. package/dist/core/index.d.ts.map +1 -1
  8. package/dist/core/index.js +5 -0
  9. package/dist/core/index.js.map +1 -1
  10. package/dist/core/location.d.ts +8 -1
  11. package/dist/core/location.d.ts.map +1 -1
  12. package/dist/core/location.js +18 -2
  13. package/dist/core/location.js.map +1 -1
  14. package/dist/core/preferences.d.ts +27 -0
  15. package/dist/core/preferences.d.ts.map +1 -0
  16. package/dist/core/preferences.js +121 -0
  17. package/dist/core/preferences.js.map +1 -0
  18. package/dist/core/scheme.d.ts +18 -0
  19. package/dist/core/scheme.d.ts.map +1 -0
  20. package/dist/core/scheme.js +24 -0
  21. package/dist/core/scheme.js.map +1 -0
  22. package/dist/core/theme.d.ts +41 -0
  23. package/dist/core/theme.d.ts.map +1 -0
  24. package/dist/core/theme.js +56 -0
  25. package/dist/core/theme.js.map +1 -0
  26. package/dist/core/themeChange.d.ts +25 -0
  27. package/dist/core/themeChange.d.ts.map +1 -0
  28. package/dist/core/themeChange.js +49 -0
  29. package/dist/core/themeChange.js.map +1 -0
  30. package/dist/core/types.d.ts +6 -0
  31. package/dist/core/types.d.ts.map +1 -1
  32. package/dist/css/apps.css +183 -0
  33. package/dist/css/overlays.css +6 -0
  34. package/dist/css/shell.css +100 -0
  35. package/dist/css/tokens.css +10 -0
  36. package/dist/css/windows.css +21 -0
  37. package/dist/desk.css +220 -0
  38. package/dist/fx/fx.d.ts.map +1 -1
  39. package/dist/fx/fx.js +7 -31
  40. package/dist/fx/fx.js.map +1 -1
  41. package/dist/host/checkChrome.d.ts +20 -0
  42. package/dist/host/checkChrome.d.ts.map +1 -0
  43. package/dist/host/checkChrome.js +219 -0
  44. package/dist/host/checkChrome.js.map +1 -0
  45. package/dist/host/checkTheme.d.ts +35 -0
  46. package/dist/host/checkTheme.d.ts.map +1 -0
  47. package/dist/host/checkTheme.js +128 -0
  48. package/dist/host/checkTheme.js.map +1 -0
  49. package/dist/host/index.d.ts +7 -0
  50. package/dist/host/index.d.ts.map +1 -0
  51. package/dist/host/index.js +8 -0
  52. package/dist/host/index.js.map +1 -0
  53. package/dist/host/router.d.ts +99 -0
  54. package/dist/host/router.d.ts.map +1 -0
  55. package/dist/host/router.js +279 -0
  56. package/dist/host/router.js.map +1 -0
  57. package/dist/react/Desktop.d.ts.map +1 -1
  58. package/dist/react/Desktop.js +13 -2
  59. package/dist/react/Desktop.js.map +1 -1
  60. package/dist/react/Dock.d.ts +26 -2
  61. package/dist/react/Dock.d.ts.map +1 -1
  62. package/dist/react/Dock.js +23 -27
  63. package/dist/react/Dock.js.map +1 -1
  64. package/dist/react/MenuBar.d.ts +1 -1
  65. package/dist/react/MenuBar.d.ts.map +1 -1
  66. package/dist/react/MenuBar.js +36 -6
  67. package/dist/react/MenuBar.js.map +1 -1
  68. package/dist/react/app.d.ts +215 -0
  69. package/dist/react/app.d.ts.map +1 -0
  70. package/dist/react/app.js +192 -0
  71. package/dist/react/app.js.map +1 -0
  72. package/dist/react/appFrame.d.ts +11 -7
  73. package/dist/react/appFrame.d.ts.map +1 -1
  74. package/dist/react/appFrame.js +24 -6
  75. package/dist/react/appFrame.js.map +1 -1
  76. package/dist/react/appPanels.d.ts +25 -0
  77. package/dist/react/appPanels.d.ts.map +1 -0
  78. package/dist/react/appPanels.js +123 -0
  79. package/dist/react/appPanels.js.map +1 -0
  80. package/dist/react/appearance.d.ts +61 -0
  81. package/dist/react/appearance.d.ts.map +1 -0
  82. package/dist/react/appearance.js +119 -0
  83. package/dist/react/appearance.js.map +1 -0
  84. package/dist/react/codeBlock.d.ts.map +1 -1
  85. package/dist/react/codeBlock.js +6 -60
  86. package/dist/react/codeBlock.js.map +1 -1
  87. package/dist/react/context.d.ts +23 -1
  88. package/dist/react/context.d.ts.map +1 -1
  89. package/dist/react/context.js +108 -5
  90. package/dist/react/context.js.map +1 -1
  91. package/dist/react/copy.d.ts +22 -0
  92. package/dist/react/copy.d.ts.map +1 -0
  93. package/dist/react/copy.js +68 -0
  94. package/dist/react/copy.js.map +1 -0
  95. package/dist/react/dockStatus.d.ts +19 -0
  96. package/dist/react/dockStatus.d.ts.map +1 -0
  97. package/dist/react/dockStatus.js +25 -0
  98. package/dist/react/dockStatus.js.map +1 -0
  99. package/dist/react/documentTitle.d.ts.map +1 -1
  100. package/dist/react/documentTitle.js +4 -1
  101. package/dist/react/documentTitle.js.map +1 -1
  102. package/dist/react/frameMenus.d.ts +28 -0
  103. package/dist/react/frameMenus.d.ts.map +1 -0
  104. package/dist/react/frameMenus.js +85 -0
  105. package/dist/react/frameMenus.js.map +1 -0
  106. package/dist/react/hostApp.d.ts +15 -0
  107. package/dist/react/hostApp.d.ts.map +1 -0
  108. package/dist/react/hostApp.js +77 -0
  109. package/dist/react/hostApp.js.map +1 -0
  110. package/dist/react/hostDock.d.ts +25 -0
  111. package/dist/react/hostDock.d.ts.map +1 -0
  112. package/dist/react/hostDock.js +98 -0
  113. package/dist/react/hostDock.js.map +1 -0
  114. package/dist/react/hostMenu.d.ts +2 -36
  115. package/dist/react/hostMenu.d.ts.map +1 -1
  116. package/dist/react/hostMenu.js.map +1 -1
  117. package/dist/react/hosted.d.ts +28 -0
  118. package/dist/react/hosted.d.ts.map +1 -0
  119. package/dist/react/hosted.js +53 -0
  120. package/dist/react/hosted.js.map +1 -0
  121. package/dist/react/index.d.ts +12 -0
  122. package/dist/react/index.d.ts.map +1 -1
  123. package/dist/react/index.js +8 -0
  124. package/dist/react/index.js.map +1 -1
  125. package/dist/react/layers.d.ts.map +1 -1
  126. package/dist/react/layers.js +7 -2
  127. package/dist/react/layers.js.map +1 -1
  128. package/dist/react/overlays.d.ts.map +1 -1
  129. package/dist/react/overlays.js +29 -12
  130. package/dist/react/overlays.js.map +1 -1
  131. package/dist/react/shell.d.ts +16 -1
  132. package/dist/react/shell.d.ts.map +1 -1
  133. package/dist/react/shell.js +19 -3
  134. package/dist/react/shell.js.map +1 -1
  135. package/dist/react/windowMenus.d.ts +19 -0
  136. package/dist/react/windowMenus.d.ts.map +1 -0
  137. package/dist/react/windowMenus.js +88 -0
  138. package/dist/react/windowMenus.js.map +1 -0
  139. package/dist/shell/HostShell.d.ts +53 -0
  140. package/dist/shell/HostShell.d.ts.map +1 -0
  141. package/dist/shell/HostShell.js +116 -0
  142. package/dist/shell/HostShell.js.map +1 -0
  143. package/dist/shell/index.d.ts +7 -0
  144. package/dist/shell/index.d.ts.map +1 -0
  145. package/dist/shell/index.js +9 -0
  146. package/dist/shell/index.js.map +1 -0
  147. package/dist/shell/keys.d.ts +47 -0
  148. package/dist/shell/keys.d.ts.map +1 -0
  149. package/dist/shell/keys.js +68 -0
  150. package/dist/shell/keys.js.map +1 -0
  151. package/dist/shell/motion.d.ts +72 -0
  152. package/dist/shell/motion.d.ts.map +1 -0
  153. package/dist/shell/motion.js +118 -0
  154. package/dist/shell/motion.js.map +1 -0
  155. package/llms.txt +84 -9
  156. package/package.json +10 -1
  157. package/src/core/hosted.ts +351 -0
  158. package/src/core/index.ts +29 -0
  159. package/src/core/location.ts +23 -3
  160. package/src/core/preferences.ts +132 -0
  161. package/src/core/scheme.ts +32 -0
  162. package/src/core/theme.ts +91 -0
  163. package/src/core/themeChange.ts +59 -0
  164. package/src/core/types.ts +6 -0
  165. package/src/css/apps.css +183 -0
  166. package/src/css/overlays.css +6 -0
  167. package/src/css/shell.css +99 -0
  168. package/src/css/tokens.css +10 -0
  169. package/src/css/windows.css +21 -0
  170. package/src/fx/fx.ts +7 -25
  171. package/src/host/checkChrome.ts +257 -0
  172. package/src/host/checkTheme.ts +134 -0
  173. package/src/host/index.ts +10 -0
  174. package/src/host/router.ts +374 -0
  175. package/src/react/Desktop.tsx +21 -3
  176. package/src/react/Dock.tsx +40 -24
  177. package/src/react/MenuBar.tsx +39 -6
  178. package/src/react/app.tsx +354 -0
  179. package/src/react/appFrame.tsx +39 -14
  180. package/src/react/appPanels.tsx +210 -0
  181. package/src/react/appearance.tsx +195 -0
  182. package/src/react/codeBlock.tsx +7 -65
  183. package/src/react/context.tsx +131 -4
  184. package/src/react/copy.ts +81 -0
  185. package/src/react/dockStatus.ts +42 -0
  186. package/src/react/documentTitle.ts +4 -1
  187. package/src/react/frameMenus.ts +100 -0
  188. package/src/react/hostApp.tsx +89 -0
  189. package/src/react/hostDock.tsx +118 -0
  190. package/src/react/hostMenu.ts +3 -38
  191. package/src/react/hosted.tsx +65 -0
  192. package/src/react/index.ts +34 -0
  193. package/src/react/layers.ts +7 -2
  194. package/src/react/overlays.tsx +30 -12
  195. package/src/react/shell.tsx +33 -3
  196. package/src/react/windowMenus.ts +107 -0
  197. package/src/shell/HostShell.tsx +220 -0
  198. package/src/shell/index.ts +11 -0
  199. package/src/shell/keys.ts +101 -0
  200. package/src/shell/motion.ts +163 -0
@@ -0,0 +1,118 @@
1
+ /*
2
+ * THE SLIDE, AS NUMBERS.
3
+ *
4
+ * When a host switches workspaces it moves the apps' live views itself, from its own process, a frame
5
+ * at a time; the shell draws the chrome around them. Both must move on one curve, so the curve is
6
+ * here as plain functions, with no DOM: a host's main process steps its views' bounds from them, and
7
+ * the shell animates with the same ones.
8
+ *
9
+ * Progress runs from 0 (the workspace being left fills the desktop) to 1 (the one arriving does). The
10
+ * spring is critically damped: it arrives without overshooting, and it can start from any progress
11
+ * and speed, so a slide caught mid-flight, or flung, carries on from where it is.
12
+ */
13
+ /** The default slide, and the short fade that replaces it under reduced motion. */
14
+ export const SLIDE_MS = 350;
15
+ export const FADE_MS = 120;
16
+ /** What a switch should do, given whether the person asked for less motion. */
17
+ export const slidePlan = (reducedMotion, durationMs = SLIDE_MS) => reducedMotion ? { kind: 'fade', durationMs: FADE_MS } : { kind: 'slide', durationMs };
18
+ /** The distance left that counts as arrived: under a tenth of a pixel on a 4K-wide desktop. */
19
+ const SETTLED = 0.00002;
20
+ /**
21
+ * A critically damped spring towards 1, from `from` with a starting speed `velocity` (progress per
22
+ * second), stiff enough to settle within `durationMs`. Returns the progress at a time in milliseconds
23
+ * since it started: exactly 1 from `durationMs` on.
24
+ */
25
+ export function spring(durationMs = SLIDE_MS, from = 0, velocity = 0) {
26
+ // (1 + ωt)·e^(−ωt) falls to SETTLED when ωt is about 13.5: pick ω so that happens at durationMs.
27
+ const omega = settleConstant() / (durationMs / 1000);
28
+ const d0 = from - 1;
29
+ const c2 = velocity + omega * d0;
30
+ return elapsedMs => {
31
+ if (elapsedMs >= durationMs)
32
+ return 1;
33
+ const t = Math.max(0, elapsedMs) / 1000;
34
+ // A hard fling would carry a critically damped spring past its target once: hold it at 1 instead.
35
+ return Math.min(1, 1 + (d0 + c2 * t) * Math.exp(-omega * t));
36
+ };
37
+ }
38
+ let settle;
39
+ /** The ωt at which a critically damped spring from rest is within SETTLED of its target. */
40
+ function settleConstant() {
41
+ if (settle !== undefined)
42
+ return settle;
43
+ let x = 10;
44
+ // Newton's method on f(x) = (1 + x)e^(−x) − SETTLED; a handful of steps is exact to the float.
45
+ for (let i = 0; i < 20; i++)
46
+ x -= ((1 + x) * Math.exp(-x) - SETTLED) / (-x * Math.exp(-x));
47
+ return (settle = x);
48
+ }
49
+ /** A plain linear ramp, for the fade: opacity follows time evenly. */
50
+ export const linear = (durationMs) => (elapsedMs) => Math.min(1, Math.max(0, elapsedMs / durationMs));
51
+ /**
52
+ * The desktops' offsets at `progress`. Moving to a workspace further along (`direction` 1) the one
53
+ * being left goes out to the left and the next comes in from the right; back (`-1`), the other way.
54
+ * Rounded to whole pixels, as a view's bounds are, and with no gap or overlap between the two.
55
+ *
56
+ * Mid-slide both views reach past the desktop area, so the host must clip them to it (the area
57
+ * `onInsets` gives): a view placed at these offsets with nothing clipping it covers the dock beside.
58
+ */
59
+ export function slideOffsets(progress, direction, width) {
60
+ const whole = Math.round(width);
61
+ const leaving = -direction * Math.round(progress * whole);
62
+ return { leaving, arriving: leaving + direction * whole };
63
+ }
64
+ /** A clock for a page: frames from requestAnimationFrame, which a hidden page never gives. */
65
+ export const pageClock = () => ({
66
+ now: () => performance.now(),
67
+ frame: callback => requestAnimationFrame(() => callback()),
68
+ after: (ms, callback) => setTimeout(callback, ms),
69
+ });
70
+ /** A clock for a process with no frames of its own, as an app host's main process: about 60 a second. */
71
+ export const timerClock = (frameMs = 1000 / 60) => ({
72
+ now: () => performance.now(),
73
+ frame: callback => setTimeout(callback, frameMs),
74
+ after: (ms, callback) => setTimeout(callback, ms),
75
+ });
76
+ /**
77
+ * Steps `step` through a curve, frame by frame, from any clock. Ends at 1 when time is up, and jumps
78
+ * straight there if frames stop arriving for `timeoutMs`.
79
+ */
80
+ export function animate({ durationMs, curve = spring(durationMs), step, clock = pageClock(), timeoutMs = 250 }) {
81
+ const start = clock.now();
82
+ let current = 0;
83
+ let ended = false;
84
+ let finish;
85
+ const done = new Promise(resolve => (finish = resolve));
86
+ const end = (how) => {
87
+ if (ended)
88
+ return;
89
+ ended = true;
90
+ if (how !== 'stopped')
91
+ step((current = 1));
92
+ finish(how);
93
+ };
94
+ let lastFrame = start;
95
+ const watchdog = () => {
96
+ if (ended)
97
+ return;
98
+ // Frames have stalled past the end: jump. Otherwise look again later.
99
+ if (clock.now() - lastFrame >= timeoutMs && clock.now() - start >= durationMs)
100
+ end('jumped');
101
+ else
102
+ clock.after(timeoutMs, watchdog);
103
+ };
104
+ const tick = () => {
105
+ if (ended)
106
+ return;
107
+ lastFrame = clock.now();
108
+ const elapsed = lastFrame - start;
109
+ if (elapsed >= durationMs)
110
+ return end('finished');
111
+ step((current = curve(elapsed)));
112
+ clock.frame(tick);
113
+ };
114
+ clock.frame(tick);
115
+ clock.after(durationMs + timeoutMs, watchdog);
116
+ return { done, progress: () => current, stop: () => end('stopped') };
117
+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AA;QAC1C,MAAM,CAAC,GAAG,CAAC,CAAA;IACb,CAAC,CAAA;IACD,IAAI,SAAS,GAAG,KAAK,CAAA;IACrB,MAAM,QAAQ,GAAG,GAAG,EAAE;QACpB,IAAI,KAAK;YAAE,OAAM;QACjB,sEAAsE;QACtE,IAAI,KAAK,CAAC,GAAG,EAAE,GAAG,SAAS,IAAI,SAAS,IAAI,KAAK,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,UAAU;YAAE,GAAG,CAAC,QAAQ,CAAC,CAAA;;YACvF,KAAK,CAAC,KAAK,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAA;IACvC,CAAC,CAAA;IACD,MAAM,IAAI,GAAG,GAAG,EAAE;QAChB,IAAI,KAAK;YAAE,OAAM;QACjB,SAAS,GAAG,KAAK,CAAC,GAAG,EAAE,CAAA;QACvB,MAAM,OAAO,GAAG,SAAS,GAAG,KAAK,CAAA;QACjC,IAAI,OAAO,IAAI,UAAU;YAAE,OAAO,GAAG,CAAC,UAAU,CAAC,CAAA;QACjD,IAAI,CAAC,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;QAChC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IACnB,CAAC,CAAA;IACD,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IACjB,KAAK,CAAC,KAAK,CAAC,UAAU,GAAG,SAAS,EAAE,QAAQ,CAAC,CAAA;IAC7C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAA;AACtE,CAAC"}
package/llms.txt CHANGED
@@ -177,6 +177,7 @@ formatShortcut('mod+comma', apple?): string // '⌘,' or 'Ctrl+,'
177
177
  isApplePlatform(): boolean // the KEYBOARD; the look is separate
178
178
  deviceLook(): Look // 'mac' | 'gnome' | 'windows' for this device
179
179
  lookFor(platform, userAgent): Look // the same, pure; resolveLook('auto' | Look): Look
180
+ COLOR_SCHEME_KEY; LOOK_KEY; COLOR_SCHEME_SCRIPT; colorSchemeScript(default?) // Appearance's storage keys and <head> script; see Settings and About
180
181
  isInstalledApp(): boolean // gate ⌘W / ⌘` on this; never take ⌘T or ⌘N
181
182
  titleCase('ride card'): string // 'Ride Card' — app and window names; a document keeps its own name
182
183
  isTitleCase(name): boolean // for a test over the names an app defines
@@ -253,8 +254,8 @@ watchAttention(desk, id, onAttended): () => void // at once if attended, the
253
254
  ### Shell
254
255
 
255
256
  ```tsx
256
- <DeskShell desk?={Desk} options?={DeskOptions} bus?={Bus} toasts?={true} look?={'auto'} services?={Service[]}>
257
- <DeskProvider desk={desk} look?={'auto'} services?={Service[]}> // or options={…} to make one
257
+ <DeskShell desk?={Desk} options?={DeskOptions} bus?={Bus} toasts?={true} look?={'auto'} services?={Service[]} app?={DeskApp}> // app: see Settings and About
258
+ <DeskProvider desk={desk} look?={'auto'} services?={Service[]} app?={DeskApp}> // or options={…} to make one
258
259
  useDesk(): Desk
259
260
  useLook(): 'mac' | 'gnome' | 'windows' // resolved; the device's outside a desk
260
261
  useDeskState(): DeskState
@@ -269,8 +270,9 @@ useWindowInfo(info: ReactNode): boolean // this view's (i) in place
269
270
  title={(id) => ReactNode}
270
271
  note?={(id) => ReactNode} // quiet text in the title bar: what this window is looking at
271
272
  info?={(id) => ReactNode} // an (i) on the bar's far edge from the controls (end on mac, start on gnome/windows): what this window IS
272
- limits?={(id) => ({ maxWidth?, maxHeight?, minWidth?, minHeight? } | null)} // a window with a natural
273
- // size is never stretched past it; filled, it centres
273
+ limits?={(id) => ({ maxWidth?, maxHeight?, minWidth?, minHeight?, fitContent? } | null)} // a window with a natural
274
+ // size is never stretched past it; filled, it centres; fitContent:
275
+ // centred, it is as tall as its content up to maxHeight
274
276
  actions?={(id) => ReactNode} // window-wide controls in the title bar
275
277
  loading?={(id) => ReactNode} // inside a window while its code loads
276
278
  failed?={(id, error, reload) => ReactNode} // inside a window that could not open
@@ -346,7 +348,7 @@ explanation only — never a warning, which belongs in front of people.
346
348
  ```tsx
347
349
  <Dock entries={DockEntry[]} label?="Dock" placement?={'overlay' | 'inline'} side?={'left' | 'right' | 'bottom'}
348
350
  pins?={{ accepts, onPin: (drag, before: id | null) => void, onMove?: (id, before: id | null) => void }} />
349
- dockItem({ id, label, icon, window?, description?, badge?, onSelect?, disabled?, contextMenu?: () => MenuItem[], movable? })
351
+ dockItem({ id, label, icon, window?, description?, badge?, onSelect?, disabled?, contextMenu?: () => MenuItem[], movable?, status?: { running, focused, minimized } }) // status: told by a host drawing a hosted app's item, instead of read from this desk
350
352
  dockStack({ id, label, items: DockItem[], icon?, contextMenu?: () => MenuItem[], movable? })
351
353
  dockSeparator(id)
352
354
  ```
@@ -369,6 +371,29 @@ interface HostMenu { id; label; primary?; status?; items: { type: 'item'|'separa
369
371
  // Republished on render and focus move only; a choice is re-checked before it runs.
370
372
  hostMenuModel(menus, status, canPerform): { model: HostMenu[]; run: Map<id, MenuItem> } // the same data, for a host built by hand
371
373
  hasModKey(shortcut): boolean // the default ownsShortcut: has `mod` in it
374
+ useWindowMenus(menus: Menu[]) // inside a window: its menus join the bar while it is in front, after the app's own, before menus with ids 'window'/'help'; drawn bar and host alike
375
+ // A window's item never takes the app's shortcut (or Desk's mod+comma): it keeps its label, loses the key, and the clash is warned once.
376
+ // Hosted mode: a host draws one menu bar and dock for several Desk apps. Hosted when globalThis.deskHost is a DeskHostBridge, or <DeskProvider|DeskShell host={bridge}>.
377
+ // MenuBar and Dock then draw nothing and send DeskChrome { menus, dock, settings, about } to the host; shortcuts are shared as with any MenuHost (the host owns `mod` ones, ⌘, included). DockItem.image?: string for the host.
378
+ // The host's frame has the one Settings and About: no gear or About item in the app. settings: { id, title, group?, badge? }[] from app.settings.sections; host command 'settings' with a section id opens the app's own Settings there.
379
+ // about: { name, version?, links, note? (text only), facts: { title?, facts: { name, value, link?, copy?: false }[] }[] | null } from the app declaration; facts null while read, [] for nothing to report. Hosted implies themeFromHost; the primary declares themeFromHost: false to keep its Appearance and its own theme.
380
+ interface DeskHostBridge { version: 1; send(m: AppToHost): void; onMessage(l: (m: HostToApp) => void): () => void }
381
+ connectHost(bridge): HostClient // core, for a page without React; DeskProvider calls it
382
+ useHost(): HostClient | null // publish(topic, payload); subscribe(publisher: appId | 'primary', topic, handler); onCommand; setChrome
383
+ useHosted(): boolean; useHostBroadcast(publisher, topic, handler); usePublishTheme(theme: DeskTheme | null) // the primary publishes its look
384
+ interface DeskTheme { mode: 'light'|'dark'; look: Look; tokens: Record<`--${string}`, string>; fonts?: { family; src; weight?; style? }[]; wallpaper?: string }
385
+ <DeskShell onTheme={theme => …}> // keep some looks of your own; mode and look always apply. Default: applyTheme(theme)
386
+ hostDockModel(entries, state): { model: HostDockEntry[]; run: Map<id, DockItem> } // the dock as data, as HostedDock sends it
387
+ // '@liberation-data/desk/host' (the host's half): createBroadcastRouter({ deliver, chrome?: (appId, chrome, dropped: string[]) => void, check?, maxPayload?, limits?: { burst?, perSecond?, topics?, maxTopics? }, clock? }), router.limited(appId), checkTheme(theme, origin), checkChrome(chrome, origin): { ok: true, chrome, dropped } | { ok: false, reason }, createMemoryHost()
388
+ // '@liberation-data/desk/shell' (the host's page only, with css/shell.css): <HostShell workspaces={{ id, title, accent?, icon?, primary?, state: 'live'|'suspended'|'discarded' }[]} current chrome={Record<appId, DeskChrome|null>} theme? snapshots?={Record<id, imageUrl>} keys?={SwitchKeys|null} clickSwitch?={'slide'} dockSide? onSwitch={(id, how) => …} onCommand={(appId, 'dock'|'menu'|'settings', itemId) => …} onInsets?={({ top, right, bottom, left }) => …} />
389
+ // It draws the current app's dock and a switcher (one Tab stop, arrows/Home/End, title announced once on arrival); the host moves the views and passes the new current.
390
+ // switchKeys(platformOf(process.platform)): mac Ctrl+Opt+←/→/↑, Linux Super+Alt, Windows Ctrl+Alt; switchKeyAction(pageEvent | electronInput, keys): 'previous'|'next'|'overview'|null (key releases ignored); neighbour(workspaces, current, step) | null at the ends
391
+ // slidePlan(reducedMotion): { kind: 'slide', 350 } | { kind: 'fade', 120 }; spring(ms, from?, velocity?) → t => progress, no overshoot; slideOffsets(progress, 1|-1, width): { leaving, arriving } whole px, no gap: clip views to the desktop area or they cover the dock
392
+ // animate({ durationMs, step, curve?, clock?: pageClock()|timerClock(), timeoutMs? = 250 }): { done: 'finished'|'jumped'|'stopped', progress(), stop() }; jumps to 1 when frames stop
393
+ // Rate limits per publisher+topic: 20 then 10/s (theme 2 then 1/s), 64 topics at once; over it the latest is held (never queued), so subscribers end on the last value; order holds within a topic.
394
+ // register({ id, origin, primary?, publishes? }): the primary's publishes must include 'theme'. A deliver that throws for one app still lets the rest hear; the error is thrown after.
395
+ // chrome(appId, null) when an app is unregistered: stop drawing its chrome. The primary's last theme is kept while it is down and replayed to subscribers of 'primary'.
396
+ // The router checks chrome before chrome() sees it: bounded text and lists, links http(s), mailto: or the app's origin, dock images from the app's origin or data: raster (no SVG). A bad part (menu item, dock item, section, link, fact; an image or fact link from its item) is dropped and named in dropped; the rest is drawn. Only the wrong shape (not lists, too large, a stack in a stack) refuses it whole. Open About links in the system browser, rel="noopener noreferrer".
372
397
  interface Menu { id: string; label: string; title?: ReactNode; emphasis?: boolean; items: MenuItem[] | (() => MenuItem[]) }
373
398
  // emphasis: the app's own menu, its name in bold, conventionally first
374
399
  menuCommand(label, command, { shortcut?, checked?, detail?, args? })
@@ -391,6 +416,53 @@ Command items are enabled via `canPerform` as the menu opens, and menus bind the
391
416
  menu does not take focus from the key window, so a chosen command reaches the same responder a shortcut
392
417
  would. `items` as a function is re-read on every open.
393
418
 
419
+ ### Settings and About
420
+
421
+ ```tsx
422
+ <DeskShell app={DeskApp}> // or DeskProvider app={…}; read on every render, so it may change
423
+ interface DeskApp { name; icon?; wordmark?: ReactNode; version?; description?; links?: { label, url, group? }[]; legal?; // wordmark: a wide mark under the icon; group: links under their heading, ungrouped first
424
+ note?: ReactNode; // a line under the links, not copied
425
+ facts?: () => AboutSection[] | null; // a HOOK, called inside the About panel; null = still reading, [] = nothing, no Copy
426
+ settings?: AppSettings } // leave out: no gear, no "Settings…", no ⌘,
427
+ interface AboutSection { title?; pending?: boolean; facts: { name; value: string; copyValue?: string; note?: ReactNode; link?: { label, url }; copy?: false }[] } // copy:false = shown, not copied; note and link never copied; copyValue copied in place of value; pending = "Checking", left out of Copy
428
+ interface AppSettings { sections?: SettingsSection[]; layout?: 'panel' | 'sidebar'; badge?: ReactNode;
429
+ open?: (route?: string) => void } // open: the app's own Settings window; Desk draws none
430
+ interface SettingsSection { id; title; group?; icon?; badge?; content: ReactNode } // id = the route of `settings`
431
+ // AppSettings.appearance?: true | { scheme?; defaultScheme?: 'system'|'light'|'dark'; look?; sounds?: Fx; soundsDescription?; theme?: ReactNode } // Desk's first section
432
+ // defaultScheme: what applies while nothing is chosen (default 'system'); give colorSchemeScript the same
433
+ // DeskApp.themeFromHost?: boolean // receives its theme from a host: no scheme/look/theme rows (sounds stay); default: found from the bridge
434
+ useColorScheme(): 'system'|'light'|'dark'; colorScheme(); setColorScheme(s) // the preference store, desk.scheme (absent = the default); data-theme on the root
435
+ useLookChoice(): LookChoice | null; lookChoice(); setLookChoice(l) // the preference store, desk.look; replaces the `look` prop
436
+ COLOR_SCHEME_SCRIPT; colorSchemeScript(defaultScheme?); COLOR_SCHEME_KEY = 'desk.scheme'; LOOK_KEY = 'desk.look' // also from the core entry (no React)
437
+ // script: for <head>, the remembered scheme (or the default) before first paint; keys: for migrations
438
+ interface PreferenceStore { get(key): string | null | undefined; set(key, value: string | null): void; subscribe?(fn: (key | null) => void): () => unsubscribe }
439
+ <DeskShell preferences={store}> // every remembered choice (COLOR_SCHEME_KEY, LOOK_KEY, createFx's storageKey) in the app's store; default localStorage (+ other tabs)
440
+ // get is sync; undefined = not loaded yet → this browser's copy; Desk writes values through to localStorage for the head script
441
+ setPreferenceStore(store?); getPreference(key); setPreference(key, value); subscribePreferences(fn); localPreferences // core entry, no React
442
+ <AppearanceSettings rows look /> // the rows, for an app's own Settings window
443
+ dockSettings(); dockAbout() // markers: where the gear / About go, among dock entries OR in a stack's items
444
+ // (a System stack); placed, Desk adds no loose one. Default: end of the system group
445
+ SETTINGS_WINDOW = 'settings'; ABOUT_WINDOW = 'about'; SettingsCommand = 'desk.settings'; SYSTEM_GROUP = 'system'
446
+ PANEL_LIMITS; SIDEBAR_LIMITS // the windows' sizes (the panel fits its content); Desktop `limits` for those ids overrides
447
+ openAbout(desk) // About as the dock opens it: a centred panel, or forward where it is
448
+ useOpenSettings(): (route?) => void // Settings as the gear opens it (the app's own `open` too); nothing without settings
449
+ openSettings(desk, route?) // the same, outside React (search results, link handlers); reads the provider's declaration
450
+ appWindowTitle(app, id): string | null // 'Settings' / 'About' for Desk's windows, for a Window menu's title function
451
+ <AboutContent />; <SettingsContent />; aboutText(app, sections): string
452
+ useDeskApp(): DeskApp | null
453
+ ```
454
+
455
+ Declared, Desk adds: in the Dock, the gear (when there are settings) and About as the last items of the system
456
+ group (entries after `dockSeparator('system')`; a separator and group of their own when there is none); in the
457
+ MenuBar's app menu (first with `emphasis`, else one is made, named `name`) "About <name>", separator,
458
+ "Settings…" (mod+comma), separator, then the app's items; Desktop draws the `about` and (with `settings` and no `open`) `settings` windows as
459
+ centred panels (sidebar layout: a bigger window with a Sidebar grouped by `group`). Gear, menu and ⌘, focus an
460
+ open panel where it is. ⌘, is bound by the provider on the command, so it works with no MenuBar; the menu item only
461
+ shows it. A `host` menu bar gets the same items through the same publish; the host owns ⌘, while it is up.
462
+ With facts, About has Copy: name + version, then each section's copyable facts. Never put credentials in facts.
463
+ Don't also add your own About/Settings dock or menu items: they would be there twice.
464
+ `syncWithLocation` keeps links to `settings` and `about` once a provider has declared the app: `isKnown` lists only the app's own ids.
465
+
394
466
  ### Commands and input
395
467
 
396
468
  ```tsx
@@ -442,7 +514,7 @@ useServiceValue(service): T // the value, live, without
442
514
  ### Generated apps
443
515
 
444
516
  ```tsx
445
- <AppFrame title src?|srcDoc? listens?={string[]} says?={string[]} accepts?={Accepts} opens?={string[]}
517
+ <AppFrame title src?|srcDoc? listens?={string[]} says?={string[]} accepts?={Accepts} opens?={string[]} menus?={boolean}
446
518
  theme?={{ mode: 'light'|'dark', tokens: Record<string,string> }}
447
519
  sandbox?="allow-scripts allow-forms" />
448
520
  // theme: sent with hello and again on change; the bridge sets the tokens as custom properties on the
@@ -452,7 +524,7 @@ APP_BRIDGE_SCRIPT // the same script, to include some other w
452
524
  ```
453
525
 
454
526
  Inside the page: `desk.on(topic, message => …)`, `desk.onDrop(message => …)`, `desk.publish(topic, payload)`,
455
- `desk.open(window)`, `desk.theme`, `desk.onTheme(fn)`, and `desk.window` once connected. Messages carry `desk: 1`. The host ignores anything not
527
+ `desk.open(window)`, `desk.theme`, `desk.onTheme(fn)`, `desk.setMenus(HostMenu[])` and `desk.onCommand(id => …)` (with `menus`: they join the bar while the frame's window is in front; checked with checkChrome, at most 4 menus; ids namespaced per frame; a shortcut needs mod/ctrl/alt or is F1–F24, else the item loses its key (warned once); a choice goes back to that frame only), and `desk.window` once connected. Messages carry `desk: 1`. The host ignores anything not
456
528
  from its own frame, drops publishes outside `says` and opens outside `opens`, never echoes an app its own
457
529
  events, and sets the frame's `pointer-events: none` while a drag is in the air so drops reach it.
458
530
 
@@ -626,8 +698,11 @@ Every value reads a `--desk-*` token; redefine tokens, never override selectors.
626
698
  `--desk-ease`, `--desk-dock-size`, `--desk-dock-glass`, `--desk-dock-offset`, `--desk-dock-room`,
627
699
  `--desk-widget-width`, `--desk-inset-bottom`, `--desk-wizard-height`, `--desk-field-gap`. Code colours (`CodeBlock`, on `--desk-page`):
628
700
  `--desk-code-comment|string|keyword|number|key`, 4.5:1 in light and dark.
701
+ An overview background for a workspace switcher: `--desk-overview-fog` (centre; default ground 82% + accent 18%,
702
+ nudged toward mid grey), `--desk-overview-fog-far` (edge; the fog 8% darker light, 10% dark) and `--desk-overview-shadow`
703
+ (tile shadow colour; `rgb(0 0 0 / 0.28)` light, `0.55` dark). Derived in CSS; a theme's own values win; checkTheme takes them.
629
704
 
630
- Light and dark follow `prefers-color-scheme`; `data-theme="light" | "dark"` on the root wins. The look is
705
+ Light and dark follow `prefers-color-scheme`; `data-theme="light" | "dark"` on the root wins. Outside React (a canvas), listen for `desk-themechange` on `document`: once per change to the drawn scheme or look, from any source (host theme, new colours included through Desk's handler, the person's choice, the system flipping, a look change), `detail: { scheme, look }`; `drawnTheme()` reads them; with no desk mounted and no theme applied, call `watchThemeChanges()` first. In React use the hooks. The look is
631
706
  `data-look="mac" | "gnome" | "windows"` on the root, set by the desk; don't set it yourself — pass `look`.
632
707
 
633
708
  ## Sounds: `@liberation-data/desk/fx`
@@ -670,7 +745,7 @@ in the accessibility tree.
670
745
  - A `DeskProvider` already carries an event bus; `BusProvider` is only for supplying or sharing one.
671
746
  - `renderWindow` must be stable (module scope or `useCallback`) for the memoisation to hold.
672
747
  - `parse`/`syncWithLocation` warn once when no `isKnown` is given: unknown ids from a URL are then trusted.
673
- - `npm run size` enforces a gzipped budget: core 16 KiB, react 76 KiB, css 24 KiB, fx 5 KiB.
748
+ - `npm run size` enforces a budget on each entry, measured gzipped without comments (so explanations cost nothing): core 13.5 KiB, react 70.5, css 14, fx 4, host 7.5; each is the measured size plus 1 KiB, rounded up to a half.
674
749
  - `fx.play` never resumes audio itself: outside a press a browser's resume may never settle. Call
675
750
  `fx.unlock()` at startup, or nothing sounds until a press after the sound was due.
676
751
  - The package is ESM only, with `"sideEffects": ["**/*.css"]`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liberation-data/desk",
3
- "version": "0.42.0",
3
+ "version": "0.44.0",
4
4
  "description": "A desktop environment for React apps: windows, a dock, menus and commands, controls, tours and setup assistants.",
5
5
  "keywords": [
6
6
  "react",
@@ -42,6 +42,14 @@
42
42
  "types": "./dist/react/index.d.ts",
43
43
  "import": "./dist/react/index.js"
44
44
  },
45
+ "./host": {
46
+ "types": "./dist/host/index.d.ts",
47
+ "import": "./dist/host/index.js"
48
+ },
49
+ "./shell": {
50
+ "types": "./dist/shell/index.d.ts",
51
+ "import": "./dist/shell/index.js"
52
+ },
45
53
  "./fx": {
46
54
  "types": "./dist/fx/index.d.ts",
47
55
  "import": "./dist/fx/index.js"
@@ -78,6 +86,7 @@
78
86
  "puppeteer-core": "^25.11.0",
79
87
  "react": "^19.3.0",
80
88
  "react-dom": "^19.3.0",
89
+ "rolldown": "~1.2.8",
81
90
  "typescript": "^7.0.2",
82
91
  "vite": "^8.3.0",
83
92
  "vitest": "^5.0.0"