@liberation-data/desk 0.43.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.
- package/README.md +225 -8
- package/dist/core/hosted.d.ts +222 -0
- package/dist/core/hosted.d.ts.map +1 -0
- package/dist/core/hosted.js +166 -0
- package/dist/core/hosted.js.map +1 -0
- package/dist/core/index.d.ts +9 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +5 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/location.d.ts +8 -1
- package/dist/core/location.d.ts.map +1 -1
- package/dist/core/location.js +18 -2
- package/dist/core/location.js.map +1 -1
- package/dist/core/preferences.d.ts +27 -0
- package/dist/core/preferences.d.ts.map +1 -0
- package/dist/core/preferences.js +121 -0
- package/dist/core/preferences.js.map +1 -0
- package/dist/core/scheme.d.ts +9 -3
- package/dist/core/scheme.d.ts.map +1 -1
- package/dist/core/scheme.js +13 -4
- package/dist/core/scheme.js.map +1 -1
- package/dist/core/theme.d.ts +41 -0
- package/dist/core/theme.d.ts.map +1 -0
- package/dist/core/theme.js +56 -0
- package/dist/core/theme.js.map +1 -0
- package/dist/core/themeChange.d.ts +25 -0
- package/dist/core/themeChange.d.ts.map +1 -0
- package/dist/core/themeChange.js +49 -0
- package/dist/core/themeChange.js.map +1 -0
- package/dist/css/apps.css +35 -1
- package/dist/css/shell.css +100 -0
- package/dist/css/tokens.css +10 -0
- package/dist/desk.css +45 -1
- package/dist/fx/fx.d.ts.map +1 -1
- package/dist/fx/fx.js +7 -31
- package/dist/fx/fx.js.map +1 -1
- package/dist/host/checkChrome.d.ts +20 -0
- package/dist/host/checkChrome.d.ts.map +1 -0
- package/dist/host/checkChrome.js +219 -0
- package/dist/host/checkChrome.js.map +1 -0
- package/dist/host/checkTheme.d.ts +35 -0
- package/dist/host/checkTheme.d.ts.map +1 -0
- package/dist/host/checkTheme.js +128 -0
- package/dist/host/checkTheme.js.map +1 -0
- package/dist/host/index.d.ts +7 -0
- package/dist/host/index.d.ts.map +1 -0
- package/dist/host/index.js +8 -0
- package/dist/host/index.js.map +1 -0
- package/dist/host/router.d.ts +99 -0
- package/dist/host/router.d.ts.map +1 -0
- package/dist/host/router.js +279 -0
- package/dist/host/router.js.map +1 -0
- package/dist/react/Dock.d.ts +23 -4
- package/dist/react/Dock.d.ts.map +1 -1
- package/dist/react/Dock.js +17 -29
- package/dist/react/Dock.js.map +1 -1
- package/dist/react/MenuBar.d.ts +1 -1
- package/dist/react/MenuBar.d.ts.map +1 -1
- package/dist/react/MenuBar.js +20 -4
- package/dist/react/MenuBar.js.map +1 -1
- package/dist/react/app.d.ts +50 -9
- package/dist/react/app.d.ts.map +1 -1
- package/dist/react/app.js +59 -13
- package/dist/react/app.js.map +1 -1
- package/dist/react/appFrame.d.ts +11 -7
- package/dist/react/appFrame.d.ts.map +1 -1
- package/dist/react/appFrame.js +24 -6
- package/dist/react/appFrame.js.map +1 -1
- package/dist/react/appPanels.d.ts +4 -1
- package/dist/react/appPanels.d.ts.map +1 -1
- package/dist/react/appPanels.js +32 -23
- package/dist/react/appPanels.js.map +1 -1
- package/dist/react/appearance.d.ts +7 -1
- package/dist/react/appearance.d.ts.map +1 -1
- package/dist/react/appearance.js +32 -53
- package/dist/react/appearance.js.map +1 -1
- package/dist/react/context.d.ts +15 -1
- package/dist/react/context.d.ts.map +1 -1
- package/dist/react/context.js +73 -14
- package/dist/react/context.js.map +1 -1
- package/dist/react/dockStatus.d.ts +19 -0
- package/dist/react/dockStatus.d.ts.map +1 -0
- package/dist/react/dockStatus.js +25 -0
- package/dist/react/dockStatus.js.map +1 -0
- package/dist/react/frameMenus.d.ts +28 -0
- package/dist/react/frameMenus.d.ts.map +1 -0
- package/dist/react/frameMenus.js +85 -0
- package/dist/react/frameMenus.js.map +1 -0
- package/dist/react/hostApp.d.ts +15 -0
- package/dist/react/hostApp.d.ts.map +1 -0
- package/dist/react/hostApp.js +77 -0
- package/dist/react/hostApp.js.map +1 -0
- package/dist/react/hostDock.d.ts +25 -0
- package/dist/react/hostDock.d.ts.map +1 -0
- package/dist/react/hostDock.js +98 -0
- package/dist/react/hostDock.js.map +1 -0
- package/dist/react/hostMenu.d.ts +2 -36
- package/dist/react/hostMenu.d.ts.map +1 -1
- package/dist/react/hostMenu.js.map +1 -1
- package/dist/react/hosted.d.ts +28 -0
- package/dist/react/hosted.d.ts.map +1 -0
- package/dist/react/hosted.js +53 -0
- package/dist/react/hosted.js.map +1 -0
- package/dist/react/index.d.ts +8 -3
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +5 -2
- package/dist/react/index.js.map +1 -1
- package/dist/react/shell.d.ts +13 -1
- package/dist/react/shell.d.ts.map +1 -1
- package/dist/react/shell.js +19 -3
- package/dist/react/shell.js.map +1 -1
- package/dist/react/windowMenus.d.ts +19 -0
- package/dist/react/windowMenus.d.ts.map +1 -0
- package/dist/react/windowMenus.js +88 -0
- package/dist/react/windowMenus.js.map +1 -0
- package/dist/shell/HostShell.d.ts +53 -0
- package/dist/shell/HostShell.d.ts.map +1 -0
- package/dist/shell/HostShell.js +116 -0
- package/dist/shell/HostShell.js.map +1 -0
- package/dist/shell/index.d.ts +7 -0
- package/dist/shell/index.d.ts.map +1 -0
- package/dist/shell/index.js +9 -0
- package/dist/shell/index.js.map +1 -0
- package/dist/shell/keys.d.ts +47 -0
- package/dist/shell/keys.d.ts.map +1 -0
- package/dist/shell/keys.js +68 -0
- package/dist/shell/keys.js.map +1 -0
- package/dist/shell/motion.d.ts +72 -0
- package/dist/shell/motion.d.ts.map +1 -0
- package/dist/shell/motion.js +118 -0
- package/dist/shell/motion.js.map +1 -0
- package/llms.txt +48 -14
- package/package.json +10 -1
- package/src/core/hosted.ts +351 -0
- package/src/core/index.ts +28 -1
- package/src/core/location.ts +23 -3
- package/src/core/preferences.ts +132 -0
- package/src/core/scheme.ts +16 -5
- package/src/core/theme.ts +91 -0
- package/src/core/themeChange.ts +59 -0
- package/src/css/apps.css +35 -1
- package/src/css/shell.css +99 -0
- package/src/css/tokens.css +10 -0
- package/src/fx/fx.ts +7 -25
- package/src/host/checkChrome.ts +257 -0
- package/src/host/checkTheme.ts +134 -0
- package/src/host/index.ts +10 -0
- package/src/host/router.ts +374 -0
- package/src/react/Dock.tsx +34 -28
- package/src/react/MenuBar.tsx +22 -4
- package/src/react/app.tsx +84 -14
- package/src/react/appFrame.tsx +39 -14
- package/src/react/appPanels.tsx +38 -25
- package/src/react/appearance.tsx +36 -45
- package/src/react/context.tsx +88 -13
- package/src/react/dockStatus.ts +42 -0
- package/src/react/frameMenus.ts +100 -0
- package/src/react/hostApp.tsx +89 -0
- package/src/react/hostDock.tsx +118 -0
- package/src/react/hostMenu.ts +3 -38
- package/src/react/hosted.tsx +65 -0
- package/src/react/index.ts +9 -2
- package/src/react/shell.tsx +30 -3
- package/src/react/windowMenus.ts +107 -0
- package/src/shell/HostShell.tsx +220 -0
- package/src/shell/index.ts +11 -0
- package/src/shell/keys.ts +101 -0
- package/src/shell/motion.ts +163 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/** How a switch is drawn: the desktops slide, or (reduced motion) the arriving one fades in over the other. */
|
|
2
|
+
export interface SlidePlan {
|
|
3
|
+
readonly kind: 'slide' | 'fade';
|
|
4
|
+
readonly durationMs: number;
|
|
5
|
+
}
|
|
6
|
+
/** The default slide, and the short fade that replaces it under reduced motion. */
|
|
7
|
+
export declare const SLIDE_MS = 350;
|
|
8
|
+
export declare const FADE_MS = 120;
|
|
9
|
+
/** What a switch should do, given whether the person asked for less motion. */
|
|
10
|
+
export declare const slidePlan: (reducedMotion: boolean, durationMs?: number) => SlidePlan;
|
|
11
|
+
/**
|
|
12
|
+
* A critically damped spring towards 1, from `from` with a starting speed `velocity` (progress per
|
|
13
|
+
* second), stiff enough to settle within `durationMs`. Returns the progress at a time in milliseconds
|
|
14
|
+
* since it started: exactly 1 from `durationMs` on.
|
|
15
|
+
*/
|
|
16
|
+
export declare function spring(durationMs?: number, from?: number, velocity?: number): (elapsedMs: number) => number;
|
|
17
|
+
/** A plain linear ramp, for the fade: opacity follows time evenly. */
|
|
18
|
+
export declare const linear: (durationMs: number) => (elapsedMs: number) => number;
|
|
19
|
+
/** Where the two desktops sit at a given progress, in whole pixels from the desktop area's left edge. */
|
|
20
|
+
export interface SlideOffsets {
|
|
21
|
+
/** The workspace being left. */
|
|
22
|
+
readonly leaving: number;
|
|
23
|
+
/** The workspace arriving. */
|
|
24
|
+
readonly arriving: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The desktops' offsets at `progress`. Moving to a workspace further along (`direction` 1) the one
|
|
28
|
+
* being left goes out to the left and the next comes in from the right; back (`-1`), the other way.
|
|
29
|
+
* Rounded to whole pixels, as a view's bounds are, and with no gap or overlap between the two.
|
|
30
|
+
*
|
|
31
|
+
* Mid-slide both views reach past the desktop area, so the host must clip them to it (the area
|
|
32
|
+
* `onInsets` gives): a view placed at these offsets with nothing clipping it covers the dock beside.
|
|
33
|
+
*/
|
|
34
|
+
export declare function slideOffsets(progress: number, direction: 1 | -1, width: number): SlideOffsets;
|
|
35
|
+
/** What `animate` needs to schedule frames: rAF in a page, a timer in a main process. */
|
|
36
|
+
export interface FrameClock {
|
|
37
|
+
readonly now: () => number;
|
|
38
|
+
/** Calls back on the next frame. */
|
|
39
|
+
readonly frame: (callback: () => void) => void;
|
|
40
|
+
/** Calls back after a delay, whatever the frames do. */
|
|
41
|
+
readonly after: (ms: number, callback: () => void) => void;
|
|
42
|
+
}
|
|
43
|
+
/** A clock for a page: frames from requestAnimationFrame, which a hidden page never gives. */
|
|
44
|
+
export declare const pageClock: () => FrameClock;
|
|
45
|
+
/** A clock for a process with no frames of its own, as an app host's main process: about 60 a second. */
|
|
46
|
+
export declare const timerClock: (frameMs?: number) => FrameClock;
|
|
47
|
+
export interface AnimateOptions {
|
|
48
|
+
readonly durationMs: number;
|
|
49
|
+
/** The curve: progress at a time; `spring(durationMs)` by default. */
|
|
50
|
+
readonly curve?: (elapsedMs: number) => number;
|
|
51
|
+
/** Called with each frame's progress, and finally with 1. */
|
|
52
|
+
readonly step: (progress: number) => void;
|
|
53
|
+
readonly clock?: FrameClock;
|
|
54
|
+
/**
|
|
55
|
+
* How long past `durationMs` to wait for frames before jumping to the end. A window that is covered,
|
|
56
|
+
* minimised or on another desktop gets no frames, and an animation must never hang on them.
|
|
57
|
+
*/
|
|
58
|
+
readonly timeoutMs?: number;
|
|
59
|
+
}
|
|
60
|
+
/** A running animation. `stop` leaves it where it is; `done` resolves at the end, or when stopped. */
|
|
61
|
+
export interface Animation {
|
|
62
|
+
readonly done: Promise<'finished' | 'jumped' | 'stopped'>;
|
|
63
|
+
/** Where it is now, for a gesture that catches it mid-flight. */
|
|
64
|
+
progress(): number;
|
|
65
|
+
stop(): void;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Steps `step` through a curve, frame by frame, from any clock. Ends at 1 when time is up, and jumps
|
|
69
|
+
* straight there if frames stop arriving for `timeoutMs`.
|
|
70
|
+
*/
|
|
71
|
+
export declare function animate({ durationMs, curve, step, clock, timeoutMs }: AnimateOptions): Animation;
|
|
72
|
+
//# sourceMappingURL=motion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"motion.d.ts","sourceRoot":"","sources":["../../src/shell/motion.ts"],"names":[],"mappings":"AAaA,+GAA+G;AAC/G,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAAA;IAC/B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAC5B;AAED,mFAAmF;AACnF,eAAO,MAAM,QAAQ,MAAM,CAAA;AAC3B,eAAO,MAAM,OAAO,MAAM,CAAA;AAE1B,+EAA+E;AAC/E,eAAO,MAAM,SAAS,kBAAmB,OAAO,0BAA0B,SACa,CAAA;AAKvF;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,UAAU,SAAW,EAAE,IAAI,SAAI,E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,SAAS,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED,sGAAsG;AACtG,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,GAAG,QAAQ,GAAG,SAAS,CAAC,CAAA;IACzD,iEAAiE;IACjE,QAAQ,IAAI,MAAM,CAAA;IAClB,IAAI,IAAI,IAAI,CAAA;CACb;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,EAAE,UAAU,EAAE,KAA0B,EAAE,IAAI,EAAE,KAAmB,EAAE,SAAe,EAAE,EAAE,cAAc,GAAG,SAAS,CA8BzI"}
|
|
@@ -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
|
+
}
|
|
118
|
+
//# sourceMappingURL=motion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"motion.js","sourceRoot":"","sources":["../../src/shell/motion.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAQH,mFAAmF;AACnF,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,CAAA;AAC3B,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,CAAA;AAE1B,+EAA+E;AAC/E,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,aAAsB,EAAE,UAAU,GAAG,QAAQ,EAAa,EAAE,CACpF,aAAa,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,CAAA;AAEvF,+FAA+F;AAC/F,MAAM,OAAO,GAAG,OAAO,CAAA;AAEvB;;;;GAIG;AACH,MAAM,UAAU,MAAM,CAAC,UAAU,GAAG,QAAQ,EAAE,IAAI,GAAG,CAAC,EAAE,QAAQ,GAAG,CAA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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,7 +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
|
|
180
|
+
COLOR_SCHEME_KEY; LOOK_KEY; COLOR_SCHEME_SCRIPT; colorSchemeScript(default?) // Appearance's storage keys and <head> script; see Settings and About
|
|
181
181
|
isInstalledApp(): boolean // gate ⌘W / ⌘` on this; never take ⌘T or ⌘N
|
|
182
182
|
titleCase('ride card'): string // 'Ride Card' — app and window names; a document keeps its own name
|
|
183
183
|
isTitleCase(name): boolean // for a test over the names an app defines
|
|
@@ -348,7 +348,7 @@ explanation only — never a warning, which belongs in front of people.
|
|
|
348
348
|
```tsx
|
|
349
349
|
<Dock entries={DockEntry[]} label?="Dock" placement?={'overlay' | 'inline'} side?={'left' | 'right' | 'bottom'}
|
|
350
350
|
pins?={{ accepts, onPin: (drag, before: id | null) => void, onMove?: (id, before: id | null) => void }} />
|
|
351
|
-
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
|
|
352
352
|
dockStack({ id, label, items: DockItem[], icon?, contextMenu?: () => MenuItem[], movable? })
|
|
353
353
|
dockSeparator(id)
|
|
354
354
|
```
|
|
@@ -371,6 +371,29 @@ interface HostMenu { id; label; primary?; status?; items: { type: 'item'|'separa
|
|
|
371
371
|
// Republished on render and focus move only; a choice is re-checked before it runs.
|
|
372
372
|
hostMenuModel(menus, status, canPerform): { model: HostMenu[]; run: Map<id, MenuItem> } // the same data, for a host built by hand
|
|
373
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".
|
|
374
397
|
interface Menu { id: string; label: string; title?: ReactNode; emphasis?: boolean; items: MenuItem[] | (() => MenuItem[]) }
|
|
375
398
|
// emphasis: the app's own menu, its name in bold, conventionally first
|
|
376
399
|
menuCommand(label, command, { shortcut?, checked?, detail?, args? })
|
|
@@ -397,26 +420,33 @@ would. `items` as a function is re-read on every open.
|
|
|
397
420
|
|
|
398
421
|
```tsx
|
|
399
422
|
<DeskShell app={DeskApp}> // or DeskProvider app={…}; read on every render, so it may change
|
|
400
|
-
interface DeskApp { name; icon?; version?; description?; links?: { label, url }[]; legal?;
|
|
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
|
|
401
424
|
note?: ReactNode; // a line under the links, not copied
|
|
402
425
|
facts?: () => AboutSection[] | null; // a HOOK, called inside the About panel; null = still reading, [] = nothing, no Copy
|
|
403
426
|
settings?: AppSettings } // leave out: no gear, no "Settings…", no ⌘,
|
|
404
|
-
interface AboutSection { title?; facts: { name; value: string; note?: ReactNode; link?: { label, url }; copy?: false }[] } // copy:false = shown, not copied; note and link never copied
|
|
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
|
|
405
428
|
interface AppSettings { sections?: SettingsSection[]; layout?: 'panel' | 'sidebar'; badge?: ReactNode;
|
|
406
429
|
open?: (route?: string) => void } // open: the app's own Settings window; Desk draws none
|
|
407
430
|
interface SettingsSection { id; title; group?; icon?; badge?; content: ReactNode } // id = the route of `settings`
|
|
408
|
-
// AppSettings.appearance?: true | { scheme?; look?; sounds?: Fx; soundsDescription?; theme?: ReactNode } // Desk's first section
|
|
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
|
|
409
433
|
// DeskApp.themeFromHost?: boolean // receives its theme from a host: no scheme/look/theme rows (sounds stay); default: found from the bridge
|
|
410
|
-
useColorScheme(): 'system'|'light'|'dark'; colorScheme(); setColorScheme(s) //
|
|
411
|
-
useLookChoice(): LookChoice | null; lookChoice(); setLookChoice(l) //
|
|
412
|
-
COLOR_SCHEME_SCRIPT; COLOR_SCHEME_KEY = 'desk.scheme'; LOOK_KEY = 'desk.look' // also from the core entry (no React)
|
|
413
|
-
// script: for <head>, the remembered scheme before first paint; keys: for migrations
|
|
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
|
|
414
442
|
<AppearanceSettings rows look /> // the rows, for an app's own Settings window
|
|
415
|
-
dockSettings()
|
|
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
|
|
416
445
|
SETTINGS_WINDOW = 'settings'; ABOUT_WINDOW = 'about'; SettingsCommand = 'desk.settings'; SYSTEM_GROUP = 'system'
|
|
417
446
|
PANEL_LIMITS; SIDEBAR_LIMITS // the windows' sizes (the panel fits its content); Desktop `limits` for those ids overrides
|
|
418
447
|
openAbout(desk) // About as the dock opens it: a centred panel, or forward where it is
|
|
419
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
|
|
420
450
|
appWindowTitle(app, id): string | null // 'Settings' / 'About' for Desk's windows, for a Window menu's title function
|
|
421
451
|
<AboutContent />; <SettingsContent />; aboutText(app, sections): string
|
|
422
452
|
useDeskApp(): DeskApp | null
|
|
@@ -431,6 +461,7 @@ open panel where it is. ⌘, is bound by the provider on the command, so it work
|
|
|
431
461
|
shows it. A `host` menu bar gets the same items through the same publish; the host owns ⌘, while it is up.
|
|
432
462
|
With facts, About has Copy: name + version, then each section's copyable facts. Never put credentials in facts.
|
|
433
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.
|
|
434
465
|
|
|
435
466
|
### Commands and input
|
|
436
467
|
|
|
@@ -483,7 +514,7 @@ useServiceValue(service): T // the value, live, without
|
|
|
483
514
|
### Generated apps
|
|
484
515
|
|
|
485
516
|
```tsx
|
|
486
|
-
<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}
|
|
487
518
|
theme?={{ mode: 'light'|'dark', tokens: Record<string,string> }}
|
|
488
519
|
sandbox?="allow-scripts allow-forms" />
|
|
489
520
|
// theme: sent with hello and again on change; the bridge sets the tokens as custom properties on the
|
|
@@ -493,7 +524,7 @@ APP_BRIDGE_SCRIPT // the same script, to include some other w
|
|
|
493
524
|
```
|
|
494
525
|
|
|
495
526
|
Inside the page: `desk.on(topic, message => …)`, `desk.onDrop(message => …)`, `desk.publish(topic, payload)`,
|
|
496
|
-
`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
|
|
497
528
|
from its own frame, drops publishes outside `says` and opens outside `opens`, never echoes an app its own
|
|
498
529
|
events, and sets the frame's `pointer-events: none` while a drag is in the air so drops reach it.
|
|
499
530
|
|
|
@@ -667,8 +698,11 @@ Every value reads a `--desk-*` token; redefine tokens, never override selectors.
|
|
|
667
698
|
`--desk-ease`, `--desk-dock-size`, `--desk-dock-glass`, `--desk-dock-offset`, `--desk-dock-room`,
|
|
668
699
|
`--desk-widget-width`, `--desk-inset-bottom`, `--desk-wizard-height`, `--desk-field-gap`. Code colours (`CodeBlock`, on `--desk-page`):
|
|
669
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.
|
|
670
704
|
|
|
671
|
-
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
|
|
672
706
|
`data-look="mac" | "gnome" | "windows"` on the root, set by the desk; don't set it yourself — pass `look`.
|
|
673
707
|
|
|
674
708
|
## Sounds: `@liberation-data/desk/fx`
|
|
@@ -711,7 +745,7 @@ in the accessibility tree.
|
|
|
711
745
|
- A `DeskProvider` already carries an event bus; `BusProvider` is only for supplying or sharing one.
|
|
712
746
|
- `renderWindow` must be stable (module scope or `useCallback`) for the memoisation to hold.
|
|
713
747
|
- `parse`/`syncWithLocation` warn once when no `isKnown` is given: unknown ids from a URL are then trusted.
|
|
714
|
-
- `npm run size` enforces a gzipped
|
|
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.
|
|
715
749
|
- `fx.play` never resumes audio itself: outside a press a browser's resume may never settle. Call
|
|
716
750
|
`fx.unlock()` at startup, or nothing sounds until a press after the sound was due.
|
|
717
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.
|
|
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"
|