@oxy.so/bloom 21.6.0 → 21.7.1

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 (203) hide show
  1. package/docs/adoption-matrix.mdx +4 -4
  2. package/docs/platform-surface.mdx +20 -0
  3. package/docs/public-parts.mdx +3 -2
  4. package/docs/task-catalog.json +1 -1
  5. package/docs/task-catalog.mdx +1 -1
  6. package/docs/window.mdx +30 -1
  7. package/lib/commonjs/floating/popup-navigation.js +19 -9
  8. package/lib/commonjs/floating/popup-navigation.js.map +1 -1
  9. package/lib/commonjs/index.js.map +1 -1
  10. package/lib/commonjs/index.web.js.map +1 -1
  11. package/lib/commonjs/locale/translations/ar.js +21 -1
  12. package/lib/commonjs/locale/translations/ar.js.map +1 -1
  13. package/lib/commonjs/locale/translations/bn.js +21 -1
  14. package/lib/commonjs/locale/translations/bn.js.map +1 -1
  15. package/lib/commonjs/locale/translations/ca.js +21 -1
  16. package/lib/commonjs/locale/translations/ca.js.map +1 -1
  17. package/lib/commonjs/locale/translations/de.js +21 -1
  18. package/lib/commonjs/locale/translations/de.js.map +1 -1
  19. package/lib/commonjs/locale/translations/es.js +21 -1
  20. package/lib/commonjs/locale/translations/es.js.map +1 -1
  21. package/lib/commonjs/locale/translations/fr.js +21 -1
  22. package/lib/commonjs/locale/translations/fr.js.map +1 -1
  23. package/lib/commonjs/locale/translations/hi.js +21 -1
  24. package/lib/commonjs/locale/translations/hi.js.map +1 -1
  25. package/lib/commonjs/locale/translations/id.js +21 -1
  26. package/lib/commonjs/locale/translations/id.js.map +1 -1
  27. package/lib/commonjs/locale/translations/it.js +21 -1
  28. package/lib/commonjs/locale/translations/it.js.map +1 -1
  29. package/lib/commonjs/locale/translations/ja.js +21 -1
  30. package/lib/commonjs/locale/translations/ja.js.map +1 -1
  31. package/lib/commonjs/locale/translations/pt.js +21 -1
  32. package/lib/commonjs/locale/translations/pt.js.map +1 -1
  33. package/lib/commonjs/locale/translations/ru.js +21 -1
  34. package/lib/commonjs/locale/translations/ru.js.map +1 -1
  35. package/lib/commonjs/locale/translations/tr.js +21 -1
  36. package/lib/commonjs/locale/translations/tr.js.map +1 -1
  37. package/lib/commonjs/locale/translations/zh.js +21 -1
  38. package/lib/commonjs/locale/translations/zh.js.map +1 -1
  39. package/lib/commonjs/platform-surface/context.js +16 -0
  40. package/lib/commonjs/platform-surface/context.js.map +1 -1
  41. package/lib/commonjs/window/WindowControls.js +61 -16
  42. package/lib/commonjs/window/WindowControls.js.map +1 -1
  43. package/lib/commonjs/window/WindowLayouts.js +86 -0
  44. package/lib/commonjs/window/WindowLayouts.js.map +1 -0
  45. package/lib/commonjs/window/layouts-registry.js +27 -0
  46. package/lib/commonjs/window/layouts-registry.js.map +1 -0
  47. package/lib/commonjs/window/layouts.js +27 -0
  48. package/lib/commonjs/window/layouts.js.map +1 -0
  49. package/lib/commonjs/window/messages.js +21 -1
  50. package/lib/commonjs/window/messages.js.map +1 -1
  51. package/lib/commonjs/window/use-window.js +16 -4
  52. package/lib/commonjs/window/use-window.js.map +1 -1
  53. package/lib/module/floating/popup-navigation.js +19 -9
  54. package/lib/module/floating/popup-navigation.js.map +1 -1
  55. package/lib/module/index.js.map +1 -1
  56. package/lib/module/index.web.js.map +1 -1
  57. package/lib/module/locale/translations/ar.js +21 -1
  58. package/lib/module/locale/translations/ar.js.map +1 -1
  59. package/lib/module/locale/translations/bn.js +21 -1
  60. package/lib/module/locale/translations/bn.js.map +1 -1
  61. package/lib/module/locale/translations/ca.js +21 -1
  62. package/lib/module/locale/translations/ca.js.map +1 -1
  63. package/lib/module/locale/translations/de.js +21 -1
  64. package/lib/module/locale/translations/de.js.map +1 -1
  65. package/lib/module/locale/translations/es.js +21 -1
  66. package/lib/module/locale/translations/es.js.map +1 -1
  67. package/lib/module/locale/translations/fr.js +21 -1
  68. package/lib/module/locale/translations/fr.js.map +1 -1
  69. package/lib/module/locale/translations/hi.js +21 -1
  70. package/lib/module/locale/translations/hi.js.map +1 -1
  71. package/lib/module/locale/translations/id.js +21 -1
  72. package/lib/module/locale/translations/id.js.map +1 -1
  73. package/lib/module/locale/translations/it.js +21 -1
  74. package/lib/module/locale/translations/it.js.map +1 -1
  75. package/lib/module/locale/translations/ja.js +21 -1
  76. package/lib/module/locale/translations/ja.js.map +1 -1
  77. package/lib/module/locale/translations/pt.js +21 -1
  78. package/lib/module/locale/translations/pt.js.map +1 -1
  79. package/lib/module/locale/translations/ru.js +21 -1
  80. package/lib/module/locale/translations/ru.js.map +1 -1
  81. package/lib/module/locale/translations/tr.js +21 -1
  82. package/lib/module/locale/translations/tr.js.map +1 -1
  83. package/lib/module/locale/translations/zh.js +21 -1
  84. package/lib/module/locale/translations/zh.js.map +1 -1
  85. package/lib/module/platform-surface/context.js +15 -0
  86. package/lib/module/platform-surface/context.js.map +1 -1
  87. package/lib/module/window/WindowControls.js +61 -16
  88. package/lib/module/window/WindowControls.js.map +1 -1
  89. package/lib/module/window/WindowLayouts.js +82 -0
  90. package/lib/module/window/WindowLayouts.js.map +1 -0
  91. package/lib/module/window/layouts-registry.js +22 -0
  92. package/lib/module/window/layouts-registry.js.map +1 -0
  93. package/lib/module/window/layouts.js +12 -0
  94. package/lib/module/window/layouts.js.map +1 -0
  95. package/lib/module/window/messages.js +21 -1
  96. package/lib/module/window/messages.js.map +1 -1
  97. package/lib/module/window/use-window.js +17 -5
  98. package/lib/module/window/use-window.js.map +1 -1
  99. package/lib/typescript/commonjs/floating/popup-navigation.d.ts.map +1 -1
  100. package/lib/typescript/commonjs/index.d.ts +1 -1
  101. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  102. package/lib/typescript/commonjs/index.web.d.ts +1 -1
  103. package/lib/typescript/commonjs/index.web.d.ts.map +1 -1
  104. package/lib/typescript/commonjs/locale/translations/ar.d.ts.map +1 -1
  105. package/lib/typescript/commonjs/locale/translations/bn.d.ts.map +1 -1
  106. package/lib/typescript/commonjs/locale/translations/ca.d.ts.map +1 -1
  107. package/lib/typescript/commonjs/locale/translations/de.d.ts.map +1 -1
  108. package/lib/typescript/commonjs/locale/translations/es.d.ts.map +1 -1
  109. package/lib/typescript/commonjs/locale/translations/fr.d.ts.map +1 -1
  110. package/lib/typescript/commonjs/locale/translations/hi.d.ts.map +1 -1
  111. package/lib/typescript/commonjs/locale/translations/id.d.ts.map +1 -1
  112. package/lib/typescript/commonjs/locale/translations/it.d.ts.map +1 -1
  113. package/lib/typescript/commonjs/locale/translations/ja.d.ts.map +1 -1
  114. package/lib/typescript/commonjs/locale/translations/pt.d.ts.map +1 -1
  115. package/lib/typescript/commonjs/locale/translations/ru.d.ts.map +1 -1
  116. package/lib/typescript/commonjs/locale/translations/tr.d.ts.map +1 -1
  117. package/lib/typescript/commonjs/locale/translations/zh.d.ts.map +1 -1
  118. package/lib/typescript/commonjs/platform-surface/context.d.ts +6 -0
  119. package/lib/typescript/commonjs/platform-surface/context.d.ts.map +1 -1
  120. package/lib/typescript/commonjs/platform-surface/index.d.ts +1 -1
  121. package/lib/typescript/commonjs/platform-surface/index.d.ts.map +1 -1
  122. package/lib/typescript/commonjs/platform-surface/types.d.ts +31 -1
  123. package/lib/typescript/commonjs/platform-surface/types.d.ts.map +1 -1
  124. package/lib/typescript/commonjs/window/WindowControls.d.ts +4 -0
  125. package/lib/typescript/commonjs/window/WindowControls.d.ts.map +1 -1
  126. package/lib/typescript/commonjs/window/WindowLayouts.d.ts +20 -0
  127. package/lib/typescript/commonjs/window/WindowLayouts.d.ts.map +1 -0
  128. package/lib/typescript/commonjs/window/layouts-registry.d.ts +19 -0
  129. package/lib/typescript/commonjs/window/layouts-registry.d.ts.map +1 -0
  130. package/lib/typescript/commonjs/window/layouts.d.ts +4 -0
  131. package/lib/typescript/commonjs/window/layouts.d.ts.map +1 -0
  132. package/lib/typescript/commonjs/window/messages.d.ts +22 -0
  133. package/lib/typescript/commonjs/window/messages.d.ts.map +1 -1
  134. package/lib/typescript/commonjs/window/types.d.ts +15 -1
  135. package/lib/typescript/commonjs/window/types.d.ts.map +1 -1
  136. package/lib/typescript/commonjs/window/use-window.d.ts.map +1 -1
  137. package/lib/typescript/module/floating/popup-navigation.d.ts.map +1 -1
  138. package/lib/typescript/module/index.d.ts +1 -1
  139. package/lib/typescript/module/index.d.ts.map +1 -1
  140. package/lib/typescript/module/index.web.d.ts +1 -1
  141. package/lib/typescript/module/index.web.d.ts.map +1 -1
  142. package/lib/typescript/module/locale/translations/ar.d.ts.map +1 -1
  143. package/lib/typescript/module/locale/translations/bn.d.ts.map +1 -1
  144. package/lib/typescript/module/locale/translations/ca.d.ts.map +1 -1
  145. package/lib/typescript/module/locale/translations/de.d.ts.map +1 -1
  146. package/lib/typescript/module/locale/translations/es.d.ts.map +1 -1
  147. package/lib/typescript/module/locale/translations/fr.d.ts.map +1 -1
  148. package/lib/typescript/module/locale/translations/hi.d.ts.map +1 -1
  149. package/lib/typescript/module/locale/translations/id.d.ts.map +1 -1
  150. package/lib/typescript/module/locale/translations/it.d.ts.map +1 -1
  151. package/lib/typescript/module/locale/translations/ja.d.ts.map +1 -1
  152. package/lib/typescript/module/locale/translations/pt.d.ts.map +1 -1
  153. package/lib/typescript/module/locale/translations/ru.d.ts.map +1 -1
  154. package/lib/typescript/module/locale/translations/tr.d.ts.map +1 -1
  155. package/lib/typescript/module/locale/translations/zh.d.ts.map +1 -1
  156. package/lib/typescript/module/platform-surface/context.d.ts +6 -0
  157. package/lib/typescript/module/platform-surface/context.d.ts.map +1 -1
  158. package/lib/typescript/module/platform-surface/index.d.ts +1 -1
  159. package/lib/typescript/module/platform-surface/index.d.ts.map +1 -1
  160. package/lib/typescript/module/platform-surface/types.d.ts +31 -1
  161. package/lib/typescript/module/platform-surface/types.d.ts.map +1 -1
  162. package/lib/typescript/module/window/WindowControls.d.ts +4 -0
  163. package/lib/typescript/module/window/WindowControls.d.ts.map +1 -1
  164. package/lib/typescript/module/window/WindowLayouts.d.ts +20 -0
  165. package/lib/typescript/module/window/WindowLayouts.d.ts.map +1 -0
  166. package/lib/typescript/module/window/layouts-registry.d.ts +19 -0
  167. package/lib/typescript/module/window/layouts-registry.d.ts.map +1 -0
  168. package/lib/typescript/module/window/layouts.d.ts +4 -0
  169. package/lib/typescript/module/window/layouts.d.ts.map +1 -0
  170. package/lib/typescript/module/window/messages.d.ts +22 -0
  171. package/lib/typescript/module/window/messages.d.ts.map +1 -1
  172. package/lib/typescript/module/window/types.d.ts +15 -1
  173. package/lib/typescript/module/window/types.d.ts.map +1 -1
  174. package/lib/typescript/module/window/use-window.d.ts.map +1 -1
  175. package/package.json +20 -2
  176. package/src/__tests__/support/public-part-classifications.json +1 -0
  177. package/src/floating/popup-navigation.tsx +71 -55
  178. package/src/index.ts +1 -0
  179. package/src/index.web.ts +1 -0
  180. package/src/locale/translations/ar.ts +20 -0
  181. package/src/locale/translations/bn.ts +20 -0
  182. package/src/locale/translations/ca.ts +20 -0
  183. package/src/locale/translations/de.ts +20 -0
  184. package/src/locale/translations/es.ts +20 -0
  185. package/src/locale/translations/fr.ts +20 -0
  186. package/src/locale/translations/hi.ts +20 -0
  187. package/src/locale/translations/id.ts +20 -0
  188. package/src/locale/translations/it.ts +20 -0
  189. package/src/locale/translations/ja.ts +20 -0
  190. package/src/locale/translations/pt.ts +20 -0
  191. package/src/locale/translations/ru.ts +20 -0
  192. package/src/locale/translations/tr.ts +20 -0
  193. package/src/locale/translations/zh.ts +20 -0
  194. package/src/platform-surface/context.ts +17 -0
  195. package/src/platform-surface/index.ts +1 -0
  196. package/src/platform-surface/types.ts +45 -0
  197. package/src/window/WindowControls.tsx +72 -18
  198. package/src/window/WindowLayouts.tsx +108 -0
  199. package/src/window/layouts-registry.ts +26 -0
  200. package/src/window/layouts.ts +12 -0
  201. package/src/window/messages.ts +42 -0
  202. package/src/window/types.ts +20 -1
  203. package/src/window/use-window.ts +14 -4
