@herbertgao/pi-extensions 2026.9.7 → 2026.9.9

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.
Files changed (158) hide show
  1. package/README.md +8 -4
  2. package/THIRD_PARTY_NOTICES.md +52 -0
  3. package/node_modules/@herbertgao/pi-bark/package.json +2 -2
  4. package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +1 -1
  5. package/node_modules/@herbertgao/pi-cc-extensions/README.md +1 -1
  6. package/node_modules/@herbertgao/pi-cc-extensions/package.json +4 -4
  7. package/node_modules/@herbertgao/resume-from/package.json +2 -2
  8. package/node_modules/@narumitw/pi-btw/README.md +6 -1
  9. package/node_modules/@narumitw/pi-btw/dist/index.ts +209 -23
  10. package/node_modules/@narumitw/pi-btw/dist/index.ts.map +4 -4
  11. package/node_modules/@narumitw/pi-btw/package.json +1 -1
  12. package/node_modules/@narumitw/pi-btw/src/btw.ts +1 -12
  13. package/node_modules/@narumitw/pi-btw/src/menu.ts +244 -15
  14. package/node_modules/@narumitw/pi-btw/src/settings.ts +5 -0
  15. package/node_modules/grok-mermaid/CHANGELOG.md +46 -0
  16. package/node_modules/grok-mermaid/LICENSE +205 -0
  17. package/node_modules/grok-mermaid/README.md +191 -0
  18. package/node_modules/grok-mermaid/dist/ansi.d.ts +16 -0
  19. package/node_modules/grok-mermaid/dist/ansi.d.ts.map +1 -0
  20. package/node_modules/grok-mermaid/dist/ansi.js +23 -0
  21. package/node_modules/grok-mermaid/dist/ansi.js.map +1 -0
  22. package/node_modules/grok-mermaid/dist/canvas.d.ts +87 -0
  23. package/node_modules/grok-mermaid/dist/canvas.d.ts.map +1 -0
  24. package/node_modules/grok-mermaid/dist/canvas.js +366 -0
  25. package/node_modules/grok-mermaid/dist/canvas.js.map +1 -0
  26. package/node_modules/grok-mermaid/dist/graph.d.ts +74 -0
  27. package/node_modules/grok-mermaid/dist/graph.d.ts.map +1 -0
  28. package/node_modules/grok-mermaid/dist/graph.js +91 -0
  29. package/node_modules/grok-mermaid/dist/graph.js.map +1 -0
  30. package/node_modules/grok-mermaid/dist/index.d.ts +32 -0
  31. package/node_modules/grok-mermaid/dist/index.d.ts.map +1 -0
  32. package/node_modules/grok-mermaid/dist/index.js +100 -0
  33. package/node_modules/grok-mermaid/dist/index.js.map +1 -0
  34. package/node_modules/grok-mermaid/dist/labels.d.ts +62 -0
  35. package/node_modules/grok-mermaid/dist/labels.d.ts.map +1 -0
  36. package/node_modules/grok-mermaid/dist/labels.js +324 -0
  37. package/node_modules/grok-mermaid/dist/labels.js.map +1 -0
  38. package/node_modules/grok-mermaid/dist/layout-seq.d.ts +12 -0
  39. package/node_modules/grok-mermaid/dist/layout-seq.d.ts.map +1 -0
  40. package/node_modules/grok-mermaid/dist/layout-seq.js +194 -0
  41. package/node_modules/grok-mermaid/dist/layout-seq.js.map +1 -0
  42. package/node_modules/grok-mermaid/dist/layout.d.ts +87 -0
  43. package/node_modules/grok-mermaid/dist/layout.d.ts.map +1 -0
  44. package/node_modules/grok-mermaid/dist/layout.js +881 -0
  45. package/node_modules/grok-mermaid/dist/layout.js.map +1 -0
  46. package/node_modules/grok-mermaid/dist/parse.d.ts +83 -0
  47. package/node_modules/grok-mermaid/dist/parse.d.ts.map +1 -0
  48. package/node_modules/grok-mermaid/dist/parse.js +1151 -0
  49. package/node_modules/grok-mermaid/dist/parse.js.map +1 -0
  50. package/node_modules/grok-mermaid/dist/source-box.d.ts +18 -0
  51. package/node_modules/grok-mermaid/dist/source-box.d.ts.map +1 -0
  52. package/node_modules/grok-mermaid/dist/source-box.js +78 -0
  53. package/node_modules/grok-mermaid/dist/source-box.js.map +1 -0
  54. package/node_modules/grok-mermaid/dist/types.d.ts +42 -0
  55. package/node_modules/grok-mermaid/dist/types.d.ts.map +1 -0
  56. package/node_modules/grok-mermaid/dist/types.js +1 -0
  57. package/node_modules/grok-mermaid/dist/types.js.map +1 -0
  58. package/node_modules/grok-mermaid/dist/width-data.d.ts +2 -0
  59. package/node_modules/grok-mermaid/dist/width-data.d.ts.map +1 -0
  60. package/node_modules/grok-mermaid/dist/width-data.js +994 -0
  61. package/node_modules/grok-mermaid/dist/width-data.js.map +1 -0
  62. package/node_modules/grok-mermaid/dist/width.d.ts +18 -0
  63. package/node_modules/grok-mermaid/dist/width.d.ts.map +1 -0
  64. package/node_modules/grok-mermaid/dist/width.js +76 -0
  65. package/node_modules/grok-mermaid/dist/width.js.map +1 -0
  66. package/node_modules/grok-mermaid/package.json +49 -0
  67. package/node_modules/grok-mermaid/src/ansi.ts +34 -0
  68. package/node_modules/grok-mermaid/src/canvas.ts +373 -0
  69. package/node_modules/grok-mermaid/src/graph.ts +142 -0
  70. package/node_modules/grok-mermaid/src/index.ts +104 -0
  71. package/node_modules/grok-mermaid/src/labels.ts +326 -0
  72. package/node_modules/grok-mermaid/src/layout-seq.ts +203 -0
  73. package/node_modules/grok-mermaid/src/layout.ts +1015 -0
  74. package/node_modules/grok-mermaid/src/parse.ts +1189 -0
  75. package/node_modules/grok-mermaid/src/source-box.ts +89 -0
  76. package/node_modules/grok-mermaid/src/types.ts +43 -0
  77. package/node_modules/grok-mermaid/src/width-data.ts +993 -0
  78. package/node_modules/grok-mermaid/src/width.ts +74 -0
  79. package/node_modules/pi-jev-auto-mode/CHANGELOG.md +110 -0
  80. package/node_modules/pi-jev-auto-mode/LICENSE +21 -0
  81. package/node_modules/pi-jev-auto-mode/README.md +285 -0
  82. package/node_modules/pi-jev-auto-mode/SECURITY.md +32 -0
  83. package/node_modules/pi-jev-auto-mode/docs/calibration.md +154 -0
  84. package/node_modules/pi-jev-auto-mode/docs/design.md +164 -0
  85. package/node_modules/pi-jev-auto-mode/docs/security.md +124 -0
  86. package/node_modules/pi-jev-auto-mode/index.ts +1 -0
  87. package/node_modules/pi-jev-auto-mode/package.json +72 -0
  88. package/node_modules/pi-jev-auto-mode/src/call.ts +180 -0
  89. package/node_modules/pi-jev-auto-mode/src/decide.ts +86 -0
  90. package/node_modules/pi-jev-auto-mode/src/extension.ts +862 -0
  91. package/node_modules/pi-jev-auto-mode/src/intent.ts +71 -0
  92. package/node_modules/pi-jev-auto-mode/src/jev/availability.ts +53 -0
  93. package/node_modules/pi-jev-auto-mode/src/jev/criteria.ts +19 -0
  94. package/node_modules/pi-jev-auto-mode/src/jev/decide.ts +187 -0
  95. package/node_modules/pi-jev-auto-mode/src/jev/engine.ts +165 -0
  96. package/node_modules/pi-jev-auto-mode/src/jev/index.ts +20 -0
  97. package/node_modules/pi-jev-auto-mode/src/jev/questions.ts +273 -0
  98. package/node_modules/pi-jev-auto-mode/src/jev/response.ts +64 -0
  99. package/node_modules/pi-jev-auto-mode/src/jev/state.ts +20 -0
  100. package/node_modules/pi-jev-auto-mode/src/jev/transport.ts +117 -0
  101. package/node_modules/pi-jev-auto-mode/src/jev/types.ts +46 -0
  102. package/node_modules/pi-jev-auto-mode/src/policy.ts +558 -0
  103. package/node_modules/pi-jev-auto-mode/src/records.ts +118 -0
  104. package/node_modules/pi-jev-auto-mode/src/settings.ts +327 -0
  105. package/node_modules/pi-jev-auto-mode/src/ui.ts +233 -0
  106. package/node_modules/pi-lens/CHANGELOG.md +45 -0
  107. package/node_modules/pi-lens/dist/clients/actionable-warnings.js +21 -9
  108. package/node_modules/pi-lens/dist/clients/cascade-format.js +24 -0
  109. package/node_modules/pi-lens/dist/clients/extension-log.js +48 -1
  110. package/node_modules/pi-lens/dist/clients/finding-delivery-gate.js +11 -12
  111. package/node_modules/pi-lens/dist/clients/lsp/cascade-tier.js +3 -0
  112. package/node_modules/pi-lens/dist/clients/lsp/index.js +41 -7
  113. package/node_modules/pi-lens/dist/clients/mcp/analyze.js +9 -2
  114. package/node_modules/pi-lens/dist/clients/path-utils.js +51 -9
  115. package/node_modules/pi-lens/dist/clients/persistent-reverify.js +271 -0
  116. package/node_modules/pi-lens/dist/clients/pipeline.js +15 -1
  117. package/node_modules/pi-lens/dist/clients/runtime-turn.js +124 -7
  118. package/node_modules/pi-lens/dist/clients/skills-resolver.js +38 -2
  119. package/node_modules/pi-lens/dist/clients/widget-state.js +152 -6
  120. package/node_modules/pi-lens/dist/index.js +729 -344
  121. package/node_modules/pi-lens/dist/tools/lens-diagnostic-mark.js +14 -2
  122. package/node_modules/pi-lens/dist/tools/lens-diagnostics.js +84 -17
  123. package/node_modules/pi-lens/dist/tools/lsp-diagnostics.js +32 -5
  124. package/node_modules/pi-lens/package.json +1 -1
  125. package/node_modules/pi-typesafe/LICENSE +21 -0
  126. package/node_modules/pi-typesafe/README.md +153 -0
  127. package/node_modules/pi-typesafe/dist/ask.d.ts +32 -0
  128. package/node_modules/pi-typesafe/dist/ask.js +25 -0
  129. package/node_modules/pi-typesafe/dist/auth.d.ts +56 -0
  130. package/node_modules/pi-typesafe/dist/auth.js +114 -0
  131. package/node_modules/pi-typesafe/dist/batch.d.ts +74 -0
  132. package/node_modules/pi-typesafe/dist/batch.js +116 -0
  133. package/node_modules/pi-typesafe/dist/calibrate.d.ts +106 -0
  134. package/node_modules/pi-typesafe/dist/calibrate.js +157 -0
  135. package/node_modules/pi-typesafe/dist/client.d.ts +69 -0
  136. package/node_modules/pi-typesafe/dist/client.js +188 -0
  137. package/node_modules/pi-typesafe/dist/credentials.d.ts +46 -0
  138. package/node_modules/pi-typesafe/dist/credentials.js +112 -0
  139. package/node_modules/pi-typesafe/dist/errors.d.ts +9 -0
  140. package/node_modules/pi-typesafe/dist/errors.js +31 -0
  141. package/node_modules/pi-typesafe/dist/extension.d.ts +3 -0
  142. package/node_modules/pi-typesafe/dist/extension.js +222 -0
  143. package/node_modules/pi-typesafe/dist/index.d.ts +18 -0
  144. package/node_modules/pi-typesafe/dist/index.js +9 -0
  145. package/node_modules/pi-typesafe/dist/key-prompt.d.ts +3 -0
  146. package/node_modules/pi-typesafe/dist/key-prompt.js +43 -0
  147. package/node_modules/pi-typesafe/dist/login.d.ts +27 -0
  148. package/node_modules/pi-typesafe/dist/login.js +38 -0
  149. package/node_modules/pi-typesafe/dist/schema.d.ts +43 -0
  150. package/node_modules/pi-typesafe/dist/schema.js +152 -0
  151. package/node_modules/pi-typesafe/dist/ui.d.ts +3 -0
  152. package/node_modules/pi-typesafe/dist/ui.js +3 -0
  153. package/node_modules/pi-typesafe/dist/usage.d.ts +73 -0
  154. package/node_modules/pi-typesafe/dist/usage.js +182 -0
  155. package/node_modules/pi-typesafe/examples/decision-extension.ts +41 -0
  156. package/node_modules/pi-typesafe/extensions/index.js +2 -0
  157. package/node_modules/pi-typesafe/package.json +89 -0
  158. package/package.json +16 -8
