@liberation-data/desk 0.32.1 → 0.34.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 +47 -2
- package/dist/core/attention.d.ts +31 -0
- package/dist/core/attention.d.ts.map +1 -0
- package/dist/core/attention.js +52 -0
- package/dist/core/attention.js.map +1 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +2 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/services.d.ts +31 -0
- package/dist/core/services.d.ts.map +1 -0
- package/dist/core/services.js +79 -0
- package/dist/core/services.js.map +1 -0
- package/dist/css/tokens.css +5 -0
- package/dist/css/windows.css +3 -1
- package/dist/desk.css +8 -1
- package/dist/react/context.d.ts +7 -1
- package/dist/react/context.d.ts.map +1 -1
- package/dist/react/context.js +5 -2
- package/dist/react/context.js.map +1 -1
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +1 -0
- package/dist/react/index.js.map +1 -1
- package/dist/react/services.d.ts +6 -0
- package/dist/react/services.d.ts.map +1 -0
- package/dist/react/services.js +11 -0
- package/dist/react/services.js.map +1 -0
- package/dist/react/shell.d.ts +4 -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/llms.txt +49 -4
- package/package.json +1 -1
- package/src/core/attention.ts +69 -0
- package/src/core/index.ts +4 -0
- package/src/core/services.ts +108 -0
- package/src/css/tokens.css +5 -0
- package/src/css/windows.css +3 -1
- package/src/react/context.tsx +11 -2
- package/src/react/index.ts +1 -0
- package/src/react/services.ts +13 -0
- package/src/react/shell.tsx +5 -2
package/README.md
CHANGED
|
@@ -289,7 +289,8 @@ Text that is read at length, such as a document's section, an answer or a report
|
|
|
289
289
|
|
|
290
290
|
A window's surface takes the theme's colour, which is right for chrome and tiring behind paragraphs. A
|
|
291
291
|
page is a sheet on a neutral ground of its own, `--desk-page`: a shade off the window in a light theme
|
|
292
|
-
and a terminal's grey in a dark one.
|
|
292
|
+
and a terminal's grey in a dark one. A trace of the accent is mixed into it, `--desk-page-tint`, so the
|
|
293
|
+
sheet belongs to the theme it is read in; set that to `0%` for the neutral alone. `fill` makes it at least as tall as the room it is given, so a short
|
|
293
294
|
section is still a whole sheet.
|
|
294
295
|
|
|
295
296
|
`InfoTip` is an (i) holding what the view would explain if asked, so a window does not open with a
|
|
@@ -576,6 +577,50 @@ carries its own bus, so this needs no extra provider. `replay`
|
|
|
576
577
|
delivers the last event on the topic straight away — the window that the event concerns is often opened by
|
|
577
578
|
that very event, and would otherwise miss it by a frame.
|
|
578
579
|
|
|
580
|
+
## Services: what outlives a window
|
|
581
|
+
|
|
582
|
+
A window's data goes when the window does. A count on the dock for a window that is shut, or a list
|
|
583
|
+
a window should not wait for when it opens, has to live somewhere else. That is a service: a value
|
|
584
|
+
anything can read and, optionally, a process that keeps it true.
|
|
585
|
+
|
|
586
|
+
```tsx
|
|
587
|
+
import { createService } from '@liberation-data/desk'
|
|
588
|
+
import { DeskShell, useService } from '@liberation-data/desk/react'
|
|
589
|
+
|
|
590
|
+
const rides = createService<Ride[] | null>({
|
|
591
|
+
id: 'rides',
|
|
592
|
+
initial: null,
|
|
593
|
+
run: ({ set, live }) => {
|
|
594
|
+
void fetchRides().then(found => { if (live()) set(found) })
|
|
595
|
+
},
|
|
596
|
+
})
|
|
597
|
+
|
|
598
|
+
<DeskShell services={[rides]}>…</DeskShell> // read before any window asks
|
|
599
|
+
|
|
600
|
+
function Rides() {
|
|
601
|
+
const found = useService(rides) // already there when the window opens
|
|
602
|
+
return found ? <RideList rides={found} /> : <Loading label="Loading the rides" />
|
|
603
|
+
}
|
|
604
|
+
```
|
|
605
|
+
|
|
606
|
+
A service **runs while somebody holds it**. The desk holds the ones it was given for as long as it is
|
|
607
|
+
on screen, and `useService` holds one for as long as the component is mounted, so a window drawn
|
|
608
|
+
without a desk still gets its data. Holds are counted: the process starts on the first and stops on
|
|
609
|
+
the last. `useServiceValue` reads without holding, which is what a dock badge wants.
|
|
610
|
+
|
|
611
|
+
It does not fetch, cache or retry. `run` brings its own way of getting data; check `live()` after
|
|
612
|
+
every await so an answer that lands after the service stopped is dropped.
|
|
613
|
+
|
|
614
|
+
For a service that counts what arrived unseen, `watchAttention(desk, id, onSeen)` says when a window
|
|
615
|
+
is being looked at: it is the key window, the tab is showing, and the browser has focus.
|
|
616
|
+
|
|
617
|
+
```ts
|
|
618
|
+
const unread = createService({ id: 'unread', initial: 0 })
|
|
619
|
+
|
|
620
|
+
const stop = watchAttention(desk, 'chat', () => unread.set(0))
|
|
621
|
+
if (becomesNews(attentionOn(desk, 'chat', unread.running()))) unread.set(unread.now() + 1)
|
|
622
|
+
```
|
|
623
|
+
|
|
579
624
|
## Conversation
|
|
580
625
|
|
|
581
626
|