@@ -57,6 +57,23 @@ export function usePlatformWindow(): PlatformWindow | null {
57
57
  return adapter.window;
58
58
  }
59
59
 
60
+ /**
61
+ * The window's layouts when the adapter reports `window` and `window-layout` (`PlatformWindow`'s
62
+ * `layOut`, and `moveToDesktop` where it has desktops), otherwise null. Throws for
63
+ * `window-layout` without `layOut`.
64
+ */
65
+ export function usePlatformWindowLayout(): Pick<PlatformWindow, 'layOut' | 'moveToDesktop'> | null {
66
+ const adapter = useContext(PlatformSurfaceContext);
67
+ const window = usePlatformWindow();
68
+ if (!window || !adapter?.capabilities.has('window-layout')) return null;
69
+ if (!window.layOut) {
70
+ throw new Error(
71
+ `Bloom: the ${adapter.platform} platform adapter reports 'window-layout' without a window's layOut.`,
72
+ );
73
+ }
74
+ return window;
75
+ }
76
+
60
77
  /**
61
78
  * The platform's menu bar when the adapter reports `menu-bar`, otherwise null
62
79
  * (a `Menubar` draws itself in the window). An adapter that reports the
@@ -79,6 +79,7 @@ export type {
79
79
  PlatformWindowMetrics,
80
80
  PlatformWindowSizeLimits,
81
81
  PlatformWindowState,
82
+ PlatformWindowLayout,
82
83
  PopupDismissReason,
83
84
  PopupSurfaceProps,
84
85
  SurfaceCapability,
@@ -11,6 +11,11 @@ import type { FloatingAlign, FloatingSide } from '../floating/types';
11
11
  * (close, minimize, zoom) in its top leading corner, and can be moved,
12
12
  * zoomed and minimized. Bloom keeps the controls' room and, where the
13
13
  * platform asks it to, draws them (`@oxy.so/bloom/window`).
14
+ * - `window-layout`: with `window`, the platform lays the window out on its
15
+ * display as a Mac tiles windows since macOS 15 (`PlatformWindow.layOut`),
16
+ * and moves it between its desktops where it has them
17
+ * (`PlatformWindow.moveToDesktop`, `PlatformWindowState.desktops`): the
18
+ * zoom control shows the layouts on hover and long press.
14
19
  * - `menu-bar`: the platform shows the active window's menus in a bar of its
15
20
  * own (the top of the screen, as on a Mac). A `Menubar` then draws nothing in
16
21
  * the window: it describes its menus to the platform (`PlatformMenuBar`) and
@@ -39,6 +44,7 @@ import type { FloatingAlign, FloatingSide } from '../floating/types';
39
44
  export type SurfaceCapability =
40
45
  | 'popup-surface'
41
46
  | 'window'
47
+ | 'window-layout'
42
48
  | 'pointer'
43
49
  | 'menu-bar'
44
50
  | 'appearance'
@@ -332,8 +338,36 @@ export interface PlatformWindowState {
332
338
  readonly maximized: boolean;
333
339
  /** Full screen: no controls and no room. */
