@kitlangton/knobs 0.4.0-next.5 → 0.4.0-next.7

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.
@@ -1,7 +1,6 @@
1
1
  import { type ContextEvent, type WalkChapter, type WalkMedia } from "./walkthrough-model.js";
2
2
  /** The glyphs the blocks draw. */
3
3
  export declare const GLYPH: {
4
- go: string;
5
4
  caret: string;
6
5
  };
7
6
  /** How media reach the page's steps: `step` on a history event, a stack item or a table cell. */
@@ -22,14 +21,18 @@ export interface Block {
22
21
  kind: string;
23
22
  };
24
23
  }
25
- /** A small arrow that goes to the step a ref names; null when it names none. */
26
- export declare function stepButton(doc: Document, ref: string | undefined, steps: StepLinks | undefined): HTMLButtonElement | null;
24
+ /**
25
+ * Makes a whole row go to the step a ref names (a click away from its links, Enter or Space when
26
+ * it has focus); nothing trails it, so rows with and without a step line up.
27
+ */
28
+ export declare function rowLink(row: HTMLElement, ref: string | undefined, steps: StepLinks | undefined): void;
29
+ /** A history through `history()`: lanes of spans over a date axis, or the older groups of events. */
27
30
  export declare function mountHistory(host: HTMLElement, m: Extract<WalkMedia, {
28
31
  kind: "history";
29
32
  }>, steps: StepLinks | undefined): Block;
30
33
  export declare function mountStack(host: HTMLElement, m: Extract<WalkMedia, {
31
34
  kind: "stack";
32
- }>, steps: StepLinks | undefined): Block;
35
+ }>, steps: StepLinks | undefined, findPR?: (n: string) => PRInfo | null): Block;
33
36
  export declare function mountTable(host: HTMLElement, m: Extract<WalkMedia, {
34
37
  kind: "table";
35
38
  }>, steps: StepLinks | undefined): Block;
@@ -55,7 +58,6 @@ export interface Disclosure {
55
58
  }
56
59
  export declare function disclosure(host: HTMLElement, options: {
57
60
  label: string;
58
- count?: number;
59
61
  open?: boolean;
60
62
  content: HTMLElement;
61
63
  }): Disclosure;
@@ -65,8 +67,20 @@ declare const PR_STATE: {
65
67
  readonly draft: "Draft";
66
68
  readonly closed: "Closed";
67
69
  };
70
+ export type PRState = keyof typeof PR_STATE;
71
+ /**
72
+ * A stack row's pull-request state from its `status` words: the first word when it's merged,
73
+ * draft, open or closed (any case), and whether they say its checks pass ("green", "passing",
74
+ * "CI"). The state comes from the words, never the tone.
75
+ */
76
+ export declare function prStatus(status: string | undefined): {
77
+ state: PRState | null;
78
+ checks: boolean;
79
+ };
80
+ /** A pull request's state as GitHub shows it: its glyph and word, quietly tinted; a check after. */
81
+ export declare function prStateLabel(doc: Document, state: PRState, checks: boolean, title?: string): HTMLSpanElement;
68
82
  export interface PRInfo {
69
- readonly state?: keyof typeof PR_STATE;
83
+ readonly state?: PRState;
70
84
  readonly title?: string;
71
85
  readonly href?: string;
72
86
  }
@@ -1,5 +1,5 @@
1
1
  import { type UiLook } from "./look.js";
2
- import { type StepLinks } from "./walkthrough-blocks.js";
2
+ import { type PRInfo, type StepLinks } from "./walkthrough-blocks.js";
3
3
  import { type ContextEvent, type MediaContext, type WalkthroughMedia } from "./walkthrough-model.js";
