@liberation-data/desk 0.33.0 → 0.35.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 +48 -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/controls.css +3 -1
- package/dist/desk.css +3 -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/outline.d.ts +6 -1
- package/dist/react/outline.d.ts.map +1 -1
- package/dist/react/outline.js +4 -3
- package/dist/react/outline.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 +52 -6
- 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/controls.css +3 -1
- package/src/react/context.tsx +11 -2
- package/src/react/index.ts +1 -0
- package/src/react/outline.tsx +11 -3
- package/src/react/services.ts +13 -0
- package/src/react/shell.tsx +5 -2
package/README.md
CHANGED
|
@@ -577,6 +577,50 @@ carries its own bus, so this needs no extra provider. `replay`
|
|
|
577
577
|
delivers the last event on the topic straight away — the window that the event concerns is often opened by
|
|
578
578
|
that very event, and would otherwise miss it by a frame.
|
|
579
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
|
+
|
|
580
624
|
## Conversation
|
|
581
625
|
|
|
582
626
|

|
|
@@ -618,7 +662,9 @@ selection, Enter or a double click opens a row, and a sortable heading says whic
|
|
|
618
662
|
hierarchy — a document's headings, a schema — given as a flat list in reading order with a `depth` on each
|
|
619
663
|
row. It is a tree to the keyboard: up and down through the rows, left out to the parent, right in to the first
|
|
620
664
|
child. Depth shows as weight, colour and a small indent, and stops changing at the fourth level, so a deep
|
|
621
|
-
hierarchy cannot indent itself out of the list. A row is one line, cut with an ellipsis and whole on hover.
|
|
665
|
+
hierarchy cannot indent itself out of the list. A row is one line, cut with an ellipsis and whole on hover.
|
|
666
|
+
When what is on show runs past the chosen row — a page that holds three headings — name the others in
|
|
667
|
+
`showing` and they are marked with it. A **pop-up button** is what a
|
|
622
668
|
segmented control becomes when there are too many options to show at once; unlike a menu it takes focus, and
|
|
623
669
|
typing jumps to an option. A **checkbox** is for a setting that waits for Save (a Toggle applies at once),
|
|
624
670
|
and can stand for a mixed set. A **slider** reads its value in words for people who cannot see it.
|
|
@@ -898,7 +944,7 @@ npm install
|
|
|
898
944
|
npm test # vitest
|
|
899
945
|
npm run typecheck
|
|
900
946
|
npm run example # the Garage sample in examples/garage
|
|
901
|
-
npm run size # the gzipped budget: core
|
|
947
|
+
npm run size # the gzipped budget: core 16 KiB, react 62, css 20, fx 5
|
|
902
948
|
npm run check # everything CI runs
|
|
903
949
|
npm run check:browser # the generated-app bridge in real Chrome, against a running sample
|
|
904
950
|
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,M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AAE,KAAK,CAAC,CAAA;IAChD,KAAK,EAAE,CAAA;IACP,OAAO,GAAG,EAAE;QACV,QAAQ,EAAE,CAAA;QACV,GAAG,EAAE,WAAW,EAAE,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;QACrD,GAAG,EAAE,mBAAmB,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAA;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,IA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AAW,EAAE,MAAM,WAAW,CAAA;AAC5D,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACjD,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAClE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AACnE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC5D,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AACjE,YAAY,EACV,cAAc,EACd,WAAW,EACX,SAAS,EACT,UAAU,EACV,KAAK,EACL,WAAW,EACX,IAAI,EACJ,QAAQ,EACR,YAAY,EACZ,UAAU,GACX,MAAM,YAAY,CAAA"}
|
package/dist/core/index.js
CHANGED
|
@@ -1,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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,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;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
|
+
//# source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AE,OAAM;YACpB,QAAQ,GAAG,IAAI,CAAA;YACf,KAAK,IAAI,CAAC,CAAA;YACV,IAAI,KAAK,GAAG,CAAC;gBAAE,OAAM;YACrB,IAAI,EAAE,EAAE,CAAA;YACR,IAAI,GAAG,IAAI,CAAA;QACb,CAAC,CAAA;IACH,CAAC,CAAA;IAED,OAAO;QACL,EAAE;QACF,GAAG;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/controls.css
CHANGED
|
@@ -971,7 +971,9 @@
|
|
|
971
971
|
|
|
972
972
|
/* Named with the hover it has to outrank: the chosen row stays the chosen colour under the pointer. */
|
|
973
973
|
.desk-outline-row[data-current],
|
|
974
|
-
.desk-outline-row[data-current]:hover:not(:disabled)
|
|
974
|
+
.desk-outline-row[data-current]:hover:not(:disabled),
|
|
975
|
+
.desk-outline-row[data-showing],
|
|
976
|
+
.desk-outline-row[data-showing]:hover:not(:disabled) {
|
|
975
977
|
background: color-mix(in srgb, var(--desk-accent) 18%, transparent);
|
|
976
978
|
color: var(--desk-ink);
|
|
977
979
|
}
|
package/dist/desk.css
CHANGED
|
@@ -2287,7 +2287,9 @@
|
|
|
2287
2287
|
|
|
2288
2288
|
/* Named with the hover it has to outrank: the chosen row stays the chosen colour under the pointer. */
|
|
2289
2289
|
.desk-outline-row[data-current],
|
|
2290
|
-
.desk-outline-row[data-current]:hover:not(:disabled)
|
|
2290
|
+
.desk-outline-row[data-current]:hover:not(:disabled),
|
|
2291
|
+
.desk-outline-row[data-showing],
|
|
2292
|
+
.desk-outline-row[data-showing]:hover:not(:disabled) {
|
|
2291
2293
|
background: color-mix(in srgb, var(--desk-accent) 18%, transparent);
|
|
2292
2294
|
color: var(--desk-ink);
|
|
2293
2295
|
}
|
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,MA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AAM,OAAO,GAAG,GAAS,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,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":"AA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E,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,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,UAA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,aAAa,CAAA;AAEzE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,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"}
|
package/dist/react/outline.d.ts
CHANGED
|
@@ -14,9 +14,14 @@ export interface OutlineProps {
|
|
|
14
14
|
/** The chosen row, or null when none is. */
|
|
15
15
|
readonly value: string | null;
|
|
16
16
|
readonly onChange: (id: string) => void;
|
|
17
|
+
/**
|
|
18
|
+
* The rows on show along with the chosen one: the headings a page holds after the one it starts
|
|
19
|
+
* at. They are marked as the chosen row is, and the chosen row stays the one the keyboard is on.
|
|
20
|
+
*/
|
|
21
|
+
readonly showing?: readonly string[];
|
|
17
22
|
/** Names the outline for assistive technology: "Sections". */
|
|
18
23
|
readonly label: string;
|
|
19
24
|
readonly className?: string;
|
|
20
25
|
}
|
|
21
|
-
export declare function Outline({ rows, value, onChange, label, className }: OutlineProps): import("react").JSX.Element;
|
|
26
|
+
export declare function Outline({ rows, value, onChange, showing, label, className }: OutlineProps): import("react").JSX.Element;
|
|
22
27
|
//# sourceMappingURL=outline.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outline.d.ts","sourceRo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CAAA;IAC7B,QAAQ,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;IACvC;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IACpC,8DAA8D;IAC9D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAC5B;AAMD,wBAAgB,OAAO,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAc,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,YAAY,+BAwEhG"}
|
package/dist/react/outline.js
CHANGED
|
@@ -15,7 +15,8 @@ import { useEffect, useRef } from 'react';
|
|
|
15
15
|
/** The deepest level drawn differently. Deeper rows look like this one. */
|
|
16
16
|
export const OUTLINE_MAX_DEPTH = 4;
|
|
17
17
|
const drawnDepth = (depth) => Math.min(Math.max(1, Math.floor(depth)), OUTLINE_MAX_DEPTH);
|
|
18
|
-
|
|
18
|
+
const NONE = [];
|
|
19
|
+
export function Outline({ rows, value, onChange, showing = NONE, label, className }) {
|
|
19
20
|
const tree = useRef(null);
|
|
20
21
|
const enabled = rows.filter(row => !row.disabled);
|
|
21
22
|
// One tab stop: the chosen row, or the first that can be chosen when none is.
|
|
@@ -60,9 +61,9 @@ export function Outline({ rows, value, onChange, label, className }) {
|
|
|
60
61
|
event.preventDefault();
|
|
61
62
|
choose(target);
|
|
62
63
|
};
|
|
63
|
-
return (_jsx("div", { ref: tree, role: "tree", "aria-label": label, className: ['desk-outline', className].filter(Boolean).join(' '), onKeyDown: onKeyDown, children: rows.map(row => {
|
|
64
|
+
return (_jsx("div", { ref: tree, role: "tree", "aria-label": label, "aria-multiselectable": showing.length > 0 || undefined, className: ['desk-outline', className].filter(Boolean).join(' '), onKeyDown: onKeyDown, children: rows.map(row => {
|
|
64
65
|
const current = row.id === value;
|
|
65
|
-
return (_jsx("button", { type: "button", role: "treeitem", "aria-level": Math.max(1, Math.floor(row.depth)), "aria-selected": current, "data-row": row.id, "data-depth": drawnDepth(row.depth), "data-current": current || undefined, className: "desk-outline-row", disabled: row.disabled, tabIndex: row.id === tabStop ? 0 : -1, title: row.label, onClick: () => onChange(row.id), children: _jsx("span", { className: "desk-outline-label", children: row.label }) }, row.id));
|
|
66
|
+
return (_jsx("button", { type: "button", role: "treeitem", "aria-level": Math.max(1, Math.floor(row.depth)), "aria-selected": current || showing.includes(row.id), "data-row": row.id, "data-depth": drawnDepth(row.depth), "data-current": current || undefined, "data-showing": (!current && showing.includes(row.id)) || undefined, className: "desk-outline-row", disabled: row.disabled, tabIndex: row.id === tabStop ? 0 : -1, title: row.label, onClick: () => onChange(row.id), children: _jsx("span", { className: "desk-outline-label", children: row.label }) }, row.id));
|
|
66
67
|
}) }));
|
|
67
68
|
}
|
|
68
69
|
//# sourceMappingURL=outline.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outline.js","sourceRoot":"","sources":["../../src/react/outline.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAGzC;;;;;;;;;;;GAWG;AAEH,2EAA2E;AAC3E,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"outline.js","sourceRoot":"","sources":["../../src/react/outline.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAGzC;;;;;;;;;;;GAWG;AAEH,2EAA2E;AAC3E,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAA;AA2BlC,MAAM,UAAU,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAA;AAE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C,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,IAAI,SAAS,EACjE,SAAS,EAAC,kBAAkB,EAC5B,QAAQ,EAAE,GAAG,CAAC,QAAQ,EACtB,QAAQ,EAAE,GAAG,CAAC,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EACrC,KAAK,EAAE,GAAG,CAAC,KAAK,EAChB,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,YAE/B,eAAM,SAAS,EAAC,oBAAoB,YAAE,GAAG,CAAC,KAAK,GAAQ,IAflD,GAAG,CAAC,EAAE,CAgBJ,CACV,CAAA;QACH,CAAC,CAAC,GACE,CACP,CAAA;AACH,CAAC"}
|
|
@@ -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
|
|
@@ -353,6 +387,14 @@ usePublish(): <T>(topic, payload) => DeskEvent<T> // stamped with the window
|
|
|
353
387
|
useDeskEvent<T>(topic, handler, { replay? }) // replay: deliver the last event immediately
|
|
354
388
|
```
|
|
355
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
|
+
|
|
356
398
|
### Generated apps
|
|
357
399
|
|
|
358
400
|
```tsx
|
|
@@ -451,14 +493,16 @@ interface Sort { key: string; direction: 'ascending' | 'descending' }
|
|
|
451
493
|
<Sidebar sections={{ id, label?, items: { id, label, icon?, badge?, disabled? }[] }[]}
|
|
452
494
|
value onChange label footer? />
|
|
453
495
|
|
|
454
|
-
<Outline rows={{ id, label, depth, disabled? }[]} value={string | null} onChange label />
|
|
496
|
+
<Outline rows={{ id, label, depth, disabled? }[]} value={string | null} onChange showing? label />
|
|
455
497
|
```
|
|
456
498
|
|
|
457
499
|
Outline: a hierarchy as a flat list in reading order, each row saying its `depth` (1 is the top). Use it
|
|
458
500
|
for a document's headings, a schema, a folder — not `Sidebar`, which is a few places at one level. One tab
|
|
459
501
|
stop; up and down move through the rows, left goes out to the parent and right in to the first child, Home
|
|
460
502
|
and End to the ends. Depth is drawn with weight, colour and indent, and stops changing at the fourth level
|
|
461
|
-
(`OUTLINE_MAX_DEPTH`). A `disabled` row is listed and cannot be chosen.
|
|
503
|
+
(`OUTLINE_MAX_DEPTH`). A `disabled` row is listed and cannot be chosen. `showing` names the rows on show
|
|
504
|
+
along with `value` (a page that holds several headings): they are marked as the chosen row is, and
|
|
505
|
+
`value` stays where the keyboard is.
|
|
462
506
|
|
|
463
507
|
Table: one tab stop, arrow keys move the selection, Enter or double click activates, `aria-sort` on
|
|
464
508
|
sortable headings. It renders what it is given — no paging, no fetching.
|
|
@@ -561,7 +605,9 @@ in the accessibility tree.
|
|
|
561
605
|
## Facts an agent should not guess
|
|
562
606
|
|
|
563
607
|
- React 19 is a peer dependency; the core entry point imports no React and touches no DOM except through
|
|
564
|
-
the command helpers.
|
|
608
|
+
the command helpers and `attentionOn`/`watchAttention`, which read the page when there is one.
|
|
609
|
+
- A service runs only while held. Give it to the desk (`services`) or read it with `useService`; a
|
|
610
|
+
service nobody holds never starts its `run`. `useServiceValue` does not hold.
|
|
565
611
|
- Focus follows the key window when it changes, but never on first render.
|
|
566
612
|
- First run (HIG §8): check on Continue with `onContinue`, not on the next step; show waiting work with
|
|
567
613
|
`useTasks` + `Checklist`; open the chosen window last so it is in front; offer the tour (`offer`) once on
|
|
@@ -569,7 +615,7 @@ in the accessibility tree.
|
|
|
569
615
|
- A `DeskProvider` already carries an event bus; `BusProvider` is only for supplying or sharing one.
|
|
570
616
|
- `renderWindow` must be stable (module scope or `useCallback`) for the memoisation to hold.
|
|
571
617
|
- `parse`/`syncWithLocation` warn once when no `isKnown` is given: unknown ids from a URL are then trusted.
|
|
572
|
-
- `npm run size` enforces a gzipped budget: core
|
|
618
|
+
- `npm run size` enforces a gzipped budget: core 16 KiB, react 62 KiB, css 20 KiB, fx 5 KiB.
|
|
573
619
|
- `fx.play` never resumes audio itself: outside a press a browser's resume may never settle. Call
|
|
574
620
|
`fx.unlock()` at startup, or nothing sounds until a press after the sound was due.
|
|
575
621
|
- 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/controls.css
CHANGED
|
@@ -970,7 +970,9 @@
|
|
|
970
970
|
|
|
971
971
|
/* Named with the hover it has to outrank: the chosen row stays the chosen colour under the pointer. */
|
|
972
972
|
.desk-outline-row[data-current],
|
|
973
|
-
.desk-outline-row[data-current]:hover:not(:disabled)
|
|
973
|
+
.desk-outline-row[data-current]:hover:not(:disabled),
|
|
974
|
+
.desk-outline-row[data-showing],
|
|
975
|
+
.desk-outline-row[data-showing]:hover:not(:disabled) {
|
|
974
976
|
background: color-mix(in srgb, var(--desk-accent) 18%, transparent);
|
|
975
977
|
color: var(--desk-ink);
|
|
976
978
|
}
|
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'
|
package/src/react/outline.tsx
CHANGED
|
@@ -32,6 +32,11 @@ export interface OutlineProps {
|
|
|
32
32
|
/** The chosen row, or null when none is. */
|
|
33
33
|
readonly value: string | null
|
|
34
34
|
readonly onChange: (id: string) => void
|
|
35
|
+
/**
|
|
36
|
+
* The rows on show along with the chosen one: the headings a page holds after the one it starts
|
|
37
|
+
* at. They are marked as the chosen row is, and the chosen row stays the one the keyboard is on.
|
|
38
|
+
*/
|
|
39
|
+
readonly showing?: readonly string[]
|
|
35
40
|
/** Names the outline for assistive technology: "Sections". */
|
|
36
41
|
readonly label: string
|
|
37
42
|
readonly className?: string
|
|
@@ -39,7 +44,9 @@ export interface OutlineProps {
|
|
|
39
44
|
|
|
40
45
|
const drawnDepth = (depth: number) => Math.min(Math.max(1, Math.floor(depth)), OUTLINE_MAX_DEPTH)
|
|
41
46
|
|
|
42
|
-
|
|
47
|
+
const NONE: readonly string[] = []
|
|
48
|
+
|
|
49
|
+
export function Outline({ rows, value, onChange, showing = NONE, label, className }: OutlineProps) {
|
|
43
50
|
const tree = useRef<HTMLDivElement>(null)
|
|
44
51
|
const enabled = rows.filter(row => !row.disabled)
|
|
45
52
|
// One tab stop: the chosen row, or the first that can be chosen when none is.
|
|
@@ -85,7 +92,7 @@ export function Outline({ rows, value, onChange, label, className }: OutlineProp
|
|
|
85
92
|
}
|
|
86
93
|
|
|
87
94
|
return (
|
|
88
|
-
<div ref={tree} role="tree" aria-label={label} className={['desk-outline', className].filter(Boolean).join(' ')} onKeyDown={onKeyDown}>
|
|
95
|
+
<div ref={tree} role="tree" aria-label={label} aria-multiselectable={showing.length > 0 || undefined} className={['desk-outline', className].filter(Boolean).join(' ')} onKeyDown={onKeyDown}>
|
|
89
96
|
{rows.map(row => {
|
|
90
97
|
const current = row.id === value
|
|
91
98
|
return (
|
|
@@ -94,10 +101,11 @@ export function Outline({ rows, value, onChange, label, className }: OutlineProp
|
|
|
94
101
|
type="button"
|
|
95
102
|
role="treeitem"
|
|
96
103
|
aria-level={Math.max(1, Math.floor(row.depth))}
|
|
97
|
-
aria-selected={current}
|
|
104
|
+
aria-selected={current || showing.includes(row.id)}
|
|
98
105
|
data-row={row.id}
|
|
99
106
|
data-depth={drawnDepth(row.depth)}
|
|
100
107
|
data-current={current || undefined}
|
|
108
|
+
data-showing={(!current && showing.includes(row.id)) || undefined}
|
|
101
109
|
className="desk-outline-row"
|
|
102
110
|
disabled={row.disabled}
|
|
103
111
|
tabIndex={row.id === tabStop ? 0 : -1}
|
|
@@ -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
|
}
|