334
340
  readonly fullscreen: boolean;
341
+ /**
342
+ * The platform's desktops (a Mac's Spaces) and the one the window is on, numbered from 0, where
343
+ * it lets a window move between them (`moveToDesktop`); absent where it does not.
344
+ */
345
+ readonly desktops?: { readonly count: number; readonly current: number };
335
346
  }
336
347
 
348
+ /**
349
+ * Where a window can be laid out on its display's work area, as a Mac's tiling since macOS 15:
350
+ * Fill and Center; the halves and quarters; the arrangements of the window with those behind it
351
+ * (`leftRight`: this one left, the next right); and back to the frame it had before.
352
+ */
353
+ export type PlatformWindowLayout =
354
+ | 'fill'
355
+ | 'center'
356
+ | 'left'
357
+ | 'right'
358
+ | 'top'
359
+ | 'bottom'
360
+ | 'topLeft'
361
+ | 'topRight'
362
+ | 'bottomLeft'
363
+ | 'bottomRight'
364
+ | 'leftRight'
365
+ | 'rightLeft'
366
+ | 'topBottom'
367
+ | 'bottomTop'
368
+ | 'quarters'
369
+ | 'returnToPrevious';
370
+
337
371
  /**
338
372
  * The application's window, with the `window` capability. Its state is an
339
373
  * external store (`getState` + `subscribe`, as `useSyncExternalStore` reads
@@ -365,6 +399,17 @@ export interface PlatformWindow {
365
399
  * any size leaves it out, and Bloom then asks nothing.
366
400
  */
