react-x11 2.16.1 → 2.17.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 (54) hide show
  1. package/README.md +38 -23
  2. package/package.json +3 -1
  3. package/src/Reconciler.js +82 -23
  4. package/src/a11y.js +18 -1
  5. package/src/appcontext.js +8 -0
  6. package/src/appearance.js +36 -0
  7. package/src/{cocoa → backend}/context2d.js +27 -7
  8. package/src/capabilities.js +99 -1
  9. package/src/cocoa/app.js +8 -4
  10. package/src/cocoa/fonts.js +1 -1
  11. package/src/cocoa/overlay.js +2 -2
  12. package/src/cocoa/panewindow.js +2 -2
  13. package/src/cocoa/presenter.js +2 -2
  14. package/src/cocoa/surface.js +3 -3
  15. package/src/cocoa/window.js +2 -2
  16. package/src/events.js +21 -0
  17. package/src/foreignnodes.js +8 -3
  18. package/src/frame/index.js +30 -4
  19. package/src/glnodes.js +12 -1
  20. package/src/idle.js +59 -1
  21. package/src/index.d.ts +41 -0
  22. package/src/index.js +30 -3
  23. package/src/launcher.js +17 -8
  24. package/src/launcherhooks.js +24 -10
  25. package/src/node.d.ts +1 -1
  26. package/src/nodes/cascade.js +9 -0
  27. package/src/nodes/node.js +6 -1
  28. package/src/nodes/window/hints.js +21 -2
  29. package/src/nodes/window/window.js +2 -2
  30. package/src/notifications.js +39 -14
  31. package/src/taskbarhooks.js +164 -0
  32. package/src/transfer.js +20 -1
  33. package/src/trayhooks.js +1 -1
  34. package/src/types/capabilities.d.ts +32 -3
  35. package/src/types/elements.d.ts +23 -1
  36. package/src/types/events.d.ts +16 -0
  37. package/src/types/launcher.d.ts +20 -6
  38. package/src/types/taskbar.d.ts +79 -0
  39. package/src/wayland/context2d.js +1 -1
  40. package/src/win32/a11y.js +604 -0
  41. package/src/win32/app.js +768 -0
  42. package/src/win32/bezels.js +158 -0
  43. package/src/win32/dnd.js +283 -0
  44. package/src/win32/fonts.js +497 -0
  45. package/src/win32/glarea.js +548 -0
  46. package/src/win32/ime.js +267 -0
  47. package/src/win32/keymap.js +116 -0
  48. package/src/win32/native.js +54 -0
  49. package/src/win32/panehost.js +106 -0
  50. package/src/win32/panewindow.js +343 -0
  51. package/src/win32/shell.js +426 -0
  52. package/src/win32/surface.js +192 -0
  53. package/src/win32/window.js +659 -0
  54. package/src/windowid.js +66 -0
@@ -429,6 +429,19 @@ function centreFor(options) {
429
429
  return app?.notifications ?? null;
430
430
  }
431
431
 