|
|
@@ -897,7 +942,7 @@ npm install
|
|
|
897
942
|
npm test # vitest
|
|
898
943
|
npm run typecheck
|
|
899
944
|
npm run example # the Garage sample in examples/garage
|
|
900
|
-
npm run size # the gzipped budget: core
|
|
945
|
+
npm run size # the gzipped budget: core 16 KiB, react 62, css 20, fx 5
|
|
901
946
|
npm run check # everything CI runs
|
|
902
947
|
npm run check:browser # the generated-app bridge in real Chrome, against a running sample
|
|
903
948
|
npm run build # dist/
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Desk } from './desk.js';
|
|
2
|
+
import type { WindowId } from './types.js';
|
|
3
|
+
/** Everything `attended` weighs, as plain values, so the rule can be read and tested without a desk. */
|
|
4
|
+
export interface Attention {
|
|
5
|
+
/** Something is drawing the count. Nothing counts otherwise: a number nobody can see only surprises them later. */
|
|
6
|
+
readonly counted: boolean;
|
|
7
|
+
/** It is the key window: in front, and therefore not minimized or closed. */
|
|
8
|
+
readonly front: boolean;
|
|
9
|
+
/** The browser tab is the one being shown. */
|
|
10
|
+
readonly visible: boolean;
|
|
11
|
+
/** The browser window has the operating system's focus. */
|
|
12
|
+
readonly focused: boolean;
|
|
13
|
+
}
|
|
14
|
+
/** Being looked at right now, which is the one state in which what arrives is not news. */
|
|
15
|
+
export declare const attended: (a: Attention) => boolean;
|
|
16
|
+
/** What arrives is news when something is drawing the count and nobody is looking at the window. */
|
|
17
|
+
export declare const becomesNews: (a: Attention) => boolean;
|
|
18
|
+
/**
|
|
19
|
+
* The attention on one window, now. `counted` is the caller's to say: usually whether the service
|
|
20
|
+
* doing the counting is running, which is whether a dock is there to draw it.
|
|
21
|
+
*/
|
|
22
|
+
export declare function attentionOn(desk: Desk, id: WindowId, counted?: boolean): Attention;
|
|
23
|
+
/**
|
|
24
|
+
* Call `onAttended` at once if the window is being looked at, and again each time it comes to be.
|
|
25
|
+
*
|
|
26
|
+
* THREE SIGNALS, BECAUSE THERE ARE THREE WAYS BACK. Opening or focusing the window is a desk
|
|
27
|
+
* change; returning to the browser tab is a visibility change; coming back to the browser from
|
|
28
|
+
* another application is a window focus. Any one of them can happen without the other two.
|
|
29
|
+
*/
|
|
30
|
+
export declare function watchAttention(desk: Desk, id: WindowId, onAttended: () => void): () => void;
|
|
31
|
+
//# sourceMappingURL=attention.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attention.d.ts","sourceRoot":"","sources":["../../src/core/attention.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAE1C,wGAAwG;AACxG,MAAM,WAAW,SAAS;IACxB,mHAAmH;IACnH,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,6EAA6E;IAC7E,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;IACvB,8CAA8C;IAC9C,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,2DAA2D;IAC3D,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAC1B;AAED,2FAA2F;AAC3F,eAAO,MAAM,QAAQ,MAAO,SAAS,KAAG,OAA4C,CAAA;AAEpF,oGAAoG;AACpG,eAAO,MAAM,WAAW,MAAO,SAAS,KAAG,OAAoC,CAAA;AAK/E;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,UAAO,GAAG,SAAS,CAQ/E;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAc3F"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* WHETHER SOMEBODY IS LOOKING AT A WINDOW RIGHT NOW.
|
|
3
|
+
*
|
|
4
|
+
* A service that counts what arrived unseen has to know what "seen" is, and the answer is the same
|
|
5
|
+
* for every window: it is the key window, the browser tab is the one showing, and the browser has
|
|
6
|
+
* the operating system's focus. All three, because each can be false on its own: a window in full
|
|
7
|
+
* view behind somebody's editor is not being looked at.
|
|
8
|
+
*/
|
|
9
|
+
import { focusedId } from './desk.js';
|
|
10
|
+
/** Being looked at right now, which is the one state in which what arrives is not news. */
|
|
11
|
+
export const attended = (a) => a.front && a.visible && a.focused;
|
|
12
|
+
/** What arrives is news when something is drawing the count and nobody is looking at the window. */
|
|
13
|
+
export const becomesNews = (a) => a.counted && !attended(a);
|
|
14
|
+
/** Where there is no document there is no tab to hide and no browser to leave: only the desk can say. */
|
|
15
|
+
const page = () => (typeof document === 'undefined' ? null : document);
|
|
16
|
+
/**
|
|
17
|
+
* The attention on one window, now. `counted` is the caller's to say: usually whether the service
|
|
18
|
+
* doing the counting is running, which is whether a dock is there to draw it.
|
|
19
|
+
*/
|
|
20
|
+
export function attentionOn(desk, id, counted = true) {
|
|
21
|
+
const doc = page();
|
|
22
|
+
return {
|
|
23
|
+
counted,
|
|
24
|
+
front: focusedId(desk.getState()) === id,
|
|
25
|
+
visible: !(doc?.hidden ?? false),
|
|
26
|
+
focused: doc?.hasFocus() ?? true,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Call `onAttended` at once if the window is being looked at, and again each time it comes to be.
|
|
31
|
+
*
|
|
32
|
+
* THREE SIGNALS, BECAUSE THERE ARE THREE WAYS BACK. Opening or focusing the window is a desk
|
|
33
|
+
* change; returning to the browser tab is a visibility change; coming back to the browser from
|
|
34
|
+
* another application is a window focus. Any one of them can happen without the other two.
|
|
35
|
+
*/
|
|
36
|
+
export function watchAttention(desk, id, onAttended) {
|
|
37
|
+
const check = () => {
|
|
38
|
+
if (attended(attentionOn(desk, id)))
|
|
39
|
+
onAttended();
|
|
40
|
+
};
|
|
41
|
+
const doc = page();
|
|
42
|
+
const stopDesk = desk.subscribe(check);
|
|
43
|
+
doc?.defaultView?.addEventListener('focus', check);
|
|
44
|
+
doc?.addEventListener('visibilitychange', check);
|
|
45
|
+
check();
|
|
46
|
+
return () => {
|
|
47
|
+
stopDesk();
|
|
48
|
+
doc?.defaultView?.removeEventListener('focus', check);
|
|
49
|
+
doc?.removeEventListener('visibilitychange', check);
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=attention.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attention.js","sourceRoot":"","sources":["../../src/core/attention.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAgBrC,2FAA2F;AAC3F,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAY,EAAW,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO,CAAA;AAEpF,oGAAoG;AACpG,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAY,EAAW,EAAE,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,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IACrD,CAAC,CAAA;AACH,CAAC"}
|
package/dist/core/index.d.ts
CHANGED
|
@@ -2,6 +2,10 @@ export { createDesk, cascadeFrame, cascadeSlot, focusedId, instancesOf, isMinimi
|
|
|
2
2
|
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
|
+
export { createService, holdAll } from './services.js';
|
|
6
|
+
export type { Holdable, Service, ServiceOptions, ServiceRun } from './services.js';
|
|
7
|
+
export { attended, attentionOn, becomesNews, watchAttention } from './attention.js';
|
|
8
|
+
export type { Attention } from './attention.js';
|
|
5
9
|
export { createBus, InputCommands, topicMatches } from './events.js';
|
|
6
10
|
export type { Bus, DeskEvent, EventHandler, InputDescription, SubscribeOptions } from './events.js';
|
|
7
11
|
export { bindShortcuts, formatShortcut, isApplePlatform, isInstalledApp, matchesShortcut, parseShortcut } from './shortcuts.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,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,EAA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AAO,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,5 +1,7 @@
|
|
|
1
1
|
export { createDesk, cascadeFrame, cascadeSlot, focusedId, instancesOf, isMinimized, isOpen, nextCascadeFrame, onDesk, normalise, windowType, EMPTY, } from './desk.js';
|
|
2
2
|
export { addCommandHandler, addDeskCommands, canPerform, chainStart, DeskCommands, perform, STAGE_ATTRIBUTE, WINDOW_ATTRIBUTE, windowElement, } from './commands.js';
|
|
3
|
+
export { createService, holdAll } from './services.js';
|
|
4
|
+
export { attended, attentionOn, becomesNews, watchAttention } from './attention.js';
|
|
3
5
|
export { createBus, InputCommands, topicMatches } from './events.js';
|
|
4
6
|
export { bindShortcuts, formatShortcut, isApplePlatform, isInstalledApp, matchesShortcut, parseShortcut } from './shortcuts.js';
|
|
5
7
|
export { deviceLook, lookFor, resolveLook } from './look.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,UAAU,EACV,KAAK,GACN,MAAM,WAAW,CAAA;AAElB,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,UAAU,EACV,UAAU,EACV,YAAY,EACZ,OAAO,EAC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M,gBAAgB,CAAA;AAE/H,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAE5D,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"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** What a service's process is given to work with. */
|
|
2
|
+
export interface ServiceRun<T> {
|
|
3
|
+
readonly now: () => T;
|
|
4
|
+
/** Replace the value and tell every reader. Setting the value it already has tells nobody. */
|
|
5
|
+
readonly set: (next: T) => void;
|
|
6
|
+
/** False once this run has been stopped. Check it after every await, so a late answer is dropped. */
|
|
7
|
+
readonly live: () => boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface ServiceOptions<T> {
|
|
10
|
+
/** Named for a log line and a test, as a window is named by its id. */
|
|
11
|
+
readonly id: string;
|
|
12
|
+
readonly initial: T;
|
|
13
|
+
/** The process, started on the first hold. What it returns is run on the last release. */
|
|
14
|
+
readonly run?: (run: ServiceRun<T>) => (() => void) | void;
|
|
15
|
+
}
|
|
16
|
+
export interface Service<T> {
|
|
17
|
+
readonly id: string;
|
|
18
|
+
readonly now: () => T;
|
|
19
|
+
readonly set: (next: T) => void;
|
|
20
|
+
readonly subscribe: (listener: () => void) => () => void;
|
|
21
|
+
/** Keep it running. Gives back the release, which may be called more than once. */
|
|
22
|
+
readonly hold: () => () => void;
|
|
23
|
+
/** True while anything holds it. */
|
|
24
|
+
readonly running: () => boolean;
|
|
25
|
+
}
|
|
26
|
+
/** Anything that can be held: a service of any value. */
|
|
27
|
+
export type Holdable = Pick<Service<unknown>, 'hold'>;
|
|
28
|
+
export declare function createService<T>({ id, initial, run }: ServiceOptions<T>): Service<T>;
|
|
29
|
+
/** Hold several at once, and give back one release for all of them. */
|
|
30
|
+
export declare function holdAll(services: readonly Holdable[]): () => void;
|
|
31
|
+
//# sourceMappingURL=services.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"services.d.ts","sourceRoot":"","sources":["../../src/core/services.ts"],"names":[],"mappings":"AAmBA,sDAAsD;AACtD,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;IACrB,8FAA8F;IAC9F,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAA;IAC/B,qGAAqG;IACrG,QAAQ,CAAC,IAAI,EAAE,MAAM,OAAO,CAAA;CAC7B;AAED,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,uEAAuE;IACvE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAA;IACnB,0FAA0F;IAC1F,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAA;CAC3D;AAED,MAAM,WAAW,OAAO,CAAC,CAAC;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;IACrB,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAA;IAC/B,QAAQ,CAAC,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAA;IACxD,mFAAmF;IACnF,QAAQ,CAAC,IAAI,EAAE,MAAM,MAAM,IAAI,CAAA;IAC/B,oCAAoC;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,OAAO,CAAA;CAChC;AAED,yDAAyD;AACzD,MAAM,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,CAAA;AAErD,wBAAgB,aAAa,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAiDpF;AAED,uEAAuE;AACvE,wBAAgB,OAAO,CAAC,QAAQ,EAAE,SAAS,QAAQ,EAAE,GAAG,MAAM,IAAI,CAKjE"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* A SERVICE: SOMETHING THE DESK KEEPS GOING THAT IS NOT A WINDOW.
|
|
3
|
+
*
|
|
4
|
+
* A window's data dies with the window. Some of what an app knows has to outlive that: a count on
|
|
5
|
+
* the dock for a window that is shut, or a list a window should not have to wait for when it opens.
|
|
6
|
+
*
|
|
7
|
+
* A service is a VALUE, readable by anything, and optionally a PROCESS that keeps the value true.
|
|
8
|
+
*
|
|
9
|
+
* IT RUNS WHILE SOMEBODY HOLDS IT. A desk holds the services it was given for as long as it is on
|
|
10
|
+
* screen; a component that reads one with `useService` holds it for as long as it is mounted. The
|
|
11
|
+
* process starts on the first hold and stops on the last release, so a window drawn without a desk
|
|
12
|
+
* (a test, a preview) still gets its data, and a desk already running it costs that window nothing.
|
|
13
|
+
* Holds are counted: two holders are independent, and neither's teardown may stop the service while
|
|
14
|
+
* the other still needs it.
|
|
15
|
+
*
|
|
16
|
+
* A SERVICE DOES NOT KNOW HOW TO FETCH. Its process brings its own way of getting data, and its own
|
|
17
|
+
* caching and retrying if it wants them. What is here is when it runs and who can read it.
|
|
18
|
+
*/
|
|
19
|
+
export function createService({ id, initial, run }) {
|
|
20
|
+
let value = initial;
|
|
21
|
+
let holds = 0;
|
|
22
|
+
let stop = null;
|
|
23
|
+
const listeners = new Set();
|
|
24
|
+
const now = () => value;
|
|
25
|
+
const set = (next) => {
|
|
26
|
+
if (Object.is(next, value))
|
|
27
|
+
return;
|
|
28
|
+
value = next;
|
|
29
|
+
for (const listener of [...listeners])
|
|
30
|
+
listener();
|
|
31
|
+
};
|
|
32
|
+
const start = () => {
|
|
33
|
+
let live = true;
|
|
34
|
+
const ended = run?.({ now, set, live: () => live });
|
|
35
|
+
stop = () => {
|
|
36
|
+
live = false;
|
|
37
|
+
if (typeof ended === 'function')
|
|
38
|
+
ended();
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
const hold = () => {
|
|
42
|
+
holds += 1;
|
|
43
|
+
if (holds === 1)
|
|
44
|
+
start();
|
|
45
|
+
let released = false;
|
|
46
|
+
return () => {
|
|
47
|
+
if (released)
|
|
48
|
+
return;
|
|
49
|
+
released = true;
|
|
50
|
+
holds -= 1;
|
|
51
|
+
if (holds > 0)
|
|
52
|
+
return;
|
|
53
|
+
stop?.();
|
|
54
|
+
stop = null;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
return {
|
|
58
|
+
id,
|
|
59
|
+
now,
|
|
60
|
+
set,
|
|
61
|
+
subscribe: listener => {
|
|
62
|
+
listeners.add(listener);
|
|
63
|
+
return () => {
|
|
64
|
+
listeners.delete(listener);
|
|
65
|
+
};
|
|
66
|
+
},
|
|
67
|
+
hold,
|
|
68
|
+
running: () => holds > 0,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/** Hold several at once, and give back one release for all of them. */
|
|
72
|
+
export function holdAll(services) {
|
|
73
|
+
const releases = services.map(service => service.hold());
|
|
74
|
+
return () => {
|
|
75
|
+
for (const release of releases)
|
|
76
|
+
release();
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=services.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"services.js","sourceRoot":"","sources":["../../src/core/services.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAiCH,MAAM,UAAU,aAAa,CAAI,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,EAAqB;IACtE,IAAI,KA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AAG;QACH,GAAG;QACH,SAAS,EAAE,QAAQ,CAAC,EAAE;YACpB,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;YACvB,OAAO,GAAG,EAAE;gBACV,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;YAC5B,CAAC,CAAA;QACH,CAAC;QACD,IAAI;QACJ,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,GAAG,CAAC;KACzB,CAAA;AACH,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,OAAO,CAAC,QAA6B;IACnD,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAA;IACxD,OAAO,GAAG,EAAE;QACV,KAAK,MAAM,OAAO,IAAI,QAAQ;YAAE,OAAO,EAAE,CAAA;IAC3C,CAAC,CAAA;AACH,CAAC"}
|
package/dist/css/tokens.css
CHANGED
|
@@ -65,6 +65,9 @@
|
|
|
65
65
|
/* What long text lies on (`Page`). Neutral, not the surface's hue: a shade off a white window,
|
|
66
66
|
a terminal's grey in a dark one. */
|
|
67
67
|
--desk-page: #f4f5f7;
|
|
68
|
+
/* How much of the accent is mixed into it, so the sheet belongs to the theme it is read in.
|
|
69
|
+
0% is the neutral alone. */
|
|
70
|
+
--desk-page-tint: 4%;
|
|
68
71
|
--desk-on-accent: #ffffff;
|
|
69
72
|
--desk-ease: cubic-bezier(.32, .72, 0, 1);
|
|
70
73
|
--desk-dock-size: 48px;
|
|
@@ -103,6 +106,7 @@
|
|
|
103
106
|
--desk-led-glow: 7px;
|
|
104
107
|
--desk-field-bg: rgb(0 0 0 / 35%);
|
|
105
108
|
--desk-page: #26282c;
|
|
109
|
+
--desk-page-tint: 5%;
|
|
106
110
|
}
|
|
107
111
|
}
|
|
108
112
|
|
|
@@ -128,4 +132,5 @@
|
|
|
128
132
|
--desk-led-glow: 7px;
|
|
129
133
|
--desk-field-bg: rgb(0 0 0 / 35%);
|
|
130
134
|
--desk-page: #26282c;
|
|
135
|
+
--desk-page-tint: 5%;
|
|
131
136
|
}
|
package/dist/css/windows.css
CHANGED
|
@@ -440,7 +440,9 @@
|
|
|
440
440
|
padding: var(--desk-space-5) var(--desk-space-6);
|
|
441
441
|
border: 1px solid var(--desk-rule);
|
|
442
442
|
border-radius: var(--desk-control-radius);
|
|
443
|
-
|
|
443
|
+
/* Mixed here and not in the token: an app that sets its accent below the root would otherwise
|
|
444
|
+
get the root's accent in its page. */
|
|
445
|
+
background: color-mix(in srgb, var(--desk-accent) var(--desk-page-tint), var(--desk-page));
|
|
444
446
|
color: var(--desk-ink);
|
|
445
447
|
}
|
|
446
448
|
|
package/dist/desk.css
CHANGED
|
@@ -65,6 +65,9 @@
|
|
|
65
65
|
/* What long text lies on (`Page`). Neutral, not the surface's hue: a shade off a white window,
|
|
66
66
|
a terminal's grey in a dark one. */
|
|
67
67
|
--desk-page: #f4f5f7;
|
|
68
|
+
/* How much of the accent is mixed into it, so the sheet belongs to the theme it is read in.
|
|
69
|
+
0% is the neutral alone. */
|
|
70
|
+
--desk-page-tint: 4%;
|
|
68
71
|
--desk-on-accent: #ffffff;
|
|
69
72
|
--desk-ease: cubic-bezier(.32, .72, 0, 1);
|
|
70
73
|
--desk-dock-size: 48px;
|
|
@@ -103,6 +106,7 @@
|
|
|
103
106
|
--desk-led-glow: 7px;
|
|
104
107
|
--desk-field-bg: rgb(0 0 0 / 35%);
|
|
105
108
|
--desk-page: #26282c;
|
|
109
|
+
--desk-page-tint: 5%;
|
|
106
110
|
}
|
|
107
111
|
}
|
|
108
112
|
|
|
@@ -128,6 +132,7 @@
|
|
|
128
132
|
--desk-led-glow: 7px;
|
|
129
133
|
--desk-field-bg: rgb(0 0 0 / 35%);
|
|
130
134
|
--desk-page: #26282c;
|
|
135
|
+
--desk-page-tint: 5%;
|
|
131
136
|
}
|
|
132
137
|
|
|
133
138
|
/* @liberation-data/desk — windows.css */
|
|
@@ -572,7 +577,9 @@
|
|
|
572
577
|
padding: var(--desk-space-5) var(--desk-space-6);
|
|
573
578
|
border: 1px solid var(--desk-rule);
|
|
574
579
|
border-radius: var(--desk-control-radius);
|
|
575
|
-
|
|
580
|
+
/* Mixed here and not in the token: an app that sets its accent below the root would otherwise
|
|
581
|
+
get the root's accent in its page. */
|
|
582
|
+
background: color-mix(in srgb, var(--desk-accent) var(--desk-page-tint), var(--desk-page));
|
|
576
583
|
color: var(--desk-ink);
|
|
577
584
|
}
|
|
578
585
|
|
package/dist/react/context.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ReactNode, RefObject } from 'react';
|
|
2
2
|
import type { Bus } from '../core/events.js';
|
|
3
|
+
import type { Holdable } from '../core/services.js';
|
|
3
4
|
import type { Look, LookChoice } from '../core/look.js';
|
|
4
5
|
import type { Desk } from '../core/desk.js';
|
|
5
6
|
import type { DeskOptions, DeskState, WindowId } from '../core/types.js';
|
|
@@ -16,9 +17,14 @@ export interface DeskProviderProps {
|
|
|
16
17
|
* chose. The app keeps that choice where it keeps its other preferences; the desk does not store it.
|
|
17
18
|
*/
|
|
18
19
|
readonly look?: LookChoice;
|
|
20
|
+
/**
|
|
21
|
+
* What the desk keeps going while it is on screen: each is held from mount to unmount. Read once,
|
|
22
|
+
* so the array need not be stable.
|
|
23
|
+
*/
|
|
24
|
+
readonly services?: readonly Holdable[];
|
|
19
25
|
readonly children: ReactNode;
|
|
20
26
|
}
|
|
21
|
-
export declare function DeskProvider({ desk, options, look, children }: DeskProviderProps): import("react").JSX.Element;
|
|
27
|
+
export declare function DeskProvider({ desk, options, look, services, children }: DeskProviderProps): import("react").JSX.Element;
|
|
22
28
|
/** The look the desk is wearing, for an app that draws chrome of its own. Outside a desk, the device's. */
|
|
23
29
|
export declare const useLook: () => Look;
|
|
24
30
|
/** The desk above, or null outside one: for parts that work on a desk and off one, like a context menu. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/react/context.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEjD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/react/context.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEjD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AAI5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAGvD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAMzD,qGAAqG;AACrG,eAAO,MAAM,UAAU,qCAAkC,CAAA;AAEzD,MAAM,WAAW,iBAAiB;IAChC,sEAAsE;IACtE,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAA;IACpB,2DAA2D;IAC3D,QAAQ,CAAC,OAAO,CAAC,EAAE,WAAW,CAAA;IAC9B;;;OAGG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,CAAA;IAC1B;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,QAAQ,EAAE,CAAA;IACvC,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAA;CAC7B;AAED,wBAAgB,YAAY,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,iBAAiB,+BAsBnG;AAED,2GAA2G;AAC3G,eAAO,MAAM,OAAO,QAAO,IAA+C,CAAA;AAE1E,2GAA2G;AAC3G,eAAO,MAAM,eAAe,QAAO,IAAI,GAAG,IAA+B,CAAA;AAEzE,wBAAgB,OAAO,IAAI,IAAI,CAI9B;AAED,wBAAgB,YAAY,IAAI,SAAS,CAGxC;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAA;IACrB,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;IAC/C,mGAAmG;IACnG,QAAQ,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI,KAAK,IAAI,CAAA;IAC/D,yGAAyG;IACzG,QAAQ,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAA;IAC3C,sDAAsD;IACtD,QAAQ,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAA;CAC5C;AAED,gFAAgF;AAChF,eAAO,MAAM,aAAa,oDAAiD,CAAA;AAE3E,sFAAsF;AACtF,eAAO,MAAM,WAAW,QAAO,QAAQ,GAAG,IAA6C,CAAA"}
|
package/dist/react/context.js
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createContext, useContext, useLayoutEffect, useState, useSyncExternalStore } from 'react';
|
|
2
|
+
import { createContext, useContext, useEffect, useLayoutEffect, useState, useSyncExternalStore } from 'react';
|
|
3
3
|
import { createBus } from '../core/events.js';
|
|
4
4
|
import { createDesk } from '../core/desk.js';
|
|
5
5
|
import { deviceLook, resolveLook } from '../core/look.js';
|
|
6
|
+
import { holdAll } from '../core/services.js';
|
|
6
7
|
import { DragProvider } from './dragContext.js';
|
|
7
8
|
import { missingProvider } from './missingProvider.js';
|
|
8
9
|
const DeskContext = createContext(null);
|
|
9
10
|
const LookContext = createContext(null);
|
|
10
11
|
/** Every desk comes with a bus; <BusProvider> only matters when one has to be shared or supplied. */
|
|
11
12
|
export const BusContext = createContext(null);
|
|
12
|
-
export function DeskProvider({ desk, options, look = 'auto', children }) {
|
|
13
|
+
export function DeskProvider({ desk, options, look = 'auto', services, children }) {
|
|
13
14
|
const [value] = useState(() => desk ?? createDesk(options));
|
|
14
15
|
const [bus] = useState(createBus);
|
|
16
|
+
const [held] = useState(() => services ?? []);
|
|
17
|
+
useEffect(() => holdAll(held), [held]);
|
|
15
18
|
const resolved = resolveLook(look);
|
|
16
19
|
// On the root, not the desk: menus and popovers are portalled out of it, and are chrome too.
|
|
17
20
|
useLayoutEffect(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/react/context.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,eAAe,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/react/context.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,eAAe,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAA;AAE7G,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAE7C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAG7C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAKtD,MAAM,WAAW,GAAG,aAAa,CAAc,IAAI,CAAC,CAAA;AAEpD,MAAM,WAAW,GAAG,aAAa,CAAc,IAAI,CAAC,CAAA;AAEpD,qGAAqG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AAI,UAAU,EAAE,CAAA;AAE1E,2GAA2G;AAC3G,MAAM,CAAC,MAAM,eAAe,GAAG,GAAgB,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,CAAA;AAEzE,MAAM,UAAU,OAAO;IACrB,MAAM,IAAI,GAAG,UAAU,CAAC,WAAW,CAAC,CAAA;IACpC,IAAI,CAAC,IAAI;QAAE,MAAM,eAAe,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAA;IAC/D,OAAO,IAAI,CAAA;AACb,CAAC;AAED,MAAM,UAAU,YAAY;IAC1B,MAAM,IAAI,GAAG,OAAO,EAAE,CAAA;IACtB,OAAO,oBAAoB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAA;AAC3E,CAAC;AAaD,gFAAgF;AAChF,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAA4B,IAAI,CAAC,CAAA;AAE3E,sFAAsF;AACtF,MAAM,CAAC,MAAM,WAAW,GAAG,GAAoB,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,EAAE,IAAI,IAAI,CAAA"}
|
package/dist/react/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export { useCanPerform, useCommand, usePerform, useShortcuts } from './commands.
|
|
|
10
10
|
export type { UseCommandOptions } from './commands.js';
|
|
11
11
|
export { Desktop } from './Desktop.js';
|
|
12
12
|
export type { DeskLayout, DesktopProps } from './Desktop.js';
|
|
13
|
+
export { useService, useServiceValue } from './services.js';
|
|
13
14
|
export { useDocumentTitle } from './documentTitle.js';
|
|
14
15
|
export type { DocumentTitleOptions } from './documentTitle.js';
|
|
15
16
|
export { lazyWindow } from './windowBoundary.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM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EAAE,SAAS,EAAE,MAAM,WAAW,CAAA"}
|
package/dist/react/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export { DeskShell } from './shell.js';
|
|
|
4
4
|
export { DeskProvider, useDesk, useDeskState, useLook, useWindowId } from './context.js';
|
|
5
5
|
export { useCanPerform, useCommand, usePerform, useShortcuts } from './commands.js';
|
|
6
6
|
export { Desktop } from './Desktop.js';
|
|
7
|
+
export { useService, useServiceValue } from './services.js';
|
|
7
8
|
export { useDocumentTitle } from './documentTitle.js';
|
|
8
9
|
export { lazyWindow } from './windowBoundary.js';
|
|
9
10
|
export { Button, Checkbox, ChoiceGroup, RadioGroup, SegmentedControl, Slider, TextField, Toggle } from './controls.js';
|
package/dist/react/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAE1E,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAWhG,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAEtC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAExF,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEnF,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAErD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAEhD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,M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AM,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAErG,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAEpD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAE9E,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC3G,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAGjD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Service } from '../core/services.js';
|
|
2
|
+
/** The value, live, WITHOUT holding the service: for a reader that must not be what keeps it running. */
|
|
3
|
+
export declare function useServiceValue<T>(service: Service<T>): T;
|
|
4
|
+
/** The value, live, and the service held for as long as this is mounted. */
|
|
5
|
+
export declare function useService<T>(service: Service<T>): T;
|
|
6
|
+
//# sourceMappingURL=services.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"services.d.ts","sourceRoot":"","sources":["../../src/react/services.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAElD,yGAAyG;AACzG,wBAAgB,eAAe,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAEzD;AAED,4EAA4E;AAC5E,wBAAgB,UAAU,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAGpD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useEffect, useSyncExternalStore } from 'react';
|
|
2
|
+
/** The value, live, WITHOUT holding the service: for a reader that must not be what keeps it running. */
|
|
3
|
+
export function useServiceValue(service) {
|
|
4
|
+
return useSyncExternalStore(service.subscribe, service.now, service.now);
|
|
5
|
+
}
|
|
6
|
+
/** The value, live, and the service held for as long as this is mounted. */
|
|
7
|
+
export function useService(service) {
|
|
8
|
+
useEffect(() => service.hold(), [service]);
|
|
9
|
+
return useServiceValue(service);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=services.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"services.js","sourceRoot":"","sources":["../../src/react/services.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAA;AAGvD,yGAAyG;AACzG,MAAM,UAAU,eAAe,CAAI,OAAmB;IACpD,OAAO,oBAAoB,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,CAAA;AAC1E,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,UAAU,CAAI,OAAmB;IAC/C,SAAS,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAA;IAC1C,OAAO,eAAe,CAAC,OAAO,CAAC,CAAA;AACjC,CAAC"}
|
package/dist/react/shell.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { ReactNode } from 'react';
|
|
|
2
2
|
import type { Desk } from '../core/desk.js';
|
|
3
3
|
import type { Bus } from '../core/events.js';
|
|
4
4
|
import type { LookChoice } from '../core/look.js';
|
|
5
|
+
import type { Holdable } from '../core/services.js';
|
|
5
6
|
import type { DeskOptions } from '../core/types.js';
|
|
6
7
|
export interface DeskShellProps {
|
|
7
8
|
/** An existing desk. One is made from `options` when this is left out. */
|
|
@@ -13,8 +14,10 @@ export interface DeskShellProps {
|
|
|
13
14
|
readonly toasts?: boolean;
|
|
14
15
|
/** The platform chrome: `auto` (the default) matches the device. See `DeskProviderProps.look`. */
|
|
15
16
|
readonly look?: LookChoice;
|
|
17
|
+
/** What the desk keeps going while it is on screen. See `DeskProviderProps.services`. */
|
|
18
|
+
readonly services?: readonly Holdable[];
|
|
16
19
|
readonly children: ReactNode;
|
|
17
20
|
}
|
|
18
21
|
/** Everything an app needs around it, in one component: the desk, its bus, and toasts. */
|
|
19
|
-
export declare function DeskShell({ desk, options, bus, toasts, look, children }: DeskShellProps): import("react").JSX.Element;
|
|
22
|
+
export declare function DeskShell({ desk, options, bus, toasts, look, services, children }: DeskShellProps): import("react").JSX.Element;
|
|
20
23
|
//# sourceMappingURL=shell.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../src/react/shell.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAKnD,MAAM,WAAW,cAAc;IAC7B,0EAA0E;IAC1E,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAA;IACpB,QAAQ,CAAC,OAAO,CAAC,EAAE,WAAW,CAAA;IAC9B,gFAAgF;IAChF,QAAQ,CAAC,GAAG,CAAC,EAAE,GAAG,CAAA;IAClB,qEAAqE;IACrE,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAA;IACzB,kGAAkG;IAClG,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,CAAA;IAC1B,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAA;CAC7B;AAED,0FAA0F;AAC1F,wBAAgB,SAAS,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAa,EAAE,IAAa,EAAE,QAAQ,EAAE,EAAE,cAAc,+
|
|
1
|
+
{"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../src/react/shell.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAKnD,MAAM,WAAW,cAAc;IAC7B,0EAA0E;IAC1E,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAA;IACpB,QAAQ,CAAC,OAAO,CAAC,EAAE,WAAW,CAAA;IAC9B,gFAAgF;IAChF,QAAQ,CAAC,GAAG,CAAC,EAAE,GAAG,CAAA;IAClB,qEAAqE;IACrE,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAA;IACzB,kGAAkG;IAClG,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,CAAA;IAC1B,yFAAyF;IACzF,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,QAAQ,EAAE,CAAA;IACvC,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAA;CAC7B;AAED,0FAA0F;AAC1F,wBAAgB,SAAS,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAa,EAAE,IAAa,EAAE,QAAa,EAAE,QAAQ,EAAE,EAAE,cAAc,+BAItH"}
|
package/dist/react/shell.js
CHANGED
|
@@ -5,9 +5,9 @@ import { DeskProvider } from './context.js';
|
|
|
5
5
|
import { BusProvider } from './events.js';
|
|
6
6
|
import { ToastProvider } from './overlays.js';
|
|
7
7
|
/** Everything an app needs around it, in one component: the desk, its bus, and toasts. */
|
|
8
|
-
export function DeskShell({ desk, options, bus, toasts = true, look = 'auto', children }) {
|
|
8
|
+
export function DeskShell({ desk, options, bus, toasts = true, look = 'auto', services = [], children }) {
|
|
9
9
|
const [made] = useState(() => desk ?? createDesk(options));
|
|
10
10
|
const inner = toasts ? _jsx(ToastProvider, { children: children }) : children;
|
|
11
|
-
return _jsx(DeskProvider, { desk: made, look: look, children: bus ? _jsx(BusProvider, { bus: bus, children: inner }) : inner });
|
|
11
|
+
return _jsx(DeskProvider, { desk: made, look: look, services: services, children: bus ? _jsx(BusProvider, { bus: bus, children: inner }) : inner });
|
|
12
12
|
}
|
|
13
13
|
//# sourceMappingURL=shell.js.map
|
package/dist/react/shell.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell.js","sourceRoot":"","sources":["../../src/react/shell.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"shell.js","sourceRoot":"","sources":["../../src/react/shell.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAM5C,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAiB7C,0FAA0F;AAC1F,MAAM,UAAU,SAAS,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,GAAG,MAAM,EAAE,QAAQ,GAAG,EAAE,EAAE,QAAQ,EAAkB;IACrH,MAAM,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,IAAI,UAAU,CAAC,OAAO,CAAC,CAAC,CAAA;IAC1D,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,KAAC,aAAa,cAAE,QAAQ,GAAiB,CAAC,CAAC,CAAC,QAAQ,CAAA;IAC3E,OAAO,KAAC,YAAY,IAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,YAAG,GAAG,CAAC,CAAC,CAAC,KAAC,WAAW,IAAC,GAAG,EAAE,GAAG,YAAG,KAAK,GAAe,CAAC,CAAC,CAAC,KAAK,GAAgB,CAAA;AAC9I,CAAC"}
|
package/llms.txt
CHANGED
|
@@ -210,13 +210,47 @@ topicMatches(pattern, topic): boolean // 'ride.*' and '*' are the o
|
|
|
210
210
|
InputCommands = { submit: 'desk.input.submit', describe: 'desk.input.describe' }
|
|
211
211
|
```
|
|
212
212
|
|
|
213
|
+
### Services
|
|
214
|
+
|
|
215
|
+
Something the desk keeps going that is not a window: a value anything can read and, optionally, a
|
|
216
|
+
process that keeps it true. For a dock count on a window that is shut, or data a window should not
|
|
217
|
+
wait for when it opens.
|
|
218
|
+
|
|
219
|
+
```ts
|
|
220
|
+
createService<T>({ id, initial, run? }): Service<T>
|
|
221
|
+
interface Service<T> {
|
|
222
|
+
id: string
|
|
223
|
+
now(): T
|
|
224
|
+
set(next: T): void // tells readers only when the value is new
|
|
225
|
+
subscribe(listener: () => void): () => void
|
|
226
|
+
hold(): () => void // counted; the release may be called twice
|
|
227
|
+
running(): boolean // true while anything holds it
|
|
228
|
+
}
|
|
229
|
+
run({ now, set, live }): (() => void) | void // started on the first hold; the return runs on the last release
|
|
230
|
+
holdAll(services): () => void
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
A service does not fetch, cache or retry: `run` brings its own way of getting data. Check `live()`
|
|
234
|
+
after every await. A stopped service keeps its value unless `run`'s cleanup sets it back.
|
|
235
|
+
|
|
236
|
+
### Attention
|
|
237
|
+
|
|
238
|
+
Whether somebody is looking at a window now, for a service that counts what arrived unseen.
|
|
239
|
+
|
|
240
|
+
```ts
|
|
241
|
+
attentionOn(desk, id, counted = true): Attention // { counted, front, visible, focused }
|
|
242
|
+
attended(a): boolean // front && visible && focused
|
|
243
|
+
becomesNews(a): boolean // counted && !attended(a)
|
|
244
|
+
watchAttention(desk, id, onAttended): () => void // at once if attended, then on desk change, tab shown, browser focused
|
|
245
|
+
```
|
|
246
|
+
|
|
213
247
|
## React: `@liberation-data/desk/react`
|
|
214
248
|
|
|
215
249
|
### Shell
|
|
216
250
|
|
|
217
251
|
```tsx
|
|
218
|
-
<DeskShell desk?={Desk} options?={DeskOptions} bus?={Bus} toasts?={true} look?={'auto'}>
|
|
219
|
-
<DeskProvider desk={desk} look?={'auto'}>
|
|
252
|
+
<DeskShell desk?={Desk} options?={DeskOptions} bus?={Bus} toasts?={true} look?={'auto'} services?={Service[]}>
|
|
253
|
+
<DeskProvider desk={desk} look?={'auto'} services?={Service[]}> // or options={…} to make one
|
|
220
254
|
useDesk(): Desk
|
|
221
255
|
useLook(): 'mac' | 'gnome' | 'windows' // resolved; the device's outside a desk
|
|
222
256
|
useDeskState(): DeskState
|
|
@@ -261,6 +295,7 @@ window; `lazyWindow` retries its import on reload, unlike `React.lazy`, which ca
|
|
|
261
295
|
<Section title={ReactNode} actions?={ReactNode}>{content}</Section> // a titled group inside a pane
|
|
262
296
|
<Toolbar label?={string} trailing?={ReactNode}>{controls}</Toolbar> // className="desk-grow" takes spare room
|
|
263
297
|
<Page label?={string} fill?>{long text}</Page> // a sheet for text read at length, on --desk-page; fill = at least the room's height
|
|
298
|
+
// --desk-page-tint (4% light, 5% dark) is how much --desk-accent is mixed into the page; 0% for the neutral alone.
|
|
264
299
|
// text size by class, never px: desk-text-body | desk-text-small | desk-text-caption, plus desk-text-muted.
|
|
265
300
|
// the scale is tokens: --desk-text-caption 11, -small 12, -body 13, -lead 15, -title 17, -display 22, -hero 28.
|
|
266
301
|
<InfoTip label={string} placement?={'below'|'above'} align?={'start'|'end'}>{explanation}</InfoTip>
|
|
@@ -352,6 +387,14 @@ usePublish(): <T>(topic, payload) => DeskEvent<T> // stamped with the window
|
|
|
352
387
|
useDeskEvent<T>(topic, handler, { replay? }) // replay: deliver the last event immediately
|
|
353
388
|
```
|
|
354
389
|
|
|
390
|
+
### Services
|
|
391
|
+
|
|
392
|
+
```tsx
|
|
393
|
+
<DeskShell services={[rides, unread]}> // held from mount to unmount; the array is read once
|
|
394
|
+
useService(service): T // the value, live, and the service held while mounted
|
|
395
|
+
useServiceValue(service): T // the value, live, without holding: for a badge
|
|
396
|
+
```
|
|
397
|
+
|
|
355
398
|
### Generated apps
|
|
356
399
|
|
|
357
400
|
```tsx
|
|
@@ -560,7 +603,9 @@ in the accessibility tree.
|
|
|
560
603
|
## Facts an agent should not guess
|
|
561
604
|
|
|
562
605
|
- React 19 is a peer dependency; the core entry point imports no React and touches no DOM except through
|
|
563
|
-
the command helpers.
|
|
606
|
+
the command helpers and `attentionOn`/`watchAttention`, which read the page when there is one.
|
|
607
|
+
- A service runs only while held. Give it to the desk (`services`) or read it with `useService`; a
|
|
608
|
+
service nobody holds never starts its `run`. `useServiceValue` does not hold.
|
|
564
609
|
- Focus follows the key window when it changes, but never on first render.
|
|
565
610
|
- First run (HIG §8): check on Continue with `onContinue`, not on the next step; show waiting work with
|
|
566
611
|
`useTasks` + `Checklist`; open the chosen window last so it is in front; offer the tour (`offer`) once on
|
|
@@ -568,7 +613,7 @@ in the accessibility tree.
|
|
|
568
613
|
- A `DeskProvider` already carries an event bus; `BusProvider` is only for supplying or sharing one.
|
|
569
614
|
- `renderWindow` must be stable (module scope or `useCallback`) for the memoisation to hold.
|
|
570
615
|
- `parse`/`syncWithLocation` warn once when no `isKnown` is given: unknown ids from a URL are then trusted.
|
|
571
|
-
- `npm run size` enforces a gzipped budget: core
|
|
616
|
+
- `npm run size` enforces a gzipped budget: core 16 KiB, react 62 KiB, css 20 KiB, fx 5 KiB.
|
|
572
617
|
- `fx.play` never resumes audio itself: outside a press a browser's resume may never settle. Call
|
|
573
618
|
`fx.unlock()` at startup, or nothing sounds until a press after the sound was due.
|
|
574
619
|
- The package is ESM only, with `"sideEffects": ["**/*.css"]`.
|
package/package.json
CHANGED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* WHETHER SOMEBODY IS LOOKING AT A WINDOW RIGHT NOW.
|
|
3
|
+
*
|
|
4
|
+
* A service that counts what arrived unseen has to know what "seen" is, and the answer is the same
|
|
5
|
+
* for every window: it is the key window, the browser tab is the one showing, and the browser has
|
|
6
|
+
* the operating system's focus. All three, because each can be false on its own: a window in full
|
|
7
|
+
* view behind somebody's editor is not being looked at.
|
|
8
|
+
*/
|
|
9
|
+
import { focusedId } from './desk.js'
|
|
10
|
+
import type { Desk } from './desk.js'
|
|
11
|
+
import type { WindowId } from './types.js'
|
|
12
|
+
|
|
13
|
+
/** Everything `attended` weighs, as plain values, so the rule can be read and tested without a desk. */
|
|
14
|
+
export interface Attention {
|
|
15
|
+
/** Something is drawing the count. Nothing counts otherwise: a number nobody can see only surprises them later. */
|
|
16
|
+
readonly counted: boolean
|
|
17
|
+
/** It is the key window: in front, and therefore not minimized or closed. */
|
|
18
|
+
readonly front: boolean
|
|
19
|
+
/** The browser tab is the one being shown. */
|
|
20
|
+
readonly visible: boolean
|
|
21
|
+
/** The browser window has the operating system's focus. */
|
|
22
|
+
readonly focused: boolean
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Being looked at right now, which is the one state in which what arrives is not news. */
|
|
26
|
+
export const attended = (a: Attention): boolean => a.front && a.visible && a.focused
|
|
27
|
+
|
|
28
|
+
/** What arrives is news when something is drawing the count and nobody is looking at the window. */
|
|
29
|
+
export const becomesNews = (a: Attention): boolean => a.counted && !attended(a)
|
|
30
|
+
|
|
31
|
+
/** Where there is no document there is no tab to hide and no browser to leave: only the desk can say. */
|
|
32
|
+
const page = (): Document | null => (typeof document === 'undefined' ? null : document)
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The attention on one window, now. `counted` is the caller's to say: usually whether the service
|
|
36
|
+
* doing the counting is running, which is whether a dock is there to draw it.
|
|
37
|
+
*/
|
|
38
|
+
export function attentionOn(desk: Desk, id: WindowId, counted = true): Attention {
|
|
39
|
+
const doc = page()
|
|
40
|
+
return {
|
|
41
|
+
counted,
|
|
42
|
+
front: focusedId(desk.getState()) === id,
|
|
43
|
+
visible: !(doc?.hidden ?? false),
|
|
44
|
+
focused: doc?.hasFocus() ?? true,
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Call `onAttended` at once if the window is being looked at, and again each time it comes to be.
|
|
50
|
+
*
|
|
51
|
+
* THREE SIGNALS, BECAUSE THERE ARE THREE WAYS BACK. Opening or focusing the window is a desk
|
|
52
|
+
* change; returning to the browser tab is a visibility change; coming back to the browser from
|
|
53
|
+
* another application is a window focus. Any one of them can happen without the other two.
|
|
54
|
+
*/
|
|
55
|
+
export function watchAttention(desk: Desk, id: WindowId, onAttended: () => void): () => void {
|
|
56
|
+
const check = () => {
|
|
57
|
+
if (attended(attentionOn(desk, id))) onAttended()
|
|
58
|
+
}
|
|
59
|
+
const doc = page()
|
|
60
|
+
const stopDesk = desk.subscribe(check)
|
|
61
|
+
doc?.defaultView?.addEventListener('focus', check)
|
|
62
|
+
doc?.addEventListener('visibilitychange', check)
|
|
63
|
+
check()
|
|
64
|
+
return () => {
|
|
65
|
+
stopDesk()
|
|
66
|
+
doc?.defaultView?.removeEventListener('focus', check)
|
|
67
|
+
doc?.removeEventListener('visibilitychange', check)
|
|
68
|
+
}
|
|
69
|
+
}
|
package/src/core/index.ts
CHANGED
|
@@ -25,6 +25,10 @@ export {
|
|
|
25
25
|
windowElement,
|
|
26
26
|
} from './commands.js'
|
|
27
27
|
export type { ChainOptions, CommandHandler, CommandId, CommandOptions } from './commands.js'
|
|
28
|
+
export { createService, holdAll } from './services.js'
|
|
29
|
+
export type { Holdable, Service, ServiceOptions, ServiceRun } from './services.js'
|
|
30
|
+
export { attended, attentionOn, becomesNews, watchAttention } from './attention.js'
|
|
31
|
+
export type { Attention } from './attention.js'
|
|
28
32
|
export { createBus, InputCommands, topicMatches } from './events.js'
|
|
29
33
|
export type { Bus, DeskEvent, EventHandler, InputDescription, SubscribeOptions } from './events.js'
|
|
30
34
|
export { bindShortcuts, formatShortcut, isApplePlatform, isInstalledApp, matchesShortcut, parseShortcut } from './shortcuts.js'
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* A SERVICE: SOMETHING THE DESK KEEPS GOING THAT IS NOT A WINDOW.
|
|
3
|
+
*
|
|
4
|
+
* A window's data dies with the window. Some of what an app knows has to outlive that: a count on
|
|
5
|
+
* the dock for a window that is shut, or a list a window should not have to wait for when it opens.
|
|
6
|
+
*
|
|
7
|
+
* A service is a VALUE, readable by anything, and optionally a PROCESS that keeps the value true.
|
|
8
|
+
*
|
|
9
|
+
* IT RUNS WHILE SOMEBODY HOLDS IT. A desk holds the services it was given for as long as it is on
|
|
10
|
+
* screen; a component that reads one with `useService` holds it for as long as it is mounted. The
|
|
11
|
+
* process starts on the first hold and stops on the last release, so a window drawn without a desk
|
|
12
|
+
* (a test, a preview) still gets its data, and a desk already running it costs that window nothing.
|
|
13
|
+
* Holds are counted: two holders are independent, and neither's teardown may stop the service while
|
|
14
|
+
* the other still needs it.
|
|
15
|
+
*
|
|
16
|
+
* A SERVICE DOES NOT KNOW HOW TO FETCH. Its process brings its own way of getting data, and its own
|
|
17
|
+
* caching and retrying if it wants them. What is here is when it runs and who can read it.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/** What a service's process is given to work with. */
|
|
21
|
+
export interface ServiceRun<T> {
|
|
22
|
+
readonly now: () => T
|
|
23
|
+
/** Replace the value and tell every reader. Setting the value it already has tells nobody. */
|
|
24
|
+
readonly set: (next: T) => void
|
|
25
|
+
/** False once this run has been stopped. Check it after every await, so a late answer is dropped. */
|
|
26
|
+
readonly live: () => boolean
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface ServiceOptions<T> {
|
|
30
|
+
/** Named for a log line and a test, as a window is named by its id. */
|
|
31
|
+
readonly id: string
|
|
32
|
+
readonly initial: T
|
|
33
|
+
/** The process, started on the first hold. What it returns is run on the last release. */
|
|
34
|
+
readonly run?: (run: ServiceRun<T>) => (() => void) | void
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface Service<T> {
|
|
38
|
+
readonly id: string
|
|
39
|
+
readonly now: () => T
|
|
40
|
+
readonly set: (next: T) => void
|
|
41
|
+
readonly subscribe: (listener: () => void) => () => void
|
|
42
|
+
/** Keep it running. Gives back the release, which may be called more than once. */
|
|
43
|
+
readonly hold: () => () => void
|
|
44
|
+
/** True while anything holds it. */
|
|
45
|
+
readonly running: () => boolean
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Anything that can be held: a service of any value. */
|
|
49
|
+
export type Holdable = Pick<Service<unknown>, 'hold'>
|
|
50
|
+
|
|
51
|
+
export function createService<T>({ id, initial, run }: ServiceOptions<T>): Service<T> {
|
|
52
|
+
let value = initial
|
|
53
|
+
let holds = 0
|
|
54
|
+
let stop: (() => void) | null = null
|
|
55
|
+
const listeners = new Set<() => void>()
|
|
56
|
+
|
|
57
|
+
const now = () => value
|
|
58
|
+
const set = (next: T) => {
|
|
59
|
+
if (Object.is(next, value)) return
|
|
60
|
+
value = next
|
|
61
|
+
for (const listener of [...listeners]) listener()
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const start = () => {
|
|
65
|
+
let live = true
|
|
66
|
+
const ended = run?.({ now, set, live: () => live })
|
|
67
|
+
stop = () => {
|
|
68
|
+
live = false
|
|
69
|
+
if (typeof ended === 'function') ended()
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const hold = () => {
|
|
74
|
+
holds += 1
|
|
75
|
+
if (holds === 1) start()
|
|
76
|
+
let released = false
|
|
77
|
+
return () => {
|
|
78
|
+
if (released) return
|
|
79
|
+
released = true
|
|
80
|
+
holds -= 1
|
|
81
|
+
if (holds > 0) return
|
|
82
|
+
stop?.()
|
|
83
|
+
stop = null
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return {
|
|
88
|
+
id,
|
|
89
|
+
now,
|
|
90
|
+
set,
|
|
91
|
+
subscribe: listener => {
|
|
92
|
+
listeners.add(listener)
|
|
93
|
+
return () => {
|
|
94
|
+
listeners.delete(listener)
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
hold,
|
|
98
|
+
running: () => holds > 0,
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** Hold several at once, and give back one release for all of them. */
|
|
103
|
+
export function holdAll(services: readonly Holdable[]): () => void {
|
|
104
|
+
const releases = services.map(service => service.hold())
|
|
105
|
+
return () => {
|
|
106
|
+
for (const release of releases) release()
|
|
107
|
+
}
|
|
108
|
+
}
|
package/src/css/tokens.css
CHANGED
|
@@ -64,6 +64,9 @@
|
|
|
64
64
|
/* What long text lies on (`Page`). Neutral, not the surface's hue: a shade off a white window,
|
|
65
65
|
a terminal's grey in a dark one. */
|
|
66
66
|
--desk-page: #f4f5f7;
|
|
67
|
+
/* How much of the accent is mixed into it, so the sheet belongs to the theme it is read in.
|
|
68
|
+
0% is the neutral alone. */
|
|
69
|
+
--desk-page-tint: 4%;
|
|
67
70
|
--desk-on-accent: #ffffff;
|
|
68
71
|
--desk-ease: cubic-bezier(.32, .72, 0, 1);
|
|
69
72
|
--desk-dock-size: 48px;
|
|
@@ -102,6 +105,7 @@
|
|
|
102
105
|
--desk-led-glow: 7px;
|
|
103
106
|
--desk-field-bg: rgb(0 0 0 / 35%);
|
|
104
107
|
--desk-page: #26282c;
|
|
108
|
+
--desk-page-tint: 5%;
|
|
105
109
|
}
|
|
106
110
|
}
|
|
107
111
|
|
|
@@ -127,4 +131,5 @@
|
|
|
127
131
|
--desk-led-glow: 7px;
|
|
128
132
|
--desk-field-bg: rgb(0 0 0 / 35%);
|
|
129
133
|
--desk-page: #26282c;
|
|
134
|
+
--desk-page-tint: 5%;
|
|
130
135
|
}
|
package/src/css/windows.css
CHANGED
|
@@ -439,7 +439,9 @@
|
|
|
439
439
|
padding: var(--desk-space-5) var(--desk-space-6);
|
|
440
440
|
border: 1px solid var(--desk-rule);
|
|
441
441
|
border-radius: var(--desk-control-radius);
|
|
442
|
-
|
|
442
|
+
/* Mixed here and not in the token: an app that sets its accent below the root would otherwise
|
|
443
|
+
get the root's accent in its page. */
|
|
444
|
+
background: color-mix(in srgb, var(--desk-accent) var(--desk-page-tint), var(--desk-page));
|
|
443
445
|
color: var(--desk-ink);
|
|
444
446
|
}
|
|
445
447
|
|
package/src/react/context.tsx
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { createContext, useContext, useLayoutEffect, useState, useSyncExternalStore } from 'react'
|
|
1
|
+
import { createContext, useContext, useEffect, useLayoutEffect, useState, useSyncExternalStore } from 'react'
|
|
2
2
|
import type { ReactNode, RefObject } from 'react'
|
|
3
3
|
import { createBus } from '../core/events.js'
|
|
4
4
|
import type { Bus } from '../core/events.js'
|
|
5
5
|
import { createDesk } from '../core/desk.js'
|
|
6
6
|
import { deviceLook, resolveLook } from '../core/look.js'
|
|
7
|
+
import { holdAll } from '../core/services.js'
|
|
8
|
+
import type { Holdable } from '../core/services.js'
|
|
7
9
|
import type { Look, LookChoice } from '../core/look.js'
|
|
8
10
|
import { DragProvider } from './dragContext.js'
|
|
9
11
|
import { missingProvider } from './missingProvider.js'
|
|
@@ -28,12 +30,19 @@ export interface DeskProviderProps {
|
|
|
28
30
|
* chose. The app keeps that choice where it keeps its other preferences; the desk does not store it.
|
|
29
31
|
*/
|
|
30
32
|
readonly look?: LookChoice
|
|
33
|
+
/**
|
|
34
|
+
* What the desk keeps going while it is on screen: each is held from mount to unmount. Read once,
|
|
35
|
+
* so the array need not be stable.
|
|
36
|
+
*/
|
|
37
|
+
readonly services?: readonly Holdable[]
|
|
31
38
|
readonly children: ReactNode
|
|
32
39
|
}
|
|
33
40
|
|
|
34
|
-
export function DeskProvider({ desk, options, look = 'auto', children }: DeskProviderProps) {
|
|
41
|
+
export function DeskProvider({ desk, options, look = 'auto', services, children }: DeskProviderProps) {
|
|
35
42
|
const [value] = useState(() => desk ?? createDesk(options))
|
|
36
43
|
const [bus] = useState(createBus)
|
|
44
|
+
const [held] = useState(() => services ?? [])
|
|
45
|
+
useEffect(() => holdAll(held), [held])
|
|
37
46
|
const resolved = resolveLook(look)
|
|
38
47
|
// On the root, not the desk: menus and popovers are portalled out of it, and are chrome too.
|
|
39
48
|
useLayoutEffect(() => {
|
package/src/react/index.ts
CHANGED
|
@@ -19,6 +19,7 @@ export { useCanPerform, useCommand, usePerform, useShortcuts } from './commands.
|
|
|
19
19
|
export type { UseCommandOptions } from './commands.js'
|
|
20
20
|
export { Desktop } from './Desktop.js'
|
|
21
21
|
export type { DeskLayout, DesktopProps } from './Desktop.js'
|
|
22
|
+
export { useService, useServiceValue } from './services.js'
|
|
22
23
|
export { useDocumentTitle } from './documentTitle.js'
|
|
23
24
|
export type { DocumentTitleOptions } from './documentTitle.js'
|
|
24
25
|
export { lazyWindow } from './windowBoundary.js'
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useEffect, useSyncExternalStore } from 'react'
|
|
2
|
+
import type { Service } from '../core/services.js'
|
|
3
|
+
|
|
4
|
+
/** The value, live, WITHOUT holding the service: for a reader that must not be what keeps it running. */
|
|
5
|
+
export function useServiceValue<T>(service: Service<T>): T {
|
|
6
|
+
return useSyncExternalStore(service.subscribe, service.now, service.now)
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/** The value, live, and the service held for as long as this is mounted. */
|
|
10
|
+
export function useService<T>(service: Service<T>): T {
|
|
11
|
+
useEffect(() => service.hold(), [service])
|
|
12
|
+
return useServiceValue(service)
|
|
13
|
+
}
|
package/src/react/shell.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import { createDesk } from '../core/desk.js'
|
|
|
4
4
|
import type { Desk } from '../core/desk.js'
|
|
5
5
|
import type { Bus } from '../core/events.js'
|
|
6
6
|
import type { LookChoice } from '../core/look.js'
|
|
7
|
+
import type { Holdable } from '../core/services.js'
|
|
7
8
|
import type { DeskOptions } from '../core/types.js'
|
|
8
9
|
import { DeskProvider } from './context.js'
|
|
9
10
|
import { BusProvider } from './events.js'
|
|
@@ -19,12 +20,14 @@ export interface DeskShellProps {
|
|
|
19
20
|
readonly toasts?: boolean
|
|
20
21
|
/** The platform chrome: `auto` (the default) matches the device. See `DeskProviderProps.look`. */
|
|
21
22
|
readonly look?: LookChoice
|
|
23
|
+
/** What the desk keeps going while it is on screen. See `DeskProviderProps.services`. */
|
|
24
|
+
readonly services?: readonly Holdable[]
|
|
22
25
|
readonly children: ReactNode
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
/** Everything an app needs around it, in one component: the desk, its bus, and toasts. */
|
|
26
|
-
export function DeskShell({ desk, options, bus, toasts = true, look = 'auto', children }: DeskShellProps) {
|
|
29
|
+
export function DeskShell({ desk, options, bus, toasts = true, look = 'auto', services = [], children }: DeskShellProps) {
|
|
27
30
|
const [made] = useState(() => desk ?? createDesk(options))
|
|
28
31
|
const inner = toasts ? <ToastProvider>{children}</ToastProvider> : children
|
|
29
|
-
return <DeskProvider desk={made} look={look}>{bus ? <BusProvider bus={bus}>{inner}</BusProvider> : inner}</DeskProvider>
|
|
32
|
+
return <DeskProvider desk={made} look={look} services={services}>{bus ? <BusProvider bus={bus}>{inner}</BusProvider> : inner}</DeskProvider>
|
|
30
33
|
}
|