@@ -0,0 +1,191 @@
1
+ # grok-mermaid
2
+
3
+ Render Mermaid diagrams as Unicode box-drawing art, for terminals.
4
+
5
+ A TypeScript port of the terminal Mermaid renderer in
6
+ [xai-org/grok-build](https://github.com/xai-org/grok-build)
7
+ (`crates/codegen/xai-grok-markdown/src/mermaid.rs`). No browser, no headless
8
+ Chrome, no SVG — a self-contained layout engine that emits text.
9
+
10
+ ```
11
+ ┌──────────────┐
12
+ │ Parse source │
13
+ └───────┬──────┘
14
+
15
+
16
+ ╭────────────╮
17
+ │ Supported? │
18
+ ╰──────┬─────╯
19
+ ┌───────┴────────┐
20
+ ▼yes ▼no
21
+ ┌─────────┐ ┌───────────────┐
22
+ │ Lay out │ │ Framed source │
23
+ └────┬────┘ └───────┬───────┘
24
+ └───────┬────────┘
25
+
26
+ ┌─────────────┐
27
+ │ Unicode art │
28
+ └─────────────┘
29
+ ```
30
+
31
+ ## Install
32
+
33
+ ```sh
34
+ npm install grok-mermaid
35
+ ```
36
+
37
+ ## Usage
38
+
39
+ ```ts
40
+ import { render } from 'grok-mermaid'
41
+
42
+ const art = render('flowchart LR\n A[Start] --> B[Done]')
43
+ if (art) console.log(art.plain.join('\n'))
44
+ ```
45
+
46
+ `render` draws the diagram at whatever size it needs and reports that as
47
+ `art.width`. It returns `null` when there is no art to show: blank input, a
48
+ syntax error, a diagram type it does not draw, or one large enough that laying
49
+ it out is refused.
50
+
51
+ ### Syntax errors
52
+
53
+ Rendering is best-effort: a source that does not fully parse still draws what it
54
+ can, and reports the rest in `art.warnings`.
55
+
56
+ ```ts
57
+ // Flowcharts are lenient, as mermaid.js is: the parseable prefix survives.
58
+ render('graph TD\n A[Start --> B')
59
+ // plain one box labelled `Start --> B` — the edge you wrote is gone
60
+ // warnings ['node "A": label is missing its closing `]`']
61
+
62
+ // The rest fail on any unreadable statement, but retry once without the last
63
+ // line — the one a half-finished source ends on.
64
+ render('stateDiagram-v2\n A --> B\n some garbage line')
65
+ // plain the A --> B transition, drawn
66
+ // warnings ['dropped, unreadable final line: "some garbage line"']
67
+ ```
68
+
69
+ An empty `warnings` means the whole source made it into the art.
70
+
71
+ **Warnings are advisory — never gate rendering on them.** The art is the best
72
+ available drawing either way, and a diagram mid-edit warns at nearly every
73
+ intermediate state: a label bracket is unterminated right up until it is typed.
74
+
75
+ `diagramKind(src)` reads the header alone, separating the two `null`s worth
76
+ different messages:
77
+
78
+ ```ts
79
+ if (render(src) === null) {
80
+ const kind = diagramKind(src) // 'flowchart' | 'state' | 'class' | 'er' | 'sequence' | null
81
+ console.log(kind ? `${kind} diagram: syntax error` : 'diagram type not supported here')
82
+ }
83
+ ```
84
+
85
+ ### Streaming
86
+
87
+ Call `render` on each prefix as it arrives — no special handling, no waiting for
88
+ a complete diagram. Best-effort parsing is what keeps it drawn instead of
89
+ alternating with the source box.
90
+
91
+ <img src="https://raw.githubusercontent.com/xl0/grok-mermaid/master/docs/streaming.gif" width="900" alt="A terminal replaying a stream of Mermaid diagrams — flowcharts and a state machine drawing themselves as box-drawing art, each one growing in place without ever reverting to a block of source text.">
92
+
93
+ ### Fitting a viewport
94
+
95
+ The renderer takes no width limit. Nothing about a terminal tells it whether a
96
+ wide diagram should be shrunk, scrolled, linked to an image or just printed, so
97
+ the decision stays with you — compare `art.width` against the space you have:
98
+
99
+ ```ts
100
+ import { render, sourceBox } from 'grok-mermaid'
101
+
102
+ const cols = process.stdout.columns
103
+ const art = render(src)
104
+ if (art && art.width <= cols) console.log(art.plain.join('\n'))
105
+ else {
106
+ console.log(sourceBox(src, cols).plain.join('\n'))
107
+ console.log(`(diagram needs ${art?.width ?? '?'} columns)`)
108
+ }
109
+ ```
110
+
111
+ `sourceBox(src, maxWidth?)` frames the source in a titled box, hard-wrapping to
112
+ `maxWidth`. It is the usual thing to show when the art does not fit or does not
113
+ exist, but it is yours to choose and yours to caption.
114
+
115
+ ### Colour
116
+
117
+ The core is colour-blind. `styled` carries the same rows as `plain`, split into
118
+ runs tagged with a semantic class, so you map classes to your own theme:
119
+
120
+ <img src="https://raw.githubusercontent.com/xl0/grok-mermaid/master/docs/demo.svg" width="330" alt="A flowchart rendered as Unicode box-drawing art on a dark panel: grey box outlines, white node labels, cyan connectors and arrowheads, grey edge labels.">
121
+
122
+ That image is real `render()` output painted through one such theme.
123
+
124
+ ```ts
125
+ import { type Cls, render } from 'grok-mermaid'
126
+
127
+ const art = render(src)!
128
+
129
+ const theme: Partial<Record<Cls, (s: string) => string>> = {
130
+ border: dim, text: white, edge: cyan, edgeLabel: gray,
131
+ }
132
+ const out = art.styled.map((row) =>
133
+ row.map((span) => (theme[span.cls] ?? identity)(span.text)).join(''),
134
+ )
135
+ ```
136
+
137
+ | Class | What it covers |
138
+ | --- | --- |
139
+ | `border` | box outlines, subgraph frames, compartment rules |
140
+ | `text` | node, participant and compartment labels |
141
+ | `edge` | connector lines and arrowheads |
142
+ | `edgeLabel` | text sitting on an edge |
143
+ | `title` | the `mermaid: <kind>` header of a source box |
144
+ | `none` | blank filler |
145
+
146
+ `styled[i]` joined is always exactly `plain[i]`, so you can swap between them
147
+ freely. A render is plain JSON: cacheable across theme changes, transferable to
148
+ a worker.
149
+
150
+ For the common case there is a helper:
151
+
152
+ ```ts
153
+ import { render, toAnsi } from 'grok-mermaid'
154
+
155
+ console.log(toAnsi(render(src)!).join('\n'))
156
+ ```
157
+
158
+ `toAnsi(art, theme)` takes `Partial<Record<Cls, string>>` of SGR parameters
159
+ (`'2'` dim, `'36'` cyan, `'38;5;244'` for 256-colour), defaulting to a dim
160
+ frame with cyan connectors.
161
+
162
+ ## Supported diagrams
163
+
164
+ | Type | Notes |
165
+ | --- | --- |
166
+ | `graph` / `flowchart` | `TD`/`TB`, `BT`, `LR`, `RL`; `subgraph` nesting; node shapes; solid/dotted/thick links; arrow, circle, cross heads; edge labels |
167
+ | `stateDiagram` / `stateDiagram-v2` | states, transitions, `[*]` start/end, `<<choice>>`, descriptions, composite states flattened |
168
+ | `classDiagram` | compartments, annotations, generics, cardinalities, inheritance/realization/composition/aggregation/dependency |
169
+ | `erDiagram` | entities, attributes, crow's-foot cardinalities |
170
+ | `sequenceDiagram` | participants, messages, self-messages, notes, `loop`/`alt`/`opt` dividers, `autonumber` |
171
+
172
+ ## Credits
173
+
174
+ Inspired by Simon Willison's
175
+ [grok-mermaid.html](https://tools.simonwillison.net/grok-mermaid)
176
+ ([source](https://github.com/simonw/tools/blob/main/grok-mermaid.html)), which
177
+ compiles the original Rust renderer to WebAssembly so it runs in a browser.
178
+ That demo is what made the renderer worth having outside the Grok CLI; this
179
+ port takes the other route and reimplements it in TypeScript, so it needs no
180
+ WASM and runs anywhere JS does.
181
+
182
+ 100% of the code written by Opus 5, with a healthy dose of feedback and direction from my side.
183
+
184
+ ## License
185
+
186
+ Apache-2.0. See [LICENSE](LICENSE).
187
+
188
+ The Rust original in [xai-org/grok-build](https://github.com/xai-org/grok-build)
189
+ (`crates/codegen/xai-grok-markdown/src/mermaid.rs`) is Apache-2.0, Copyright
190
+ 2023-2026 SpaceXAI. Its layout algorithms, glyph tables, parser behaviour and
191
+ test corpus are what this port is derived from.
@@ -0,0 +1,16 @@
1
+ import type { Cls, MermaidArt } from './types.ts';
2
+ /**
3
+ * SGR parameter per semantic class, e.g. `'2'` for dim, `'36'` for cyan,
4
+ * `'38;5;244'` for a 256-colour index. A class left out is printed unstyled.
5
+ */
6
+ export type AnsiTheme = Partial<Record<Cls, string>>;
7
+ /** Dim frame, plain labels, cyan connectors. Readable on light and dark. */
8
+ export declare const DEFAULT_THEME: AnsiTheme;
9
+ /**
10
+ * Render art to ANSI-coloured lines.
11
+ *
12
+ * A convenience over mapping `art.styled` yourself — reach for that directly
13
+ * when your TUI has its own styling model.
14
+ */
15
+ export declare function toAnsi(art: MermaidArt, theme?: AnsiTheme): string[];
16
+ //# sourceMappingURL=ansi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ansi.d.ts","sourceRoot":"","sources":["../src/ansi.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAIjD;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAA;AAEpD,4EAA4E;AAC5E,eAAO,MAAM,aAAa,EAAE,SAK3B,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,GAAE,SAAyB,GAAG,MAAM,EAAE,CASlF"}
@@ -0,0 +1,23 @@
1
+ const ESC = String.fromCharCode(27);
2
+ /** Dim frame, plain labels, cyan connectors. Readable on light and dark. */
3
+ export const DEFAULT_THEME = {
4
+ border: '2',
5
+ edge: '36',
6
+ edgeLabel: '2;36',
7
+ title: '1',
8
+ };
9
+ /**
10
+ * Render art to ANSI-coloured lines.
11
+ *
12
+ * A convenience over mapping `art.styled` yourself — reach for that directly
13
+ * when your TUI has its own styling model.
14
+ */
15
+ export function toAnsi(art, theme = DEFAULT_THEME) {
16
+ return art.styled.map((row) => row
17
+ .map((span) => {
18
+ const sgr = theme[span.cls];
19
+ return sgr === undefined ? span.text : `${ESC}[${sgr}m${span.text}${ESC}[0m`;
20
+ })
21
+ .join(''));
22
+ }
23
+ //# sourceMappingURL=ansi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ansi.js","sourceRoot":"","sources":["../src/ansi.ts"],"names":[],"mappings":"AAEA,MAAM,GAAG,GAAG,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC,CAAA;AAQnC,4EAA4E;AAC5E,MAAM,CAAC,MAAM,aAAa,GAAc;IACtC,MAAM,EAAE,GAAG;IACX,IAAI,EAAE,IAAI;IACV,SAAS,EAAE,MAAM;IACjB,KAAK,EAAE,GAAG;CACX,CAAA;AAED;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CAAC,GAAe,EAAE,KAAK,GAAc,aAAa;IACtE,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAC5B,GAAG;SACA,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACZ,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAC3B,OAAO,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,GAAG,IAAI,IAAI,CAAC,IAAI,GAAG,GAAG,KAAK,CAAA;IAC9E,CAAC,CAAC;SACD,IAAI,CAAC,EAAE,CAAC,CACZ,CAAA;AACH,CAAC"}
@@ -0,0 +1,87 @@
1
+ import type { Cls, Span } from './types.ts';
2
+ /**
3
+ * Sentinel occupying the trailing column of a wide glyph. Never emitted: the
4
+ * line builder skips it so a CJK character claims two cells of layout but
5
+ * contributes one character of output.
6
+ */
7
+ export declare const CONT: string;
8
+ /** Connection direction bits, combined into a box-drawing glyph by `maskChar`. */
9
+ export declare const U = 1;
10
+ export declare const D = 2;
11
+ export declare const L = 4;
12
+ export declare const R = 8;
13
+ /** Line styles, tracked per cell so crossing edges keep their own stroke. */
14
+ export declare const STY_DOT = 1;
15
+ export declare const STY_THICK = 2;
16
+ export declare const STY_SOLID = 4;
17
+ /**
18
+ * A grid of cells. Edges accumulate as direction bits rather than glyphs so
19
+ * that crossings and junctions resolve correctly whatever order they are drawn
20
+ * in; `finalizeMask` turns the accumulated bits into characters at the end.
21
+ *
22
+ * `occupied` marks cells claimed by a box, which edge bits must not overwrite.
23
+ */
24
+ export declare class Canvas {
25
+ readonly w: number;
26
+ readonly h: number;
27
+ ch: string[];
28
+ cls: Cls[];
29
+ mask: Uint8Array;
30
+ style: Uint8Array;
31
+ occupied: Uint8Array;
32
+ curStyle: number;
33
+ constructor(w: number, h: number);
34
+ idx(x: number, y: number): number;
35
+ set(x: number, y: number, c: string, cls: Cls): void;
36
+ /**
37
+ * Accumulate direction bits on a free cell.
38
+ *
39
+ * `cls` is the class to claim the cell for; `border` cells are never
40
+ * reclassified, so a connector meeting a box keeps the box's styling.
41
+ */
42
+ addBits(x: number, y: number, bits: number, cls?: Cls): void;
43
+ /** Stamp a finished sub-canvas (a subgraph frame's contents) at an offset. */
44
+ blit(sub: Canvas, ox: number, oy: number): void;
45
+ /** Add direction bits even to an occupied cell, so an edge can meet a border. */
46
+ junction(x: number, y: number, bits: number): void;
47
+ segV(x: number, y0: number, y1: number): void;
48
+ segH(y: number, x0: number, x1: number): void;
49
+ /** Resolve accumulated direction bits into glyphs, honouring line style. */
50
+ finalizeMask(): void;
51
+ /**
52
+ * Mirror top-to-bottom for `BT`. Rows reorder but within-row text does not,
53
+ * so labels stay readable; box-drawing glyphs flip to match.
54
+ */
55
+ flipVertical(): void;
56
+ /**
57
+ * Mirror left-to-right for `RL`. Mirroring reverses each row, so after
58
+ * flipping glyphs each text/label run is reversed back to reading order.
59
+ */
60
+ flipHorizontal(): void;
61
+ /** Group each row into runs of one class, dropping wide-glyph continuations. */
62
+ toLines(): {
63
+ plain: string[];
64
+ styled: Span[][];
65
+ width: number;
66
+ };
67
+ }
68
+ /**
69
+ * Paint `text` at `x, y`, one grapheme cluster per cell.
70
+ *
71
+ * A wide cluster claims a second cell, marked with `CONT` so the line builder
72
+ * emits one character for it rather than a stray space.
73
+ */
74
+ export declare function drawText(canvas: Canvas, text: string, x: number, y: number, cls: Cls): void;
75
+ /**
76
+ * Paint `text` at `x, y`, clearing any edge bits underneath first.
77
+ *
78
+ * Used where text sits on top of a drawn line (sequence messages, dividers,
79
+ * compartment rows) and must win over it.
80
+ */
81
+ export declare function drawTextOverEdges(canvas: Canvas, text: string, x: number, y: number, cls: Cls): void;
82
+ export declare function maskChar(mask: number): string;
83
+ export declare const dottedChar: (c: string) => string;
84
+ export declare const thickChar: (c: string) => string;
85
+ export declare const flipGlyphV: (c: string) => string;
86
+ export declare const flipGlyphH: (c: string) => string;
87
+ //# sourceMappingURL=canvas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canvas.d.ts","sourceRoot":"","sources":["../src/canvas.ts"],"names":[],"mappings":"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"}