@liberation-data/desk 0.43.0 → 0.45.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 +238 -10
- package/dist/core/desk.d.ts +2 -0
- package/dist/core/desk.d.ts.map +1 -1
- package/dist/core/desk.js +11 -2
- package/dist/core/desk.js.map +1 -1
- 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/core/types.d.ts +5 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/css/apps.css +52 -1
- package/dist/css/shell.css +100 -0
- package/dist/css/tokens.css +10 -0
- package/dist/css/windows.css +28 -0
- package/dist/desk.css +90 -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/Desktop.d.ts.map +1 -1
- package/dist/react/Desktop.js +11 -14
- package/dist/react/Desktop.js.map +1 -1
- 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 +65 -12
- package/dist/react/app.d.ts.map +1 -1
- package/dist/react/app.js +79 -21
- 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 +76 -28
- 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 +25 -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 +10 -5
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +6 -3
- package/dist/react/index.js.map +1 -1
- package/dist/react/mediaQuery.d.ts +3 -0
- package/dist/react/mediaQuery.d.ts.map +1 -0
- package/dist/react/mediaQuery.js +11 -0
- package/dist/react/mediaQuery.js.map +1 -0
- 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/sidebar.d.ts +6 -1
- package/dist/react/sidebar.d.ts.map +1 -1
- package/dist/react/sidebar.js +6 -3
- package/dist/react/sidebar.js.map +1 -1
- package/dist/react/windowDescription.d.ts +7 -0
- package/dist/react/windowDescription.d.ts.map +1 -1
- package/dist/react/windowDescription.js +9 -0
- package/dist/react/windowDescription.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 +57 -20
- package/package.json +10 -1
- package/src/core/desk.ts +11 -2
- 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/core/types.ts +5 -0
- package/src/css/apps.css +52 -1
- package/src/css/shell.css +99 -0
- package/src/css/tokens.css +10 -0
- package/src/css/windows.css +28 -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/Desktop.tsx +16 -21
- package/src/react/Dock.tsx +34 -28
- package/src/react/MenuBar.tsx +22 -4
- package/src/react/app.tsx +116 -22
- package/src/react/appFrame.tsx +39 -14
- package/src/react/appPanels.tsx +102 -31
- package/src/react/appearance.tsx +36 -45
- package/src/react/context.tsx +99 -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 +12 -4
- package/src/react/mediaQuery.ts +18 -0
- package/src/react/shell.tsx +30 -3
- package/src/react/sidebar.tsx +10 -3
- package/src/react/windowDescription.ts +12 -1
- 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,116 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
3
|
+
import { applyTheme } from '../core/theme.js';
|
|
4
|
+
import { DeskProvider } from '../react/context.js';
|
|
5
|
+
import { Dock, roveFocus } from '../react/Dock.js';
|
|
6
|
+
import { neighbour, platformOf, switchKeyAction, switchKeys } from './keys.js';
|
|
7
|
+
const imageIcon = (label, image) => image ? _jsx("img", { src: image, alt: "", draggable: false }) : _jsx("span", { className: "desk-shell-initial", children: label.slice(0, 1).toUpperCase() });
|
|
8
|
+
/** An app's dock entries, as data, turned back into entries the drawn dock draws; choosing one asks the host. */
|
|
9
|
+
export function dockFromHost(entries, choose) {
|
|
10
|
+
const item = (entry) => ({
|
|
11
|
+
id: entry.id,
|
|
12
|
+
label: entry.label,
|
|
13
|
+
icon: imageIcon(entry.label, entry.image),
|
|
14
|
+
...(entry.description === undefined ? {} : { description: entry.description }),
|
|
15
|
+
...(entry.badge === undefined ? {} : { badge: entry.badge === '' ? _jsx("span", { className: "desk-shell-dot" }) : entry.badge }),
|
|
16
|
+
...(entry.disabled ? { disabled: true } : {}),
|
|
17
|
+
status: { running: entry.running, focused: entry.focused, minimized: entry.minimized },
|
|
18
|
+
onSelect: () => choose(entry.id),
|
|
19
|
+
});
|
|
20
|
+
return entries.map((entry) => {
|
|
21
|
+
if (entry.type === 'separator')
|
|
22
|
+
return { type: 'separator', id: entry.id };
|
|
23
|
+
if (entry.type === 'item')
|
|
24
|
+
return { type: 'item', ...item(entry) };
|
|
25
|
+
return { type: 'stack', id: entry.id, label: entry.label, icon: imageIcon(entry.label, entry.image), items: entry.items.map(item) };
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
const defaultKeys = () => switchKeys(platformOf(typeof navigator === 'undefined' ? '' : navigator.platform || navigator.userAgent));
|
|
29
|
+
export function HostShell(props) {
|
|
30
|
+
// Its own desk, never hosted: this page is the host's, drawing for the apps.
|
|
31
|
+
return (_jsx(DeskProvider, { host: null, look: props.theme?.look ?? 'auto', children: _jsx(Shell, { ...props }) }));
|
|
32
|
+
}
|
|
33
|
+
function Shell({ workspaces, current, chrome, theme, onSwitch, onCommand, onInsets, keys, clickSwitch = 'slide', dockSide = 'left' }) {
|
|
34
|
+
useLayoutEffect(() => {
|
|
35
|
+
if (theme)
|
|
36
|
+
applyTheme(theme);
|
|
37
|
+
}, [theme]);
|
|
38
|
+
const entries = useMemo(() => dockFromHost(chrome[current]?.dock ?? [], itemId => onCommand(current, 'dock', itemId)), [chrome, current, onCommand]);
|
|
39
|
+
// The arrived workspace's title, said once, politely: only on a change, never on first showing.
|
|
40
|
+
const [arrived, setArrived] = useState('');
|
|
41
|
+
const shown = useRef(current);
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (shown.current === current)
|
|
44
|
+
return;
|
|
45
|
+
shown.current = current;
|
|
46
|
+
setArrived(workspaces.find(w => w.id === current)?.title ?? '');
|
|
47
|
+
}, [current, workspaces]);
|
|
48
|
+
// The switching keys, when this page has focus; a host catches them first when an app has it.
|
|
49
|
+
const bound = useMemo(() => (keys === null ? null : keys ?? defaultKeys()), [keys]);
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
if (!bound)
|
|
52
|
+
return;
|
|
53
|
+
const onKey = (event) => {
|
|
54
|
+
const action = switchKeyAction(event, bound);
|
|
55
|
+
if (action !== 'previous' && action !== 'next')
|
|
56
|
+
return;
|
|
57
|
+
const to = neighbour(workspaces, current, action);
|
|
58
|
+
event.preventDefault();
|
|
59
|
+
if (to)
|
|
60
|
+
onSwitch(to.id, 'slide');
|
|
61
|
+
};
|
|
62
|
+
window.addEventListener('keydown', onKey);
|
|
63
|
+
return () => window.removeEventListener('keydown', onKey);
|
|
64
|
+
}, [bound, workspaces, current, onSwitch]);
|
|
65
|
+
const root = useRef(null);
|
|
66
|
+
useInsets(root, dockSide, onInsets);
|
|
67
|
+
return (_jsxs("div", { ref: root, className: "desk-shell", "data-dock-side": dockSide, children: [_jsx("div", { className: "desk-shell-bar", children: _jsx(Switcher, { workspaces: workspaces, current: current, onChoose: id => id !== current && onSwitch(id, clickSwitch) }) }), _jsx(Dock, { entries: entries, side: dockSide, label: `${workspaces.find(w => w.id === current)?.title ?? 'App'} dock` }), _jsx("div", { className: "desk-shell-announce", role: "status", "aria-live": "polite", children: arrived })] }));
|
|
68
|
+
}
|
|
69
|
+
function Switcher({ workspaces, current, onChoose }) {
|
|
70
|
+
// One Tab stop: the current workspace's, or the first while the current one is not listed.
|
|
71
|
+
const stop = workspaces.some(w => w.id === current) ? current : workspaces[0]?.id;
|
|
72
|
+
const toolbar = useRef(null);
|
|
73
|
+
// Arrowing moves the stop by hand; once the host has moved, it is the current workspace's again.
|
|
74
|
+
useLayoutEffect(() => {
|
|
75
|
+
toolbar.current?.querySelectorAll('button').forEach(b => (b.tabIndex = b.dataset.workspace === stop ? 0 : -1));
|
|
76
|
+
}, [stop, workspaces]);
|
|
77
|
+
return (_jsx("div", { ref: toolbar, role: "toolbar", "aria-label": "Workspaces", className: "desk-shell-switcher", onKeyDown: event => {
|
|
78
|
+
// A held modifier makes the arrow a switching key, which the page's listener handles: don't rove too.
|
|
79
|
+
if (!event.ctrlKey && !event.altKey && !event.metaKey)
|
|
80
|
+
roveFocus(event, { next: ['ArrowRight'], previous: ['ArrowLeft'] });
|
|
81
|
+
}, children: workspaces.map(w => (_jsxs("button", { type: "button", className: "desk-shell-workspace", "data-rove": true, "data-workspace": w.id, tabIndex: w.id === stop ? 0 : -1, "aria-current": w.id === current ? 'true' : undefined, "data-state": w.state, onClick: () => onChoose(w.id), children: [w.icon ? _jsx("img", { src: w.icon, alt: "", draggable: false }) : _jsx("span", { className: "desk-shell-mark", style: w.accent ? { background: w.accent } : undefined, "aria-hidden": "true" }), _jsx("span", { children: w.title })] }, w.id))) }));
|
|
82
|
+
}
|
|
83
|
+
/** Reports the room the bar and the dock take, whenever either changes size. */
|
|
84
|
+
function useInsets(root, side, onInsets) {
|
|
85
|
+
const last = useRef('');
|
|
86
|
+
useLayoutEffect(() => {
|
|
87
|
+
const el = root.current;
|
|
88
|
+
if (!el || !onInsets)
|
|
89
|
+
return;
|
|
90
|
+
const measure = () => {
|
|
91
|
+
const bounds = el.getBoundingClientRect();
|
|
92
|
+
const bar = el.querySelector('.desk-shell-bar')?.getBoundingClientRect();
|
|
93
|
+
const dock = el.querySelector('.desk-dock')?.getBoundingClientRect();
|
|
94
|
+
const gap = dock && dock.width > 0 ? 1 : 0;
|
|
95
|
+
const insets = {
|
|
96
|
+
top: Math.ceil(bar ? bar.bottom - bounds.top : 0),
|
|
97
|
+
left: side === 'left' && gap ? Math.ceil(dock.right - bounds.left) : 0,
|
|
98
|
+
right: side === 'right' && gap ? Math.ceil(bounds.right - dock.left) : 0,
|
|
99
|
+
bottom: side === 'bottom' && gap ? Math.ceil(bounds.bottom - dock.top) : 0,
|
|
100
|
+
};
|
|
101
|
+
const key = JSON.stringify(insets);
|
|
102
|
+
if (key === last.current)
|
|
103
|
+
return;
|
|
104
|
+
last.current = key;
|
|
105
|
+
onInsets(insets);
|
|
106
|
+
};
|
|
107
|
+
measure();
|
|
108
|
+
if (typeof ResizeObserver === 'undefined')
|
|
109
|
+
return;
|
|
110
|
+
const observer = new ResizeObserver(measure);
|
|
111
|
+
observer.observe(el);
|
|
112
|
+
el.querySelectorAll('.desk-shell-bar, .desk-dock').forEach(node => observer.observe(node));
|
|
113
|
+
return () => observer.disconnect();
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=HostShell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HostShell.js","s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GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;aAC5E,CAAA;YACD,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;YAClC,IAAI,GAAG,KAAK,IAAI,CAAC,OAAO;gBAAE,OAAM;YAChC,IAAI,CAAC,OAAO,GAAG,GAAG,CAAA;YAClB,QAAQ,CAAC,MAAM,CAAC,CAAA;QAClB,CAAC,CAAA;QACD,OAAO,EAAE,CAAA;QACT,IAAI,OAAO,cAAc,KAAK,WAAW;YAAE,OAAM;QACjD,MAAM,QAAQ,GAAG,IAAI,cAAc,CAAC,OAAO,CAAC,CAAA;QAC5C,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;QACpB,EAAE,CAAC,gBAAgB,CAAC,6BAA6B,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;QAC1F,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAA;IACpC,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { dockFromHost, HostShell } from './HostShell.js';
|
|
2
|
+
export type { HostShellProps, ShellInsets, ShellWorkspace, SwitchHow } from './HostShell.js';
|
|
3
|
+
export { neighbour, platformOf, switchKeyAction, switchKeys } from './keys.js';
|
|
4
|
+
export type { KeyInput, ShellPlatform, SwitchKey, SwitchKeys } from './keys.js';
|
|
5
|
+
export { animate, FADE_MS, linear, pageClock, SLIDE_MS, slideOffsets, slidePlan, spring, timerClock } from './motion.js';
|
|
6
|
+
export type { Animation, AnimateOptions, FrameClock, SlideOffsets, SlidePlan } from './motion.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shell/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AACxD,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC5F,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAC9E,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAC/E,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxH,YAAY,EAAE,SAAS,EAAE,cAAc,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The shell of a host that runs several Desk apps side by side: one dock and one switcher drawn for
|
|
3
|
+
* all of them, and the curve the host moves their views on. Only the host's own page loads it; no
|
|
4
|
+
* app does, and nothing in core or react imports it.
|
|
5
|
+
*/
|
|
6
|
+
export { dockFromHost, HostShell } from './HostShell.js';
|
|
7
|
+
export { neighbour, platformOf, switchKeyAction, switchKeys } from './keys.js';
|
|
8
|
+
export { animate, FADE_MS, linear, pageClock, SLIDE_MS, slideOffsets, slidePlan, spring, timerClock } from './motion.js';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/shell/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAExD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAE9E,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/** One key with its modifiers. `meta` is ⌘ on a Mac, Super (the Windows key) elsewhere. */
|
|
2
|
+
export interface SwitchKey {
|
|
3
|
+
readonly key: string;
|
|
4
|
+
readonly ctrl?: boolean;
|
|
5
|
+
readonly alt?: boolean;
|
|
6
|
+
readonly meta?: boolean;
|
|
7
|
+
readonly shift?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/** What each switching key does. */
|
|
10
|
+
export interface SwitchKeys {
|
|
11
|
+
readonly previous: SwitchKey;
|
|
12
|
+
readonly next: SwitchKey;
|
|
13
|
+
/** Opens the overview, once there is one to open. */
|
|
14
|
+
readonly overview: SwitchKey;
|
|
15
|
+
}
|
|
16
|
+
export type ShellPlatform = 'mac' | 'linux' | 'windows';
|
|
17
|
+
/**
|
|
18
|
+
* The platform, from a browser's `navigator.platform` or user agent, or a Node `process.platform`
|
|
19
|
+
* ('darwin', 'linux', 'win32').
|
|
20
|
+
*/
|
|
21
|
+
export declare function platformOf(name: string): ShellPlatform;
|
|
22
|
+
/** The default keys on a platform: Ctrl+Option on a Mac, Super+Alt on Linux, Ctrl+Alt on Windows. */
|
|
23
|
+
export declare function switchKeys(platform: ShellPlatform): SwitchKeys;
|
|
24
|
+
/** A key event from a page (`ctrlKey`…) or from Electron's `before-input-event` (`control`…). */
|
|
25
|
+
export interface KeyInput {
|
|
26
|
+
readonly key: string;
|
|
27
|
+
/** `keydown`/`keyup` from a page, `keyDown`/`keyUp` from Electron: only a key going down switches. */
|
|
28
|
+
readonly type?: string;
|
|
29
|
+
readonly ctrlKey?: boolean;
|
|
30
|
+
readonly altKey?: boolean;
|
|
31
|
+
readonly metaKey?: boolean;
|
|
32
|
+
readonly shiftKey?: boolean;
|
|
33
|
+
readonly control?: boolean;
|
|
34
|
+
readonly alt?: boolean;
|
|
35
|
+
readonly meta?: boolean;
|
|
36
|
+
readonly shift?: boolean;
|
|
37
|
+
}
|
|
38
|
+
/** What a key does, if it is one of the switching keys: modifiers must match exactly. */
|
|
39
|
+
export declare function switchKeyAction(input: KeyInput, keys: SwitchKeys): 'previous' | 'next' | 'overview' | null;
|
|
40
|
+
/**
|
|
41
|
+
* The workspace one step from `current`, in the order given (the switcher's order), or null at
|
|
42
|
+
* either end: like the OS's own workspaces, switching does not wrap round.
|
|
43
|
+
*/
|
|
44
|
+
export declare function neighbour<T extends {
|
|
45
|
+
readonly id: string;
|
|
46
|
+
}>(workspaces: readonly T[], current: string, step: 'previous' | 'next'): T | null;
|
|
47
|
+
//# sourceMappingURL=keys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../src/shell/keys.ts"],"names":[],"mappings":"AAaA,2FAA2F;AAC3F,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAA;IACvB,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,CAAA;IACtB,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAA;IACvB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CACzB;AAED,oCAAoC;AACpC,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAA;IAC5B,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;IACxB,qDAAqD;IACrD,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAA;CAC7B;AAED,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,OAAO,GAAG,SAAS,CAAA;AAEvD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAItD;AAQD,qGAAqG;AACrG,wBAAgB,UAAU,CAAC,QAAQ,EAAE,aAAa,GAAG,UAAU,CAS9D;AAED,iGAAiG;AACjG,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,sGAAsG;IACtG,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAA;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAA;IAC1B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAC3B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAA;IAC1B,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,CAAA;IACtB,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAA;IACvB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CACzB;AASD,yFAAyF;AACzF,wBAAgB,eAAe,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,GAAG,UAAU,GAAG,MAAM,GAAG,UAAU,GAAG,IAAI,CAO1G;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,EAAE,UAAU,EAAE,SAAS,CAAC,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,CAAC,GAAG,IAAI,CAI3I"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* THE KEYS THAT SWITCH WORKSPACES, PER PLATFORM.
|
|
3
|
+
*
|
|
4
|
+
* Every OS has keys of its own for its own workspaces, and a host's must never fight them: macOS takes
|
|
5
|
+
* Ctrl+←/→ for Spaces and Ctrl+↑ for Mission Control; GNOME takes Ctrl+Alt+←/→ (and Super+PageUp/Down),
|
|
6
|
+
* KDE Meta+Ctrl+←/→; Windows takes Ctrl+Win+←/→ for its virtual desktops. So the defaults step around
|
|
7
|
+
* each, and a host can offer its own in Settings.
|
|
8
|
+
*
|
|
9
|
+
* A key reaches whichever view has focus, usually an app's. So a host catches these before the app
|
|
10
|
+
* does (in Electron, `before-input-event`) and asks `switchKeyAction` what the key means; the shell's
|
|
11
|
+
* own page uses the same function for the keys it sees itself.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* The platform, from a browser's `navigator.platform` or user agent, or a Node `process.platform`
|
|
15
|
+
* ('darwin', 'linux', 'win32').
|
|
16
|
+
*/
|
|
17
|
+
export function platformOf(name) {
|
|
18
|
+
if (/mac|darwin|iphone|ipad/i.test(name))
|
|
19
|
+
return 'mac';
|
|
20
|
+
if (/win/i.test(name))
|
|
21
|
+
return 'windows';
|
|
22
|
+
return 'linux';
|
|
23
|
+
}
|
|
24
|
+
const arrows = (mods) => ({
|
|
25
|
+
previous: { key: 'ArrowLeft', ...mods },
|
|
26
|
+
next: { key: 'ArrowRight', ...mods },
|
|
27
|
+
overview: { key: 'ArrowUp', ...mods },
|
|
28
|
+
});
|
|
29
|
+
/** The default keys on a platform: Ctrl+Option on a Mac, Super+Alt on Linux, Ctrl+Alt on Windows. */
|
|
30
|
+
export function switchKeys(platform) {
|
|
31
|
+
switch (platform) {
|
|
32
|
+
case 'mac':
|
|
33
|
+
return arrows({ ctrl: true, alt: true });
|
|
34
|
+
case 'linux':
|
|
35
|
+
return arrows({ meta: true, alt: true });
|
|
36
|
+
case 'windows':
|
|
37
|
+
return arrows({ ctrl: true, alt: true });
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const matches = (input, key) => input.key === key.key &&
|
|
41
|
+
Boolean(input.ctrlKey ?? input.control) === Boolean(key.ctrl) &&
|
|
42
|
+
Boolean(input.altKey ?? input.alt) === Boolean(key.alt) &&
|
|
43
|
+
Boolean(input.metaKey ?? input.meta) === Boolean(key.meta) &&
|
|
44
|
+
Boolean(input.shiftKey ?? input.shift) === Boolean(key.shift);
|
|
45
|
+
/** What a key does, if it is one of the switching keys: modifiers must match exactly. */
|
|
46
|
+
export function switchKeyAction(input, keys) {
|
|
47
|
+
// Electron's before-input-event sends the key's release too: one press must switch once.
|
|
48
|
+
if (/up$/i.test(input.type ?? ''))
|
|
49
|
+
return null;
|
|
50
|
+
if (matches(input, keys.previous))
|
|
51
|
+
return 'previous';
|
|
52
|
+
if (matches(input, keys.next))
|
|
53
|
+
return 'next';
|
|
54
|
+
if (matches(input, keys.overview))
|
|
55
|
+
return 'overview';
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The workspace one step from `current`, in the order given (the switcher's order), or null at
|
|
60
|
+
* either end: like the OS's own workspaces, switching does not wrap round.
|
|
61
|
+
*/
|
|
62
|
+
export function neighbour(workspaces, current, step) {
|
|
63
|
+
const index = workspaces.findIndex(w => w.id === current);
|
|
64
|
+
if (index < 0)
|
|
65
|
+
return null;
|
|
66
|
+
return workspaces[index + (step === 'next' ? 1 : -1)] ?? null;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=keys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../src/shell/keys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAqBH;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,IAAI,yBAAyB,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAA;IACtD,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,SAAS,CAAA;IACvC,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,MAAM,MAAM,GAAG,CAAC,IAA4B,EAAc,EAAE,CAAC,CAAC;IAC5D,QAAQ,EAAE,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,IAAI,EAAE;IACvC,IAAI,EAAE,EA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C,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC;QAAE,OAAO,IAAI,CAAA;IAC9C,IAAI,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC;QAAE,OAAO,UAAU,CAAA;IACpD,IAAI,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,MAAM,CAAA;IAC5C,IAAI,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC;QAAE,OAAO,UAAU,CAAA;IACpD,OAAO,IAAI,CAAA;AACb,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAoC,UAAwB,EAAE,OAAe,EAAE,IAAyB;IAC/H,MAAM,KAAK,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,OAAO,CAAC,CAAA;IACzD,IAAI,KAAK,GAAG,CAAC;QAAE,OAAO,IAAI,CAAA;IAC1B,OAAO,UAAU,CAAC,KAAK,GAAG,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAA;AAC/D,CAAC"}
|
|
@@ -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,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CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;IACzC,QAAQ,CAAC,KAAK,CAAC,EAAE,UAAU,CAAA;IAC3B;;;OAGG;IACH,QAAQ,CAAC,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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