4
4
  export interface MediaSlotOptions extends UiLook {
5
5
  readonly media: WalkthroughMedia;
@@ -9,6 +9,8 @@ export interface MediaSlotOptions extends UiLook {
9
9
  readonly onEvent?: (event: Omit<ContextEvent, "at" | "step">) => void;
10
10
  /** The page's steps, for `step` on a history event, a stack item or a table cell. */
11
11
  readonly steps?: StepLinks;
12
+ /** What the page knows of a pull request by its number (a stack row's state and link). */
13
+ readonly findPR?: (n: string) => PRInfo | null;
12
14
  }
13
15
  export type { StepLinks };
14
16
  export interface MediaSlot {
@@ -1,5 +1,6 @@
1
1
  import type { CompareMode } from "./compare-model.js";
2
2
  import type { DiffSource } from "./diff-model.js";
3
+ import type { HistoryData, HistoryEvent } from "./history-model.js";
3
4
  /** Where a PR or topic stands, as the agent sees it: a chip beside its title. */
4
5
  export type WalkthroughStatus = "ready" | "needs-taste" | "draft" | "blocked" | "merged" | (string & {});
5
6
  /** A picture or video, by URL. */
@@ -89,6 +90,22 @@ export interface WalkthroughTableColumn {
89
90
  export type WalkthroughTableRow = Readonly<Record<string, WalkthroughTableCell>> | {
90
91
  readonly cells: Readonly<Record<string, WalkthroughTableCell>>;
91
92
  };
93
+ /**
94
+ * A mark on a picture drawing the eye to what matters: a ring round a box, a dot or an arrow at a
95
+ * point, with a small label. In 0–1 of the picture (`x`, `y` the box's top-left or the point).
96
+ */
97
+ export interface WalkthroughAnnotation {
98
+ readonly x: number;
99
+ readonly y: number;
100
+ /** A box's size; left out, it's a point. */
101
+ readonly w?: number;
102
+ readonly h?: number;
103
+ readonly label?: string;
104
+ /** Seconds it shows between, on a video or compare; always, left out. */
105
+ readonly at?: readonly [number, number];
106
+ /** `"box"` where it has a size, else `"dot"`. */
107
+ readonly shape?: "box" | "dot" | "arrow";
108
+ }
92
109
  /** A stretch of a video: a pill under it, and a marker on its timeline. */
93
110
  export interface WalkthroughChapter {
94
111
  readonly id?: string;
@@ -115,6 +132,8 @@ export type WalkthroughMedia = string | {
115
132
  readonly strip?: boolean;
116
133
  /** Pills under it that seek, and markers on its timeline. */
117
134
  readonly chapters?: readonly WalkthroughChapter[];
135
+ /** Marks on the pictures, on both sides (and under a zoom). */
136
+ readonly annotations?: readonly WalkthroughAnnotation[];
118
137
  } | {
119
138
  readonly kind: "video";
120
139
  readonly src: string;
@@ -127,12 +146,23 @@ export type WalkthroughMedia = string | {
127
146
  readonly captions?: string;
128
147
  /** Another name for `captions`. */
129
148
  readonly captionsSrc?: string;
149
+ /** Marks on the picture. */
150
+ readonly annotations?: readonly WalkthroughAnnotation[];
130
151
  } | {
131
152
  readonly kind: "history";
132
- /** Dated events under quiet headings… */
153
+ /** Lanes of dated spans over one axis (`history()`'s shape)… */
154
+ readonly lanes?: HistoryData["lanes"];
155
+ readonly bands?: HistoryData["bands"];
156
+ readonly states?: HistoryData["states"];
157
+ readonly axis?: HistoryData["axis"];
158
+ /** …dated events (on the lanes, or one run of them in the older shape)… */
159
+ readonly events?: readonly (WalkthroughHistoryEvent | HistoryEvent)[];
160
+ /** …or the older groups of events under quiet headings. */
133
161
  readonly groups?: readonly WalkthroughHistoryGroup[];
134
- /** …or one run of them. */
135
- readonly events?: readonly WalkthroughHistoryEvent[];
162
+ /** Its accessible name. */
163
+ readonly label?: string;
164
+ /** The event types marked from the start (releases and deletions), or `"all"`. */
165
+ readonly marks?: readonly string[] | "all";
136
166
  } | {
137
167
  readonly kind: "stack";
138
168
  /** The branch the stack lands on ("dev"); else the one most items merge into. */
@@ -157,6 +187,8 @@ export type WalkthroughMedia = string | {
157
187
  readonly src: string;
158
188
  readonly label?: string;
159
189
  readonly alt?: string;
190
+ /** Marks on the picture. */
191
+ readonly annotations?: readonly WalkthroughAnnotation[];
160
192
  } | {
161
193
  readonly kind: "diff";
162
194
  /** `git diff` / `git show` output. */
@@ -245,6 +277,7 @@ export interface WalkthroughSection {
245
277
  * `link` is a pull request, or the doc's `kickers` noun), your own words, or `false` for none.
246
278
  */
247
279
  readonly kicker?: string | false;
280
+ /** A chip on its meta line ("needs-taste" → Needs taste), with `review: true` only. */
248
281
  readonly status?: WalkthroughStatus;
249
282
  readonly summary?: string;
250
283
  /** The rest, folded away under the summary behind "More" (Markdown). */
@@ -336,11 +369,6 @@ export interface WalkChapter {
336
369
  readonly start: number;
337
370
  readonly end?: number;
338
371
  }
339
- export interface WalkHistoryGroup {
340
- readonly heading?: string;
341
- readonly summary?: string;
342
- readonly events: readonly WalkthroughHistoryEvent[];
343
- }
344
372
  /** A stack's item filled in: its PR as `#123`, its branch split, `step` for `stepId`. */
345
373
  export interface WalkStackItem {
346
374
  readonly pr: string;
@@ -387,7 +415,9 @@ export type WalkMedia = Exclude<WalkthroughMedia, string | {
387
415
  readonly chapters?: readonly WalkChapter[];
388
416
  }) | {
389
417
  readonly kind: "history";
390
- readonly groups: readonly WalkHistoryGroup[];
418
+ readonly data: HistoryData;
419
+ readonly label?: string;
420
+ readonly marks?: readonly string[] | "all";
391
421
  } | {
392
422
  readonly kind: "stack";
393
423
  readonly base?: string;
@@ -486,6 +516,13 @@ export declare const mediaOf: (src: string) => WalkMedia;
486
516
  export declare function parseAspect(aspect: number | string | undefined): number | undefined;
487
517
  /** Media filled in: a bare URL as a video or image, sources resolved against `base`. */
488
518
  export declare function fillMedia(m: WalkthroughMedia, base?: string): WalkMedia;
519
+ /**
520
+ * What `history()` draws: the lanes shape as written, or the older groups (`rows` read as
521
+ * `events`, bare `events` as one group first) for it to lay on the code lane.
522
+ */
523
+ export declare function historyData(m: Extract<WalkthroughMedia, {
524
+ kind: "history";
525
+ }>): HistoryData;
489
526
  /** `"head → base"` (or `->`, `=>`, `⇒`) as its two branches; one name is the head alone. */
490
527
  export declare function parseBranch(branch: string | undefined): {
491
528
  head?: string;