367
401
  setSizeLimits?(limits: PlatformWindowSizeLimits): void;
402
+ /**
403
+ * Lays the window out (`PlatformWindowLayout`), as the platform's own tiling does: required with
404
+ * the `window-layout` capability, which makes the zoom control show the layouts on hover and
405
+ * long press, as a Mac's green button does.
406
+ */
407
+ layOut?(layout: PlatformWindowLayout): void;
408
+ /**
409
+ * Moves the window to another of the platform's desktops, numbered from 0
410
+ * (`PlatformWindowState.desktops`), with `window-layout`, where the platform has desktops.
411
+ */
412
+ moveToDesktop?(desktop: number): void;
368
413
  }
369
414
 
370
415
  /**
@@ -1,6 +1,6 @@
1
1
  import type React from 'react';
2
2
  import { useState } from 'react';
3
- import { Pressable, View } from 'react-native';
3
+ import { Pressable, type PressableProps, View } from 'react-native';
4
4
  import Animated, {
5
5
  cancelAnimation,
6
6
  useAnimatedStyle,
@@ -27,6 +27,7 @@ import {
27
27
  import { WINDOW_MESSAGES } from './messages';
28
28
  import type { WindowControlsProps } from './types';
29
29
  import { useWindow } from './use-window';
30
+ import { registeredWindowLayouts } from './layouts-registry';
30
31
  import { usePrefersReducedMotion } from '../hooks/use-prefers-reduced-motion';
31
32
  import { useInteractionState } from '../hooks/use-interaction-state';
32
33
 
@@ -51,6 +52,8 @@ function WindowControl({
51
52
  symbols,
52
53
  onPress,
53
54
  testID,
55
+ placed = true,
56
+ ...trigger
54
57
  }: {
55
58
  label: string;
56
59
  icon: React.ComponentType<IconProps>;
@@ -61,7 +64,12 @@ function WindowControl({
61
64
  symbols: boolean;
62
65
  onPress: () => void;
63
66
  testID?: string;
64
- }) {
67
+ /**
68
+ * False when what holds it is placed instead (the zoom control as the trigger of its layouts:
69
+ * the trigger's box is where the menu is anchored, so it takes the control's place).
70
+ */
71
+ placed?: boolean;
72
+ } & Omit<PressableProps, 'style' | 'children' | 'onPress'>) {
65
73
  const reducedMotion = usePrefersReducedMotion();
66
74
  const scale = useSharedValue(1);
67
75
  // `scale` in the deps: web without the worklets plugin does not track reads.
@@ -71,6 +79,8 @@ function WindowControl({
71
79
  // The first click on an inactive window's bubble acts, as a Mac's do.
72
80
  {...ACCEPTS_FIRST_MOUSE}
73
81
  role="button"
82
+ // The layouts' trigger, on the zoom control: its long press, its state and its action.
83
+ {...trigger}
74
84
  accessibilityLabel={label}
75
85
  onPress={onPress}
76
86
  onPressIn={() => {
@@ -83,10 +93,8 @@ function WindowControl({
83
93
  }}
84
94
  testID={testID}
85
95
  style={[
96
+ placed ? controlPlace(offset, top) : null,
86
97
  {
87
- position: 'absolute',
88
- top,
89
- insetInlineStart: offset,
90
98
  width: WINDOW_CONTROL_TARGET,
91
99
  height: WINDOW_CONTROL_TARGET,
92
100
  alignItems: 'center',
@@ -126,6 +134,31 @@ function WindowControl({
126
134
  );
127
135
  }
128
136
 
137
+ let warnedUnregistered = false;
138
+
139
+ /**
140
+ * The zoom control's layouts where the platform lays windows out (`window-layout`), as its adapter
141
+ * registered them (`@oxy.so/bloom/window/layouts`); null elsewhere. Reported without them, the
142
+ * control only zooms and development says why, once.
143
+ */
144
+ function windowLayoutsFor(enabled: boolean) {
145
+ if (!enabled) return null;
146
+ const registered = registeredWindowLayouts();
147
+ if (!registered && process.env.NODE_ENV !== 'production' && !warnedUnregistered) {
148
+ warnedUnregistered = true;
149
+ console.warn(
150
+ "[Bloom] WindowControls: the platform reports 'window-layout', but nothing imported " +
151
+ "'@oxy.so/bloom/window/layouts', so the zoom control shows no layouts.",
152
+ );
153
+ }
154
+ return registered;
155
+ }
156
+
157
+ /** A control's place in its group: `offset` from the group's leading edge, `top` from its top. */
158
+ function controlPlace(offset: number, top: number) {
159
+ return { position: 'absolute' as const, top, insetInlineStart: offset };
160
+ }
161
+
129
162
  /**
130
163
  * The window's controls (close, minimize, zoom): three bubbles of the surface
131
164
  * material where the platform says they are, `metrics.controls`, from the top
@@ -136,6 +169,10 @@ function WindowControl({
136
169
  * 88 % and springs it back as it acts. They act on the first click on an
137
170
  * inactive window (`ACCEPTS_FIRST_MOUSE`), as a Mac's do.
138
171
  *
172
+ * With the `window-layout` capability, the zoom control shows the window's layouts as the
173
+ * pointer rests on it, on a long press, or by its "Show menu" action, as a Mac's green button
174
+ * does (`WindowLayouts`); its press still zooms.
175
+ *
139
176
  * Draws nothing without the `window` capability, where the platform draws its
140
177
  * own controls (`controls: 'platform'`), and while the window is full screen.
141
178
  */
@@ -151,6 +188,7 @@ export function WindowControls({
151
188
  const { colors } = useTheme();
152
189
  const dirProps = useDirectionProps();
153
190
  const { state: hovered, onIn: onHoverIn, onOut: onHoverOut } = useInteractionState();
191
+ const WindowLayouts = windowLayoutsFor(appWindow?.layOut !== undefined);
154
192
  if (appWindow?.controls !== 'bloom' || appWindow.fullscreen) return null;
155
193
 
156
194
  const { start, top, width, height } = appWindow.metrics.controls;
@@ -209,19 +247,35 @@ export function WindowControls({
209
247
  testID={testID ? `${testID}-group` : undefined}
210
248
  style={{ position: 'absolute', top: pad, insetInlineStart: pad, width, height }}
211
249
  >
212
- {controls.map((control, index) => (
213
- <WindowControl
214
- key={control.key}
215
- label={control.label}
216
- icon={control.icon}
217
- paint={control.paint}
218
- offset={pitch * index}
219
- top={targetTop}
220
- symbols={hovered}
221
- onPress={control.onPress}
222
- testID={testID ? `${testID}-${control.key}` : undefined}
223
- />
224
- ))}
250
+ {controls.map((control, index) => {
251
+ const drawn = (placed: boolean) => (
252
+ <WindowControl
253
+ key={control.key}
254
+ label={control.label}
255
+ icon={control.icon}
256
+ paint={control.paint}
257
+ offset={pitch * index}
258
+ top={targetTop}
259
+ symbols={hovered}
260
+ onPress={control.onPress}
261
+ placed={placed}
262
+ testID={testID ? `${testID}-${control.key}` : undefined}
263
+ />
264
+ );
265
+ // The zoom control shows the window's layouts, where the platform lays windows out.
266
+ if (control.key === 'zoom' && WindowLayouts) {
267
+ return (
268
+ <WindowLayouts
269
+ key={control.key}
270
+ style={controlPlace(pitch * index, targetTop)}
271
+ testID={testID ? `${testID}-layouts` : undefined}
272
+ >
273
+ {drawn(false)}
274
+ </WindowLayouts>
275
+ );
276
+ }
277
+ return drawn(true);
278
+ })}
225
279
  </View>
226
280
  </View>
227
281
  );
@@ -0,0 +1,108 @@
1
+ /**
2
+ * The zoom control's layouts, as a Mac's green button shows them since macOS 15: the pointer
3
+ * resting on it, a long press, or the screen reader's "Show menu" action on it opens a menu of
4
+ * where the window can go (Move & Resize: the halves and the quarters; Fill & Arrange: Fill,
5
+ * Center and the arrangements of the window with those behind it; Return to Previous Size) and,
6
+ * where the platform has desktops, Move to each other one. The control's own press still zooms.
7
+ *
8
+ * Bloom's `DropdownMenu` (`activation="hover"`): its rows take the arrows, typeahead and Return
9
+ * as any menu's, each named by its label, the menu by its own ("Window layouts").
10
+ *
11
+ * Shown only where the platform lays windows out (the `window-layout` capability) and its adapter
12
+ * imported `@oxy.so/bloom/window/layouts`, which registers it (`layouts-registry.ts`); the
13
+ * platform does it (`PlatformWindow.layOut`, `moveToDesktop`).
14
+ */
15
+
16
+ import {
17
+ DropdownMenu,
18
+ DropdownMenuContent,
19
+ DropdownMenuGroup,
20
+ DropdownMenuItem,
21
+ DropdownMenuLabel,
22
+ DropdownMenuSeparator,
23
+ DropdownMenuTrigger,
24
+ } from '../dropdown-menu';
25
+ import { useMessages } from '../locale/messages';
26
+ import type { PlatformWindowLayout } from '../platform-surface/types';
27
+ import { WINDOW_MESSAGES } from './messages';
28
+ import type { WindowLayoutsProps } from './types';
29
+ import { useWindow } from './use-window';
30
+
31
+ /** How long the pointer rests on the zoom control before its layouts show. */
32
+ export const WINDOW_LAYOUTS_OPEN_DELAY = 500;
33
+
34
+ /** Move & Resize: the halves, then the quarters, as a Mac's menu orders them. */
35
+ const MOVE_AND_RESIZE: readonly PlatformWindowLayout[] = [
36
+ 'left',
37
+ 'right',
38
+ 'top',
39
+ 'bottom',
40
+ 'topLeft',
41
+ 'topRight',
42
+ 'bottomLeft',
43
+ 'bottomRight',
44
+ ];
45
+ /** Fill & Arrange: Fill and Center, then the arrangements with the windows behind. */
46
+ const FILL_AND_ARRANGE: readonly PlatformWindowLayout[] = [
47
+ 'fill',
48
+ 'center',
49
+ 'leftRight',
50
+ 'rightLeft',
51
+ 'topBottom',
52
+ 'bottomTop',
53
+ 'quarters',
54
+ ];
55
+
56
+ /** `children` (the zoom control) with the window's layouts on hover, long press and "Show menu". */
57
+ export function WindowLayouts({ children, style, testID }: WindowLayoutsProps) {
58
+ const appWindow = useWindow();
59
+ const { messages } = useMessages(WINDOW_MESSAGES);
60
+ const layOut = appWindow?.layOut;
61
+ if (!layOut) return children;
62
+ const { desktops, moveToDesktop } = appWindow;
63
+ const others =
64
+ desktops && moveToDesktop
65
+ ? Array.from({ length: desktops.count }, (_, index) => index).filter(
66
+ (index) => index !== desktops.current,
67
+ )
68
+ : [];
69
+ const row = (layout: PlatformWindowLayout) => (
70
+ <DropdownMenuItem
71
+ key={layout}
72
+ testID={testID ? `${testID}-${layout}` : undefined}
73
+ onPress={() => layOut(layout)}
74
+ >
75
+ {messages[layout]}
76
+ </DropdownMenuItem>
77
+ );
78
+ return (
79
+ <DropdownMenu activation="hover" openDelay={WINDOW_LAYOUTS_OPEN_DELAY}>
80
+ <DropdownMenuTrigger asChild style={style}>
81
+ {children}
82
+ </DropdownMenuTrigger>
83
+ <DropdownMenuContent label={messages.layouts} testID={testID}>
84
+ <DropdownMenuGroup>
85
+ <DropdownMenuLabel>{messages.moveAndResize}</DropdownMenuLabel>
86
+ {MOVE_AND_RESIZE.map(row)}
87
+ </DropdownMenuGroup>
88
+ <DropdownMenuSeparator />
89
+ <DropdownMenuGroup>
90
+ <DropdownMenuLabel>{messages.fillAndArrange}</DropdownMenuLabel>
91
+ {FILL_AND_ARRANGE.map(row)}
92
+ </DropdownMenuGroup>
93
+ <DropdownMenuSeparator />
94
+ {row('returnToPrevious')}
95
+ {others.length > 0 ? <DropdownMenuSeparator /> : null}
96
+ {others.map((desktop) => (
97
+ <DropdownMenuItem
98
+ key={`desktop-${desktop}`}
99
+ testID={testID ? `${testID}-desktop-${desktop + 1}` : undefined}
100
+ onPress={() => moveToDesktop?.(desktop)}
101
+ >
102
+ {messages.moveToDesktop(desktop + 1)}
103
+ </DropdownMenuItem>
104
+ ))}
105
+ </DropdownMenuContent>
106
+ </DropdownMenu>
107
+ );
108
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The zoom control's layouts (`WindowLayouts`) as the platform's adapter registered them, by
3
+ * importing `@oxy.so/bloom/window/layouts` (`layouts.ts`). `WindowControls` reads it here and
4
+ * never imports the menu itself: a window's controls on every other platform (a web page, a
5
+ * settings modal, a phone's screen) must not link Bloom's `DropdownMenu` and what a phone's sheet
6
+ * needs, which only a platform that lays windows out (`window-layout`) uses.
7
+ *
8
+ * `globalThis`-anchored, as `kbd/window-keys` is, so two copies of Bloom share it.
9
+ */
10
+ import type { ComponentType } from 'react';
11
+
12
+ import type { WindowLayoutsProps } from './types';
13
+
14
+ declare global {
15
+ var __oxy_so_bloom_window_layouts__: ComponentType<WindowLayoutsProps> | undefined;
16
+ }
17
+
18
+ /** Makes `component` the zoom control's layouts (`@oxy.so/bloom/window/layouts` calls it). */
19
+ export function registerWindowLayouts(component: ComponentType<WindowLayoutsProps>): void {
20
+ globalThis.__oxy_so_bloom_window_layouts__ = component;
21
+ }
22
+
23
+ /** The registered layouts, or null when nothing imported `@oxy.so/bloom/window/layouts`. */
24
+ export function registeredWindowLayouts(): ComponentType<WindowLayoutsProps> | null {
25
+ return globalThis.__oxy_so_bloom_window_layouts__ ?? null;
26
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * `@oxy.so/bloom/window/layouts`: the zoom control's layouts (`WindowLayouts`, a Mac's green
3
+ * button's menu), registered for `WindowControls` as it is imported. A platform's adapter that
4
+ * reports `window-layout` imports it (OxyOS's does); nothing else links it.
5
+ */
6
+ import { registerWindowLayouts } from './layouts-registry';
7
+ import { WindowLayouts, WINDOW_LAYOUTS_OPEN_DELAY } from './WindowLayouts';
8
+
9
+ registerWindowLayouts(WindowLayouts);
10
+
11
+ export { WindowLayouts, WINDOW_LAYOUTS_OPEN_DELAY };
12
+ export type { WindowLayoutsProps } from './types';
@@ -9,6 +9,28 @@ export interface WindowMessages {
9
9
  minimize: string;
10
10
  /** Maximize, or restore the window's frame. */
11
11
  zoom: string;
12
+ /** The zoom control's layouts (hover or long press), as a Mac's green button shows them. */
13
+ layouts: string;
14
+ moveAndResize: string;
15
+ fillAndArrange: string;
16
+ fill: string;
17
+ center: string;
18
+ left: string;
19
+ right: string;
20
+ top: string;
21
+ bottom: string;
22
+ topLeft: string;
23
+ topRight: string;
24
+ bottomLeft: string;
25
+ bottomRight: string;
26
+ leftRight: string;
27
+ rightLeft: string;
28
+ topBottom: string;
29
+ bottomTop: string;
30
+ quarters: string;
31
+ returnToPrevious: string;
32
+ /** "Move to Desktop 2", desktops numbered from 1 as the person counts them. */
33
+ moveToDesktop: (desktop: number) => string;
12
34
  }
13
35
 
14
36
  export const WINDOW_MESSAGES: MessageCatalog<WindowMessages> = defineMessages<WindowMessages>(
@@ -17,5 +39,25 @@ export const WINDOW_MESSAGES: MessageCatalog<WindowMessages> = defineMessages<Wi
17
39
  close: 'Close',
18
40
  minimize: 'Minimize',
19
41
  zoom: 'Zoom',
42
+ layouts: 'Window layouts',
43
+ moveAndResize: 'Move & Resize',
44
+ fillAndArrange: 'Fill & Arrange',
45
+ fill: 'Fill',
46
+ center: 'Center',
47
+ left: 'Left',
48
+ right: 'Right',
49
+ top: 'Top',
50
+ bottom: 'Bottom',
51
+ topLeft: 'Top Left',
52
+ topRight: 'Top Right',
53
+ bottomLeft: 'Bottom Left',
54
+ bottomRight: 'Bottom Right',
55
+ leftRight: 'Left & Right',
56
+ rightLeft: 'Right & Left',
57
+ topBottom: 'Top & Bottom',
58
+ bottomTop: 'Bottom & Top',
59
+ quarters: 'Quarters',
60
+ returnToPrevious: 'Return to Previous Size',
61
+ moveToDesktop: (desktop) => `Move to Desktop ${desktop}`,
20
62
  },
21
63
  );
@@ -1,7 +1,12 @@
1
+ import type React from 'react';
1
2
  import type { ReactNode } from 'react';
2
3
  import type { StyleProp, ViewProps, ViewStyle } from 'react-native';
3
4
 
4
- import type { PlatformWindowMetrics, PlatformWindowState } from '../platform-surface/types';
5
+ import type {
6
+ PlatformWindowLayout,
7
+ PlatformWindowMetrics,
8
+ PlatformWindowState,
9
+ } from '../platform-surface/types';
5
10
 
6
11
  /** The window's state and the actions on it (`useWindow()`). */
7
12
  export interface WindowHandle extends PlatformWindowState {
@@ -15,6 +20,10 @@ export interface WindowHandle extends PlatformWindowState {
15
20
  zoom(): void;
16
21
  /** Start an interactive move from the press being handled. */
17
22
  startMove(): void;
23
+ /** Lays the window out, where the platform tiles windows; absent where it does not. */
24
+ readonly layOut?: (layout: PlatformWindowLayout) => void;
25
+ /** Moves the window to another desktop, where the platform has them; absent where it does not. */
26
+ readonly moveToDesktop?: (desktop: number) => void;
18
27
  }
19
28
 
20
29
  /**
@@ -75,3 +84,13 @@ export interface WindowDragRegionProps
75
84
  style?: StyleProp<ViewStyle>;
76
85
  testID?: string;
77
86
  }
87
+
88
+ /** `WindowLayouts`' props (`@oxy.so/bloom/window/layouts`). */
89
+ export interface WindowLayoutsProps {
90
+ /** The zoom control. */
91
+ children: React.ReactElement;
92
+ /** The control's place: the trigger's box, where the menu is anchored. */
93
+ style?: StyleProp<ViewStyle>;
94
+ /** The menu's rows are `${testID}-${layout}` and `${testID}-desktop-${n}`. */
95
+ testID?: string;
96
+ }
@@ -1,8 +1,8 @@
1
1
  import { useCallback, useEffect, useMemo, useRef, useSyncExternalStore } from 'react';
2
2
 
3
- import { usePlatformWindow } from '../platform-surface/context';
3
+ import { usePlatformWindow, usePlatformWindowLayout } from '../platform-surface/context';
4
4
  import { useWindowChrome } from './context';
5
- import type { PlatformWindowState } from '../platform-surface/types';
5
+ import type { PlatformWindowLayout, PlatformWindowState } from '../platform-surface/types';
6
6
  import type { WindowControlsRoom, WindowHandle, WindowSizeLimits } from './types';
7
7
 
8
8
  const NO_ROOM: WindowControlsRoom = { top: 0, leading: 0 };
@@ -16,6 +16,7 @@ function unsubscribed() {}
16
16
  */
17
17
  export function useWindow(): WindowHandle | null {
18
18
  const platform = usePlatformWindow();
19
+ const layouts = usePlatformWindowLayout();
19
20
  // `useSyncExternalStore` compares snapshots by identity, so an adapter that
20
21
  // builds a fresh object on every `getState()` must not read as a change.
21
22
  const last = useRef<PlatformWindowState | null>(null);
@@ -31,13 +32,16 @@ export function useWindow(): WindowHandle | null {
31
32
  previous &&
32
33
  previous.active === next.active &&
33
34
  previous.maximized === next.maximized &&
34
- previous.fullscreen === next.fullscreen
35
+ previous.fullscreen === next.fullscreen &&
36
+ previous.desktops?.count === next.desktops?.count &&
37
+ previous.desktops?.current === next.desktops?.current
35
38
  )
36
39
  return previous;
37
40
  last.current = {
38
41
  active: next.active,
39
42
  maximized: next.maximized,
40
43
  fullscreen: next.fullscreen,
44
+ ...(next.desktops ? { desktops: { ...next.desktops } } : null),
41
45
  };
42
46
  return last.current;
43
47
  }, [platform]);
@@ -53,9 +57,15 @@ export function useWindow(): WindowHandle | null {
53
57
  minimize: () => platform.minimize(),
54
58
  zoom: () => platform.zoom(),
55
59
  startMove: () => platform.startMove(),
60
+ ...(layouts?.layOut
61
+ ? { layOut: (layout: PlatformWindowLayout) => layouts.layOut?.(layout) }
62
+ : null),
63
+ ...(layouts?.moveToDesktop
64
+ ? { moveToDesktop: (desktop: number) => layouts.moveToDesktop?.(desktop) }
65
+ : null),
56
66
  }
57
67
  : null,
58
- [platform, state],
68
+ [platform, layouts, state],
59
69
  );
60
70
  }
61
71