@bridgebrew/shell 0.0.9 → 0.0.10
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/browser/overlay-hold.ts +22 -8
- package/package.json +2 -2
package/browser/overlay-hold.ts
CHANGED
|
@@ -29,8 +29,13 @@ export function createOverlayHold(
|
|
|
29
29
|
let count = 0;
|
|
30
30
|
/** A joined Bridge's page shows under the home page (the app's state). */
|
|
31
31
|
let shown = false;
|
|
32
|
-
/** The
|
|
32
|
+
/** The shell raised the home page and has not lowered it: what it must lower. An overlay another raised (an older
|
|
33
|
+
* rail's own count) is never the shell's. */
|
|
33
34
|
let sent = false;
|
|
35
|
+
/** The app's overlay as it last said (`state.overlay`): raised while `sent` is not, it is another's. */
|
|
36
|
+
let raised = false;
|
|
37
|
+
/** Disposed: no hold raises the home page any more. */
|
|
38
|
+
let disposed = false;
|
|
34
39
|
/** The last overlay request: a hold while it runs waits for it. */
|
|
35
40
|
let request: Promise<void> = Promise.resolve();
|
|
36
41
|
/** The app's state came through `onState`: the first `state()` read, answering later, is stale. */
|
|
@@ -43,8 +48,12 @@ export function createOverlayHold(
|
|
|
43
48
|
const app = desktop();
|
|
44
49
|
|
|
45
50
|
const send = (open: boolean, focus = false): Promise<void> => {
|
|
46
|
-
if (!app
|
|
47
|
-
|
|
51
|
+
if (!app) return request;
|
|
52
|
+
// Already raised by another (an older rail's own count): theirs, the shell neither takes it over nor lowers it on
|
|
53
|
+
// release; a modal hold still asks for the focus.
|
|
54
|
+
const theirs = open && raised && !sent;
|
|
55
|
+
if ((open === sent || theirs) && !focus) return request;
|
|
56
|
+
if (!theirs) sent = open;
|
|
48
57
|
request = app.overlay(open, ...(focus ? [{ focus: true }] : [])).then(
|
|
49
58
|
() => undefined,
|
|
50
59
|
// Refused (the app is closing, an older app): the popup opens anyway, the next hold asks again.
|
|
@@ -56,10 +65,13 @@ export function createOverlayHold(
|
|
|
56
65
|
};
|
|
57
66
|
const follow = (state: DesktopState) => {
|
|
58
67
|
shown = state.shown !== null && state.shown !== undefined;
|
|
59
|
-
// The app's overlay, set by someone else: what
|
|
60
|
-
|
|
68
|
+
// The app's overlay, set off by someone else: what the shell raised is down. Set on by someone else, it is still
|
|
69
|
+
// theirs: the shell does not take it over (nor lower it on dispose).
|
|
70
|
+
if (state.overlay !== undefined) raised = state.overlay;
|
|
71
|
+
if (state.overlay === false) sent = false;
|
|
61
72
|
// A remote page shown while a popup is open: the home page comes in front now; none any more: nothing to cover.
|
|
62
|
-
|
|
73
|
+
// Holding nothing, the overlay is not the shell's: another raised it (an older rail's own count), it lowers it.
|
|
74
|
+
if (count > 0) void send(shown);
|
|
63
75
|
};
|
|
64
76
|
const stop = app?.onState((state) => {
|
|
65
77
|
followed = true;
|
|
@@ -97,9 +109,10 @@ export function createOverlayHold(
|
|
|
97
109
|
const releaseId = id === undefined ? undefined : held.hold(id);
|
|
98
110
|
// The desktop app focuses the home page over its remote view (`focus`, ignored by an older app); the page too.
|
|
99
111
|
if (modal) window.focus();
|
|
100
|
-
const raise = () => (shown ? send(true, modal).then(frame) : Promise.resolve());
|
|
101
|
-
const ready = !app ? Promise.resolve() : bounded(followed || settled ? raise() : watching.then(raise));
|
|
102
112
|
let released = false;
|
|
113
|
+
// Released (or the shell disposed) before the app's first state answered: nothing to raise any more.
|
|
114
|
+
const raise = () => (shown && !released && !disposed ? send(true, modal).then(frame) : Promise.resolve());
|
|
115
|
+
const ready = !app ? Promise.resolve() : bounded(followed || settled ? raise() : watching.then(raise));
|
|
103
116
|
const release = () => {
|
|
104
117
|
if (released) return;
|
|
105
118
|
released = true;
|
|
@@ -116,6 +129,7 @@ export function createOverlayHold(
|
|
|
116
129
|
/** The shell is disposed: stop following the app, drop every hold, give the window back. */
|
|
117
130
|
dispose() {
|
|
118
131
|
stop?.();
|
|
132
|
+
disposed = true;
|
|
119
133
|
clearTimeout(lowering);
|
|
120
134
|
count = 0;
|
|
121
135
|
held.clear();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bridgebrew/shell",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "The page around everything: the rail, the sidebar column, the stage beside it and the theme controls.",
|
|
6
6
|
"keywords": [
|
|
@@ -103,6 +103,6 @@
|
|
|
103
103
|
"typecheck": "bridge plugin check ."
|
|
104
104
|
},
|
|
105
105
|
"engines": {
|
|
106
|
-
"bridge": ">=0.0.2-nightly.
|
|
106
|
+
"bridge": ">=0.0.2-nightly.20261130.1"
|
|
107
107
|
}
|
|
108
108
|
}
|