432
+ /**
433
+ * Which rung a backend's own notification centre is.
434
+ *
435
+ * The seam is the backend's, not macOS's: a centre answers `available()` and
436
+ * `post()`, and the cocoa one was simply the first. `kind` is how a centre
437
+ * says which rung it is, so `notificationBackend()` reports the truth rather
438
+ * than the name of whoever got here first. Cocoa's predates the field and is
439
+ * the default.
440
+ */
441
+ function kindOf(centre) {
442
+ return centre?.kind ?? 'cocoa';
443
+ }
444
+
432
445
  /**
433
446
  * Which rung this machine lands on, without posting anything.
434
447
  *
@@ -442,10 +455,11 @@ function centreFor(options) {
442
455
  export async function notificationBackend(options = {}) {
443
456
  const backend = options.backend;
444
457
  const want = (rung) => !backend || backend === rung;
445
- if (want('cocoa')) {
446
- const centre = centreFor(options);
447
- if (centre && (await centre.available())) return 'cocoa';
448
- if (backend === 'cocoa') return null;
458
+ const centre = centreFor(options);
459
+ const kind = kindOf(centre);
460
+ if (want(kind)) {
461
+ if (centre && (await centre.available())) return kind;
462
+ if (backend === kind) return null;
449
463
  }
450
464
  if (want('dbus')) {
451
465
  const ref = await sessionBus();
@@ -461,7 +475,14 @@ export async function notificationBackend(options = {}) {
461
475
  if (want('osascript') && (process.platform === 'darwin' || backend)) {
462
476
  return 'osascript';
463
477
  }
464
- if (want('notify-send') && (process.platform !== 'darwin' || backend)) {
478
+ // `notify-send` is a freedesktop tool. Windows has neither it nor a shell
479
+ // command that shows a notification, so the rung above is the floor there
480
+ // and `null` is the honest answer when the tree is not on the win32
481
+ // backend — a spawn that would fail with ENOENT is not a rung.
482
+ if (
483
+ want('notify-send') &&
484
+ (backend || (process.platform !== 'darwin' && process.platform !== 'win32'))
485
+ ) {
465
486
  return 'notify-send';
466
487
  }
467
488
  return null;
@@ -497,26 +518,28 @@ export async function notify(options = {}) {
497
518
  const backend = options.backend;
498
519
  const want = (rung) => !backend || backend === rung;
499
520
 
500
- if (want('cocoa')) {
501
- const centre = centreFor(options);
521
+ const centre = centreFor(options);
522
+ const kind = kindOf(centre);
523
+ if (want(kind)) {
502
524
  if (centre && (await centre.available())) {
503
525
  const handle = await centre.post(options);
504
526
  if (handle) return handle;
505
527
  // The bundle is right and the centre is there, but the system never
506
528
  // put the prompt in front of anybody, so nobody declined: not the
507
529
  // refusal above, and no reason to stop. The ladder moves on.
508
- if (backend === 'cocoa') {
530
+ if (backend === kind) {
509
531
  throw new NoNotificationServiceError(
510
- "backend: 'cocoa' — the centre could not ask for authorization " +
532
+ `backend: '${kind}' — the centre could not ask for authorization ` +
511
533
  '(the status is still notDetermined). A bundle macOS has not ' +
512
534
  'registered never gets the prompt (docs/notifications.md).',
513
535
  );
514
536
  }
515
- } else if (backend === 'cocoa') {
537
+ } else if (backend === kind) {
516
538
  throw new NoNotificationServiceError(
517
- "backend: 'cocoa' — no notification centre here: the tree is not " +
518
- 'on the cocoa backend, the bridge is older than 0.5, or this ' +
519
- 'process is not an app bundle (docs/notifications.md).',
539
+ `backend: '${kind}' — no notification centre here: the tree is not ` +
540
+ 'on a backend that has one, the bridge is older than the version ' +
541
+ 'that added it, or on macOS this process is not an app bundle ' +
542
+ '(docs/notifications.md).',
520
543
  );
521
544
  }
522
545
  }
@@ -534,7 +557,9 @@ export async function notify(options = {}) {
534
557
  const shell =
535
558
  want('osascript') && (process.platform === 'darwin' || backend)
536
559
  ? 'osascript'
537
- : want('notify-send') && (process.platform !== 'darwin' || backend)
560
+ : want('notify-send') &&
561
+ (backend ||
562
+ (process.platform !== 'darwin' && process.platform !== 'win32'))
538
563
  ? 'notify-send'
539
564
  : null;
540
565
  if (shell) {
@@ -0,0 +1,164 @@
1
+ // The Windows taskbar's own surfaces, as hooks.
2
+ //
3
+ // Three things the taskbar has that no other desktop does, so none of them is
4
+ // a rung on an existing ladder and none of them pretends to be portable. What
5
+ // makes them safe to use anyway is that the answer to "is this here" is a
6
+ // value a component branches on rather than a platform check, and the hooks
7
+ // below do nothing at all where the backend has not installed them. An app
8
+ // writes the same tree everywhere and gets the feature where it exists.
9
+ //
10
+ // ```jsx
11
+ // const launcher = useDesktopCapability('launcher');
12
+ // useThumbnailToolbar(
13
+ // launcher.features.thumbnailToolbar ? [
14
+ // { id: 'prev', tooltip: 'Previous', icon: prevIcon },
15
+ // { id: 'play', tooltip: playing ? 'Pause' : 'Play', icon: playIcon },
16
+ // ] : null,
17
+ // (id) => transport(id),
18
+ // );
19
+ // ```
20
+ //
21
+ // They are **features of the launcher** — the same rung as the badge and the
22
+ // progress bar, since all of them hang off the one icon the desktop shows for
23
+ // this app — and not entries in `useSupports()`, which answers for the
24
+ // display. The seam is one rule: the backend installs a method, and its
25
+ // presence is the capability; the probe in `src/capabilities.js` reads those
26
+ // same methods, so the prediction and the hook cannot disagree. Nothing here
27
+ // knows what Windows is, and neither does anything in an app that uses it.
28
+ import { useEffect, useRef } from 'react';
29
+
30
+ import { useAppOrNull } from './appcontext.js';
31
+ import { liveApps } from './trace-registry.js';
32
+ import { useTopLevelWindow } from './windowid.js';
33
+
34
+ /** The app to act on when the caller did not say — the same rule the
35
+ * launcher's own imperative calls use. */
36
+ function soleApp() {
37
+ const apps = liveApps();
38
+ if (apps.length <= 1) return apps[0] ?? null;
39
+ const showing = apps.filter((app) => (app._rootChildren ?? []).length > 0);
40
+ return showing.length === 1 ? showing[0] : null;
41
+ }
42
+
43
+ /** The value a caller passed, read by an effect that must not re-run for it. */
44
+ function useLatest(value) {
45
+ const ref = useRef(value);
46
+ ref.current = value;
47
+ return ref;
48
+ }
49
+
50
+ /** A stable key for a button list, so an effect re-runs when one actually
51
+ * changed rather than on every render. Icons compare by identity — a caller
52
+ * holding its icons still is the fast path, and one that rebuilds them every
53
+ * render was going to re-upload them anyway. */
54
+ function signatureOf(buttons) {
55
+ if (!buttons) return '';
56
+ return buttons
57
+ .map(
58
+ (b) =>
59
+ `${b.id ?? ''}\u0000${b.tooltip ?? b.label ?? ''}\u0000` +
60
+ `${b.enabled === false ? 0 : 1}${b.dismissOnClick ? 1 : 0}`,
61
+ )
62
+ .join('\u0001');
63
+ }
64
+
65
+ /**
66
+ * Up to seven buttons under this window's taskbar hover preview — where a
67
+ * media player puts play and skip.
68
+ *
69
+ * `buttons` is `[{ id, tooltip, icon, enabled, dismissOnClick }]`, and `icon`
70
+ * is whatever `useTray` takes: an ntk `Image`, raw RGBA with a size, or a
71
+ * path. `null` takes the toolbar down as far as the shell allows, which is to
72
+ * hide the buttons — a toolbar cannot be removed once the window has one, and
73
+ * saying so is better than a call that looks like it worked.
74
+ *
75
+ * `onClick` is called with the button's own `id`.
76
+ *
77
+ * Does nothing where the backend has no toolbar. The eighth button and beyond
78
+ * are dropped rather than refused, because the shell refuses the whole call
79
+ * for an eighth and one silently missing button is a better outcome than a
80
+ * toolbar that never appears.
81
+ */
82
+ export function useThumbnailToolbar(buttons, onClick) {
83
+ const app = useAppOrNull();
84
+ const owner = useTopLevelWindow();
85
+ const handler = useLatest(onClick);
86
+ const latest = useLatest(buttons);
87
+ const signature = signatureOf(buttons);
88
+
89
+ useEffect(() => {
90
+ if (typeof app?.thumbnailToolbar !== 'function') return;
91
+ // Read inside the effect: `useTopLevelWindow` answers through a getter,
92
+ // so the window a tree is in is whatever it is when the effect runs
93
+ // rather than what it was at render.
94
+ const wnd = owner?.current?.window;
95
+ if (!wnd?.id) return;
96
+ app.thumbnailToolbar(wnd.id, latest.current ?? []);
97
+
98
+ const fire = (event) => handler.current?.(event.id, event);
99
+ wnd.on?.('thumbbutton', fire);
100
+ return () => {
101
+ wnd.off?.('thumbbutton', fire);
102
+ // Hidden rather than removed, which is all the shell offers.
103
+ app.thumbnailToolbar(wnd.id, []);
104
+ };
105
+ // `signature` is the dependency; the buttons themselves are read through
106
+ // a ref, so a new array holding the same buttons does not re-send them.
107
+ }, [app, owner, signature, latest, handler]);
108
+ }
109
+
110
+ /**
111
+ * The Tasks category of this application's jump list — the menu on a right
112
+ * click of its taskbar button.
113
+ *
114
+ * `tasks` is `[{ title, arguments, description }]`. Each one **relaunches
115
+ * this executable** with the arguments given, which is what a jump-list task
116
+ * is: the shell starts the program, it does not call back into the running
117
+ * one. An app that wants the running instance to answer needs the single
118
+ * instance path, which is not built (docs/windows-integrations.md) — so until
119
+ * then a task is for something the app can do from a cold start.
120
+ *
121
+ * `null` deletes the category.
122
+ */
123
+ export function useJumpList(tasks) {
124
+ const app = useAppOrNull();
125
+ const latest = useLatest(tasks);
126
+ // The tasks are plain data — a title, arguments, a description — so their
127
+ // own JSON is the dependency, and a caller rebuilding an equal array every
128
+ // render does not re-send it. Read through a ref for the same reason
129
+ // `useThumbnailToolbar` does: the value is what it is when the effect runs.
130
+ const signature = JSON.stringify(tasks ?? null);
131
+
132
+ useEffect(() => {
133
+ if (typeof app?.jumpList !== 'function') return;
134
+ app.jumpList(latest.current ?? []);
135
+ return () => app.jumpList([]);
136
+ }, [app, signature, latest]);
137
+ }
138
+
139
+ /**
140
+ * Note a document this app just opened, for the shell's Recent lists — the
141
+ * jump list's own Recent section, and Explorer's quick access.
142
+ *
143
+ * The same act as macOS's `noteNewRecentDocumentURL:`; it lives here rather
144
+ * than in a cross-platform hook because this is the only backend with one to
145
+ * call today. Where the file type is not associated with this application the
146
+ * shell may keep it and show it nowhere, which is its decision to make.
147
+ *
148
+ * `null` clears the list.
149
+ */
150
+ export function noteRecentDocument(path, { app } = {}) {
151
+ const target = app ?? soleApp();
152
+ if (typeof target?.noteRecentDocument !== 'function') return false;
153
+ target.noteRecentDocument(path);
154
+ return true;
155
+ }
156
+
157
+ /** The hook form: notes `path` whenever it changes. */
158
+ export function useRecentDocument(path) {
159
+ const app = useAppOrNull();
160
+ useEffect(() => {
161
+ if (typeof app?.noteRecentDocument !== 'function' || path == null) return;
162
+ app.noteRecentDocument(path);
163
+ }, [app, path]);
164
+ }
package/src/transfer.js CHANGED
@@ -70,6 +70,25 @@ export function decodeData(data, target) {
70
70
  * URIs that are actually local — a remote `file://host/...` has no local
71
71
  * path and must not pretend to.
72
72
  */
73
+ /**
74
+ * A `file:` URL's pathname as a path this machine can open.
75
+ *
76
+ * On a POSIX path the two are the same string. A Windows one is not: the URL
77
+ * form of `C:\Users\a` is `file:///C:/Users/a`, whose pathname is
78
+ * `/C:/Users/a` — a leading slash that no Windows API accepts, and forward
79
+ * slashes that most of them tolerate and no user recognises. A drive letter
80
+ * after the slash is the tell, and it is unambiguous: no POSIX path begins
81
+ * `/C:`.
82
+ *
83
+ * Decided by the shape of the path rather than by `process.platform`, so a
84
+ * uri-list that arrived from another machine reads the same way on both.
85
+ */
86
+ function pathOfFileUrl(pathname) {
87
+ const drive = /^\/([A-Za-z]:)(\/.*)?$/.exec(pathname);
88
+ if (!drive) return pathname;
89
+ return (drive[1] + (drive[2] ?? '\\')).replace(/\//g, '\\');
90
+ }
91
+
73
92
  export function parseUriList(text) {
74
93
  const files = [];
75
94
  for (const line of String(text).split(/\r?\n/)) {
@@ -82,7 +101,7 @@ export function parseUriList(text) {
82
101
  url.protocol === 'file:' &&
83
102
  (url.hostname === '' || url.hostname === 'localhost')
84
103
  ) {
85
- entry.path = decodeURIComponent(url.pathname);
104
+ entry.path = pathOfFileUrl(decodeURIComponent(url.pathname));
86
105
  }
87
106
  } catch {
88
107
  // not a parseable URI — keep the raw line, claim no path
package/src/trayhooks.js CHANGED
@@ -73,7 +73,7 @@ import { StatusNotifierItem, allocateItemSlot } from './statusnotifier.js';
73
73
  * ```
74
74
  *
75
75
  * With `menu`, a click opens it — the same `items` vocabulary `MenuBar` and
76
- * `useDockMenu` take, an item's `onSelect` firing when picked. Without one,
76
+ * `useLauncherMenu` take, an item's `onSelect` firing when picked. Without one,
77
77
  * `onClick` is called with the button and where the click was, in logical
78
78
  * screen pixels — with the item's rect, where the backend knows it. `null`
79
79
  * means no item. Every field follows its value while mounted; the item is
@@ -10,7 +10,13 @@ export type DesktopBackend =
10
10
  | 'osascript'
11
11
  | 'notify-send'
12
12
  | 'statusnotifier'
13
- | 'launcherentry';
13
+ | 'launcherentry'
14
+ /** A Shell_NotifyIcon balloon. */
15
+ | 'win32'
16
+ /** The notify icon itself, as a tray. */
17
+ | 'shellnotifyicon'
18
+ /** `ITaskbarList3` and the jump list, as a launcher. */
19
+ | 'taskbar';
14
20
 
15
21
  /** The capabilities {@link desktopCapability} can be asked about. */
16
22
  export type DesktopCapabilityName = 'notifications' | 'tray' | 'launcher';
@@ -60,14 +66,37 @@ export interface TrayFeatures {
60
66
 
61
67
  export interface LauncherFeatures {
62
68
  badge: boolean;
63
- /** A string badge. macOS only — the launcher protocol carries a count. */
69
+ /**
70
+ * A string badge rather than a count. False on the launcher protocol,
71
+ * which carries a number; the taskbar draws the text into its overlay
72
+ * icon, where about three glyphs fit before it becomes `99+`.
73
+ */
64
74
  badgeText: boolean;
65
75
  progress: boolean;
66
76
  urgent: boolean;
67
- /** The Dock menu / quicklist. */
77
+ /**
78
+ * The Dock menu / quicklist: entries that **call back into this process**.
79
+ * False on the taskbar, whose menu is the jump list — see `tasks`.
80
+ */
68
81
  menu: boolean;
69
82
  /** The launcher needs an installed `.desktop` file to attach this to. */
70
83
  needsDesktopFile: boolean;
84
+ /**
85
+ * Static entries on the icon's menu that start a **new process** with
86
+ * arguments, rather than calling back into this one: the jump list's Tasks
87
+ * category. A different feature from `menu`, and `useJumpList` drives it.
88
+ */
89
+ tasks: boolean;
90
+ /**
91
+ * Buttons under the icon's hover preview, which `useThumbnailToolbar`
92
+ * drives. The taskbar's alone.
93
+ */
94
+ thumbnailToolbar: boolean;
95
+ /**
96
+ * The launcher keeps a Recent list this app can add to, through
97
+ * `useRecentDocument`.
98
+ */
99
+ recentDocuments: boolean;
71
100
  }
72
101
 
73
102
  export interface DesktopCapabilityResult<F = Record<string, boolean>> {
@@ -371,7 +371,29 @@ export interface WindowProps
371
371
  y?: number;
372
372
  /** Palette that `$token` style values resolve against, for this subtree. */
373
373
  theme?: Record<string, string | number>;
374
- /** ICCCM `WM_CLASS`. */
374
+ /**
375
+ * The desktop identity of this window — which application it belongs to,
376
+ * and so which launcher icon it groups under and which `.desktop` entry a
377
+ * launcher matches it to.
378
+ *
379
+ * One name for what every desktop calls something else: ICCCM `WM_CLASS` on
380
+ * X11, `xdg_toplevel.set_app_id` on Wayland, the AppUserModelID on Windows.
381
+ * Normally the same string as `registerApplication({ appId })`, which is
382
+ * what a launcher matches against.
383
+ *
384
+ * A string is the modern single-id form. X11's instance/class pair is still
385
+ * accepted and passed through on that backend; every other backend takes
386
+ * the class, which is the part naming the application.
387
+ *
388
+ * Honoured on X11, on Windows — where it is the window's AppUserModelID,
389
+ * and where the jump list is attached to the same id — and, for windows
390
+ * opened after it is set, on Wayland, whose `app_id` is fixed when the
391
+ * surface is created. The cocoa backend accepts it and does nothing with
392
+ * it: macOS identity is the bundle's, decided at build time.
393
+ */
394
+ appId?: string | [string, string] | { instance: string; class?: string };
395
+ /** @deprecated Renamed to {@link WindowProps.appId} — `wmClass` is X11's
396
+ * word for an identity every desktop has. Still accepted. */
375
397
  wmClass?: string | [string, string] | { instance: string; class?: string };
376
398
  /** EWMH `_NET_WM_WINDOW_TYPE`, or a list of fallbacks. */
377
399
  windowType?: WindowType | WindowType[];
@@ -39,6 +39,22 @@ export interface SyntheticEvent<T = DrawnNode> {
39
39
  * what a node's `abs` is in (docs/scale.md). */
40
40
  x: number;
41
41
  y: number;
42
+ /**
43
+ * Where the pointer is on the **virtual screen**, in the same logical
44
+ * pixels `x`/`y` are in — what to reach for when placing something outside
45
+ * the window, such as a context menu at the pointer.
46
+ *
47
+ * Present exactly where the backend reported a position. That is most
48
+ * events, including keys on X11, whose KeyPress carries where the pointer
49
+ * was; it is undefined rather than `0` where a backend reported none, since
50
+ * zero is the screen's top-left corner and not an absence.
51
+ *
52
+ * `nativeEvent.rootx`/`rooty` is X11's name for the same point and is still
53
+ * there, in *device* pixels — the same split as `x` against
54
+ * `nativeEvent.x`.
55
+ */
56
+ screenX?: number;
57
+ screenY?: number;
42
58
  /** Coordinates relative to `target`'s box. */
43
59
  localX: number;
44
60
  localY: number;
@@ -35,17 +35,23 @@ export declare function setBadge(
35
35
  export declare function useBadge(value: BadgeValue): void;
36
36
 
37
37
  /**
38
- * The menu behind a right-click on the app's icon in the Dock or launcher,
39
- * from the same item vocabulary `MenuBar` takes; an item's `onSelect` fires
40
- * when picked. Installed while mounted, replaced when `items` changes, taken
41
- * down on unmount.
38
+ * The menu behind a right-click on the app's **launcher icon** the Dock on
39
+ * macOS, the launcher on Linux — from the same item vocabulary `MenuBar`
40
+ * takes; an item's `onSelect` fires when picked. Installed while mounted,
41
+ * replaced when `items` changes, taken down on unmount.
42
42
  *
43
43
  * `NSDockTile`'s menu on the cocoa backend; the launcher protocol's
44
44
  * **quicklist** on Linux — a `com.canonical.dbusmenu` tree, the same menu
45
45
  * protocol the tray and the global menu speak. Needs the identity
46
46
  * `registerApplication({ appId })` establishes and a `.desktop` file of that
47
47
  * name, like the badge.
48
+ *
49
+ * Reads `useDesktopCapability('launcher').features.menu`.
48
50
  */
51
+ export declare function useLauncherMenu(items: MenuItem[] | null): void;
52
+
53
+ /** @deprecated Renamed to {@link useLauncherMenu} — "Dock" is one desktop's
54
+ * word for the icon every desktop has. Still exported and still works. */
49
55
  export declare function useDockMenu(items: MenuItem[] | null): void;
50
56
 
51
57
  /**
@@ -80,9 +86,17 @@ export declare function setUrgent(
80
86
  ): Promise<boolean>;
81
87
 
82
88
  /**
83
- * {@link useDockMenu}'s imperative twin, for code with no component. `null`
84
- * takes the menu down.
89
+ * {@link useLauncherMenu}'s imperative twin, for code with no component.
90
+ * `null` takes the menu down.
85
91
  */
92
+ export declare function setLauncherMenu(
93
+ items: MenuItem[] | null,
94
+ options?: SetBadgeOptions,
95
+ ): Promise<boolean>;
96
+
97
+ /** @deprecated Renamed to {@link setLauncherMenu} — "quicklist" is the Unity
98
+ * launcher's word for the menu macOS calls the Dock menu, and this drove
99
+ * both all along. Still exported and still works. */
86
100
  export declare function setQuicklist(
87
101
  items: MenuItem[] | null,
88
102
  options?: SetBadgeOptions,
@@ -0,0 +1,79 @@
1
+ /**
2
+ * The Windows taskbar's own surfaces. See docs/windows-integrations.md.
3
+ *
4
+ * Three things the taskbar has that no other desktop does, so none of them is
5
+ * a rung on an existing ladder. They are reported as features of the
6
+ * **launcher** — `useDesktopCapability('launcher').features.thumbnailToolbar`
7
+ * and its two siblings — because all of them hang off the one icon the
8
+ * desktop shows for this app, beside the badge and the progress bar. The
9
+ * hooks do nothing where the backend has none, so they are safe to call
10
+ * unconditionally and an app needs no platform check.
11
+ */
12
+
13
+ /**
14
+ * An icon for a toolbar button: raw RGBA with its size, an ntk `Image`, or a
15
+ * path to a file. The shell tints it for the theme, so the shape is the whole
16
+ * of it and a white glyph on transparent is the usual choice.
17
+ */
18
+ export type TaskbarIcon =
19
+ | string
20
+ | { data: Uint8Array; width: number; height: number }
21
+ | { width: number; height: number };
22
+
23
+ export interface ThumbnailToolbarButton {
24
+ /** What a click is reported as. Not the shell's index. */
25
+ id: string;
26
+ /** The hover tooltip; `label` is accepted as a synonym. */
27
+ tooltip?: string;
28
+ label?: string;
29
+ icon?: TaskbarIcon | null;
30
+ /** Default true. A disabled button is shown greyed rather than hidden. */
31
+ enabled?: boolean;
32
+ /** Close the hover preview when this one is clicked. */
33
+ dismissOnClick?: boolean;
34
+ }
35
+
36
+ /**
37
+ * Up to seven buttons under this window's taskbar hover preview — where a
38
+ * media player puts play and skip. `null` hides them, which is as far down as
39
+ * the shell allows: a window that has had a toolbar keeps one.
40
+ *
41
+ * The eighth button and beyond are dropped rather than refused, because the
42
+ * shell refuses the whole call for an eighth.
43
+ */
44
+ export declare function useThumbnailToolbar(
45
+ buttons: readonly ThumbnailToolbarButton[] | null | undefined,
46
+ onClick?: (id: string, event: unknown) => void,
47
+ ): void;
48
+
49
+ export interface JumpListTask {
50
+ title: string;
51
+ /** Passed to a **new** process; nothing calls back into this one. */
52
+ arguments?: string;
53
+ description?: string;
54
+ }
55
+
56
+ /**
57
+ * The Tasks category of this application's jump list — the menu on a right
58
+ * click of its taskbar button. `null` deletes the category.
59
+ *
60
+ * Each entry **relaunches this executable** with the arguments given, which
61
+ * is what a jump-list task is. That is why this is not `useLauncherMenu`, whose
62
+ * items carry a callback: reported as `features.tasks` rather than
63
+ * `features.menu`, so an app cannot mistake one for the other.
64
+ */
65
+ export declare function useJumpList(
66
+ tasks: readonly JumpListTask[] | null | undefined,
67
+ ): void;
68
+
69
+ /** Notes `path` for the shell's Recent lists whenever it changes. */
70
+ export declare function useRecentDocument(path?: string | null): void;
71
+
72
+ /**
73
+ * The imperative form of {@link useRecentDocument}. Returns false where the
74
+ * backend has no Recent list, rather than throwing.
75
+ */
76
+ export declare function noteRecentDocument(
77
+ path: string | null,
78
+ options?: { app?: unknown },
79
+ ): boolean;
@@ -206,7 +206,7 @@ function scaleOf(m) {
206
206
 
207
207
  /**
208
208
  * The Render ops a `drawGlyphs` call can name, numbered as XRender numbers
209
- * them — the same table the Cocoa backend answers (`src/cocoa/context2d.js`),
209
+ * them — the same table the native backends answer (`src/backend/context2d.js`),
210
210
  * so `ctx.Render.PictOp.Over` reads the same on every backend. The op is
211
211
  * ignored here: text composites Over, and for the opaque inks text uses Src
212
212
  * and Over agree.