@kabmo-labs/kabmo 0.29.0 → 0.30.1

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.
@@ -144,6 +144,92 @@ print(json.dumps({ "codepoints": len(cmap), "uncovered": uncovered, "missing": [
144
144
  expect(file.size).toBeGreaterThan(100_000);
145
145
  });
146
146
 
147
+ /**
148
+ * The powerline separators must fill the terminal's CELL BOX, not one em.
149
+ *
150
+ * Upstream draws them one em tall, but the cell is 15 px at a 12 px font
151
+ * (the text face's ink plus the block padding in `terminal-panel/fonts.ts`),
152
+ * so a separator ended 1.5 px above and below the coloured run it terminates:
153
+ * the rounded end of a prompt segment read as a small semicircle floating
154
+ * inside a taller rectangle. A machine with a real Nerd Font never saw it —
155
+ * that face draws to its own ~1.2 em line box — so the defect only appeared
156
+ * on a phone, where the bundled face is the one that renders.
157
+ *
158
+ * The box is stated here rather than imported: `measureTerminalCell` needs a
159
+ * canvas, and this test runs in Bun. The numbers are the ones that function
160
+ * produces for 12 px Fira Code, and `scripts/nerd-symbols-font.mjs` maps the
161
+ * glyphs onto the same box.
162
+ */
163
+ test('the powerline separators fill the terminal cell box', () => {
164
+ const available = Bun.spawnSync({
165
+ cmd: ['python3', '-c', 'import fontTools, brotli'],
166
+ timeout: 5_000,
167
+ });
168
+ if (available.exitCode !== 0) {
169
+ console.warn('skipping powerline cell-box check: python3 fonttools/brotli unavailable');
170
+ return;
171
+ }
172
+
173
+ const probe = Bun.spawnSync([
174
+ 'python3',
175
+ '-c',
176
+ `
177
+ import json
178
+ from fontTools.ttLib import TTFont
179
+ from fontTools.pens.boundsPen import BoundsPen
180
+
181
+ font = TTFont(${JSON.stringify(WOFF2)})
182
+ upm = font['head'].unitsPerEm
183
+ units_per_px = upm / 12.0
184
+ top = 11 * units_per_px
185
+ bottom = (11 - 15) * units_per_px
186
+ cell_width = 8 * units_per_px
187
+ glyf = font['glyf']
188
+ cmap = font.getBestCmap()
189
+ bounds = {}
190
+ for cp in range(0xE0B0, 0xE0B8):
191
+ name = cmap.get(cp)
192
+ if name is None:
193
+ continue
194
+ pen = BoundsPen(None)
195
+ glyf[name].draw(pen, glyf)
196
+ bounds[hex(cp)] = pen.bounds
197
+ print(json.dumps({ 'top': top, 'bottom': bottom, 'cellWidth': cell_width, 'upm': upm, 'bounds': bounds }))
198
+ `,
199
+ ]);
200
+
201
+ expect(probe.stderr.toString()).toBe('');
202
+ const result = JSON.parse(probe.stdout.toString()) as {
203
+ top: number;
204
+ bottom: number;
205
+ cellWidth: number;
206
+ upm: number;
207
+ bounds: Record<string, [number, number, number, number]>;
208
+ };
209
+ // Every separator is present, and each one's ink spans the cell box.
210
+ expect(Object.keys(result.bounds).length).toBe(8);
211
+ const em = result.upm;
212
+ for (const [codepoint, bounds] of Object.entries(result.bounds)) {
213
+ expect({ codepoint, bottom: Math.round(bounds[1]) }).toEqual({
214
+ codepoint,
215
+ bottom: Math.round(result.bottom),
216
+ });
217
+ expect({ codepoint, top: Math.round(bounds[3]) }).toEqual({
218
+ codepoint,
219
+ top: Math.round(result.top),
220
+ });
221
+ // Horizontal: the ink must sit AT the cell's left edge, not 0.4 em into
222
+ // it. A right-aligned glyph left at its design position was clipped to a
223
+ // sliver on a phone — the front cap of the prompt line.
224
+ expect({ codepoint, left: bounds[0] < 0.15 * em }).toEqual({ codepoint, left: true });
225
+ expect({ codepoint, right: bounds[2] > 0.5 * em }).toEqual({ codepoint, right: true });
226
+ expect({ codepoint, right: bounds[2] < result.cellWidth + 0.15 * em }).toEqual({
227
+ codepoint,
228
+ right: true,
229
+ });
230
+ }
231
+ }, 20_000);
232
+
147
233
  /**
148
234
  * The UI stack is the SECOND consumer of this face, and it was missing one.
149
235
  * omp heads a session title with a card icon — a PUA glyph
@@ -54,19 +54,20 @@ export const ICON_HUES: Readonly<Record<string, number>> = {
54
54
  Maximize2: 270, Menu: 100, MessageSquare: 150, MessageSquareOff: 40, MessageSquarePlus: 350, MessagesSquare: 220,
55
55
  Mic: 160, MicOff: 170, Minimize: 290, Minimize2: 130, Minus: 110, Monitor: 250,
56
56
  Moon: 80, MoreHorizontal: 160, MousePointerClick: 70, MoveVertical: 300, Music: 280, Package: 270,
57
- Paintbrush: 250, Palette: 320, PanelLeft: 280, PanelLeftClose: 160, PanelRight: 330, PanelRightClose: 350,
58
- Paperclip: 310, Pause: 10, Pencil: 0, PencilLine: 260, Pin: 0, PinOff: 50,
59
- Pipette: 120, Play: 310, Plug: 50, Plus: 210, Power: 340, Puzzle: 50,
60
- Quote: 110, Radio: 320, Ratio: 160, RefreshCw: 180, Regex: 280, Replace: 190,
61
- ReplaceAll: 140, Rocket: 210, RotateCcw: 330, RotateCw: 0, Rows: 160, Rows3: 250,
62
- Save: 40, SaveAll: 190, Scissors: 260, Search: 250, Send: 110, Server: 300,
63
- ServerCog: 50, Settings: 240, Settings2: 20, Shield: 160, Shrink: 160, Sliders: 290,
64
- SlidersHorizontal: 50, Smartphone: 20, Space: 290, Sparkles: 180, Square: 60, SquareFunction: 220,
65
- SquarePen: 10, Star: 170, StickyNote: 100, Store: 340, Sun: 90, Tablet: 290,
66
- Tag: 310, Target: 200, Terminal: 210, TextSelect: 220, Ticket: 170, TriangleAlert: 210,
67
- Type: 170, Undo2: 310, Upload: 0, UploadCloud: 50, User: 140, Variable: 330,
68
- Volume2: 270, VolumeX: 50, Wand2: 270, WandSparkles: 40, Waypoints: 30, WholeWord: 240,
69
- WrapText: 340, Wrench: 0, X: 230, Zap: 120, ZoomIn: 250, ZoomOut: 340,
57
+ PackageOpen: 230, Paintbrush: 250, Palette: 320, PanelLeft: 280, PanelLeftClose: 160, PanelRight: 330,
58
+ PanelRightClose: 350, Paperclip: 310, Pause: 10, Pencil: 0, PencilLine: 260, Pin: 0,
59
+ PinOff: 50, Pipette: 120, Play: 310, Plug: 50, Plus: 210, Power: 340,
60
+ Puzzle: 50, Quote: 110, Radio: 320, Ratio: 160, RefreshCw: 180, Regex: 280,
61
+ Replace: 190, ReplaceAll: 140, Rocket: 210, RotateCcw: 330, RotateCw: 0, Rows: 160,
62
+ Rows3: 250, Save: 40, SaveAll: 190, Scissors: 260, Search: 250, Send: 110,
63
+ Server: 300, ServerCog: 50, Settings: 240, Settings2: 20, Shield: 160, Shrink: 160,
64
+ Sliders: 290, SlidersHorizontal: 50, Smartphone: 20, Space: 290, Sparkles: 180, Square: 60,
65
+ SquareFunction: 220, SquarePen: 10, Star: 170, StickyNote: 100, Store: 340, Sun: 90,
66
+ Tablet: 290, Tag: 310, Target: 200, Terminal: 210, TextSelect: 220, Ticket: 170,
67
+ TriangleAlert: 210, Type: 170, Undo2: 310, Upload: 0, UploadCloud: 50, User: 140,
68
+ Variable: 330, Volume2: 270, VolumeX: 50, Wand2: 270, WandSparkles: 40, Waypoints: 30,
69
+ WholeWord: 240, WrapText: 340, Wrench: 0, X: 230, Zap: 120, ZoomIn: 250,
70
+ ZoomOut: 340,
70
71
  };
71
72
 
72
73
  /**
@@ -21,6 +21,7 @@ import type { h as PreactH, render as PreactRender } from 'preact';
21
21
  import type { act as PreactAct } from 'preact/test-utils';
22
22
  import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
23
23
  import type {
24
+ FileEditorTarget,
24
25
  UseFileEditorOptions,
25
26
  UseFileEditorResult,
26
27
  useFileEditor as UseFileEditorHook,
@@ -143,7 +144,7 @@ export interface EditorHarness {
143
144
  /** Latest render's result — re-read after every settle, never held across one. */
144
145
  readonly mounted: UseFileEditorResult | null;
145
146
  settle(): Promise<void>;
146
- mount(target?: typeof TARGET, options?: UseFileEditorOptions): Promise<void>;
147
+ mount(target?: FileEditorTarget, options?: UseFileEditorOptions): Promise<void>;
147
148
  /** Run a state update inside Preact's `act`, then settle. */
148
149
  run(update: () => void): Promise<void>;
149
150
  /**
@@ -177,7 +178,7 @@ export function createEditorHarness(): EditorHarness {
177
178
  });
178
179
  }
179
180
 
180
- async function mount(target: typeof TARGET = TARGET, options: UseFileEditorOptions = {}) {
181
+ async function mount(target: FileEditorTarget = TARGET, options: UseFileEditorOptions = {}) {
181
182
  const Probe = () => {
182
183
  mounted = useFileEditor(target, options);
183
184
  return null;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Reading the client's own CSS in a test.
8
+ *
9
+ * The glass contract is asserted against the stylesheets themselves — a token
10
+ * declared in the wrong block is invisible to `getComputedStyle` in a way no
11
+ * component test can see — so more than one spec needs to read a file and pull
12
+ * one rule's body out of it. Both helpers live here rather than in each spec:
13
+ * a second copy of `ruleBody`'s selector escaping is how one spec starts
14
+ * matching a rule the other does not.
15
+ */
16
+
17
+ const CLIENT_DIR = new URL('../client/', import.meta.url);
18
+
19
+ /** The text of a stylesheet under `src/client/`, e.g. `readClientCss('glass.css')`. */
20
+ export const readClientCss = (file: string): Promise<string> => Bun.file(new URL(file, CLIENT_DIR)).text();
21
+
22
+ /** The body of the first rule whose selector starts a line, e.g. `[x] {`. */
23
+ export function ruleBody(css: string, selector: string): string {
24
+ const start = css.search(new RegExp(`^${selector.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')} \\{`, 'm'));
25
+ if (start < 0) throw new Error(`no rule for ${selector}`);
26
+ const open = css.indexOf('{', start);
27
+ const close = css.indexOf('\n}', open);
28
+ if (close < 0) throw new Error(`unterminated rule for ${selector}`);
29
+ return css.slice(open + 1, close);
30
+ }