@kabmo-labs/kabmo 0.19.0 → 0.21.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 +32 -5
- package/dist/client/index.html +3 -3
- package/dist/client/index.js +362 -362
- package/dist/client/static/js/{index-sxdw908m.css → index-0721wrkf.css} +1 -1
- package/dist/client/static/js/{index-fcee4c13.js → index-zg32n2sk.js} +685 -685
- package/dist/client/static/{manifest-42r8wcmg.webmanifest → manifest-q6h8k9e0.webmanifest} +1 -1
- package/index.html +1 -1
- package/package.json +1 -1
- package/public/manifest.webmanifest +1 -1
- package/src/client/components/common/checkbox/style.test.ts +11 -8
- package/src/client/components/common/panel-mark/index.test.tsx +124 -0
- package/src/client/components/common/panel-mark/index.tsx +9 -1
- package/src/client/components/settings/categories/panel-plugins/GitFreshness.test.tsx +46 -0
- package/src/client/components/settings/categories/panel-plugins/GitFreshness.tsx +1 -1
- package/src/client/components/settings/categories/panel-plugins/InstalledList.tsx +7 -9
- package/src/client/components/settings/categories/panel-plugins/PluginCard.test.tsx +149 -0
- package/src/client/components/settings/categories/panel-plugins/PluginCard.tsx +33 -6
- package/src/client/components/settings/categories/panel-plugins/PluginMark.test.ts +15 -0
- package/src/client/components/settings/categories/panel-plugins/PluginMark.tsx +6 -2
- package/src/client/components/settings/categories/panel-plugins/Section.tsx +7 -1
- package/src/client/components/settings/categories/panel-plugins/Toolbar.tsx +35 -2
- package/src/client/glass-sticky.test.ts +46 -0
- package/src/client/glass.css +27 -17
- package/src/client/glass.test.ts +21 -61
- package/src/client/hooks/ui/stuck-header.test.ts +28 -3
- package/src/client/hooks/ui/stuck-header.ts +36 -5
- package/src/client/hooks/workspace/panel-registry.ts +8 -4
- package/src/server/lib/lifecycle/tls.test.ts +6 -1
- package/src/server/lib/panels/git-update.server.test.ts +20 -0
- package/src/server/lib/panels/git-update.server.ts +20 -4
- package/src/server/lib/panels/sync.server.ts +9 -1
- package/src/server/lib/panels/update.server.test.ts +193 -0
- package/src/server/lib/panels/update.server.ts +210 -0
- package/src/server/lib/plugins/server-half.server.ts +42 -0
- package/src/server/lib/terminal/attach-replay.test.ts +26 -8
- package/src/server/routes/panels/install-route.test.ts +238 -0
- package/src/server/routes/panels/install.ts +36 -64
- package/src/server/routes/panels/panel-routes.test-util.ts +6 -1
- package/src/server/routes/panels/routes.test.ts +1 -118
- package/src/shared/lib/icons/icon-paint-css.test.ts +8 -7
- package/src/shared/lib/icons/icon-paint-css.ts +2 -1
- package/src/shared/lib/icons/icon-paint-panel.ts +16 -7
- package/src/shared/lib/icons/icon-tone.ts +166 -0
- package/src/shared/lib/icons/tint-hues.generated.ts +50 -3
- package/src/shared/lib/icons/tint.test.ts +75 -15
- package/src/shared/lib/icons/tint.ts +40 -11
- package/src/shared/lib/panels/update.test.ts +107 -0
- package/src/shared/lib/panels/update.ts +73 -0
- package/src/shared/lib/theme/color.ts +50 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AlertTriangle, Trash2, X } from 'lucide-preact';
|
|
2
2
|
import type { PanelPluginError } from '@/shared/types';
|
|
3
|
+
import { countPluginUpdates } from '@/shared/lib/panels/update';
|
|
3
4
|
import {
|
|
4
5
|
refreshPanelRegistry,
|
|
5
6
|
usePanelPluginActions,
|
|
@@ -99,6 +100,9 @@ export function PanelPluginsSection() {
|
|
|
99
100
|
const iconUrls = new Map(panels.map((panel) => [panel.pluginId, panel.iconUrl]));
|
|
100
101
|
const readmeUrls = new Map(panels.map((panel) => [panel.pluginId, panel.readmeUrl]));
|
|
101
102
|
const gitCount = plugins.filter((plugin) => plugin.gitOrigin).length;
|
|
103
|
+
// The same predicate the cards use — one answer for the count, the buttons
|
|
104
|
+
// and the Installed header, so they cannot disagree about what is waiting.
|
|
105
|
+
const updateCount = countPluginUpdates(plugins, gitStatus);
|
|
102
106
|
|
|
103
107
|
return (
|
|
104
108
|
<div className="space-y-4">
|
|
@@ -115,8 +119,10 @@ export function PanelPluginsSection() {
|
|
|
115
119
|
autoUpdate={autoUpdate}
|
|
116
120
|
busy={actions.busy}
|
|
117
121
|
gitCount={gitCount}
|
|
122
|
+
updateCount={updateCount}
|
|
118
123
|
onSetAutoUpdate={actions.setAutoUpdate}
|
|
119
124
|
onCheckUpdates={actions.checkUpdates}
|
|
125
|
+
onUpdateAll={actions.updateAll}
|
|
120
126
|
onRefresh={refresh}
|
|
121
127
|
/>
|
|
122
128
|
|
|
@@ -183,7 +189,7 @@ export function PanelPluginsSection() {
|
|
|
183
189
|
onRemove={actions.remove}
|
|
184
190
|
onSetEnabled={actions.setEnabled}
|
|
185
191
|
gitStatus={gitStatus}
|
|
186
|
-
|
|
192
|
+
onUpdate={actions.update}
|
|
187
193
|
/>
|
|
188
194
|
) : null}
|
|
189
195
|
|
|
@@ -16,20 +16,33 @@
|
|
|
16
16
|
* a write. It is the latter, and the sentence says so.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
import { CheckSquare, RefreshCw, Square } from 'lucide-preact';
|
|
19
|
+
import { ArrowDownToLine, CheckSquare, Loader2, RefreshCw, Square } from 'lucide-preact';
|
|
20
20
|
|
|
21
21
|
interface PluginToolbarProps {
|
|
22
22
|
autoUpdate: boolean;
|
|
23
23
|
busy: string | null;
|
|
24
24
|
/** How many installed plugins are git clones — the check's own subject. */
|
|
25
25
|
gitCount: number;
|
|
26
|
+
/** How many installed plugins have an update waiting, from any source. */
|
|
27
|
+
updateCount: number;
|
|
26
28
|
onSetAutoUpdate: (enabled: boolean) => Promise<boolean>;
|
|
27
29
|
onCheckUpdates: () => Promise<boolean>;
|
|
30
|
+
onUpdateAll: () => Promise<boolean>;
|
|
28
31
|
onRefresh: () => void;
|
|
29
32
|
}
|
|
30
33
|
|
|
31
|
-
export function PluginToolbar({
|
|
34
|
+
export function PluginToolbar({
|
|
35
|
+
autoUpdate,
|
|
36
|
+
busy,
|
|
37
|
+
gitCount,
|
|
38
|
+
updateCount,
|
|
39
|
+
onSetAutoUpdate,
|
|
40
|
+
onCheckUpdates,
|
|
41
|
+
onUpdateAll,
|
|
42
|
+
onRefresh,
|
|
43
|
+
}: PluginToolbarProps) {
|
|
32
44
|
const checking = busy === 'check_updates';
|
|
45
|
+
const updatingAll = busy === 'update_all';
|
|
33
46
|
return (
|
|
34
47
|
<div className="flex flex-wrap items-center gap-2">
|
|
35
48
|
<button
|
|
@@ -64,6 +77,25 @@ export function PluginToolbar({ autoUpdate, busy, gitCount, onSetAutoUpdate, onC
|
|
|
64
77
|
Check for updates
|
|
65
78
|
</button>
|
|
66
79
|
|
|
80
|
+
{/* The count is on the button because it is the button's subject: one
|
|
81
|
+
action for every waiting update, whatever the plugin's source. A
|
|
82
|
+
plugin whose files were edited is refused and reported, never
|
|
83
|
+
overwritten — that is what the blocked notice exists for. */}
|
|
84
|
+
<button
|
|
85
|
+
type="button"
|
|
86
|
+
onClick={() => void onUpdateAll()}
|
|
87
|
+
disabled={busy !== null || updateCount === 0}
|
|
88
|
+
title={
|
|
89
|
+
updateCount === 0
|
|
90
|
+
? 'No updates to apply — press Check for updates to ask the git plugins\u2019 remotes'
|
|
91
|
+
: `Apply ${updateCount} update${updateCount === 1 ? '' : 's'} — a plugin with local edits is refused and reported, never overwritten`
|
|
92
|
+
}
|
|
93
|
+
className="flex items-center gap-1.5 px-2.5 py-1.5 text-xs rounded border border-warning/50 text-warning hover:bg-warning/10 disabled:opacity-50"
|
|
94
|
+
>
|
|
95
|
+
{updatingAll ? <Loader2 size={13} className="animate-spin" /> : <ArrowDownToLine size={13} />}
|
|
96
|
+
Update all{updateCount > 0 ? ` (${updateCount})` : ''}
|
|
97
|
+
</button>
|
|
98
|
+
|
|
67
99
|
<button
|
|
68
100
|
type="button"
|
|
69
101
|
onClick={onRefresh}
|
|
@@ -83,3 +115,4 @@ export function PluginToolbar({ autoUpdate, busy, gitCount, onSetAutoUpdate, onC
|
|
|
83
115
|
</div>
|
|
84
116
|
);
|
|
85
117
|
}
|
|
118
|
+
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The sticky folder header's material, split from `glass.test.ts` by subject:
|
|
8
|
+
* it is the one element in `glass.css` that matches BOTH a tier rule (the
|
|
9
|
+
* `bg-canvas` well) and a state rule (`.glass-sticky[data-stuck]`).
|
|
10
|
+
*
|
|
11
|
+
* The phone drawer's header paints `bg-canvas` because its rows sit on canvas
|
|
12
|
+
* (see `modern/WorkspaceHeader.tsx`), so the well rule matched it. That
|
|
13
|
+
* selector is (0,4,0) and the stuck fill is (0,3,0), so the well won: measured
|
|
14
|
+
* at 412x900 with the drawer open and 420px scrolled, a PINNED header computed
|
|
15
|
+
* to `rgba(0,0,0,0)` — sticky active, background transparent — while the
|
|
16
|
+
* desktop column's `bg-paper` header painted its fill. A sticky header is a
|
|
17
|
+
* sticky header, never a well.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { describe, expect, test } from 'bun:test';
|
|
21
|
+
|
|
22
|
+
const read = (file: string): Promise<string> => Bun.file(new URL(file, import.meta.url)).text();
|
|
23
|
+
|
|
24
|
+
describe('glass sticky header material', () => {
|
|
25
|
+
test('the canvas well rule steps aside for a sticky header', async () => {
|
|
26
|
+
const glass = await read('./glass.css');
|
|
27
|
+
const well = glass.slice(glass.indexOf('[data-surface="glass"] .app-window .bg-canvas'));
|
|
28
|
+
expect(well.slice(0, well.indexOf('{'))).toContain(':not(.glass-sticky)');
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test('the fill belongs to the stuck state and outlives the well rule', async () => {
|
|
32
|
+
const glass = await read('./glass.css');
|
|
33
|
+
// At rest: nothing, so a folder header is not a stripe across the list.
|
|
34
|
+
const rest = glass.slice(glass.indexOf('[data-surface="glass"] .glass-sticky {'));
|
|
35
|
+
expect(rest.slice(0, rest.indexOf('}'))).toContain('background-color: transparent;');
|
|
36
|
+
|
|
37
|
+
// While pinned: the opaque composite, painted AFTER the rest rule so source
|
|
38
|
+
// order agrees with the state it describes.
|
|
39
|
+
const restAt = glass.indexOf('[data-surface="glass"] .glass-sticky {');
|
|
40
|
+
const stuckAt = glass.indexOf('[data-surface="glass"] .glass-sticky[data-stuck] {');
|
|
41
|
+
expect(stuckAt).toBeGreaterThan(restAt);
|
|
42
|
+
const stuck = glass.slice(stuckAt);
|
|
43
|
+
expect(stuck.slice(0, stuck.indexOf('}'))).toContain('background-color: var(--glass-stuck);');
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
package/src/client/glass.css
CHANGED
|
@@ -468,25 +468,35 @@
|
|
|
468
468
|
* ground, so the plane never depends on `<body>` — whose colour is pinned once
|
|
469
469
|
* per request by the first-frame style, which is exactly the layer that would go
|
|
470
470
|
* stale when the palette changes without a reload.
|
|
471
|
-
*/
|
|
472
|
-
[data-surface="glass"] .app-window .bg-canvas:not(.app-window) {
|
|
473
|
-
background-color: transparent;
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
/*
|
|
477
|
-
* …except a knob ON a switch, which is a SHAPE, not a well.
|
|
478
471
|
*
|
|
479
|
-
*
|
|
480
|
-
*
|
|
481
|
-
*
|
|
482
|
-
*
|
|
483
|
-
*
|
|
484
|
-
*
|
|
485
|
-
*
|
|
486
|
-
*
|
|
472
|
+
* A STICKY header is excluded too, and that exclusion is load-bearing rather than
|
|
473
|
+
* tidy: the phone drawer's header paints `bg-canvas` (its rows sit on canvas, see
|
|
474
|
+
* `WorkspaceHeader`), so it is a `.bg-canvas` inside `.app-window` — and THIS
|
|
475
|
+
* selector is (0,5,0) against the stuck fill's (0,4,0), so the well won and the
|
|
476
|
+
* pinned header stayed transparent. Measured at 412x900 with the drawer open and
|
|
477
|
+
* 420px scrolled: `data-stuck` set (after the scrollport fix), header pinned at
|
|
478
|
+
* the container's top edge, computed `background-color: rgba(0,0,0,0)` — an
|
|
479
|
+
* active sticky folder header with no surface, while the desktop column's
|
|
480
|
+
* `bg-paper` header (which this rule never matched) painted its fill. A sticky
|
|
481
|
+
* header is never a well: its own state decides, one rule below.
|
|
482
|
+
*
|
|
483
|
+
* A switch KNOB is excluded for the same reason, and it has to be excluded
|
|
484
|
+
* HERE: `bg-canvas` is the app's ground, but a knob uses it as an OPAQUE
|
|
485
|
+
* contrasting disc, and `bg-canvas` on `bg-ink/70` is what makes the control
|
|
486
|
+
* read as a toggle at all. Making it transparent deleted the knob — measured on
|
|
487
|
+
* the plugin switches, the 12px disc composited to `rgba(0,0,0,0)` and the
|
|
488
|
+
* control became a plain pill with no "on" position.
|
|
489
|
+
*
|
|
490
|
+
* It was first written as a SECOND rule ("…except a knob on a switch"), and that
|
|
491
|
+
* rule never applied once: `[role="switch"] .bg-canvas` is (0,4,0) and this
|
|
492
|
+
* selector is (0,5,0), so the well won and every knob on every surface — desktop
|
|
493
|
+
* and phone alike — painted nothing. A same-property override is a specificity
|
|
494
|
+
* race; an exclusion in the ONE rule that causes the problem is not. The mark is
|
|
495
|
+
* the switch ROLE rather than a class name, so any control that declares itself
|
|
496
|
+
* a switch owns its knob, whatever it paints it with.
|
|
487
497
|
*/
|
|
488
|
-
[data-surface="glass"] .app-window [role="switch"]
|
|
489
|
-
background-color:
|
|
498
|
+
[data-surface="glass"] .app-window .bg-canvas:not(.app-window):not(.glass-sticky):not([role="switch"] *) {
|
|
499
|
+
background-color: transparent;
|
|
490
500
|
}
|
|
491
501
|
|
|
492
502
|
/*
|
package/src/client/glass.test.ts
CHANGED
|
@@ -197,6 +197,21 @@ describe('glass dialog material', () => {
|
|
|
197
197
|
expect(glass).toContain('[data-surface="glass"] .glass-overlay > .bg-paper {\n background-color: transparent;');
|
|
198
198
|
});
|
|
199
199
|
|
|
200
|
+
test('a switch knob is not a canvas well, and the exclusion is in the well rule itself', async () => {
|
|
201
|
+
const glass = await read('./glass.css');
|
|
202
|
+
// The knob is `bg-canvas` on `bg-ink/70`: an OPAQUE contrasting disc is what
|
|
203
|
+
// makes the control read as a toggle. It was first exempted by a SECOND rule,
|
|
204
|
+
// and that rule never applied — `[role="switch"] .bg-canvas` is (0,4,0) and
|
|
205
|
+
// the well selector is (0,5,0), so the well won and every knob on every
|
|
206
|
+
// surface (desktop and phone alike) computed `rgba(0,0,0,0)`. Measured on the
|
|
207
|
+
// plugin switches: a plain pill with no "on" position.
|
|
208
|
+
const well = glass.slice(glass.indexOf('[data-surface="glass"] .app-window .bg-canvas'));
|
|
209
|
+
expect(well.slice(0, well.indexOf('{'))).toContain(':not([role="switch"] *)');
|
|
210
|
+
// A same-property override anywhere later would be the same race again, so
|
|
211
|
+
// there must be no second `background-color` rule for that knob at all.
|
|
212
|
+
expect(glass).not.toContain('[data-surface="glass"] .app-window [role="switch"] .bg-canvas');
|
|
213
|
+
});
|
|
214
|
+
|
|
200
215
|
test('both fallback blocks outrank the dark palette block', async () => {
|
|
201
216
|
const glass = await read('./glass.css');
|
|
202
217
|
// The dark tokens live in `[data-surface="glass"][data-theme-variant="dark"]`
|
|
@@ -230,67 +245,8 @@ describe('glass dialog material', () => {
|
|
|
230
245
|
|
|
231
246
|
/**
|
|
232
247
|
* The material has to hold on EVERY palette in the catalog, not on the eighteen
|
|
233
|
-
* it was tuned against.
|
|
234
|
-
* cannot drift from the shipped values, and the composite it measures is the one
|
|
235
|
-
* the browser computes: `color-mix(… paper N%, transparent)` over the plane,
|
|
236
|
-
* which is itself paper over canvas.
|
|
248
|
+
* it was tuned against.
|
|
237
249
|
*
|
|
238
|
-
* The invariant is the one a new palette can break without anyone noticing: body
|
|
239
|
-
* text on the chrome and on a card keeps the 4.5:1 floor. Measured across all 63
|
|
240
|
-
* palettes, the worst is `solarized-light` at 4.89:1 — the same number its
|
|
241
|
-
* opaque paper has, which is what "the tint costs no contrast" means.
|
|
242
|
-
*/
|
|
243
|
-
describe('glass material across the catalog', () => {
|
|
244
|
-
const alphaOf = (body: string, token: string): number => {
|
|
245
|
-
const match = new RegExp(`${token}: color-mix\\(in srgb, var\\(--theme-paper\\) (\\d+)%, transparent\\)`).exec(body);
|
|
246
|
-
if (!match) throw new Error(`no ${token} alpha`);
|
|
247
|
-
return Number(match[1]) / 100;
|
|
248
|
-
};
|
|
249
|
-
const percentOf = (body: string, token: string): number => {
|
|
250
|
-
const match = new RegExp(`${token}: (\\d+)%;`).exec(body);
|
|
251
|
-
if (!match) throw new Error(`no ${token}`);
|
|
252
|
-
return Number(match[1]) / 100;
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
test('every palette keeps body text legible on the plane, the chrome and a card', async () => {
|
|
256
|
-
const glass = await read('./glass.css');
|
|
257
|
-
const light = ruleBody(glass, '[data-surface="glass"]');
|
|
258
|
-
const dark = ruleBody(glass, '[data-surface="glass"][data-theme-variant="dark"]');
|
|
259
|
-
const root = ruleBody(glass, ':root');
|
|
260
|
-
const darkVariant = ruleBody(glass, '[data-theme-variant="dark"]');
|
|
261
|
-
|
|
262
|
-
const alphas = {
|
|
263
|
-
light: {
|
|
264
|
-
tint: percentOf(light, '--glass-tint'),
|
|
265
|
-
chrome: alphaOf(light, '--glass-chrome'),
|
|
266
|
-
// A card's fill is surface-INDEPENDENT (the composer's `glass` style is
|
|
267
|
-
// offered in the classic look), so it lives on `:root` / the variant.
|
|
268
|
-
card: alphaOf(root, '--glass-card'),
|
|
269
|
-
},
|
|
270
|
-
dark: {
|
|
271
|
-
tint: percentOf(dark, '--glass-tint'),
|
|
272
|
-
chrome: alphaOf(dark, '--glass-chrome'),
|
|
273
|
-
card: alphaOf(darkVariant, '--glass-card'),
|
|
274
|
-
},
|
|
275
|
-
};
|
|
276
|
-
|
|
277
|
-
for (const theme of THEMES) {
|
|
278
|
-
const alpha = alphas[theme.variant];
|
|
279
|
-
const plane = mixHex(theme.canvas, theme.paper, alpha.tint);
|
|
280
|
-
const chrome = mixHex(plane, theme.paper, alpha.chrome);
|
|
281
|
-
const card = mixHex(plane, theme.paper, alpha.card);
|
|
282
|
-
for (const [tier, surface] of [['plane', plane], ['chrome', chrome], ['card', card]] as const) {
|
|
283
|
-
expect({ id: theme.id, tier, ratio: contrastRatio(theme.ink, surface) >= 4.5 }).toEqual({
|
|
284
|
-
id: theme.id,
|
|
285
|
-
tier,
|
|
286
|
-
ratio: true,
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
/**
|
|
294
250
|
* The material is DERIVED from the palette — `--glass-panel` is
|
|
295
251
|
* `color-mix(paper N%, transparent)` and the chrome is one more mix over it — so
|
|
296
252
|
* a theme does not "support glass" by declaring something; it supports it when
|
|
@@ -300,7 +256,11 @@ describe('glass material across the catalog', () => {
|
|
|
300
256
|
*
|
|
301
257
|
* The alphas are read out of `glass.css` rather than repeated here, so the test
|
|
302
258
|
* cannot drift from the shipped values, and the composite is the browser's own:
|
|
303
|
-
* plane = paper over canvas, chrome/card = paper over plane.
|
|
259
|
+
* plane = paper over canvas, chrome/card = paper over plane. The invariant a new
|
|
260
|
+
* palette breaks without anyone noticing is body text keeping the 4.5:1 floor on
|
|
261
|
+
* the chrome and on a card. Measured across all 63 palettes, the worst is
|
|
262
|
+
* `solarized-light` at 4.89:1 — the same number its opaque paper has, which is
|
|
263
|
+
* what "the tint costs no contrast" means.
|
|
304
264
|
*/
|
|
305
265
|
describe('glass material on every catalog palette', () => {
|
|
306
266
|
/** A percentage out of a token, whether bare (`50%`) or inside a `color-mix`. */
|
|
@@ -86,7 +86,7 @@ afterAll(() => {
|
|
|
86
86
|
* exactly what `useStuckHeader` reads. The header's rect is a LIVE getter over
|
|
87
87
|
* `headerTop`, so a test scrolls by changing one number.
|
|
88
88
|
*/
|
|
89
|
-
function mountHarness(): HTMLElement {
|
|
89
|
+
function mountHarness(options: { collapsed?: boolean } = {}): HTMLElement {
|
|
90
90
|
function Probe() {
|
|
91
91
|
const ref = useRef<HTMLDivElement>(null);
|
|
92
92
|
const stuck = useStuckHeader(ref);
|
|
@@ -95,8 +95,9 @@ function mountHarness(): HTMLElement {
|
|
|
95
95
|
|
|
96
96
|
scroller = document.createElement('div');
|
|
97
97
|
scroller.style.overflowY = 'auto';
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
// `collapsed` is the phone drawer's mount: the list is inside a hidden screen,
|
|
99
|
+
// so it measures 0x0 and the "does it overflow" test answers false.
|
|
100
|
+
setScrollerSizes(options.collapsed ? 0 : 1000, options.collapsed ? 0 : 300);
|
|
100
101
|
Object.defineProperty(scroller, 'scrollTop', {
|
|
101
102
|
get: () => scrollTop,
|
|
102
103
|
set: (value: number) => {
|
|
@@ -118,6 +119,12 @@ function mountHarness(): HTMLElement {
|
|
|
118
119
|
return header;
|
|
119
120
|
}
|
|
120
121
|
|
|
122
|
+
/** The container's scroll extent, which is what the hook may NOT use to find it. */
|
|
123
|
+
function setScrollerSizes(scrollHeight: number, clientHeight: number) {
|
|
124
|
+
Object.defineProperty(scroller, 'scrollHeight', { value: scrollHeight, configurable: true });
|
|
125
|
+
Object.defineProperty(scroller, 'clientHeight', { value: clientHeight, configurable: true });
|
|
126
|
+
}
|
|
127
|
+
|
|
121
128
|
/**
|
|
122
129
|
* Scroll the harness and wait for the hook's OWN measurement.
|
|
123
130
|
*
|
|
@@ -185,4 +192,22 @@ describe('useStuckHeader', () => {
|
|
|
185
192
|
scrollTo(40, 0);
|
|
186
193
|
expect(header.hasAttribute('data-stuck')).toBe(false);
|
|
187
194
|
});
|
|
195
|
+
|
|
196
|
+
test('a container mounted at 0x0 is still the scrollport (the phone drawer)', () => {
|
|
197
|
+
// Measured in the real drawer at 412x900: the list is mounted inside a
|
|
198
|
+
// `hidden` screen, so `scrollHeight`/`clientHeight` both read 0 at mount. The
|
|
199
|
+
// old container test required an overflow, gave up, and fell back to
|
|
200
|
+
// `window.scrollY` — which never moves for an inner scroller — so the folder
|
|
201
|
+
// header sat PINNED at the container's top edge with no `data-stuck`: an
|
|
202
|
+
// active sticky header painting nothing.
|
|
203
|
+
const header = mountHarness({ collapsed: true });
|
|
204
|
+
scrollTo(120, 0);
|
|
205
|
+
expect(header.hasAttribute('data-stuck')).toBe(false);
|
|
206
|
+
|
|
207
|
+
// The drawer opens (the box gets real) and the user scrolls: the fill must
|
|
208
|
+
// appear, which only happens if the CONTAINER was listened to.
|
|
209
|
+
setScrollerSizes(1000, 300);
|
|
210
|
+
scrollTo(0, 120);
|
|
211
|
+
expect(header.hasAttribute('data-stuck')).toBe(true);
|
|
212
|
+
});
|
|
188
213
|
});
|
|
@@ -19,17 +19,38 @@
|
|
|
19
19
|
*
|
|
20
20
|
* `root: null`-style viewport maths is deliberately NOT used: the sidebar is an
|
|
21
21
|
* inner scroll container, so the comparison has to be against THAT box.
|
|
22
|
+
*
|
|
23
|
+
* ## The scrollport is found by `overflow-y`, never by "does it overflow"
|
|
24
|
+
*
|
|
25
|
+
* From a sentinel-free test it is tempting to require `scrollHeight > clientHeight`
|
|
26
|
+
* when picking the container — "the nearest ancestor that actually scrolls".
|
|
27
|
+
* That test reads ZERO for a subtree mounted hidden, and the phone drawer IS
|
|
28
|
+
* mounted hidden: its screen is a sibling carrying `hidden`, so at mount the
|
|
29
|
+
* scroller measures 0/0. The hook then fell through to `window` (`scrollY`),
|
|
30
|
+
* which never moves for an inner scroller — measured on a 412x900 viewport with
|
|
31
|
+
* the drawer open and 420px scrolled, the folder header sat pinned at the
|
|
32
|
+
* container's top edge with **no** `data-stuck`, i.e. an active sticky header
|
|
33
|
+
* with a transparent background, while the desktop column (mounted visible)
|
|
34
|
+
* painted its fill. Per spec a `position: sticky` element is bound to its
|
|
35
|
+
* nearest SCROLL CONTAINER whether or not it overflows at this instant, so the
|
|
36
|
+
* `overflow-y` test alone is the accurate one — and it answers correctly for a
|
|
37
|
+
* hidden subtree, because computed style does not depend on the ancestor's
|
|
38
|
+
* `display`.
|
|
39
|
+
*
|
|
40
|
+
* Showing the drawer then has to re-measure by itself: a hidden subtree resizes
|
|
41
|
+
* from 0x0, so a `ResizeObserver` on the header (and on the container) is the
|
|
42
|
+
* signal that layout became real.
|
|
22
43
|
*/
|
|
23
44
|
|
|
24
45
|
import { useEffect, useState } from 'preact/hooks';
|
|
25
46
|
import type { RefObject } from 'preact';
|
|
26
47
|
|
|
27
|
-
/** The nearest ancestor that
|
|
48
|
+
/** The nearest ancestor that scrolls (the sticky containing block), or null. */
|
|
28
49
|
function scrollParent(element: HTMLElement): HTMLElement | null {
|
|
29
50
|
let node = element.parentElement;
|
|
30
51
|
while (node) {
|
|
31
52
|
const style = getComputedStyle(node);
|
|
32
|
-
if (/(auto|scroll|overlay)/.test(style.overflowY)
|
|
53
|
+
if (/(auto|scroll|overlay)/.test(style.overflowY)) return node;
|
|
33
54
|
node = node.parentElement;
|
|
34
55
|
}
|
|
35
56
|
return null;
|
|
@@ -38,9 +59,10 @@ function scrollParent(element: HTMLElement): HTMLElement | null {
|
|
|
38
59
|
/**
|
|
39
60
|
* True while `ref`'s element is pinned against the top of its scroll container.
|
|
40
61
|
*
|
|
41
|
-
* Re-measured on the container's `scroll`, on resize,
|
|
42
|
-
* (layout settles a frame later). A
|
|
43
|
-
* scroll
|
|
62
|
+
* Re-measured on the container's `scroll`, on resize, whenever the header or its
|
|
63
|
+
* container changes SIZE, and once after mount (layout settles a frame later). A
|
|
64
|
+
* rAF coalesces the scroll events, so a fast scroll costs one measurement per
|
|
65
|
+
* frame rather than one per event.
|
|
44
66
|
*/
|
|
45
67
|
export function useStuckHeader(ref: RefObject<HTMLElement | null>): boolean {
|
|
46
68
|
const [stuck, setStuck] = useState(false);
|
|
@@ -78,10 +100,19 @@ export function useStuckHeader(ref: RefObject<HTMLElement | null>): boolean {
|
|
|
78
100
|
};
|
|
79
101
|
|
|
80
102
|
measure();
|
|
103
|
+
// A hidden subtree mounts at 0x0 and its sticky geometry only becomes real
|
|
104
|
+
// when the ancestor stops being `hidden` — which is the phone drawer's whole
|
|
105
|
+
// lifecycle (`SessionSidebar` keeps the list mounted behind a hidden
|
|
106
|
+
// screen). Both boxes are watched: the container for the drawer appearing,
|
|
107
|
+
// the header for a density or label-height change.
|
|
108
|
+
const resize = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(schedule);
|
|
109
|
+
resize?.observe(element);
|
|
110
|
+
if (container) resize?.observe(container);
|
|
81
111
|
(container ?? window).addEventListener('scroll', schedule, { passive: true });
|
|
82
112
|
window.addEventListener('resize', schedule);
|
|
83
113
|
return () => {
|
|
84
114
|
pending = false;
|
|
115
|
+
resize?.disconnect();
|
|
85
116
|
(container ?? window).removeEventListener('scroll', schedule);
|
|
86
117
|
window.removeEventListener('resize', schedule);
|
|
87
118
|
};
|
|
@@ -244,8 +244,10 @@ export interface PanelPluginActions {
|
|
|
244
244
|
setEnabled: (pluginId: string, enabled: boolean) => Promise<boolean>;
|
|
245
245
|
/** Probe every git-installed plugin's remote for a newer commit. */
|
|
246
246
|
checkUpdates: () => Promise<boolean>;
|
|
247
|
-
/** Bring one
|
|
248
|
-
|
|
247
|
+
/** Bring one installed plugin up to its source — a remote, or the store's copy. */
|
|
248
|
+
update: (pluginId: string) => Promise<boolean>;
|
|
249
|
+
/** Apply every update that is available, in one pass. */
|
|
250
|
+
updateAll: () => Promise<boolean>;
|
|
249
251
|
/** Turn automatic updating of git-installed plugins on or off. */
|
|
250
252
|
setAutoUpdate: (enabled: boolean) => Promise<boolean>;
|
|
251
253
|
/** Replace a blocked bundled plugin's edited files with the store's copy. */
|
|
@@ -317,7 +319,8 @@ export function usePanelPluginActions(): PanelPluginActions {
|
|
|
317
319
|
[run],
|
|
318
320
|
);
|
|
319
321
|
const checkUpdates = useCallback(() => run('check_updates', { type: 'check_updates' }), [run]);
|
|
320
|
-
const
|
|
322
|
+
const update = useCallback((pluginId: string) => run(`update:${pluginId}`, { type: 'update', pluginId }), [run]);
|
|
323
|
+
const updateAll = useCallback(() => run('update_all', { type: 'update_all' }), [run]);
|
|
321
324
|
const setAutoUpdate = useCallback(
|
|
322
325
|
(enabled: boolean) => run('set_auto_update', { type: 'set_auto_update', enabled }),
|
|
323
326
|
[run],
|
|
@@ -335,7 +338,8 @@ export function usePanelPluginActions(): PanelPluginActions {
|
|
|
335
338
|
build,
|
|
336
339
|
setEnabled,
|
|
337
340
|
checkUpdates,
|
|
338
|
-
|
|
341
|
+
update,
|
|
342
|
+
updateAll,
|
|
339
343
|
setAutoUpdate,
|
|
340
344
|
forceSync,
|
|
341
345
|
};
|
|
@@ -44,6 +44,11 @@ describe('the tls flag', () => {
|
|
|
44
44
|
});
|
|
45
45
|
|
|
46
46
|
describe('ensureTlsCertificate', () => {
|
|
47
|
+
// A GENEROUS budget, because this spawns a real `openssl req -newkey rsa:2048`
|
|
48
|
+
// and the runner is not the machine this was written on: 63 ms here, and on
|
|
49
|
+
// the Windows gate it outran Bun's 5 s default and reported `ok: false` for a
|
|
50
|
+
// certificate that was being generated correctly. The work is unchanged; only
|
|
51
|
+
// the window it has to finish in is honest about RSA keygen on a slow host.
|
|
47
52
|
test('generates a usable pair on first call', () => {
|
|
48
53
|
const result = ensureTlsCertificate();
|
|
49
54
|
|
|
@@ -62,7 +67,7 @@ describe('ensureTlsCertificate', () => {
|
|
|
62
67
|
// mismatch on top of the self-signed warning.
|
|
63
68
|
expect(san).toContain('DNS:localhost');
|
|
64
69
|
expect(san).toContain('IP Address:127.0.0.1');
|
|
65
|
-
});
|
|
70
|
+
}, 60_000);
|
|
66
71
|
|
|
67
72
|
test('reuses an existing pair rather than regenerating it', () => {
|
|
68
73
|
const first = ensureTlsCertificate();
|
|
@@ -220,6 +220,26 @@ describe('updateGitPlugin', () => {
|
|
|
220
220
|
expect(fs.readFileSync(join(root, 'plugins', 'from-git', 'dist', 'app.js'), 'utf8')).toContain('edited');
|
|
221
221
|
});
|
|
222
222
|
|
|
223
|
+
test.skipIf(!hasGit)('updates a clone whose only untracked files are Kabmo’s own build output', async () => {
|
|
224
|
+
// A repository that does not gitignore `dist/` is ordinary, and Kabmo's build
|
|
225
|
+
// writes `dist/` and `node_modules/` into every clone. Counting those as
|
|
226
|
+
// uncommitted work made such a plugin permanently un-updatable — measured on a
|
|
227
|
+
// fixture repo with no .gitignore, where Update answered "has uncommitted
|
|
228
|
+
// changes" forever. `reset --hard` never touches an untracked file, so they
|
|
229
|
+
// are not what the refusal is protecting.
|
|
230
|
+
const repo = makeRepo();
|
|
231
|
+
await installPanelPluginFromGit(repo);
|
|
232
|
+
advance(repo, '2.0.0');
|
|
233
|
+
fs.mkdirSync(join(root, 'plugins', 'from-git', 'node_modules', 'dep'), { recursive: true });
|
|
234
|
+
fs.writeFileSync(join(root, 'plugins', 'from-git', 'node_modules', 'dep', 'index.js'), 'export default 1;');
|
|
235
|
+
|
|
236
|
+
const result = await updateGitPlugin('from-git');
|
|
237
|
+
expect(result.ok).toBe(true);
|
|
238
|
+
expect(result.updated).toBe(true);
|
|
239
|
+
// The untracked file was left alone rather than swept away by the reset.
|
|
240
|
+
expect(fs.existsSync(join(root, 'plugins', 'from-git', 'node_modules', 'dep', 'index.js'))).toBe(true);
|
|
241
|
+
});
|
|
242
|
+
|
|
223
243
|
test('refuses a plugin that is not a git clone', async () => {
|
|
224
244
|
const dir = join(root, 'plugins', 'plain');
|
|
225
245
|
fs.mkdirSync(dir, { recursive: true });
|
|
@@ -108,11 +108,27 @@ async function readRemoteVersion(dir: string): Promise<string | undefined> {
|
|
|
108
108
|
return undefined;
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
/**
|
|
111
|
+
/**
|
|
112
|
+
* Whether the clone has uncommitted work that an update would discard.
|
|
113
|
+
*
|
|
114
|
+
* `--untracked-files=no` is load-bearing, and it is not a shortcut: the update
|
|
115
|
+
* moves the tree with `git reset --hard`, which never touches an untracked file.
|
|
116
|
+
* Counting them refused every clone whose repository does not gitignore the
|
|
117
|
+
* build output — and Kabmo's OWN build writes `dist/` and `node_modules/` into
|
|
118
|
+
* the clone, so a perfectly ordinary plugin repo became permanently
|
|
119
|
+
* un-updatable the moment it was installed. Measured on a clone of a fixture
|
|
120
|
+
* repository with no `.gitignore`: `?? dist/` and `?? node_modules/` made Update
|
|
121
|
+
* answer "has uncommitted changes", and commiting nothing there is possible
|
|
122
|
+
* because the files are the install's, not the user's.
|
|
123
|
+
*
|
|
124
|
+
* A status that cannot be read is still treated as dirty: refusing an update is
|
|
125
|
+
* recoverable, discarding a user's edit is not.
|
|
126
|
+
*/
|
|
112
127
|
async function isDirty(dir: string): Promise<boolean> {
|
|
113
|
-
const result = await gitRun(['status', '--porcelain'], {
|
|
114
|
-
|
|
115
|
-
|
|
128
|
+
const result = await gitRun(['status', '--porcelain', '--untracked-files=no'], {
|
|
129
|
+
cwd: dir,
|
|
130
|
+
timeoutMs: PROBE_TIMEOUT_MS,
|
|
131
|
+
});
|
|
116
132
|
return result.exitCode !== 0 || result.stdout.trim().length > 0;
|
|
117
133
|
}
|
|
118
134
|
|
|
@@ -171,7 +171,14 @@ async function applyStoreCopy(
|
|
|
171
171
|
* say why, and it is cleared on the next pass that finds the tree unchanged, so a
|
|
172
172
|
* user who reverts their edit gets the update without doing anything else.
|
|
173
173
|
*/
|
|
174
|
-
export async function syncBundledPlugins(
|
|
174
|
+
export async function syncBundledPlugins(options: {
|
|
175
|
+
/**
|
|
176
|
+
* Only this plugin id. The pane's own Update action is what needs it: the
|
|
177
|
+
* whole-store pass is the BOOT question ("is anything behind?"), while a
|
|
178
|
+
* user naming one plugin must not touch the others.
|
|
179
|
+
*/
|
|
180
|
+
only?: string;
|
|
181
|
+
} = {}): Promise<{
|
|
175
182
|
updated: BundledSyncOutcome[];
|
|
176
183
|
blocked: BundledSyncBlocked[];
|
|
177
184
|
failed: Array<{ pluginId: string; error: string }>;
|
|
@@ -184,6 +191,7 @@ export async function syncBundledPlugins(): Promise<{
|
|
|
184
191
|
const installedRoot = getMarketplacePluginsDir();
|
|
185
192
|
|
|
186
193
|
for (const pluginId of await subdirectories(storeRoot)) {
|
|
194
|
+
if (options.only && pluginId !== options.only) continue;
|
|
187
195
|
const destination = join(installedRoot, pluginId);
|
|
188
196
|
if (!(await pathExists(destination))) continue;
|
|
189
197
|
// A git-installed plugin is the user's own clone; the store's copy is not
|