@bridgebrew/rail 0.0.3 → 0.0.4
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/browser.tsx +46 -27
- package/package.json +2 -2
package/browser/browser.tsx
CHANGED
|
@@ -113,48 +113,64 @@ function useDesktopState() {
|
|
|
113
113
|
return state;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
/**
|
|
116
|
+
/** The shell's one hold of the home page over a joined Bridge's page (`ctx.shell.holdOverlay`, research-128 §7), set
|
|
117
|
+
* by `apply`: every popup and window of every plugin counts in it, so one closing never gives the window back while
|
|
118
|
+
* another is open. An older shell has none: the rail's own count (`railHold`). */
|
|
119
|
+
let holdOverlay: NonNullable<Context['shell']['holdOverlay']> | undefined;
|
|
120
|
+
/** A remote page shows under this one (the desktop app's state): only then does `railHold` need the window. */
|
|
117
121
|
let remoteShown = false;
|
|
118
|
-
/** The rail's
|
|
119
|
-
*
|
|
120
|
-
|
|
121
|
-
let
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
122
|
+
/** The rail's own count, with a shell from before research-128 §7: the home view covers the window while any of the
|
|
123
|
+
* rail's popups is open over a remote page. */
|
|
124
|
+
const railHold = (() => {
|
|
125
|
+
let count = 0;
|
|
126
|
+
return (): ReturnType<NonNullable<typeof holdOverlay>> => {
|
|
127
|
+
const desktop = window.bridgeDesktop;
|
|
128
|
+
if (!desktop || !remoteShown) return Object.assign(() => {}, { ready: Promise.resolve() });
|
|
129
|
+
count++;
|
|
130
|
+
// The popup paints one frame after the view grew; a refused request opens it anyway.
|
|
131
|
+
const ready = desktop
|
|
132
|
+
.overlay(true)
|
|
133
|
+
.then(
|
|
134
|
+
() => new Promise<void>((done) => requestAnimationFrame(() => done())),
|
|
135
|
+
() => {},
|
|
136
|
+
);
|
|
137
|
+
let released = false;
|
|
138
|
+
const release = () => {
|
|
139
|
+
if (released) return;
|
|
140
|
+
released = true;
|
|
141
|
+
count = Math.max(0, count - 1);
|
|
142
|
+
if (count === 0) void desktop.overlay(false).catch(() => {});
|
|
143
|
+
};
|
|
144
|
+
return Object.assign(release, { ready });
|
|
145
|
+
};
|
|
146
|
+
})();
|
|
132
147
|
|
|
133
|
-
/** A popup's open state,
|
|
148
|
+
/** A popup's open state, held in the shell's count while open: over a remote page in the desktop app, it opens once
|
|
149
|
+
* the app made room for it. `initial`: a dialog, open from the start, a modal hold (the home page focused). */
|
|
134
150
|
function useLayer(initial = false) {
|
|
135
151
|
const [open, setOpen] = React.useState(false);
|
|
136
152
|
const wanted = React.useRef(false);
|
|
137
|
-
const
|
|
153
|
+
const release = React.useRef<(() => void) | undefined>(undefined);
|
|
138
154
|
const change = React.useCallback((next: boolean) => {
|
|
139
155
|
wanted.current = next;
|
|
140
|
-
const desktop = window.bridgeDesktop;
|
|
141
156
|
if (!next) {
|
|
142
157
|
setOpen(false);
|
|
143
|
-
|
|
144
|
-
|
|
158
|
+
release.current?.();
|
|
159
|
+
release.current = undefined;
|
|
145
160
|
return;
|
|
146
161
|
}
|
|
147
|
-
if (
|
|
148
|
-
held
|
|
149
|
-
|
|
162
|
+
if (release.current || !holdOverlay) return setOpen(true);
|
|
163
|
+
const held = holdOverlay(initial ? { modal: true } : {});
|
|
164
|
+
release.current = held;
|
|
165
|
+
void held.ready.then(() => {
|
|
150
166
|
if (wanted.current) setOpen(true);
|
|
151
167
|
});
|
|
152
168
|
}, []);
|
|
153
169
|
React.useEffect(() => {
|
|
154
170
|
if (initial) change(true);
|
|
155
171
|
return () => {
|
|
156
|
-
|
|
157
|
-
|
|
172
|
+
release.current?.();
|
|
173
|
+
release.current = undefined;
|
|
158
174
|
};
|
|
159
175
|
}, []);
|
|
160
176
|
return [open, change] as const;
|
|
@@ -1318,10 +1334,12 @@ function Rail({
|
|
|
1318
1334
|
onRestore={(key) => settle(window.bridgeDesktop?.restore(key))}
|
|
1319
1335
|
/>
|
|
1320
1336
|
<span className="flex-1" />
|
|
1337
|
+
<Moved node={controls} divider="after" />
|
|
1338
|
+
{/* Plugins' icons at the bottom (research-128 §7): after the divider of the sidebar's moved controls, with
|
|
1339
|
+
Bridge's own controls, named by the rail's tooltip as their neighbours. */}
|
|
1321
1340
|
<div data-slot="rail-bottom" className="flex w-full flex-col items-center gap-2 empty:hidden">
|
|
1322
|
-
{renderSlot('rail-bottom', {})}
|
|
1341
|
+
{renderSlot('rail-bottom', { tip: RailTip })}
|
|
1323
1342
|
</div>
|
|
1324
|
-
<Moved node={controls} divider="after" />
|
|
1325
1343
|
{statusShown(status) && (
|
|
1326
1344
|
<RailTip label={statusLabel[status]}>
|
|
1327
1345
|
<a
|
|
@@ -1424,6 +1442,7 @@ function Rail({
|
|
|
1424
1442
|
}
|
|
1425
1443
|
|
|
1426
1444
|
export function apply(ctx: Context) {
|
|
1445
|
+
holdOverlay = ctx.shell.holdOverlay ?? railHold;
|
|
1427
1446
|
const list = { kind: 'list', scope: 'root' } as const;
|
|
1428
1447
|
// The rail's commands in the ⌘K palette (research-034), when the `commands` plugin is there (followed if it comes).
|
|
1429
1448
|
const ask = (dialog: 'create' | 'join') => () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bridgebrew/rail",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "The column of workspace tiles, with the Bridge button and its status dot.",
|
|
6
6
|
"keywords": [
|
|
@@ -36,6 +36,6 @@
|
|
|
36
36
|
"typecheck": "bridge plugin check ."
|
|
37
37
|
},
|
|
38
38
|
"engines": {
|
|
39
|
-
"bridge": ">=0.0.1-nightly.
|
|
39
|
+
"bridge": ">=0.0.1-nightly.20261124.1"
|
|
40
40
|
}
|
|
41
41
|
}
|