@linxiraos/pi-wire 1.5.1 → 1.5.11

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/src/tsp.ts CHANGED
@@ -50,6 +50,7 @@ export const TSP_KINDS = [
50
50
  "math",
51
51
  "image",
52
52
  "media",
53
+ "web",
53
54
  "kv",
54
55
  "table",
55
56
  "tree",
@@ -68,6 +69,9 @@ export const TSP_KINDS = [
68
69
  "editor",
69
70
  "input",
70
71
  "button",
72
+ "buttons",
73
+ "menu",
74
+ "doc",
71
75
  "status",
72
76
  "seg",
73
77
  "overlay",
@@ -129,6 +133,23 @@ export type TspText = string | readonly TspSpan[];
129
133
  */
130
134
  export type TspAction = "toggle" | "copy" | "open" | "zoom" | "select" | "activate" | (string & {});
131
135
 
136
+ /**
137
+ * One entry of `actions.menu` or `actions.hold`: an action name (labeled from it), `"-"` a separator, a dim
138
+ * `{ header }`, or a row running action `id`, with its `label`, `icon` and `detail` (the hold menu shows it dim
139
+ * at the row's end).
140
+ */
141
+ export type TspMenuEntry =
142
+ | TspAction
143
+ | { header: string }
144
+ | {
145
+ id: TspAction;
146
+ label?: string;
147
+ icon?: string;
148
+ detail?: string;
149
+ disabled?: boolean | string;
150
+ danger?: boolean;
151
+ };
152
+
132
153
  /** Props every node accepts. */
133
154
  export interface TspCommonProps {
134
155
  role?: string;
@@ -140,7 +161,16 @@ export interface TspCommonProps {
140
161
  basis?: "auto" | "content" | number;
141
162
  min?: { w?: TspExtent; h?: TspExtent };
142
163
  max?: { w?: TspExtent; h?: TspExtent };
143
- actions?: { click?: TspAction; dblclick?: TspAction; menu?: readonly TspAction[] };
164
+ /**
165
+ * What a pointer does: `menu` lists what a right-click offers; `hold` what a long press on a touch screen
166
+ * offers (a phone's hold menu over the lifted node), which a desktop ignores.
167
+ */
168
+ actions?: {
169
+ click?: TspAction;
170
+ dblclick?: TspAction;
171
+ menu?: readonly TspMenuEntry[];
172
+ hold?: readonly TspMenuEntry[];
173
+ };
144
174
  title?: string;
145
175
  /** Accessible name for icon-only or visual-only nodes. */
146
176
  aria?: string;
@@ -224,6 +254,31 @@ export interface TspMarkdownProps {
224
254
  /** Literal runs drawn as these spans wherever they occur in prose (a sent prompt's chip tokens). */
225
255
  marks?: readonly TspSpan[];
226
256
  }
257
+ /** A comment drawn on a {@link TspDocProps} document, anchored to a quote of its source. */
258
+ export interface TspDocComment {
259
+ /** The program's comment id; `comment`/`uncomment` events name it. */
260
+ id: string;
261
+ /** The commented source text. */
262
+ quote: string;
263
+ /** UTF-16 offset of the quote's first char in `text`; the first occurrence of `quote` when it doesn't match there. */
264
+ at?: number;
265
+ note: string;
266
+ }
267
+ /**
268
+ * A rich Markdown document the user reads, selects, edits in place (double-click, `edit`) and comments on
269
+ * (`comment`): edits arrive as `change` events with the full source, comments as `comment`/`uncomment`.
270
+ */
271
+ export interface TspDocProps {
272
+ /** Markdown source in omp's dialect; the document's own current source is a no-op. */
273
+ text?: string;
274
+ /** Double-click enters in-place editing; Esc or a press outside leaves it. */
275
+ edit?: boolean;
276
+ /** A still, non-empty selection offers a Comment bubble. */
277
+ comment?: boolean;
278
+ comments?: readonly TspDocComment[];
279
+ /** Scroll heading number `heading` (0-based, document order, all levels) to the top; each new `n` scrolls again. */
280
+ jump?: { heading: number; n: number };
281
+ }
227
282
  /** One marked line of a {@link TspCodeProps.marks}. */
228
283
  export interface TspCodeMark {
229
284
  line: number;
@@ -339,6 +394,21 @@ export interface TspMediaProps {
339
394
  /** Size cap; the node otherwise fills its container. */
340
395
  max?: { w?: TspExtent; h?: TspExtent };
341
396
  }
397
+ /**
398
+ * A live web page shown inline (an `<iframe>` of a reply): passive until clicked, focused by a
399
+ * click, left with Escape, and replaced by a still of itself once idle. Programs check
400
+ * `cx.supports("web")` first.
401
+ */
402
+ export interface TspWebProps {
403
+ /** The page: an `http(s)` or `file://` URL. */
404
+ url: string;
405
+ /** What the page is, until it reports its own title. */
406
+ title?: string;
407
+ /** Width as a CSS length (`"50%"`, `"400px"`, `"60vw"`, `"80ch"`, `"30em"`); default: the column's. */
408
+ w?: string;
409
+ /** Height as a CSS length; default: a 16:10 box of the width. */
410
+ h?: string;
411
+ }
342
412
  export interface TspKvProps {
343
413
  items: readonly { k: TspText; v: TspText }[];
344
414
  layout?: "grid" | "inline";
@@ -430,6 +500,63 @@ export interface TspItemProps {
430
500
  disabled?: boolean;
431
501
  value?: TspText;
432
502
  }
503
+ /**
504
+ * One row of a {@link TspMenuProps} menu: `"-"` a separator, `{ header }` a dim section title, an action id
505
+ * (labeled from it), or an item sending its `id` as an `action` event's `act`.
506
+ */
507
+ export type TspMenuItem =
508
+ | string
509
+ | { header: string }
510
+ | {
511
+ id: string;
512
+ label?: string;
513
+ icon?: string;
514
+ /** Shortcut keys drawn at the row's right (display only). */
515
+ keys?: string | readonly string[];
516
+ /** A second line under the label (a rich row). */
517
+ detail?: string;
518
+ /** A check row, checked while true. */
519
+ checked?: boolean;
520
+ /** A radio row of this group. */
521
+ radio?: string;
522
+ /** Dimmed, not choosable; a string is the reason. */
523
+ disabled?: boolean | string;
524
+ danger?: boolean;
525
+ /** A submenu; the row itself sends nothing. */
526
+ items?: readonly TspMenuItem[];
527
+ };
528
+ /**
529
+ * A button opening a dropdown of commands. Choosing a row sends `action` (`act` = the row's id, `checked` for
530
+ * check/radio rows); opening or closing it sends `toggle` with `open`. As the last child of a split
531
+ * {@link TspButtonsProps} group it draws as the split's menu part. Pointer-only: it never takes focus.
532
+ */
533
+ export interface TspMenuProps {
534
+ items?: readonly TspMenuItem[];
535
+ /** The trigger's label; without `text` and `icon` the trigger is a square … button. */
536
+ text?: string;
537
+ icon?: string;
538
+ trigger?: "default" | "quiet" | "primary";
539
+ /** A chevron after the label. */
540
+ caret?: boolean;
541
+ size?: "sm" | "md";
542
+ variant?: "default" | "dense";
543
+ /** Whether the menu shows; a change wins over the user's local open/close. */
544
+ open?: boolean;
545
+ /** The highlighted row's id (the program's keyboard cursor). */
546
+ active?: string;
547
+ /** Which trigger edge the menu lines up with. */
548
+ align?: "start" | "end";
549
+ /** The trigger is dimmed and does not open; a string is the reason. */
550
+ disabled?: boolean | string;
551
+ }
552
+ /** `button` children drawn as one control: joined, an action with its menu part (`split`), or a toolbar well. */
553
+ export interface TspButtonsProps {
554
+ variant?: "joined" | "split" | "toolbar";
555
+ /** The children's size, winning over their own. */
556
+ size?: "sm" | "md";
557
+ /** Accessible name of the group. */
558
+ label?: string;
559
+ }
433
560
  export interface TspTabsProps {
434
561
  items: readonly { id: string; label: TspText }[];
435
562
  active?: string;
@@ -462,6 +589,8 @@ export interface TspEditorDecoration {
462
589
  to: number;
463
590
  s: string;
464
591
  fx?: TspEffect;
592
+ /** An image blob the range stands for (an attachment token): copying the range copies the image. */
593
+ blob?: string;
465
594
  }
466
595
  export interface TspEditorProps {
467
596
  text?: string;
@@ -517,6 +646,10 @@ export interface TspToastProps {
517
646
  text: string;
518
647
  sub?: string;
519
648
  ttl?: number;
649
+ /** A button after the text (Undo): clicking it takes the toast down and sends this action for the node. */
650
+ action?: TspAction;
651
+ /** The button's text; defaults to the action's name labeled (`undo` → Undo). */
652
+ label?: string;
520
653
  }
521
654
  export interface TspRowsProps {
522
655
  /** Width the rows were rendered at. */
@@ -608,6 +741,28 @@ export interface TspPickerAction {
608
741
  end?: boolean;
609
742
  /** A toggle's state (`Task model ⌥P`): drawn pressed when true. */
610
743
  on?: boolean;
744
+ /** Drawn in the head as an icon-only button before its esc keycap (`icon`, else the label's initial), its label and keys as tooltip; `on` tints it. */
745
+ head?: boolean;
746
+ /** A head action's icon name. */
747
+ icon?: string;
748
+ disabled?: string | true;
749
+ }
750
+
751
+ /** A picker's stepped slider. */
752
+ export interface TspPickerLevel {
753
+ /** What it sets ("Thinking"): shown, or with `icon` its tooltip and accessible name. */
754
+ label: string;
755
+ /** An icon drawn in place of the label. */
756
+ icon?: string;
757
+ /** A dim note after the value in its chip (the model switcher: the highlighted model's provider). */
758
+ detail?: string;
759
+ /** Its steps, low to high: the terminal heats the track up the ladder (color, then motion). */
760
+ steps: readonly { id: string; label: string }[];
761
+ /** The current step's id. */
762
+ value: string;
763
+ /** The keys the program binds to step it, shown in its tooltip (`["alt", "left", "right"]`). */
764
+ keys?: readonly string[];
765
+ /** Drawn but frozen, the reason as its tooltip. */
611
766
  disabled?: string | true;
612
767
  }
613
768
 
@@ -633,6 +788,19 @@ export interface TspPickerProps {
633
788
  /** Plural noun for counts and empty copy ("models", "sessions"). */
634
789
  noun?: string;
635
790
  size?: "md" | "lg" | "screen";
791
+ /**
792
+ * Where the sheet sits: absent, its size's place in the layer; `"composer"`, rising from the program's composer
793
+ * (its `composerPart: "composer"` column), left edges aligned — a drop-up for a picker acting on the draft, such as
794
+ * the model switcher. Placed as if absent while no composer is drawn, and on a phone.
795
+ */
796
+ anchor?: "composer";
797
+ /**
798
+ * Where the search sits: the head (default), or `"list"`: no head row, the query leading the column heads' row
799
+ * (count and esc gone), head actions atop a `rail`. Ignored on a phone.
800
+ */
801
+ search?: "head" | "list";
802
+ /** How tall rows run: regular (default), or `"snug"`: 30px rows and 26px group headers, the chrome tightened to match. Ignored on a phone. */
803
+ density?: "regular" | "snug";
636
804
  layout?: "rows" | "cards" | "timeline" | "tree";
637
805
  /** The program's search text (keys stay the program's); `null` hides the field. */
638
806
  query?: string | null;
@@ -641,6 +809,8 @@ export interface TspPickerProps {
641
809
  placeholder?: string;
642
810
  scopes?: readonly TspPickerScope[];
643
811
  scope?: string;
812
+ /** How `scopes` draw: a labeled column (default), or `"rail"`: icons only, label and count as the tooltip, kept on narrow sheets. A `group` change draws a separator. */
813
+ scopeStyle?: "column" | "rail";
644
814
  tabs?: readonly { id: string; label: TspText; count?: number }[];
645
815
  tab?: string;
646
816
  columns?: readonly TspPickerColumn[];
@@ -667,6 +837,8 @@ export interface TspPickerProps {
667
837
  items: readonly { id: string; label: TspText; on?: boolean; dot?: string }[];
668
838
  selected?: string;
669
839
  } | null;
840
+ /** A stepped slider docked above the action bar (the model switcher's thinking effort). A press or drag ending on another step sends `action {act:"level", value: <step id>}`. */
841
+ level?: TspPickerLevel | null;
670
842
  state?: "ready" | "loading" | "error";
671
843
  message?: TspText;
672
844
  empty?: TspText;
@@ -947,12 +1119,15 @@ export interface TspShellProps {
947
1119
  replayEpoch?: number;
948
1120
  /** This mounted call received a real execution-start event, not a settled historical load. */
949
1121
  liveOrigin?: boolean;
1122
+ /** The command text is still streaming in: the host marks its write head and the preview follows it. */
1123
+ stream?: boolean;
950
1124
  /** Working directory shown ahead of the script when it differs from the project's. */
951
1125
  cwd?: string;
952
1126
  lang?: "bash" | "zsh";
953
1127
  /**
954
- * Clamp the command to its first `lines` drawn lines under a "N more lines" button; gives way inside an open
955
- * disclosure, and never applies in the inspector. The Raw/Pseudo switch and menu stay on the first line.
1128
+ * Clamp the command to `lines` drawn lines under an Expand button, the window following the write head
1129
+ * (`stream`), then the playhead, with the enclosing scope heads pinned; gives way inside an open
1130
+ * disclosure, and never applies in the inspector. The Raw/Pseudo switch and menu stay on the first visible line.
956
1131
  */
957
1132
  preview?: { lines: number };
958
1133
  }
@@ -973,6 +1148,7 @@ export interface TspPropsByKind {
973
1148
  math: TspMathProps;
974
1149
  image: TspImageProps;
975
1150
  media: TspMediaProps;
1151
+ web: TspWebProps;
976
1152
  kv: TspKvProps;
977
1153
  table: TspTableProps;
978
1154
  tree: TspTreeProps;
@@ -991,6 +1167,9 @@ export interface TspPropsByKind {
991
1167
  editor: TspEditorProps;
992
1168
  input: TspInputProps;
993
1169
  button: TspButtonProps;
1170
+ buttons: TspButtonsProps;
1171
+ menu: TspMenuProps;
1172
+ doc: TspDocProps;
994
1173
  status: TspStatusProps;
995
1174
  seg: TspSegProps;
996
1175
  overlay: TspOverlayProps;
@@ -1025,7 +1204,7 @@ export type TspPropNode = {
1025
1204
  }[TspKind];
1026
1205
 
1027
1206
  /** Kinds whose primary text the `text` and `splice` ops address (the `text` prop). */
1028
- export const TSP_TEXT_KINDS = ["text", "md", "code", "ansi", "math", "editor", "input", "shimmer"] as const;
1207
+ export const TSP_TEXT_KINDS = ["text", "md", "code", "ansi", "math", "editor", "input", "shimmer", "doc"] as const;
1029
1208
 
1030
1209
  /** A node on the wire. */
1031
1210
  export type TspNode = {
@@ -1120,7 +1299,16 @@ export type TspEvent =
1120
1299
  | { ev: "toggle"; sf: string; id: string; key?: string; collapsed: boolean }
1121
1300
  | { ev: "select"; sf: string; id: string; item: string }
1122
1301
  | { ev: "activate"; sf: string; id: string; item: string }
1123
- | { ev: "action"; sf: string; id: string; act: string; value?: string; mods?: readonly string[] }
1302
+ /** A click action; a `menu` check or radio row adds its new `checked` state. */
1303
+ | {
1304
+ ev: "action";
1305
+ sf: string;
1306
+ id: string;
1307
+ act: string;
1308
+ value?: string;
1309
+ mods?: readonly string[];
1310
+ checked?: boolean;
1311
+ }
1124
1312
  /** A typed value changed by pointer (prefs rows, picker toggles); `null` resets to the default. */
1125
1313
  | {
1126
1314
  ev: "change";
@@ -1129,6 +1317,18 @@ export type TspEvent =
1129
1317
  item: string;
1130
1318
  value: boolean | number | string | readonly string[] | null;
1131
1319
  }
1320
+ /** The user edited a `doc` (~300 ms after typing pauses, and when editing ends): `text` is its full new source. */
1321
+ | { ev: "change"; sf: string; id: string; text: string }
1322
+ /**
1323
+ * A comment on a `doc`: a new one on `quote` (`at` its UTF-16 offset in the source the user saw), or the
1324
+ * edited `note` of existing comment `comment`.
1325
+ */
1326
+ | { ev: "comment"; sf: string; id: string; quote: string; at: number; note: string }
1327
+ | { ev: "comment"; sf: string; id: string; comment: string; note: string }
1328
+ /** Comment `comment` of a `doc` deleted. */
1329
+ | { ev: "uncomment"; sf: string; id: string; comment: string }
1330
+ /** In-place editing of a `doc` started (`on`) or ended. */
1331
+ | { ev: "editing"; sf: string; id: string; on: boolean }
1132
1332
  /**
1133
1333
  * An edit over the terminal's selection in an `editor`/`input` node: replace
1134
1334
  * `[from, to)` with `text`, caret to `cursor` (UTF-16 offsets; `len` is the