@liberation-data/desk 0.45.0 → 0.47.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 +73 -7
- package/dist/core/hosted.d.ts +39 -1
- package/dist/core/hosted.d.ts.map +1 -1
- package/dist/core/hosted.js +44 -0
- package/dist/core/hosted.js.map +1 -1
- package/dist/core/index.d.ts +5 -3
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +3 -2
- package/dist/core/index.js.map +1 -1
- package/dist/core/swipe.d.ts +15 -0
- package/dist/core/swipe.d.ts.map +1 -0
- package/dist/core/swipe.js +77 -0
- package/dist/core/swipe.js.map +1 -0
- package/dist/core/theme.d.ts +15 -0
- package/dist/core/theme.d.ts.map +1 -1
- package/dist/core/theme.js +73 -1
- package/dist/core/theme.js.map +1 -1
- package/dist/css/shell.css +89 -0
- package/dist/host/checkTheme.d.ts +2 -7
- package/dist/host/checkTheme.d.ts.map +1 -1
- package/dist/host/checkTheme.js +3 -27
- package/dist/host/checkTheme.js.map +1 -1
- package/dist/host/router.d.ts +17 -4
- package/dist/host/router.d.ts.map +1 -1
- package/dist/host/router.js +94 -2
- package/dist/host/router.js.map +1 -1
- package/dist/react/Desktop.d.ts.map +1 -1
- package/dist/react/Desktop.js +5 -0
- package/dist/react/Desktop.js.map +1 -1
- package/dist/react/context.d.ts +6 -1
- package/dist/react/context.d.ts.map +1 -1
- package/dist/react/context.js +5 -3
- package/dist/react/context.js.map +1 -1
- package/dist/react/hostApp.d.ts +3 -1
- package/dist/react/hostApp.d.ts.map +1 -1
- package/dist/react/hostApp.js +3 -2
- package/dist/react/hostApp.js.map +1 -1
- package/dist/react/hosted.d.ts +10 -3
- package/dist/react/hosted.d.ts.map +1 -1
- package/dist/react/hosted.js +68 -8
- package/dist/react/hosted.js.map +1 -1
- package/dist/react/shell.d.ts +3 -1
- package/dist/react/shell.d.ts.map +1 -1
- package/dist/react/shell.js +2 -2
- package/dist/react/shell.js.map +1 -1
- package/dist/shell/HostOverview.d.ts +41 -0
- package/dist/shell/HostOverview.d.ts.map +1 -0
- package/dist/shell/HostOverview.js +219 -0
- package/dist/shell/HostOverview.js.map +1 -0
- package/dist/shell/HostShell.d.ts +3 -1
- package/dist/shell/HostShell.d.ts.map +1 -1
- package/dist/shell/HostShell.js +6 -4
- package/dist/shell/HostShell.js.map +1 -1
- package/dist/shell/index.d.ts +6 -0
- package/dist/shell/index.d.ts.map +1 -1
- package/dist/shell/index.js +3 -0
- package/dist/shell/index.js.map +1 -1
- package/dist/shell/swipe.d.ts +60 -0
- package/dist/shell/swipe.d.ts.map +1 -0
- package/dist/shell/swipe.js +158 -0
- package/dist/shell/swipe.js.map +1 -0
- package/dist/shell/zoom.d.ts +62 -0
- package/dist/shell/zoom.d.ts.map +1 -0
- package/dist/shell/zoom.js +116 -0
- package/dist/shell/zoom.js.map +1 -0
- package/llms.txt +14 -5
- package/package.json +12 -7
- package/src/core/hosted.ts +70 -1
- package/src/core/index.ts +5 -2
- package/src/core/swipe.ts +101 -0
- package/src/core/theme.ts +69 -1
- package/src/css/shell.css +89 -0
- package/src/host/checkTheme.ts +3 -25
- package/src/host/router.ts +100 -6
- package/src/react/Desktop.tsx +6 -0
- package/src/react/context.tsx +9 -2
- package/src/react/hostApp.tsx +3 -2
- package/src/react/hosted.tsx +68 -8
- package/src/react/shell.tsx +4 -2
- package/src/shell/HostOverview.tsx +317 -0
- package/src/shell/HostShell.tsx +8 -5
- package/src/shell/index.ts +20 -0
- package/src/shell/swipe.ts +202 -0
- package/src/shell/zoom.ts +151 -0
package/README.md
CHANGED
|
@@ -10,6 +10,9 @@ A desktop environment for React apps: windows that fill the desk, layered, and a
|
|
|
10
10
|
npm install @liberation-data/desk
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
+
It is an ES module. CommonJS code, such as an Electron main process, can `require()` it too on Node 22.12
|
|
14
|
+
or later.
|
|
15
|
+
|
|
13
16
|
## Window manager defaults
|
|
14
17
|
|
|
15
18
|
Every window opens filling the desk, over the ones already open, and keeps filling it when the browser
|
|
@@ -877,10 +880,19 @@ the host provides: an Electron preload, or `postMessage` between frames), or whe
|
|
|
877
880
|
and its name, version, links, note (when it is text) and facts, each fact's link and `copy: false`
|
|
878
881
|
kept. ⌘, is the host's too: Desk steps aside for it, as it does for any host's menu bar, so it is
|
|
879
882
|
bound once.
|
|
880
|
-
- One app, the primary, sets the look every app wears
|
|
881
|
-
`
|
|
882
|
-
|
|
883
|
-
|
|
883
|
+
- One app, the primary, sets the look every app wears, and every other app wears it through
|
|
884
|
+
`applyTheme`, so their Appearance offers no scheme, look or theme of its own. An app says `hello` when it
|
|
885
|
+
connects, and the host answers with its `role` (`{ primary: true }` or `false`), and says it again when
|
|
886
|
+
it changes; `primary()` and `onRole(listener)` on the connection read it. Until the host has said, the
|
|
887
|
+
app publishes nothing, so under a host that never answers (one built before `role`) the primary
|
|
888
|
+
publishes only through `usePublishTheme`. The primary publishes the theme it wears as a `DeskTheme`
|
|
889
|
+
(`appliedTheme()`: light or dark and the look as drawn, and Desk's tokens as they apply on its root)
|
|
890
|
+
with no code of its own, at once and again on every change of scheme, look or tokens. A token that
|
|
891
|
+
would load something, such as a `url(…)` wallpaper, is left out, and so are fonts, so what it sends
|
|
892
|
+
passes the host's check. `publishTheme={false}` on `DeskShell` or `DeskProvider` turns this off;
|
|
893
|
+
`usePublishTheme(theme)` publishes a different theme instead while it is mounted (with `fonts` or a
|
|
894
|
+
`wallpaper`, say). The primary declares `themeFromHost: false`: it keeps its Appearance and wears no
|
|
895
|
+
theme but its own. An app that keeps some
|
|
884
896
|
looks of its own passes `onTheme`; light or dark and the look apply whatever it does, since one
|
|
885
897
|
desktop light and the next dark would look broken side by side.
|
|
886
898
|
- Apps never talk to each other directly. `useHost()` gives the connection: `publish(topic, payload)`,
|
|
@@ -890,7 +902,8 @@ the host provides: an Electron preload, or `postMessage` between frames), or whe
|
|
|
890
902
|
each topic, so an app that starts late hears it at once. The primary's theme outlives it: an app that
|
|
891
903
|
starts while the primary is down still wears its last look.
|
|
892
904
|
|
|
893
|
-
A page without React connects with `connectHost(bridge)`, from the core entry
|
|
905
|
+
A page without React connects with `connectHost(bridge)`, from the core entry, and passes its background's
|
|
906
|
+
swipes on with `watchSwipes(element, gesture => client.gesture(gesture))`.
|
|
894
907
|
|
|
895
908
|
```tsx
|
|
896
909
|
<DeskShell onTheme={theme => keepMyAccent(theme)}> {/* hosted when the page has a deskHost */}
|
|
@@ -905,7 +918,10 @@ rules above, so every transport keeps them alike:
|
|
|
905
918
|
|
|
906
919
|
- The host registers each app (`id`, `origin`, `primary`, `publishes`) and hands the router every message
|
|
907
920
|
the app sends, identified by the transport, never by the message. The primary's `publishes` must
|
|
908
|
-
include `theme`.
|
|
921
|
+
include `theme`. The router answers an app's `hello` with its `role`, and tells it again when the host
|
|
922
|
+
registers it with a different `primary`; register an app before it connects, since a `hello` from an app
|
|
923
|
+
the router doesn't know is refused, unanswered. A host built without the router does the same: it sends
|
|
924
|
+
`{ desk: 1, kind: 'role', primary }` in answer to `hello` and on every change. When the host unregisters an app, `chrome` is called with null for it, and the host
|
|
909
925
|
stops drawing its menus and dock.
|
|
910
926
|
- A theme is checked before it is passed on (`checkTheme`): tokens must be plain values (colours,
|
|
911
927
|
lengths, font names, gradients) with nothing that loads, such as `url(…)`, and fonts and image
|
|
@@ -952,7 +968,9 @@ import '@liberation-data/desk/css/shell.css'
|
|
|
952
968
|
current="notes"
|
|
953
969
|
chrome={chromeByApp} // each app's DeskChrome, as the router's `chrome` hands it over
|
|
954
970
|
theme={primaryTheme}
|
|
955
|
-
onSwitch={(id, how) => …} // how: 'slide' (or 'zoom'
|
|
971
|
+
onSwitch={(id, how) => …} // how: 'slide' (the keys), or 'zoom' (a click: through HostOverview)
|
|
972
|
+
clickSwitch="slide" // optional: a click slides too, for a host without HostOverview
|
|
973
|
+
onOverview={() => …} // the overview key: open HostOverview
|
|
956
974
|
onCommand={(appId, target, itemId) => …}
|
|
957
975
|
onInsets={insets => …} // bound the apps' views inside these
|
|
958
976
|
/>
|
|
@@ -972,6 +990,54 @@ import '@liberation-data/desk/css/shell.css'
|
|
|
972
990
|
dock. `animate({ durationMs, step, clock: timerClock() })` steps them from a main process, and jumps to
|
|
973
991
|
the end if frames stop, as they do for a hidden window.
|
|
974
992
|
|
|
993
|
+
`HostOverview` is the overview, and the zoom between workspaces through it. A live view can't be scaled,
|
|
994
|
+
so it is drawn with pictures, on an overlay over the apps' views: in an app host, a transparent view of its
|
|
995
|
+
own on top; in a page, a layer over the desktop area (`insets`). The host asks for a move with `request`
|
|
996
|
+
and does what the overlay says:
|
|
997
|
+
|
|
998
|
+
```tsx
|
|
999
|
+
<HostOverview
|
|
1000
|
+
workspaces={workspaces} current="notes" theme={primaryTheme} insets={insets}
|
|
1001
|
+
snapshots={pictureById} // URLs or data: URIs; a tile with none shows its title ("Live" if awake)
|
|
1002
|
+
request={{ kind: 'switch', to: 'garage' }} // or { kind: 'open' }; a new object starts a new move, null clears
|
|
1003
|
+
onWantCapture={id => …} // capture this workspace's view now, pass it in `snapshots`, and return a promise of its URL
|
|
1004
|
+
onCover={() => …} // the overlay covers the desktop: the live views may hide
|
|
1005
|
+
onArrive={id => …} // a full-size picture of it shows: swap its view in, clear `request`
|
|
1006
|
+
/>
|
|
1007
|
+
```
|
|
1008
|
+
|
|
1009
|
+
- Only the current workspace is captured, and waited for at most `CAPTURE_WAIT_MS` (100 ms): with no
|
|
1010
|
+
picture by then it goes on with the one it holds, and a late one restarts nothing. A promise returned by
|
|
1011
|
+
`onWantCapture` says when the picture is ready, so an unchanged workspace, which captures the same
|
|
1012
|
+
picture as last time, needn't wait the 100 ms out; without one, only a changed picture in `snapshots`
|
|
1013
|
+
counts. The fog comes in from the first frame. `onCover` and `onArrive` are each said once per move; a request that comes mid-flight
|
|
1014
|
+
carries on from where the tiles are, with no new capture, and a move cut short by a cleared request or
|
|
1015
|
+
an unmount arrives nowhere. The pictures stay the host's: revoke an object URL once its replacement is
|
|
1016
|
+
passed in.
|
|
1017
|
+
- A click on another workspace is out, across and in, about 650 ms (`ZOOM_OUT_MS`, `ZOOM_ACROSS_MS`,
|
|
1018
|
+
`ZOOM_IN_MS`); under reduced motion (`reducedMotion`, else the system's) a 120 ms fade in place
|
|
1019
|
+
(`ZOOM_FADE_MS`), and with `visible={false}` or a hidden page it jumps.
|
|
1020
|
+
- Open, the focus is on the current tile, the overview is said once ("Overview, 3 workspaces"), the arrow
|
|
1021
|
+
keys, Home and End move the focus (the row follows it), Enter or a click goes there, and Escape goes back
|
|
1022
|
+
to the current workspace. The focus goes back where it was when the overlay clears.
|
|
1023
|
+
- The motion is numbers a host can read too, with no DOM: `planZoom(from, to, reducedMotion)` gives the
|
|
1024
|
+
phases between two poses (`{ zoom, centre, fog, opacity }`), `poseAt(plan, ms)` where they stand, and
|
|
1025
|
+
`overviewTiles(count, pose, width)` each tile's place. `pose` holds one pose instead of moving, for a
|
|
1026
|
+
gesture that drives the overview by hand or a still.
|
|
1027
|
+
|
|
1028
|
+
The swipe between workspaces comes from the apps. A hosted app passes on a two-finger sideways swipe that
|
|
1029
|
+
starts on its desktop background (`watchSwipes`, which a hosted `Desktop` sets up itself); a swipe that
|
|
1030
|
+
starts in a window stays the window's, and three and four fingers stay the system's. The router passes
|
|
1031
|
+
gestures from the app in front only (`createBroadcastRouter({ gesture, front })`), holding back moves over
|
|
1032
|
+
the rate (30 at once then 120 a second, `limits.topics.gesture`) but never a begin, end or cancel, and cancels
|
|
1033
|
+
a swipe whose app leaves the front, goes or reconnects mid-way, or is overtaken by another begin. `createSwipeController` turns them into slide frames with no DOM:
|
|
1034
|
+
it follows the fingers 1:1, goes on past half way or on a flick and springs back otherwise, and catches a
|
|
1035
|
+
slide still settling, a key's included (`slideTo`). A host closing calls `stop()`: no more frames, and no `arrive`.
|
|
1036
|
+
|
|
1037
|
+
- **Known limit, macOS:** the trackpad's momentum after the fingers lift arrives as more wheel events, and a
|
|
1038
|
+
page is given nothing to tell them apart from the swipe itself, so they count as part of it and the swipe
|
|
1039
|
+
ends when they stop.
|
|
1040
|
+
|
|
975
1041
|
### Menus from the window in front
|
|
976
1042
|
|
|
977
1043
|
As on a Mac, the menu bar follows what is in front. A window, or an app embedded in one, can add menus of
|
package/dist/core/hosted.d.ts
CHANGED
|
@@ -139,6 +139,21 @@ export interface BroadcastSender {
|
|
|
139
139
|
export type Publisher = 'primary' | (string & {});
|
|
140
140
|
/** What a host's command is for: the app's menus, its dock, or its Settings. */
|
|
141
141
|
export type CommandTarget = 'menu' | 'dock' | 'settings';
|
|
142
|
+
/**
|
|
143
|
+
* A two-finger horizontal swipe that started on the app's desktop background, passed to the host,
|
|
144
|
+
* which moves between apps with it. One that starts inside a window is the window's, and never sent.
|
|
145
|
+
*/
|
|
146
|
+
export interface AppGesture {
|
|
147
|
+
readonly type: 'swipe';
|
|
148
|
+
readonly phase: 'begin' | 'move' | 'end' | 'cancel';
|
|
149
|
+
/**
|
|
150
|
+
* How far the fingers have gone since `begin`, in CSS pixels, as the page scrolls: positive toward
|
|
151
|
+
* the next workspace. The total, not the step, so a host that drops moves loses nothing.
|
|
152
|
+
*/
|
|
153
|
+
readonly delta: number;
|
|
154
|
+
/** At `end`: how fast they were going as they lifted, in pixels a second, signed as `delta`. */
|
|
155
|
+
readonly velocity?: number;
|
|
156
|
+
}
|
|
142
157
|
/** What an app sends its host. Untrusted at the host's end: check it with `isAppToHost`. */
|
|
143
158
|
export type AppToHost = {
|
|
144
159
|
readonly desk: 1;
|
|
@@ -159,6 +174,15 @@ export type AppToHost = {
|
|
|
159
174
|
readonly kind: 'unsubscribe';
|
|
160
175
|
readonly publisher: Publisher;
|
|
161
176
|
readonly topic: string;
|
|
177
|
+
}
|
|
178
|
+
/** Sent on connecting: the host answers with the app's `role`. */
|
|
179
|
+
| {
|
|
180
|
+
readonly desk: 1;
|
|
181
|
+
readonly kind: 'hello';
|
|
182
|
+
} | {
|
|
183
|
+
readonly desk: 1;
|
|
184
|
+
readonly kind: 'gesture';
|
|
185
|
+
readonly gesture: AppGesture;
|
|
162
186
|
};
|
|
163
187
|
/** What a host sends an app: a choice from the chrome it draws, or another app's broadcast, stamped. */
|
|
164
188
|
export type HostToApp =
|
|
@@ -174,6 +198,12 @@ export type HostToApp =
|
|
|
174
198
|
readonly from: BroadcastSender;
|
|
175
199
|
readonly topic: string;
|
|
176
200
|
readonly payload: unknown;
|
|
201
|
+
}
|
|
202
|
+
/** Whether the app is the primary, whose theme the others wear: the answer to `hello`, and again when it changes. */
|
|
203
|
+
| {
|
|
204
|
+
readonly desk: 1;
|
|
205
|
+
readonly kind: 'role';
|
|
206
|
+
readonly primary: boolean;
|
|
177
207
|
};
|
|
178
208
|
/**
|
|
179
209
|
* The app's end of the connection to its host. The host provides it — an Electron preload through
|
|
@@ -192,6 +222,8 @@ export declare function isDeskHostBridge(value: unknown): value is DeskHostBridg
|
|
|
192
222
|
export declare function findDeskHost(): DeskHostBridge | null;
|
|
193
223
|
/** Whether a message from an app has the shape of one. A host checks before acting on it: the app is not trusted. */
|
|
194
224
|
export declare function isAppToHost(value: unknown): value is AppToHost;
|
|
225
|
+
/** Whether `value` is a gesture as an app sends one: a known phase, and finite numbers. */
|
|
226
|
+
export declare const isAppGesture: (value: unknown) => value is AppGesture;
|
|
195
227
|
/** Whether a message from a host has the shape of one. */
|
|
196
228
|
export declare function isHostToApp(value: unknown): value is HostToApp;
|
|
197
229
|
/** A broadcast as an app hears it. */
|
|
@@ -214,7 +246,13 @@ export interface HostClient {
|
|
|
214
246
|
* one straight away, so an app that starts late still hears the current theme.
|
|
215
247
|
*/
|
|
216
248
|
subscribe<T = unknown>(publisher: Publisher, topic: string, handler: (broadcast: Broadcast<T>) => void): () => void;
|
|
217
|
-
/**
|
|
249
|
+
/** Whether the host says this app is the primary; null until it has said. */
|
|
250
|
+
primary(): boolean | null;
|
|
251
|
+
/** Calls the listener when the host says whether this app is the primary, now and on any change. */
|
|
252
|
+
onRole(listener: (primary: boolean) => void): () => void;
|
|
253
|
+
/** Passes a swipe on the desktop background to the host. `DeskProvider`'s `Desktop` does this itself. */
|
|
254
|
+
gesture(gesture: AppGesture): void;
|
|
255
|
+
/** Stops listening, takes the chrome away, and puts back a swipe under way. */
|
|
218
256
|
close(): void;
|
|
219
257
|
}
|
|
220
258
|
/** Connects an app to its host over `bridge`. `DeskProvider` does this for a React app; a page without React calls it itself. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hosted.d.ts","sourceRoot":"","sources":["../../src/core/hosted.ts"],"names":[],"mappings":"AAoBA,gGAAgG;AAChG,eAAO,MAAM,aAAa,IAAI,CAAA;AAE9B,6FAA6F;AAC7F,eAAO,MAAM,WAAW,UAAU,CAAA;AAElC,sFAAsF;AACtF,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAA;IAC9C;;;;OAIG;IACH,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAA;IACpB,sCAAsC;IACtC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,uDAAuD;IACvD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAC1B;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAC3B,wBAAwB;IACxB,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAA;IAC1B,8CAA8C;IAC9C,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAC3B;AAED,sCAAsC;AACtC,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,6FAA6F;IAC7F,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,2DAA2D;IAC3D,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAA;IAC1B,yEAAyE;IACzE,QAAQ,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zG,OAAO,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAAA;IAClC,+EAA+E;IAC/E,KAAK,IAAI,IAAI,CAAA;CACd;AAID,iIAAiI;AACjI,wBAAgB,WAAW,CAAC,MAAM,EAAE,cAAc,GAAG,UAAU,CAgH9D"}
|
package/dist/core/hosted.js
CHANGED
|
@@ -46,10 +46,18 @@ export function isAppToHost(value) {
|
|
|
46
46
|
case 'subscribe':
|
|
47
47
|
case 'unsubscribe':
|
|
48
48
|
return isString(value.publisher) && isString(value.topic) && value.topic.length > 0;
|
|
49
|
+
case 'hello':
|
|
50
|
+
return true;
|
|
51
|
+
case 'gesture':
|
|
52
|
+
return isAppGesture(value.gesture);
|
|
49
53
|
default:
|
|
50
54
|
return false;
|
|
51
55
|
}
|
|
52
56
|
}
|
|
57
|
+
const PHASES = ['begin', 'move', 'end', 'cancel'];
|
|
58
|
+
const isFiniteNumber = (value) => typeof value === 'number' && Number.isFinite(value);
|
|
59
|
+
/** Whether `value` is a gesture as an app sends one: a known phase, and finite numbers. */
|
|
60
|
+
export const isAppGesture = (value) => isRecord(value) && value.type === 'swipe' && PHASES.includes(value.phase) && isFiniteNumber(value.delta) && (value.velocity === undefined || isFiniteNumber(value.velocity));
|
|
53
61
|
/** Whether a message from a host has the shape of one. */
|
|
54
62
|
export function isHostToApp(value) {
|
|
55
63
|
if (!isRecord(value) || value.desk !== DESK_PROTOCOL)
|
|
@@ -59,6 +67,8 @@ export function isHostToApp(value) {
|
|
|
59
67
|
return (value.target === 'menu' || value.target === 'dock' || value.target === 'settings') && isString(value.id);
|
|
60
68
|
case 'broadcast':
|
|
61
69
|
return isRecord(value.from) && isString(value.from.id) && isString(value.topic);
|
|
70
|
+
case 'role':
|
|
71
|
+
return typeof value.primary === 'boolean';
|
|
62
72
|
default:
|
|
63
73
|
return false;
|
|
64
74
|
}
|
|
@@ -73,9 +83,22 @@ export function connectHost(bridge) {
|
|
|
73
83
|
/** Per subscription, the broadcasts last heard on each topic it covers, for a second handler that joins later. */
|
|
74
84
|
const subscriptions = new Map();
|
|
75
85
|
const keyOf = (publisher, topic) => `${publisher}\u0000${topic}`;
|
|
86
|
+
let primary = null;
|
|
87
|
+
const roles = new Set();
|
|
88
|
+
/** How far a swipe under way had got, so closing puts it back: a watcher stopped after the close is not heard. */
|
|
89
|
+
let swipe = null;
|
|
76
90
|
const stop = bridge.onMessage(message => {
|
|
77
91
|
if (closed || !isHostToApp(message))
|
|
78
92
|
return;
|
|
93
|
+
if (message.kind === 'role') {
|
|
94
|
+
if (primary === message.primary)
|
|
95
|
+
return;
|
|
96
|
+
primary = message.primary;
|
|
97
|
+
for (const listener of [...roles])
|
|
98
|
+
if (roles.has(listener))
|
|
99
|
+
listener(message.primary);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
79
102
|
if (message.kind === 'command') {
|
|
80
103
|
const listeners = commands[message.target];
|
|
81
104
|
// Copied, and each still checked: a listener may take another away while this one runs.
|
|
@@ -96,6 +119,8 @@ export function connectHost(bridge) {
|
|
|
96
119
|
handler(broadcast);
|
|
97
120
|
}
|
|
98
121
|
});
|
|
122
|
+
// Listening first, so a host that answers at once is heard.
|
|
123
|
+
bridge.send({ desk: DESK_PROTOCOL, kind: 'hello' });
|
|
99
124
|
return {
|
|
100
125
|
bridge,
|
|
101
126
|
setChrome(part) {
|
|
@@ -121,6 +146,12 @@ export function connectHost(bridge) {
|
|
|
121
146
|
if (!closed)
|
|
122
147
|
bridge.send({ desk: DESK_PROTOCOL, kind: 'publish', topic, payload });
|
|
123
148
|
},
|
|
149
|
+
gesture(gesture) {
|
|
150
|
+
if (closed)
|
|
151
|
+
return;
|
|
152
|
+
swipe = gesture.phase === 'begin' || gesture.phase === 'move' ? gesture.delta : null;
|
|
153
|
+
bridge.send({ desk: DESK_PROTOCOL, kind: 'gesture', gesture });
|
|
154
|
+
},
|
|
124
155
|
subscribe(publisher, topic, handler) {
|
|
125
156
|
const key = keyOf(publisher, topic);
|
|
126
157
|
const existing = subscriptions.get(key);
|
|
@@ -148,10 +179,23 @@ export function connectHost(bridge) {
|
|
|
148
179
|
}
|
|
149
180
|
};
|
|
150
181
|
},
|
|
182
|
+
primary: () => primary,
|
|
183
|
+
onRole(listener) {
|
|
184
|
+
roles.add(listener);
|
|
185
|
+
if (primary !== null)
|
|
186
|
+
listener(primary);
|
|
187
|
+
return () => {
|
|
188
|
+
roles.delete(listener);
|
|
189
|
+
};
|
|
190
|
+
},
|
|
151
191
|
close() {
|
|
152
192
|
if (closed)
|
|
153
193
|
return;
|
|
194
|
+
roles.clear();
|
|
195
|
+
primary = null;
|
|
154
196
|
bridge.send({ desk: DESK_PROTOCOL, kind: 'chrome', chrome: EMPTY_CHROME });
|
|
197
|
+
if (swipe !== null)
|
|
198
|
+
bridge.send({ desk: DESK_PROTOCOL, kind: 'gesture', gesture: { type: 'swipe', phase: 'cancel', delta: swipe } });
|
|
155
199
|
// So the host stops sending what nobody here hears.
|
|
156
200
|
for (const { publisher, topic } of subscriptions.values())
|
|
157
201
|
bridge.send({ desk: DESK_PROTOCOL, kind: 'unsubscribe', publisher, topic });
|
package/dist/core/hosted.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hosted.js","sourceRoot":"","sources":["../../src/core/hosted.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C;;;;;;;;;;;;;;;;GAgBG;AAEH,gGAAgG;AAChG,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAA;AAE9B,6FAA6F;AAC7F,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"hosted.js","sourceRoot":"","sources":["../../src/core/hosted.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C;;;;;;;;;;;;;;;;GAgBG;AAEH,gGAAgG;AAChG,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAA;A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AAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAAA;YACpI,oDAAoD;YACpD,KAAK,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,aAAa,CAAC,MAAM,EAAE;gBAAE,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAA;YACtI,MAAM,GAAG,IAAI,CAAA;YACb,IAAI,EAAE,CAAA;YACN,aAAa,CAAC,KAAK,EAAE,CAAA;YACrB,KAAK,MAAM,SAAS,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;gBAAE,SAAS,CAAC,KAAK,EAAE,CAAA;QACpE,CAAC;KACF,CAAA;AACH,CAAC"}
|
package/dist/core/index.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ export type { Desk, FitResult } from './desk.js';
|
|
|
3
3
|
export { addCommandHandler, addDeskCommands, canPerform, chainStart, DeskCommands, perform, STAGE_ATTRIBUTE, WINDOW_ATTRIBUTE, windowElement, } from './commands.js';
|
|
4
4
|
export type { ChainOptions, CommandHandler, CommandId, CommandOptions } from './commands.js';
|
|
5
5
|
export { createService, holdAll } from './services.js';
|
|
6
|
+
export { watchSwipes } from './swipe.js';
|
|
7
|
+
export type { SwipeOptions } from './swipe.js';
|
|
6
8
|
export type { Holdable, Service, ServiceOptions, ServiceRun } from './services.js';
|
|
7
9
|
export { attended, attentionOn, becomesNews, watchAttention } from './attention.js';
|
|
8
10
|
export type { Attention } from './attention.js';
|
|
@@ -15,12 +17,12 @@ export { COLOR_SCHEME_KEY, COLOR_SCHEME_SCRIPT, colorSchemeScript, LOOK_KEY } fr
|
|
|
15
17
|
export { getPreference, localPreferences, setPreference, setPreferenceStore, subscribePreferences } from './preferences.js';
|
|
16
18
|
export type { PreferenceStore } from './preferences.js';
|
|
17
19
|
export type { ColorScheme } from './scheme.js';
|
|
18
|
-
export { applyTheme, applyThemeBasics } from './theme.js';
|
|
20
|
+
export { applyTheme, applyThemeBasics, appliedTheme } from './theme.js';
|
|
19
21
|
export { drawnTheme, THEME_CHANGE, watchThemeChanges } from './themeChange.js';
|
|
20
22
|
export type { ThemeChange } from './themeChange.js';
|
|
21
23
|
export type { AppTheme, DeskTheme, ThemeFont } from './theme.js';
|
|
22
|
-
export { connectHost, DESK_PROTOCOL, findDeskHost, isAppToHost, isDeskHostBridge, isHostToApp, THEME_TOPIC } from './hosted.js';
|
|
23
|
-
export type { AppToHost, Broadcast, BroadcastSender, CommandTarget, DeskChrome, DeskHostBridge, HostAbout, HostAboutFact, HostAboutSection, HostClient, HostDockEntry, HostDockItem, HostDockStack, HostMenu, HostMenuItem, HostSettingsSection, HostToApp, Publisher, } from './hosted.js';
|
|
24
|
+
export { connectHost, DESK_PROTOCOL, findDeskHost, isAppGesture, isAppToHost, isDeskHostBridge, isHostToApp, THEME_TOPIC } from './hosted.js';
|
|
25
|
+
export type { AppGesture, AppToHost, Broadcast, BroadcastSender, CommandTarget, DeskChrome, DeskHostBridge, HostAbout, HostAboutFact, HostAboutSection, HostClient, HostDockEntry, HostDockItem, HostDockStack, HostMenu, HostMenuItem, HostSettingsSection, HostToApp, Publisher, } from './hosted.js';
|
|
24
26
|
export type { Look, LookChoice } from './look.js';
|
|
25
27
|
export { parse, serialize, syncWithLocation } from './location.js';
|
|
26
28
|
export { isTitleCase, titleCase } from './titles.js';
|
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,YAAY,EACZ,WAAW,EACX,SAAS,EACT,WAAW,EACX,WAAW,EACX,MAAM,E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Aa,EACb,QAAQ,EACR,YAAY,EACZ,mBAAmB,EACnB,SAAS,EACT,SAAS,GACV,MAAM,aAAa,CAAA;AACpB,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACjD,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAClE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AACnE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC5D,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AACjE,YAAY,EACV,cAAc,EACd,WAAW,EACX,SAAS,EACT,UAAU,EACV,KAAK,EACL,WAAW,EACX,IAAI,EACJ,QAAQ,EACR,YAAY,EACZ,UAAU,GACX,MAAM,YAAY,CAAA"}
|
package/dist/core/index.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
export { createDesk, cascadeFrame, cascadeSlot, focusedId, instancesOf, isMinimized, isOpen, nextCascadeFrame, onDesk, normalise, routeOf, windowType, EMPTY, } from './desk.js';
|
|
2
2
|
export { addCommandHandler, addDeskCommands, canPerform, chainStart, DeskCommands, perform, STAGE_ATTRIBUTE, WINDOW_ATTRIBUTE, windowElement, } from './commands.js';
|
|
3
3
|
export { createService, holdAll } from './services.js';
|
|
4
|
+
export { watchSwipes } from './swipe.js';
|
|
4
5
|
export { attended, attentionOn, becomesNews, watchAttention } from './attention.js';
|
|
5
6
|
export { createBus, InputCommands, topicMatches } from './events.js';
|
|
6
7
|
export { bindShortcuts, formatShortcut, isApplePlatform, isInstalledApp, matchesShortcut, parseShortcut } from './shortcuts.js';
|
|
7
8
|
export { deviceLook, lookFor, resolveLook } from './look.js';
|
|
8
9
|
export { COLOR_SCHEME_KEY, COLOR_SCHEME_SCRIPT, colorSchemeScript, LOOK_KEY } from './scheme.js';
|
|
9
10
|
export { getPreference, localPreferences, setPreference, setPreferenceStore, subscribePreferences } from './preferences.js';
|
|
10
|
-
export { applyTheme, applyThemeBasics } from './theme.js';
|
|
11
|
+
export { applyTheme, applyThemeBasics, appliedTheme } from './theme.js';
|
|
11
12
|
export { drawnTheme, THEME_CHANGE, watchThemeChanges } from './themeChange.js';
|
|
12
|
-
export { connectHost, DESK_PROTOCOL, findDeskHost, isAppToHost, isDeskHostBridge, isHostToApp, THEME_TOPIC } from './hosted.js';
|
|
13
|
+
export { connectHost, DESK_PROTOCOL, findDeskHost, isAppGesture, isAppToHost, isDeskHostBridge, isHostToApp, THEME_TOPIC } from './hosted.js';
|
|
13
14
|
export { parse, serialize, syncWithLocation } from './location.js';
|
|
14
15
|
export { isTitleCase, titleCase } from './titles.js';
|
|
15
16
|
export { fitFrame, localLayoutStore, stepFrom } from './layouts.js';
|
package/dist/core/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,YAAY,EACZ,WAAW,EACX,SAAS,EACT,WAAW,EACX,WAAW,EACX,MAAM,EACN,gBAAgB,EAChB,MAAM,EACN,SAAS,EACT,OAAO,EACP,UAAU,EACV,KAAK,GACN,MAAM,WAAW,CAAA;AAElB,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,UAAU,EACV,UAAU,EACV,YAAY,EACZ,OAAO,EACP,eAAe,EACf,gBAAgB,EAChB,aAAa,GACd,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,YAAY,EACZ,WAAW,EACX,SAAS,EACT,WAAW,EACX,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,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAClE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AppGesture } from './hosted.js';
|
|
2
|
+
export interface SwipeOptions {
|
|
3
|
+
/** Whether a run that starts on this element is the background's; by default, anything outside a window or the widget list. */
|
|
4
|
+
readonly isBackground?: (target: EventTarget | null) => boolean;
|
|
5
|
+
/** The pause that ends a swipe, in ms. */
|
|
6
|
+
readonly endAfterMs?: number;
|
|
7
|
+
/** For tests: the time, and a delay that returns its cancel. */
|
|
8
|
+
readonly clock?: {
|
|
9
|
+
readonly now: () => number;
|
|
10
|
+
readonly later: (run: () => void, ms: number) => () => void;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/** Watches `element` for swipes that start on its background and passes each on. Returns a stop. */
|
|
14
|
+
export declare function watchSwipes(element: HTMLElement, send: (gesture: AppGesture) => void, options?: SwipeOptions): () => void;
|
|
15
|
+
//# sourceMappingURL=swipe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swipe.d.ts","sourceRoot":"","sources":["../../src/core/swipe.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAiB7C,MAAM,WAAW,YAAY;IAC3B,+HAA+H;IAC/H,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,KAAK,OAAO,CAAA;IAC/D,0CAA0C;IAC1C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;IAC5B,gEAAgE;IAChE,QAAQ,CAAC,KAAK,CAAC,EAAE;QAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,IAAI,EAAE,EAAE,EAAE,MAAM,KAAK,MAAM,IAAI,CAAA;KAAE,CAAA;CAC7G;AAeD,oGAAoG;AACpG,wBAAgB,WAAW,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,OAAO,EAAE,UAAU,KAAK,IAAI,EAAE,OAAO,GAAE,YAAiB,GAAG,MAAM,IAAI,CA2D7H"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { WINDOW_ATTRIBUTE } from './commands.js';
|
|
2
|
+
/** How far a run must go before it is a swipe or a scroll, in px, and how much more sideways than up and down. */
|
|
3
|
+
const DECIDE_PX = 6;
|
|
4
|
+
const SIDEWAYS = 1.5;
|
|
5
|
+
/** A line of a wheel in px, as Chromium scrolls one. */
|
|
6
|
+
const LINE_PX = 40;
|
|
7
|
+
/** How far back the lift-off speed is measured, in ms. */
|
|
8
|
+
const VELOCITY_MS = 80;
|
|
9
|
+
const pixels = (delta, mode, page) => (mode === 1 ? delta * LINE_PX : mode === 2 ? delta * page : delta);
|
|
10
|
+
const outsideWindows = (target) => typeof Element !== 'undefined' && target instanceof Element && !target.closest(`[${WINDOW_ATTRIBUTE}], .desk-widget-list`);
|
|
11
|
+
/** Watches `element` for swipes that start on its background and passes each on. Returns a stop. */
|
|
12
|
+
export function watchSwipes(element, send, options = {}) {
|
|
13
|
+
const isBackground = options.isBackground ?? outsideWindows;
|
|
14
|
+
const endAfter = options.endAfterMs ?? 120;
|
|
15
|
+
const clock = options.clock ?? { now: () => performance.now(), later: (run, ms) => clearTimeout.bind(null, setTimeout(run, ms)) };
|
|
16
|
+
let state = 'idle';
|
|
17
|
+
let x = 0;
|
|
18
|
+
let y = 0;
|
|
19
|
+
let samples = [];
|
|
20
|
+
let cancelEnd = null;
|
|
21
|
+
const velocity = () => {
|
|
22
|
+
const last = samples.at(-1);
|
|
23
|
+
const first = last && samples.find(s => last.at - s.at <= VELOCITY_MS);
|
|
24
|
+
return last && first && last.at > first.at ? ((last.x - first.x) * 1000) / (last.at - first.at) : 0;
|
|
25
|
+
};
|
|
26
|
+
const finish = (phase) => {
|
|
27
|
+
cancelEnd?.();
|
|
28
|
+
cancelEnd = null;
|
|
29
|
+
if (state === 'swiping')
|
|
30
|
+
send(phase === 'end' ? { type: 'swipe', phase, delta: x, velocity: velocity() } : { type: 'swipe', phase, delta: x });
|
|
31
|
+
state = 'idle';
|
|
32
|
+
x = y = 0;
|
|
33
|
+
samples = [];
|
|
34
|
+
};
|
|
35
|
+
const onWheel = (event) => {
|
|
36
|
+
if (event.ctrlKey || event.shiftKey)
|
|
37
|
+
return;
|
|
38
|
+
cancelEnd?.();
|
|
39
|
+
cancelEnd = clock.later(() => finish('end'), endAfter);
|
|
40
|
+
if (state === 'idle')
|
|
41
|
+
state = isBackground(event.target) ? 'deciding' : 'scrolling';
|
|
42
|
+
if (state === 'scrolling')
|
|
43
|
+
return;
|
|
44
|
+
x += pixels(event.deltaX, event.deltaMode, element.clientWidth || innerWidth);
|
|
45
|
+
y += pixels(event.deltaY, event.deltaMode, element.clientHeight || innerHeight);
|
|
46
|
+
if (state === 'deciding') {
|
|
47
|
+
if (Math.abs(x) + Math.abs(y) < DECIDE_PX)
|
|
48
|
+
return;
|
|
49
|
+
if (Math.abs(x) <= SIDEWAYS * Math.abs(y))
|
|
50
|
+
return void (state = 'scrolling');
|
|
51
|
+
state = 'swiping';
|
|
52
|
+
send({ type: 'swipe', phase: 'begin', delta: 0 });
|
|
53
|
+
// Stopped as the begin was heard: it was cancelled, so no move comes after.
|
|
54
|
+
if (state !== 'swiping')
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
// The background's to move now: not the browser's back and forward.
|
|
58
|
+
event.preventDefault();
|
|
59
|
+
samples.push({ at: clock.now(), x });
|
|
60
|
+
if (samples.length > 32)
|
|
61
|
+
samples.shift();
|
|
62
|
+
send({ type: 'swipe', phase: 'move', delta: x });
|
|
63
|
+
};
|
|
64
|
+
// Leaving the window mid-swipe leaves it unfinished: the host puts things back.
|
|
65
|
+
const onLeave = () => finish('cancel');
|
|
66
|
+
const onVisibility = () => document.visibilityState === 'hidden' && finish('cancel');
|
|
67
|
+
element.addEventListener('wheel', onWheel, { passive: false });
|
|
68
|
+
addEventListener('blur', onLeave);
|
|
69
|
+
document.addEventListener('visibilitychange', onVisibility);
|
|
70
|
+
return () => {
|
|
71
|
+
finish('cancel');
|
|
72
|
+
element.removeEventListener('wheel', onWheel);
|
|
73
|
+
removeEventListener('blur', onLeave);
|
|
74
|
+
document.removeEventListener('visibilitychange', onVisibility);
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=swipe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swipe.js","sourceRoot":"","sources":["../../src/core/swipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AA2BhD,kHAAkH;AAClH,MAAM,SAAS,GAAG,CAAC,CAAA;AACnB,MAAM,QAAQ,GAAG,GAAG,CAAA;AACpB,wDAAwD;AACxD,MAAM,OAAO,GAAG,EAAE,CAAA;AAClB,0DAA0D;AAC1D,MAAM,WAAW,GAAG,EAAE,CAAA;AAEtB,MAAM,MAAM,GAAG,CAAC,KAAa,EAAE,IAAY,EAAE,IAAY,EAAE,EAAE,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;AAEhI,MAAM,cAAc,GAAG,CAAC,MAA0B,EAAE,EAAE,CACpD,OAAO,OAAO,KAAK,WAAW,IAAI,MAAM,YAAY,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,gBAAgB,sBAAsB,CAAC,CAAA;AAE5H,oGAAoG;AACpG,MAAM,UA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,QAAQ,CAAC,CAAA;QAChB,OAAO,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QAC7C,mBAAmB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;QACpC,QAAQ,CAAC,mBAAmB,CAAC,kBAAkB,EAAE,YAAY,CAAC,CAAA;IAChE,CAAC,CAAA;AACH,CAAC"}
|
package/dist/core/theme.d.ts
CHANGED
|
@@ -25,6 +25,13 @@ export interface DeskTheme extends AppTheme {
|
|
|
25
25
|
* scheme with a host (an Electron app's `app://` too), or a path.
|
|
26
26
|
*/
|
|
27
27
|
export declare const isImageRef: (wallpaper: string) => boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Whether a custom property's value is plain: a colour, a length, a number, a font list or a gradient.
|
|
30
|
+
* Only letters, digits, spaces and `#.,%/'"+-()*` may appear, every function is one of `FUNCTIONS`, and
|
|
31
|
+
* nothing may escape, end the declaration or open a block. So `url(…)`, `image-set(…)`, `\75rl(` and
|
|
32
|
+
* `red; background: …` are all refused.
|
|
33
|
+
*/
|
|
34
|
+
export declare function isPlainValue(value: string): boolean;
|
|
28
35
|
/**
|
|
29
36
|
* The part of a theme every hosted app wears whatever else it does: light or dark, and the
|
|
30
37
|
* platform chrome. One desktop light and the next dark would look broken as they slide past each
|
|
@@ -38,4 +45,12 @@ export declare function applyThemeBasics(theme: Pick<DeskTheme, 'mode' | 'look'>
|
|
|
38
45
|
* New colours under the same scheme and look still fire `desk-themechange`, for a canvas to repaint.
|
|
39
46
|
*/
|
|
40
47
|
export declare function applyTheme(theme: DeskTheme, root?: HTMLElement): void;
|
|
48
|
+
/** The most tokens a theme may carry: `checkTheme` refuses more, and `appliedTheme` takes no more. */
|
|
49
|
+
export declare const MAX_THEME_TOKENS = 400;
|
|
50
|
+
/**
|
|
51
|
+
* The theme this page wears now, as data another page can wear: light or dark and the look as drawn,
|
|
52
|
+
* and Desk's tokens as they apply on the root. Only what `checkTheme` would pass is taken: a token that
|
|
53
|
+
* loads something (`url(…)`) is left out, and so are fonts, which the page loads its own way.
|
|
54
|
+
*/
|
|
55
|
+
export declare function appliedTheme(root?: HTMLElement): DeskTheme;
|
|
41
56
|
//# sourceMappingURL=theme.d.ts.map
|
package/dist/core/theme.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/core/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAgBrC,sGAAsG;AACtG,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAAA;IAC/B,sFAAsF;IACtF,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CAClD;AAED,mEAAmE;AACnE,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,6DAA6D;IAC7D,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,KAAK,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAA;CACrC;AAED,iGAAiG;AACjG,MAAM,WAAW,SAAU,SAAQ,QAAQ;IACzC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAA;IACnB,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,SAAS,EAAE,CAAA;IACrC,sGAAsG;IACtG,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED;;;GAGG;AACH,eAAO,MAAM,UAAU,cAAe,MAAM,KAAG,OAA4D,CAAA;
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/core/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAgBrC,sGAAsG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