@liberation-data/desk 0.45.0 → 0.46.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 +58 -6
- package/dist/core/hosted.d.ts +15 -0
- package/dist/core/hosted.d.ts.map +1 -1
- package/dist/core/hosted.js +28 -0
- package/dist/core/hosted.js.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/index.js.map +1 -1
- 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 +1 -0
- package/dist/host/router.d.ts.map +1 -1
- package/dist/host/router.js +11 -0
- package/dist/host/router.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 +4 -0
- package/dist/shell/index.d.ts.map +1 -1
- package/dist/shell/index.js +2 -0
- package/dist/shell/index.js.map +1 -1
- 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 +9 -4
- package/package.json +12 -7
- package/src/core/hosted.ts +33 -0
- package/src/core/index.ts +1 -1
- 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 +12 -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 +18 -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)`,
|
|
@@ -905,7 +917,10 @@ rules above, so every transport keeps them alike:
|
|
|
905
917
|
|
|
906
918
|
- The host registers each app (`id`, `origin`, `primary`, `publishes`) and hands the router every message
|
|
907
919
|
the app sends, identified by the transport, never by the message. The primary's `publishes` must
|
|
908
|
-
include `theme`.
|
|
920
|
+
include `theme`. The router answers an app's `hello` with its `role`, and tells it again when the host
|
|
921
|
+
registers it with a different `primary`; register an app before it connects, since a `hello` from an app
|
|
922
|
+
the router doesn't know is refused, unanswered. A host built without the router does the same: it sends
|
|
923
|
+
`{ 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
924
|
stops drawing its menus and dock.
|
|
910
925
|
- A theme is checked before it is passed on (`checkTheme`): tokens must be plain values (colours,
|
|
911
926
|
lengths, font names, gradients) with nothing that loads, such as `url(…)`, and fonts and image
|
|
@@ -952,7 +967,9 @@ import '@liberation-data/desk/css/shell.css'
|
|
|
952
967
|
current="notes"
|
|
953
968
|
chrome={chromeByApp} // each app's DeskChrome, as the router's `chrome` hands it over
|
|
954
969
|
theme={primaryTheme}
|
|
955
|
-
onSwitch={(id, how) => …} // how: 'slide' (or 'zoom'
|
|
970
|
+
onSwitch={(id, how) => …} // how: 'slide' (the keys), or 'zoom' (a click: through HostOverview)
|
|
971
|
+
clickSwitch="slide" // optional: a click slides too, for a host without HostOverview
|
|
972
|
+
onOverview={() => …} // the overview key: open HostOverview
|
|
956
973
|
onCommand={(appId, target, itemId) => …}
|
|
957
974
|
onInsets={insets => …} // bound the apps' views inside these
|
|
958
975
|
/>
|
|
@@ -972,6 +989,41 @@ import '@liberation-data/desk/css/shell.css'
|
|
|
972
989
|
dock. `animate({ durationMs, step, clock: timerClock() })` steps them from a main process, and jumps to
|
|
973
990
|
the end if frames stop, as they do for a hidden window.
|
|
974
991
|
|
|
992
|
+
`HostOverview` is the overview, and the zoom between workspaces through it. A live view can't be scaled,
|
|
993
|
+
so it is drawn with pictures, on an overlay over the apps' views: in an app host, a transparent view of its
|
|
994
|
+
own on top; in a page, a layer over the desktop area (`insets`). The host asks for a move with `request`
|
|
995
|
+
and does what the overlay says:
|
|
996
|
+
|
|
997
|
+
```tsx
|
|
998
|
+
<HostOverview
|
|
999
|
+
workspaces={workspaces} current="notes" theme={primaryTheme} insets={insets}
|
|
1000
|
+
snapshots={pictureById} // URLs or data: URIs; a tile with none shows its title ("Live" if awake)
|
|
1001
|
+
request={{ kind: 'switch', to: 'garage' }} // or { kind: 'open' }; a new object starts a new move, null clears
|
|
1002
|
+
onWantCapture={id => …} // capture this workspace's view now, pass it in `snapshots`, and return a promise of its URL
|
|
1003
|
+
onCover={() => …} // the overlay covers the desktop: the live views may hide
|
|
1004
|
+
onArrive={id => …} // a full-size picture of it shows: swap its view in, clear `request`
|
|
1005
|
+
/>
|
|
1006
|
+
```
|
|
1007
|
+
|
|
1008
|
+
- Only the current workspace is captured, and waited for at most `CAPTURE_WAIT_MS` (100 ms): with no
|
|
1009
|
+
picture by then it goes on with the one it holds, and a late one restarts nothing. A promise returned by
|
|
1010
|
+
`onWantCapture` says when the picture is ready, so an unchanged workspace, which captures the same
|
|
1011
|
+
picture as last time, needn't wait the 100 ms out; without one, only a changed picture in `snapshots`
|
|
1012
|
+
counts. The fog comes in from the first frame. `onCover` and `onArrive` are each said once per move; a request that comes mid-flight
|
|
1013
|
+
carries on from where the tiles are, with no new capture, and a move cut short by a cleared request or
|
|
1014
|
+
an unmount arrives nowhere. The pictures stay the host's: revoke an object URL once its replacement is
|
|
1015
|
+
passed in.
|
|
1016
|
+
- A click on another workspace is out, across and in, about 650 ms (`ZOOM_OUT_MS`, `ZOOM_ACROSS_MS`,
|
|
1017
|
+
`ZOOM_IN_MS`); under reduced motion (`reducedMotion`, else the system's) a 120 ms fade in place
|
|
1018
|
+
(`ZOOM_FADE_MS`), and with `visible={false}` or a hidden page it jumps.
|
|
1019
|
+
- Open, the focus is on the current tile, the overview is said once ("Overview, 3 workspaces"), the arrow
|
|
1020
|
+
keys, Home and End move the focus (the row follows it), Enter or a click goes there, and Escape goes back
|
|
1021
|
+
to the current workspace. The focus goes back where it was when the overlay clears.
|
|
1022
|
+
- The motion is numbers a host can read too, with no DOM: `planZoom(from, to, reducedMotion)` gives the
|
|
1023
|
+
phases between two poses (`{ zoom, centre, fog, opacity }`), `poseAt(plan, ms)` where they stand, and
|
|
1024
|
+
`overviewTiles(count, pose, width)` each tile's place. `pose` holds one pose instead of moving, for a
|
|
1025
|
+
gesture that drives the overview by hand or a still.
|
|
1026
|
+
|
|
975
1027
|
### Menus from the window in front
|
|
976
1028
|
|
|
977
1029
|
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
|
@@ -159,6 +159,11 @@ export type AppToHost = {
|
|
|
159
159
|
readonly kind: 'unsubscribe';
|
|
160
160
|
readonly publisher: Publisher;
|
|
161
161
|
readonly topic: string;
|
|
162
|
+
}
|
|
163
|
+
/** Sent on connecting: the host answers with the app's `role`. */
|
|
164
|
+
| {
|
|
165
|
+
readonly desk: 1;
|
|
166
|
+
readonly kind: 'hello';
|
|
162
167
|
};
|
|
163
168
|
/** What a host sends an app: a choice from the chrome it draws, or another app's broadcast, stamped. */
|
|
164
169
|
export type HostToApp =
|
|
@@ -174,6 +179,12 @@ export type HostToApp =
|
|
|
174
179
|
readonly from: BroadcastSender;
|
|
175
180
|
readonly topic: string;
|
|
176
181
|
readonly payload: unknown;
|
|
182
|
+
}
|
|
183
|
+
/** Whether the app is the primary, whose theme the others wear: the answer to `hello`, and again when it changes. */
|
|
184
|
+
| {
|
|
185
|
+
readonly desk: 1;
|
|
186
|
+
readonly kind: 'role';
|
|
187
|
+
readonly primary: boolean;
|
|
177
188
|
};
|
|
178
189
|
/**
|
|
179
190
|
* The app's end of the connection to its host. The host provides it — an Electron preload through
|
|
@@ -214,6 +225,10 @@ export interface HostClient {
|
|
|
214
225
|
* one straight away, so an app that starts late still hears the current theme.
|
|
215
226
|
*/
|
|
216
227
|
subscribe<T = unknown>(publisher: Publisher, topic: string, handler: (broadcast: Broadcast<T>) => void): () => void;
|
|
228
|
+
/** Whether the host says this app is the primary; null until it has said. */
|
|
229
|
+
primary(): boolean | null;
|
|
230
|
+
/** Calls the listener when the host says whether this app is the primary, now and on any change. */
|
|
231
|
+
onRole(listener: (primary: boolean) => void): () => void;
|
|
217
232
|
/** Stops listening, and takes the chrome away. */
|
|
218
233
|
close(): void;
|
|
219
234
|
}
|
|
@@ -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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EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI,CAAA;IACnH,6EAA6E;IAC7E,OAAO,IAAI,OAAO,GAAG,IAAI,CAAA;IACzB,oGAAoG;IACpG,MAAM,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,GAAG,MAAM,IAAI,CAAA;IACxD,kDAAkD;IAClD,KAAK,IAAI,IAAI,CAAA;CACd;AAID,iIAAiI;AACjI,wBAAgB,WAAW,CAAC,MAAM,EAAE,cAAc,GAAG,UAAU,CAwG9D"}
|
package/dist/core/hosted.js
CHANGED
|
@@ -46,6 +46,8 @@ 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;
|
|
49
51
|
default:
|
|
50
52
|
return false;
|
|
51
53
|
}
|
|
@@ -59,6 +61,8 @@ export function isHostToApp(value) {
|
|
|
59
61
|
return (value.target === 'menu' || value.target === 'dock' || value.target === 'settings') && isString(value.id);
|
|
60
62
|
case 'broadcast':
|
|
61
63
|
return isRecord(value.from) && isString(value.from.id) && isString(value.topic);
|
|
64
|
+
case 'role':
|
|
65
|
+
return typeof value.primary === 'boolean';
|
|
62
66
|
default:
|
|
63
67
|
return false;
|
|
64
68
|
}
|
|
@@ -73,9 +77,20 @@ export function connectHost(bridge) {
|
|
|
73
77
|
/** Per subscription, the broadcasts last heard on each topic it covers, for a second handler that joins later. */
|
|
74
78
|
const subscriptions = new Map();
|
|
75
79
|
const keyOf = (publisher, topic) => `${publisher}\u0000${topic}`;
|
|
80
|
+
let primary = null;
|
|
81
|
+
const roles = new Set();
|
|
76
82
|
const stop = bridge.onMessage(message => {
|
|
77
83
|
if (closed || !isHostToApp(message))
|
|
78
84
|
return;
|
|
85
|
+
if (message.kind === 'role') {
|
|
86
|
+
if (primary === message.primary)
|
|
87
|
+
return;
|
|
88
|
+
primary = message.primary;
|
|
89
|
+
for (const listener of [...roles])
|
|
90
|
+
if (roles.has(listener))
|
|
91
|
+
listener(message.primary);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
79
94
|
if (message.kind === 'command') {
|
|
80
95
|
const listeners = commands[message.target];
|
|
81
96
|
// Copied, and each still checked: a listener may take another away while this one runs.
|
|
@@ -96,6 +111,8 @@ export function connectHost(bridge) {
|
|
|
96
111
|
handler(broadcast);
|
|
97
112
|
}
|
|
98
113
|
});
|
|
114
|
+
// Listening first, so a host that answers at once is heard.
|
|
115
|
+
bridge.send({ desk: DESK_PROTOCOL, kind: 'hello' });
|
|
99
116
|
return {
|
|
100
117
|
bridge,
|
|
101
118
|
setChrome(part) {
|
|
@@ -148,9 +165,20 @@ export function connectHost(bridge) {
|
|
|
148
165
|
}
|
|
149
166
|
};
|
|
150
167
|
},
|
|
168
|
+
primary: () => primary,
|
|
169
|
+
onRole(listener) {
|
|
170
|
+
roles.add(listener);
|
|
171
|
+
if (primary !== null)
|
|
172
|
+
listener(primary);
|
|
173
|
+
return () => {
|
|
174
|
+
roles.delete(listener);
|
|
175
|
+
};
|
|
176
|
+
},
|
|
151
177
|
close() {
|
|
152
178
|
if (closed)
|
|
153
179
|
return;
|
|
180
|
+
roles.clear();
|
|
181
|
+
primary = null;
|
|
154
182
|
bridge.send({ desk: DESK_PROTOCOL, kind: 'chrome', chrome: EMPTY_CHROME });
|
|
155
183
|
// So the host stops sending what nobody here hears.
|
|
156
184
|
for (const { publisher, topic } of subscriptions.values())
|
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;;;;;;;;;;;;;;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CAAC;YACH,CAAC,CAAA;QACH,CAAC;QACD,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO;QACtB,MAAM,CAAC,QAAQ;YACb,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;YACnB,IAAI,OAAO,KAAK,IAAI;gBAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;YACvC,OAAO,GAAG,EAAE;gBACV,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;YACxB,CAAC,CAAA;QACH,CAAC;QACD,KAAK;YACH,IAAI,MAAM;gBAAE,OAAM;YAClB,KAAK,CAAC,KAAK,EAAE,CAAA;YACb,OAAO,GAAG,IAAI,CAAA;YACd,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAA;YAC1E,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
|
@@ -15,7 +15,7 @@ export { COLOR_SCHEME_KEY, COLOR_SCHEME_SCRIPT, colorSchemeScript, LOOK_KEY } fr
|
|
|
15
15
|
export { getPreference, localPreferences, setPreference, setPreferenceStore, subscribePreferences } from './preferences.js';
|
|
16
16
|
export type { PreferenceStore } from './preferences.js';
|
|
17
17
|
export type { ColorScheme } from './scheme.js';
|
|
18
|
-
export { applyTheme, applyThemeBasics } from './theme.js';
|
|
18
|
+
export { applyTheme, applyThemeBasics, appliedTheme } from './theme.js';
|
|
19
19
|
export { drawnTheme, THEME_CHANGE, watchThemeChanges } from './themeChange.js';
|
|
20
20
|
export type { ThemeChange } from './themeChange.js';
|
|
21
21
|
export type { AppTheme, DeskTheme, ThemeFont } from './theme.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,EACN,gBAAgB,EAChB,MAAM,EACN,SAAS,EACT,OAAO,EACP,UAAU,EACV,KAAK,GACN,MAAM,WAAW,CAAA;AAClB,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,UAAU,EACV,UAAU,EACV,YAAY,EACZ,OAAO,EACP,eAAe,EACf,gBAAgB,EAChB,aAAa,GACd,MAAM,eAAe,CAAA;AACtB,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC5F,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACtD,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAClF,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACnF,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AACpE,YAAY,EAAE,GAAG,EAAE,SAAS,E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,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAChE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC/H,YAAY,EACV,SAAS,EACT,SAAS,EACT,eAAe,EACf,aAAa,EACb,UAAU,EACV,cAAc,EACd,SAAS,EACT,aAAa,EACb,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,YAAY,EACZ,aAAa,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
|
@@ -7,7 +7,7 @@ export { bindShortcuts, formatShortcut, isApplePlatform, isInstalledApp, matches
|
|
|
7
7
|
export { deviceLook, lookFor, resolveLook } from './look.js';
|
|
8
8
|
export { COLOR_SCHEME_KEY, COLOR_SCHEME_SCRIPT, colorSchemeScript, LOOK_KEY } from './scheme.js';
|
|
9
9
|
export { getPreference, localPreferences, setPreference, setPreferenceStore, subscribePreferences } from './preferences.js';
|
|
10
|
-
export { applyTheme, applyThemeBasics } from './theme.js';
|
|
10
|
+
export { applyTheme, applyThemeBasics, appliedTheme } from './theme.js';
|
|
11
11
|
export { drawnTheme, THEME_CHANGE, watchThemeChanges } from './themeChange.js';
|
|
12
12
|
export { connectHost, DESK_PROTOCOL, findDeskHost, isAppToHost, isDeskHostBridge, isHostToApp, THEME_TOPIC } from './hosted.js';
|
|
13
13
|
export { parse, serialize, syncWithLocation } from './location.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;AAEtD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEnF,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAEpE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAE/H,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAC5D,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,QAAQ,EAAE,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AAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACvE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAG9E,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAsB/H,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"}
|
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;CAC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CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,GAAE,WAAsC,GAAG,IAAI,CAwB/F;AAED,sGAAsG;AACtG,eAAO,MAAM,gBAAgB,MAAM,CAAA;AA2BnC;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,GAAE,WAAsC,GAAG,SAAS,CASpF"}
|
package/dist/core/theme.js
CHANGED
|
@@ -1,9 +1,33 @@
|
|
|
1
|
-
import { themeChanged, watchThemeChanges } from './themeChange.js';
|
|
1
|
+
import { drawnTheme, themeChanged, watchThemeChanges } from './themeChange.js';
|
|
2
2
|
/**
|
|
3
3
|
* A wallpaper that names an image, rather than being a colour or gradient: a `data:` URI, a URL on any
|
|
4
4
|
* scheme with a host (an Electron app's `app://` too), or a path.
|
|
5
5
|
*/
|
|
6
6
|
export const isImageRef = (wallpaper) => /^(data:|[a-z][\w+.-]*:\/\/|\/)/i.test(wallpaper);
|
|
7
|
+
/** The CSS functions a token may use: colours, maths, gradients and other custom properties. Nothing that loads. */
|
|
8
|
+
const FUNCTIONS = new Set([
|
|
9
|
+
'rgb', 'rgba', 'hsl', 'hsla', 'hwb', 'lab', 'lch', 'oklab', 'oklch', 'color', 'color-mix', 'light-dark',
|
|
10
|
+
'var', 'calc', 'min', 'max', 'clamp',
|
|
11
|
+
'linear-gradient', 'radial-gradient', 'conic-gradient', 'repeating-linear-gradient', 'repeating-radial-gradient',
|
|
12
|
+
]);
|
|
13
|
+
const MAX_VALUE = 300;
|
|
14
|
+
/**
|
|
15
|
+
* Whether a custom property's value is plain: a colour, a length, a number, a font list or a gradient.
|
|
16
|
+
* Only letters, digits, spaces and `#.,%/'"+-()*` may appear, every function is one of `FUNCTIONS`, and
|
|
17
|
+
* nothing may escape, end the declaration or open a block. So `url(…)`, `image-set(…)`, `\75rl(` and
|
|
18
|
+
* `red; background: …` are all refused.
|
|
19
|
+
*/
|
|
20
|
+
export function isPlainValue(value) {
|
|
21
|
+
if (value.length > MAX_VALUE)
|
|
22
|
+
return false;
|
|
23
|
+
if (!/^[\w\s#.,%/'"+*()-]*$/.test(value))
|
|
24
|
+
return false;
|
|
25
|
+
for (const match of value.matchAll(/([\w-]*)\s*\(/g)) {
|
|
26
|
+
if (!FUNCTIONS.has((match[1] ?? '').toLowerCase()))
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
7
31
|
/**
|
|
8
32
|
* The part of a theme every hosted app wears whatever else it does: light or dark, and the
|
|
9
33
|
* platform chrome. One desktop light and the next dark would look broken as they slide past each
|
|
@@ -53,4 +77,52 @@ export function applyTheme(theme, root = document.documentElement) {
|
|
|
53
77
|
if (root.style.cssText !== was)
|
|
54
78
|
themeChanged(root.ownerDocument);
|
|
55
79
|
}
|
|
80
|
+
/** The most tokens a theme may carry: `checkTheme` refuses more, and `appliedTheme` takes no more. */
|
|
81
|
+
export const MAX_THEME_TOKENS = 400;
|
|
82
|
+
/** Desk's custom properties the page sets on its root: in rules on the root, and in the root's own style. */
|
|
83
|
+
function rootTokens(root) {
|
|
84
|
+
const names = new Set();
|
|
85
|
+
const take = (style) => {
|
|
86
|
+
for (let i = 0; i < style.length; i++)
|
|
87
|
+
if (style[i].startsWith('--desk-'))
|
|
88
|
+
names.add(style[i]);
|
|
89
|
+
};
|
|
90
|
+
const walk = (sheet) => {
|
|
91
|
+
let rules;
|
|
92
|
+
try {
|
|
93
|
+
rules = Array.from(sheet?.cssRules ?? []);
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
// Another origin's stylesheet can't be read, and sets none of Desk's tokens.
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
for (const rule of rules) {
|
|
100
|
+
if ('selectorText' in rule && /:root|html|\[data-(theme|look)/.test(rule.selectorText))
|
|
101
|
+
take(rule.style);
|
|
102
|
+
// A block (@media, @layer, @supports) or an @import's sheet, such as desk.css imported by the app's own.
|
|
103
|
+
else if ('cssRules' in rule || 'styleSheet' in rule)
|
|
104
|
+
walk('styleSheet' in rule ? rule.styleSheet : rule);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
for (const sheet of Array.from(root.ownerDocument.styleSheets))
|
|
108
|
+
walk(sheet);
|
|
109
|
+
take(root.style);
|
|
110
|
+
return names;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* The theme this page wears now, as data another page can wear: light or dark and the look as drawn,
|
|
114
|
+
* and Desk's tokens as they apply on the root. Only what `checkTheme` would pass is taken: a token that
|
|
115
|
+
* loads something (`url(…)`) is left out, and so are fonts, which the page loads its own way.
|
|
116
|
+
*/
|
|
117
|
+
export function appliedTheme(root = document.documentElement) {
|
|
118
|
+
const drawn = drawnTheme(root.ownerDocument);
|
|
119
|
+
const computed = getComputedStyle(root);
|
|
120
|
+
const tokens = {};
|
|
121
|
+
for (const name of [...rootTokens(root)].sort()) {
|
|
122
|
+
const value = computed.getPropertyValue(name).trim();
|
|
123
|
+
if (value && isPlainValue(value) && Object.keys(tokens).length < MAX_THEME_TOKENS)
|
|
124
|
+
tokens[name] = value;
|
|
125
|
+
}
|
|
126
|
+
return { mode: drawn.scheme, look: drawn.look, tokens };
|
|
127
|
+
}
|
|
56
128
|
//# sourceMappingURL=theme.js.map
|
package/dist/core/theme.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.js","sourceRoot":"","sources":["../../src/core/theme.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"theme.js","sourceRoot":"","sources":["../../src/core/theme.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAuC9E;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,SAAiB,EAAW,EAAE,CAAC,iCAAiC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;AAE3G,oHAAoH;A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AC,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;QAChD,MAAM,KAAK,GAAG,QAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAA;QACpD,IAAI,KAAK,IAAI,YAAY,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,gBAAgB;YAAE,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAA;IACzG,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,CAAA;AACzD,CAAC"}
|
package/dist/css/shell.css
CHANGED
|
@@ -98,3 +98,92 @@
|
|
|
98
98
|
clip-path: inset(50%);
|
|
99
99
|
white-space: nowrap;
|
|
100
100
|
}
|
|
101
|
+
|
|
102
|
+
/* ── The overview: tiles floating in a fog, drawn on an overlay over the apps' views ── */
|
|
103
|
+
|
|
104
|
+
.desk-overview {
|
|
105
|
+
position: fixed;
|
|
106
|
+
overflow: hidden;
|
|
107
|
+
perspective: 1600px;
|
|
108
|
+
font-family: var(--desk-font);
|
|
109
|
+
color: var(--desk-ink);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.desk-overview-fog {
|
|
113
|
+
position: absolute;
|
|
114
|
+
inset: 0;
|
|
115
|
+
opacity: 0;
|
|
116
|
+
background: radial-gradient(ellipse at center, var(--desk-overview-fog), var(--desk-overview-fog-far));
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/* Each tile is the desktop area's full size, moved and scaled by transform alone, so the compositor does it. */
|
|
120
|
+
.desk-overview-tile {
|
|
121
|
+
position: absolute;
|
|
122
|
+
inset: 0;
|
|
123
|
+
padding: 0;
|
|
124
|
+
border: 0;
|
|
125
|
+
border-radius: 14px;
|
|
126
|
+
background: var(--desk-ground);
|
|
127
|
+
color: inherit;
|
|
128
|
+
font: inherit;
|
|
129
|
+
opacity: 0;
|
|
130
|
+
transform-origin: center;
|
|
131
|
+
will-change: transform, opacity;
|
|
132
|
+
cursor: default;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.desk-overview-tile img {
|
|
136
|
+
position: absolute;
|
|
137
|
+
inset: 0;
|
|
138
|
+
width: 100%;
|
|
139
|
+
height: 100%;
|
|
140
|
+
object-fit: cover;
|
|
141
|
+
border-radius: inherit;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/*
|
|
145
|
+
* The shadow is a small blurred picture, sliced in nine and tinted with the shadow token, not a
|
|
146
|
+
* box-shadow on a layer the size of a desktop. It grows in as the tile goes back.
|
|
147
|
+
*/
|
|
148
|
+
.desk-overview-shadow {
|
|
149
|
+
position: absolute;
|
|
150
|
+
inset: -40px;
|
|
151
|
+
background: var(--desk-overview-shadow);
|
|
152
|
+
-webkit-mask-box-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='b' x='-1' y='-1' width='3' height='3'%3E%3CfeGaussianBlur stdDeviation='14'/%3E%3C/filter%3E%3Crect x='40' y='46' width='80' height='80' rx='14' filter='url(%23b)'/%3E%3C/svg%3E") 60 fill / 60px;
|
|
153
|
+
opacity: var(--desk-overview-depth, 0);
|
|
154
|
+
pointer-events: none;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.desk-overview-note {
|
|
158
|
+
position: absolute;
|
|
159
|
+
inset: 0;
|
|
160
|
+
display: grid;
|
|
161
|
+
place-content: center;
|
|
162
|
+
gap: var(--desk-space-2);
|
|
163
|
+
text-align: center;
|
|
164
|
+
border-radius: inherit;
|
|
165
|
+
background: var(--desk-surface);
|
|
166
|
+
color: var(--desk-muted);
|
|
167
|
+
font-size: var(--desk-text-hero);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.desk-overview-note strong {
|
|
171
|
+
color: var(--desk-ink);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/* The title under each tile, at a size that reads once the tile is small. */
|
|
175
|
+
.desk-overview-title {
|
|
176
|
+
position: absolute;
|
|
177
|
+
top: calc(100% + 24px);
|
|
178
|
+
left: 0;
|
|
179
|
+
right: 0;
|
|
180
|
+
text-align: center;
|
|
181
|
+
font-size: var(--desk-text-hero);
|
|
182
|
+
font-weight: 600;
|
|
183
|
+
opacity: var(--desk-overview-depth, 0);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.desk-overview-tile:focus-visible {
|
|
187
|
+
outline: 5px solid var(--desk-accent);
|
|
188
|
+
outline-offset: 6px;
|
|
189
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isPlainValue } from '../core/theme.js';
|
|
1
2
|
import type { DeskTheme } from '../core/theme.js';
|
|
2
3
|
/** A theme fit to pass on, as a fresh copy, or why it is not. */
|
|
3
4
|
export type ThemeCheck = {
|
|
@@ -7,13 +8,7 @@ export type ThemeCheck = {
|
|
|
7
8
|
readonly ok: false;
|
|
8
9
|
readonly reason: string;
|
|
9
10
|
};
|
|
10
|
-
|
|
11
|
-
* Whether a custom property's value is plain: a colour, a length, a number, a font list or a gradient.
|
|
12
|
-
* Only letters, digits, spaces and `#.,%/'"+-()*` may appear, every function is one of `FUNCTIONS`, and
|
|
13
|
-
* nothing may escape, end the declaration or open a block. So `url(…)`, `image-set(…)`, `\75rl(` and
|
|
14
|
-
* `red; background: …` are all refused.
|
|
15
|
-
*/
|
|
16
|
-
export declare function isPlainValue(value: string): boolean;
|
|
11
|
+
export { isPlainValue };
|
|
17
12
|
/**
|
|
18
13
|
* Whether `url` is on `origin`: the same scheme and host. Compared by hand rather than by `URL.origin`,
|
|
19
14
|
* which is `'null'` for every scheme a browser does not know (an Electron app's `app://` among them,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkTheme.d.ts","sourceRoot":"","sources":["../../src/host/checkTheme.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"checkTheme.d.ts","sourceRoot":"","sources":["../../src/host/checkTheme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,YAAY,EAAoB,MAAM,kBAAkB,CAAA;AAC7E,OAAO,KAAK,EAAE,SAAS,EAAa,MAAM,kBAAkB,CAAA;AAY5D,iEAAiE;AACjE,MAAM,MAAM,UAAU,GAAG;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAA;AAI3H,OAAO,EAAE,YAAY,EAAE,CAAA;AAIvB;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAG1D;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAQ1F;AAGD,eAAO,MAAM,UAAU,QAA0C,CAAA;AAIjE;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,CAsDrE"}
|
package/dist/host/checkTheme.js
CHANGED
|
@@ -1,31 +1,7 @@
|
|
|
1
|
-
import { isImageRef } from '../core/theme.js';
|
|
1
|
+
import { isImageRef, isPlainValue, MAX_THEME_TOKENS } from '../core/theme.js';
|
|
2
2
|
const LOOKS = ['mac', 'gnome', 'windows'];
|
|
3
|
-
|
|
4
|
-
const FUNCTIONS = new Set([
|
|
5
|
-
'rgb', 'rgba', 'hsl', 'hsla', 'hwb', 'lab', 'lch', 'oklab', 'oklch', 'color', 'color-mix', 'light-dark',
|
|
6
|
-
'var', 'calc', 'min', 'max', 'clamp',
|
|
7
|
-
'linear-gradient', 'radial-gradient', 'conic-gradient', 'repeating-linear-gradient', 'repeating-radial-gradient',
|
|
8
|
-
]);
|
|
9
|
-
const MAX_VALUE = 300;
|
|
10
|
-
const MAX_TOKENS = 400;
|
|
3
|
+
export { isPlainValue };
|
|
11
4
|
const MAX_FONTS = 16;
|
|
12
|
-
/**
|
|
13
|
-
* Whether a custom property's value is plain: a colour, a length, a number, a font list or a gradient.
|
|
14
|
-
* Only letters, digits, spaces and `#.,%/'"+-()*` may appear, every function is one of `FUNCTIONS`, and
|
|
15
|
-
* nothing may escape, end the declaration or open a block. So `url(…)`, `image-set(…)`, `\75rl(` and
|
|
16
|
-
* `red; background: …` are all refused.
|
|
17
|
-
*/
|
|
18
|
-
export function isPlainValue(value) {
|
|
19
|
-
if (value.length > MAX_VALUE)
|
|
20
|
-
return false;
|
|
21
|
-
if (!/^[\w\s#.,%/'"+*()-]*$/.test(value))
|
|
22
|
-
return false;
|
|
23
|
-
for (const match of value.matchAll(/([\w-]*)\s*\(/g)) {
|
|
24
|
-
if (!FUNCTIONS.has((match[1] ?? '').toLowerCase()))
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
return true;
|
|
28
|
-
}
|
|
29
5
|
/**
|
|
30
6
|
* Whether `url` is on `origin`: the same scheme and host. Compared by hand rather than by `URL.origin`,
|
|
31
7
|
* which is `'null'` for every scheme a browser does not know (an Electron app's `app://` among them,
|
|
@@ -71,7 +47,7 @@ export function checkTheme(value, origin) {
|
|
|
71
47
|
if (typeof theme.tokens !== 'object' || theme.tokens === null)
|
|
72
48
|
return fail('tokens must be an object');
|
|
73
49
|
const entries = Object.entries(theme.tokens);
|
|
74
|
-
if (entries.length >
|
|
50
|
+
if (entries.length > MAX_THEME_TOKENS)
|
|
75
51
|
return fail('too many tokens');
|
|
76
52
|
const tokens = {};
|
|
77
53
|
for (const [name, token] of entries) {
|