@textui/core 0.1.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.
Files changed (323) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +67 -0
  3. package/dist/adapters/index.d.ts +12 -0
  4. package/dist/adapters/index.d.ts.map +1 -0
  5. package/dist/adapters/index.js +11 -0
  6. package/dist/app/app.d.ts +200 -0
  7. package/dist/app/app.d.ts.map +1 -0
  8. package/dist/app/app.js +980 -0
  9. package/dist/core/animation.d.ts +34 -0
  10. package/dist/core/animation.d.ts.map +1 -0
  11. package/dist/core/animation.js +125 -0
  12. package/dist/core/clipboard.d.ts +29 -0
  13. package/dist/core/clipboard.d.ts.map +1 -0
  14. package/dist/core/clipboard.js +30 -0
  15. package/dist/core/commands.d.ts +42 -0
  16. package/dist/core/commands.d.ts.map +1 -0
  17. package/dist/core/commands.js +146 -0
  18. package/dist/core/components.d.ts +27 -0
  19. package/dist/core/components.d.ts.map +1 -0
  20. package/dist/core/components.js +78 -0
  21. package/dist/core/events.d.ts +23 -0
  22. package/dist/core/events.d.ts.map +1 -0
  23. package/dist/core/events.js +77 -0
  24. package/dist/core/focus.d.ts +69 -0
  25. package/dist/core/focus.d.ts.map +1 -0
  26. package/dist/core/focus.js +336 -0
  27. package/dist/core/i18n.d.ts +27 -0
  28. package/dist/core/i18n.d.ts.map +1 -0
  29. package/dist/core/i18n.js +88 -0
  30. package/dist/core/keybindings.d.ts +53 -0
  31. package/dist/core/keybindings.d.ts.map +1 -0
  32. package/dist/core/keybindings.js +163 -0
  33. package/dist/core/layers.d.ts +28 -0
  34. package/dist/core/layers.d.ts.map +1 -0
  35. package/dist/core/layers.js +84 -0
  36. package/dist/core/manifest.d.ts +22 -0
  37. package/dist/core/manifest.d.ts.map +1 -0
  38. package/dist/core/manifest.js +85 -0
  39. package/dist/core/navigation.d.ts +47 -0
  40. package/dist/core/navigation.d.ts.map +1 -0
  41. package/dist/core/navigation.js +110 -0
  42. package/dist/core/resources.d.ts +115 -0
  43. package/dist/core/resources.d.ts.map +1 -0
  44. package/dist/core/resources.js +321 -0
  45. package/dist/core/services.d.ts +21 -0
  46. package/dist/core/services.d.ts.map +1 -0
  47. package/dist/core/services.js +63 -0
  48. package/dist/core/store.d.ts +60 -0
  49. package/dist/core/store.d.ts.map +1 -0
  50. package/dist/core/store.js +593 -0
  51. package/dist/core/surfaces.d.ts +81 -0
  52. package/dist/core/surfaces.d.ts.map +1 -0
  53. package/dist/core/surfaces.js +237 -0
  54. package/dist/core/syntax.d.ts +49 -0
  55. package/dist/core/syntax.d.ts.map +1 -0
  56. package/dist/core/syntax.js +172 -0
  57. package/dist/core/when.d.ts +15 -0
  58. package/dist/core/when.d.ts.map +1 -0
  59. package/dist/core/when.js +224 -0
  60. package/dist/index.d.ts +49 -0
  61. package/dist/index.d.ts.map +1 -0
  62. package/dist/index.js +54 -0
  63. package/dist/jsx/factory.d.ts +27 -0
  64. package/dist/jsx/factory.d.ts.map +1 -0
  65. package/dist/jsx/factory.js +102 -0
  66. package/dist/jsx/intrinsics.d.ts +96 -0
  67. package/dist/jsx/intrinsics.d.ts.map +1 -0
  68. package/dist/jsx/intrinsics.js +1 -0
  69. package/dist/jsx/jsx-dev-runtime.d.ts +13 -0
  70. package/dist/jsx/jsx-dev-runtime.d.ts.map +1 -0
  71. package/dist/jsx/jsx-dev-runtime.js +12 -0
  72. package/dist/jsx/jsx-runtime.d.ts +42 -0
  73. package/dist/jsx/jsx-runtime.d.ts.map +1 -0
  74. package/dist/jsx/jsx-runtime.js +16 -0
  75. package/dist/render/buffer.d.ts +77 -0
  76. package/dist/render/buffer.d.ts.map +1 -0
  77. package/dist/render/buffer.js +275 -0
  78. package/dist/render/color.d.ts +35 -0
  79. package/dist/render/color.d.ts.map +1 -0
  80. package/dist/render/color.js +160 -0
  81. package/dist/render/diff.d.ts +37 -0
  82. package/dist/render/diff.d.ts.map +1 -0
  83. package/dist/render/diff.js +66 -0
  84. package/dist/render/layout.d.ts +72 -0
  85. package/dist/render/layout.d.ts.map +1 -0
  86. package/dist/render/layout.js +633 -0
  87. package/dist/render/static.d.ts +63 -0
  88. package/dist/render/static.d.ts.map +1 -0
  89. package/dist/render/static.js +209 -0
  90. package/dist/runtime/bindings.d.ts +46 -0
  91. package/dist/runtime/bindings.d.ts.map +1 -0
  92. package/dist/runtime/bindings.js +116 -0
  93. package/dist/runtime/hooks.d.ts +284 -0
  94. package/dist/runtime/hooks.d.ts.map +1 -0
  95. package/dist/runtime/hooks.js +846 -0
  96. package/dist/runtime/instance.d.ts +106 -0
  97. package/dist/runtime/instance.d.ts.map +1 -0
  98. package/dist/runtime/instance.js +181 -0
  99. package/dist/runtime/paint.d.ts +27 -0
  100. package/dist/runtime/paint.d.ts.map +1 -0
  101. package/dist/runtime/paint.js +567 -0
  102. package/dist/runtime/reconcile.d.ts +23 -0
  103. package/dist/runtime/reconcile.d.ts.map +1 -0
  104. package/dist/runtime/reconcile.js +260 -0
  105. package/dist/runtime/runtime.d.ts +42 -0
  106. package/dist/runtime/runtime.d.ts.map +1 -0
  107. package/dist/runtime/runtime.js +1 -0
  108. package/dist/runtime/style.d.ts +55 -0
  109. package/dist/runtime/style.d.ts.map +1 -0
  110. package/dist/runtime/style.js +143 -0
  111. package/dist/themes/borders.d.ts +10 -0
  112. package/dist/themes/borders.d.ts.map +1 -0
  113. package/dist/themes/borders.js +88 -0
  114. package/dist/themes/builtin.d.ts +31 -0
  115. package/dist/themes/builtin.d.ts.map +1 -0
  116. package/dist/themes/builtin.js +291 -0
  117. package/dist/themes/glyphs.d.ts +15 -0
  118. package/dist/themes/glyphs.d.ts.map +1 -0
  119. package/dist/themes/glyphs.js +97 -0
  120. package/dist/themes/index.d.ts +5 -0
  121. package/dist/themes/index.d.ts.map +1 -0
  122. package/dist/themes/index.js +4 -0
  123. package/dist/themes/registry.d.ts +20 -0
  124. package/dist/themes/registry.d.ts.map +1 -0
  125. package/dist/themes/registry.js +204 -0
  126. package/dist/types/adapter.d.ts +38 -0
  127. package/dist/types/adapter.d.ts.map +1 -0
  128. package/dist/types/adapter.js +1 -0
  129. package/dist/types/animation.d.ts +31 -0
  130. package/dist/types/animation.d.ts.map +1 -0
  131. package/dist/types/animation.js +1 -0
  132. package/dist/types/app.d.ts +148 -0
  133. package/dist/types/app.d.ts.map +1 -0
  134. package/dist/types/app.js +1 -0
  135. package/dist/types/async.d.ts +30 -0
  136. package/dist/types/async.d.ts.map +1 -0
  137. package/dist/types/async.js +1 -0
  138. package/dist/types/capabilities.d.ts +44 -0
  139. package/dist/types/capabilities.d.ts.map +1 -0
  140. package/dist/types/capabilities.js +33 -0
  141. package/dist/types/cells.d.ts +72 -0
  142. package/dist/types/cells.d.ts.map +1 -0
  143. package/dist/types/cells.js +10 -0
  144. package/dist/types/command.d.ts +127 -0
  145. package/dist/types/command.d.ts.map +1 -0
  146. package/dist/types/command.js +1 -0
  147. package/dist/types/component-registry.d.ts +77 -0
  148. package/dist/types/component-registry.d.ts.map +1 -0
  149. package/dist/types/component-registry.js +1 -0
  150. package/dist/types/disposable.d.ts +8 -0
  151. package/dist/types/disposable.d.ts.map +1 -0
  152. package/dist/types/disposable.js +1 -0
  153. package/dist/types/focus.d.ts +72 -0
  154. package/dist/types/focus.d.ts.map +1 -0
  155. package/dist/types/focus.js +1 -0
  156. package/dist/types/geometry.d.ts +28 -0
  157. package/dist/types/geometry.d.ts.map +1 -0
  158. package/dist/types/geometry.js +14 -0
  159. package/dist/types/graph.d.ts +129 -0
  160. package/dist/types/graph.d.ts.map +1 -0
  161. package/dist/types/graph.js +31 -0
  162. package/dist/types/i18n.d.ts +23 -0
  163. package/dist/types/i18n.d.ts.map +1 -0
  164. package/dist/types/i18n.js +1 -0
  165. package/dist/types/index.d.ts +32 -0
  166. package/dist/types/index.d.ts.map +1 -0
  167. package/dist/types/index.js +31 -0
  168. package/dist/types/input.d.ts +65 -0
  169. package/dist/types/input.d.ts.map +1 -0
  170. package/dist/types/input.js +1 -0
  171. package/dist/types/keybinding.d.ts +49 -0
  172. package/dist/types/keybinding.d.ts.map +1 -0
  173. package/dist/types/keybinding.js +1 -0
  174. package/dist/types/layer.d.ts +54 -0
  175. package/dist/types/layer.d.ts.map +1 -0
  176. package/dist/types/layer.js +1 -0
  177. package/dist/types/manifest.d.ts +114 -0
  178. package/dist/types/manifest.d.ts.map +1 -0
  179. package/dist/types/manifest.js +1 -0
  180. package/dist/types/markdown.d.ts +58 -0
  181. package/dist/types/markdown.d.ts.map +1 -0
  182. package/dist/types/markdown.js +1 -0
  183. package/dist/types/navigation.d.ts +40 -0
  184. package/dist/types/navigation.d.ts.map +1 -0
  185. package/dist/types/navigation.js +1 -0
  186. package/dist/types/render.d.ts +72 -0
  187. package/dist/types/render.d.ts.map +1 -0
  188. package/dist/types/render.js +1 -0
  189. package/dist/types/resource.d.ts +170 -0
  190. package/dist/types/resource.d.ts.map +1 -0
  191. package/dist/types/resource.js +1 -0
  192. package/dist/types/services.d.ts +24 -0
  193. package/dist/types/services.d.ts.map +1 -0
  194. package/dist/types/services.js +3 -0
  195. package/dist/types/shell.d.ts +32 -0
  196. package/dist/types/shell.d.ts.map +1 -0
  197. package/dist/types/shell.js +1 -0
  198. package/dist/types/store.d.ts +124 -0
  199. package/dist/types/store.d.ts.map +1 -0
  200. package/dist/types/store.js +1 -0
  201. package/dist/types/stream.d.ts +18 -0
  202. package/dist/types/stream.d.ts.map +1 -0
  203. package/dist/types/stream.js +1 -0
  204. package/dist/types/style.d.ts +166 -0
  205. package/dist/types/style.d.ts.map +1 -0
  206. package/dist/types/style.js +1 -0
  207. package/dist/types/surface.d.ts +97 -0
  208. package/dist/types/surface.d.ts.map +1 -0
  209. package/dist/types/surface.js +1 -0
  210. package/dist/types/syntax.d.ts +68 -0
  211. package/dist/types/syntax.d.ts.map +1 -0
  212. package/dist/types/syntax.js +5 -0
  213. package/dist/types/terminal.d.ts +52 -0
  214. package/dist/types/terminal.d.ts.map +1 -0
  215. package/dist/types/terminal.js +1 -0
  216. package/dist/types/theme.d.ts +117 -0
  217. package/dist/types/theme.d.ts.map +1 -0
  218. package/dist/types/theme.js +1 -0
  219. package/dist/types/when.d.ts +19 -0
  220. package/dist/types/when.d.ts.map +1 -0
  221. package/dist/types/when.js +1 -0
  222. package/dist/ui/primitives.d.ts +56 -0
  223. package/dist/ui/primitives.d.ts.map +1 -0
  224. package/dist/ui/primitives.js +108 -0
  225. package/dist/ui/screen.d.ts +23 -0
  226. package/dist/ui/screen.d.ts.map +1 -0
  227. package/dist/ui/screen.js +18 -0
  228. package/dist/util/disposable.d.ts +6 -0
  229. package/dist/util/disposable.d.ts.map +1 -0
  230. package/dist/util/disposable.js +49 -0
  231. package/dist/util/markdown.d.ts +24 -0
  232. package/dist/util/markdown.d.ts.map +1 -0
  233. package/dist/util/markdown.js +220 -0
  234. package/dist/util/paths.d.ts +47 -0
  235. package/dist/util/paths.d.ts.map +1 -0
  236. package/dist/util/paths.js +134 -0
  237. package/dist/util/stream.d.ts +32 -0
  238. package/dist/util/stream.d.ts.map +1 -0
  239. package/dist/util/stream.js +206 -0
  240. package/dist/util/text.d.ts +65 -0
  241. package/dist/util/text.d.ts.map +1 -0
  242. package/dist/util/text.js +419 -0
  243. package/package.json +70 -0
  244. package/src/adapters/index.ts +11 -0
  245. package/src/app/app.ts +1096 -0
  246. package/src/core/animation.ts +144 -0
  247. package/src/core/clipboard.ts +40 -0
  248. package/src/core/commands.ts +169 -0
  249. package/src/core/components.ts +91 -0
  250. package/src/core/events.ts +95 -0
  251. package/src/core/focus.ts +358 -0
  252. package/src/core/i18n.ts +107 -0
  253. package/src/core/keybindings.ts +184 -0
  254. package/src/core/layers.ts +94 -0
  255. package/src/core/manifest.ts +84 -0
  256. package/src/core/navigation.ts +135 -0
  257. package/src/core/resources.ts +362 -0
  258. package/src/core/services.ts +69 -0
  259. package/src/core/store.ts +640 -0
  260. package/src/core/surfaces.ts +292 -0
  261. package/src/core/syntax.ts +200 -0
  262. package/src/core/when.ts +238 -0
  263. package/src/index.ts +76 -0
  264. package/src/jsx/factory.ts +124 -0
  265. package/src/jsx/intrinsics.ts +99 -0
  266. package/src/jsx/jsx-dev-runtime.ts +23 -0
  267. package/src/jsx/jsx-runtime.ts +76 -0
  268. package/src/render/buffer.ts +318 -0
  269. package/src/render/color.ts +180 -0
  270. package/src/render/diff.ts +99 -0
  271. package/src/render/layout.ts +764 -0
  272. package/src/render/static.ts +290 -0
  273. package/src/runtime/bindings.ts +150 -0
  274. package/src/runtime/hooks.ts +1057 -0
  275. package/src/runtime/instance.ts +284 -0
  276. package/src/runtime/paint.ts +737 -0
  277. package/src/runtime/reconcile.ts +335 -0
  278. package/src/runtime/runtime.ts +47 -0
  279. package/src/runtime/style.ts +205 -0
  280. package/src/themes/borders.ts +95 -0
  281. package/src/themes/builtin.ts +301 -0
  282. package/src/themes/glyphs.ts +101 -0
  283. package/src/themes/index.ts +4 -0
  284. package/src/themes/registry.ts +224 -0
  285. package/src/types/adapter.ts +41 -0
  286. package/src/types/animation.ts +34 -0
  287. package/src/types/app.ts +149 -0
  288. package/src/types/async.ts +35 -0
  289. package/src/types/capabilities.ts +79 -0
  290. package/src/types/cells.ts +79 -0
  291. package/src/types/command.ts +139 -0
  292. package/src/types/component-registry.ts +82 -0
  293. package/src/types/disposable.ts +8 -0
  294. package/src/types/focus.ts +77 -0
  295. package/src/types/geometry.ts +50 -0
  296. package/src/types/graph.ts +174 -0
  297. package/src/types/i18n.ts +25 -0
  298. package/src/types/index.ts +31 -0
  299. package/src/types/input.ts +81 -0
  300. package/src/types/keybinding.ts +51 -0
  301. package/src/types/layer.ts +46 -0
  302. package/src/types/manifest.ts +101 -0
  303. package/src/types/markdown.ts +47 -0
  304. package/src/types/navigation.ts +42 -0
  305. package/src/types/render.ts +86 -0
  306. package/src/types/resource.ts +185 -0
  307. package/src/types/services.ts +28 -0
  308. package/src/types/shell.ts +30 -0
  309. package/src/types/store.ts +148 -0
  310. package/src/types/stream.ts +24 -0
  311. package/src/types/style.ts +205 -0
  312. package/src/types/surface.ts +119 -0
  313. package/src/types/syntax.ts +93 -0
  314. package/src/types/terminal.ts +58 -0
  315. package/src/types/theme.ts +121 -0
  316. package/src/types/when.ts +21 -0
  317. package/src/ui/primitives.ts +118 -0
  318. package/src/ui/screen.ts +41 -0
  319. package/src/util/disposable.ts +49 -0
  320. package/src/util/markdown.ts +225 -0
  321. package/src/util/paths.ts +138 -0
  322. package/src/util/stream.ts +213 -0
  323. package/src/util/text.ts +428 -0
@@ -0,0 +1,117 @@
1
+ import type { Color } from './cells.js';
2
+ import type { BorderChars, BorderStyle, ColorToken, Density, Style, StyleColor } from './style.js';
3
+ import type { SyntaxScope } from './syntax.js';
4
+ import type { Disposable } from './disposable.js';
5
+ import type { TerminalCapabilities } from './capabilities.js';
6
+ /** Spacing scale, in cells. Terminals have no sub-cell spacing. */
7
+ export interface ThemeSpacing {
8
+ none: number;
9
+ xs: number;
10
+ sm: number;
11
+ md: number;
12
+ lg: number;
13
+ xl: number;
14
+ }
15
+ /**
16
+ * The glyph vocabulary. Separated from colour because a 16-colour terminal may
17
+ * still be full-Unicode, and an ascii-only terminal may be truecolor.
18
+ */
19
+ export interface ThemeGlyphs {
20
+ /** Status dots, bullets, arrows - keyed by role so a component names a role. */
21
+ bulletFilled: string;
22
+ bulletHollow: string;
23
+ bulletHalf: string;
24
+ check: string;
25
+ cross: string;
26
+ warning: string;
27
+ info: string;
28
+ chevronRight: string;
29
+ chevronDown: string;
30
+ chevronLeft: string;
31
+ chevronUp: string;
32
+ arrowUp: string;
33
+ arrowDown: string;
34
+ ellipsis: string;
35
+ search: string;
36
+ radioOn: string;
37
+ radioOff: string;
38
+ checkboxOn: string;
39
+ checkboxOff: string;
40
+ checkboxMixed: string;
41
+ /** Eight levels for sparklines and bar charts. */
42
+ blocks: readonly string[];
43
+ /** Progress bar track and fill. */
44
+ progressFull: string;
45
+ progressEmpty: string;
46
+ progressPartial: readonly string[];
47
+ spinner: readonly string[];
48
+ /** Text cursor when the terminal cursor is unavailable. */
49
+ caret: string;
50
+ separator: string;
51
+ /** Path separator in a breadcrumb. */
52
+ breadcrumb: string;
53
+ /**
54
+ * Where a region sits in the frame.
55
+ *
56
+ * One family, so a list of regions reads as a diagram rather than as six
57
+ * unrelated marks: the glyph says *where*, and `regionOff` says the region
58
+ * is not on screen. A tick cannot say where, which is why a list of ticks
59
+ * needs a second column of words to be readable at all.
60
+ */
61
+ regionTop: string;
62
+ regionBottom: string;
63
+ regionLeft: string;
64
+ regionRight: string;
65
+ regionCentre: string;
66
+ regionOff: string;
67
+ }
68
+ export interface ThemeDefinition {
69
+ id: string;
70
+ name: string;
71
+ appearance: 'light' | 'dark';
72
+ /** Extend another registered theme; only the differences need stating. */
73
+ extends?: string;
74
+ colors: Partial<Record<ColorToken, Color>>;
75
+ spacing?: Partial<ThemeSpacing>;
76
+ glyphs?: Partial<ThemeGlyphs>;
77
+ /** Default border style for chrome. `'none'` gives the borderless look. */
78
+ border?: BorderStyle;
79
+ borderChars?: Partial<Record<BorderStyle, BorderChars>>;
80
+ density?: Density;
81
+ /** Per-component style overrides, keyed by component name then variant. */
82
+ components?: Record<string, Record<string, Style>>;
83
+ /**
84
+ * Colours for syntax scopes. Every scope has a default drawn from the
85
+ * semantic palette, so a theme states only what it wants to differ - and a
86
+ * theme that states nothing still highlights.
87
+ */
88
+ syntax?: Partial<Record<SyntaxScope, StyleColor>>;
89
+ }
90
+ /** A theme after `extends` resolution and capability downgrade. */
91
+ export interface ResolvedTheme {
92
+ id: string;
93
+ name: string;
94
+ appearance: 'light' | 'dark';
95
+ colors: Record<ColorToken, Color>;
96
+ spacing: ThemeSpacing;
97
+ glyphs: ThemeGlyphs;
98
+ border: BorderStyle;
99
+ density: Density;
100
+ components: Record<string, Record<string, Style>>;
101
+ /** Every syntax scope, resolved to a colour. */
102
+ syntax: Record<SyntaxScope, Color>;
103
+ /** Resolve a token (or pass a literal colour through). */
104
+ color(token: string): Color;
105
+ borderChars(style?: BorderStyle): BorderChars;
106
+ /** Component style for a name + variant list, merged in order. */
107
+ styleFor(component: string, variants?: string[]): Style;
108
+ }
109
+ export interface ThemeRegistry {
110
+ register(def: ThemeDefinition): Disposable;
111
+ unregister(id: string): void;
112
+ get(id: string): ThemeDefinition | undefined;
113
+ list(): ThemeDefinition[];
114
+ /** Resolve `extends`, apply capability downgrade, return a usable theme. */
115
+ resolve(id: string, caps: TerminalCapabilities): ResolvedTheme;
116
+ }
117
+ //# sourceMappingURL=theme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/types/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACnG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,mEAAmE;AACnE,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,gFAAgF;IAChF,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC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AAC;IAC3C,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS,CAAC;IAC7C,IAAI,IAAI,eAAe,EAAE,CAAC;IAC1B,4EAA4E;IAC5E,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,oBAAoB,GAAG,aAAa,CAAC;CAChE"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,19 @@
1
+ import type { BindingPath } from './graph.js';
2
+ export type ContextValue = string | number | boolean | null;
3
+ /**
4
+ * A small expression over store paths and context keys. Chrome that should not
5
+ * exist for this user does not mount, rather than mounting disabled.
6
+ *
7
+ * "$/session/role == 'admin'"
8
+ * "$/modus/capabilities/mouse && !$/ui/sidebar/collapsed"
9
+ * "$/modus/size/width >= 100"
10
+ */
11
+ export type WhenClause = string;
12
+ export interface WhenEngine {
13
+ evaluate(clause: WhenClause | undefined, extra?: Record<string, ContextValue>): boolean;
14
+ /** Paths a clause reads, so a caller can subscribe to exactly those. */
15
+ dependencies(clause: WhenClause): BindingPath[];
16
+ setContext(key: string, value: ContextValue): void;
17
+ getContext(key: string): ContextValue | undefined;
18
+ }
19
+ //# sourceMappingURL=when.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"when.d.ts","sourceRoot":"","sources":["../../src/types/when.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAE5D;;;;;;;GAOG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAEhC,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG,SAAS,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,OAAO,CAAC;IACxF,wEAAwE;IACxE,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,WAAW,EAAE,CAAC;IAChD,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;IACnD,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAAC;CACnD"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,56 @@
1
+ import type { ComponentDefinition } from '../types/component-registry.js';
2
+ /**
3
+ * The host primitives.
4
+ *
5
+ * There are four, and there is a reason not to add a fifth: the layout engine
6
+ * and the painter only reason about these shapes, so every component in the
7
+ * catalog composing them means layout has one implementation rather than
8
+ * dozens. Painting for `box`, `text` and `canvas` lives in the painter, which
9
+ * is why these carry no `paint` of their own.
10
+ */
11
+ /**
12
+ * The container. Flex layout, background, border, title and footer.
13
+ *
14
+ * Props: `BoxProps`. The same node as `<box/>` - this constant is the string,
15
+ * so JSX resolves the tag as an intrinsic rather than as a component.
16
+ *
17
+ * ```tsx
18
+ * <Box border="round" padding={1} direction="column" gap={1}>
19
+ * <Text bold>Title</Text>
20
+ * </Box>
21
+ * ```
22
+ */
23
+ export declare const Box: "box";
24
+ /**
25
+ * A run of text. Wraps, truncates and aligns within its box.
26
+ *
27
+ * Props: `TextProps` - `content`, or children as a shorthand, plus `truncate`
28
+ * and every style key. The same node as `<text/>`.
29
+ *
30
+ * ```tsx
31
+ * <Text bold fg="success">{count} tests passed</Text>
32
+ * ```
33
+ */
34
+ export declare const Text: "text";
35
+ /**
36
+ * Direct cell painting. The escape hatch charts and gauges use.
37
+ *
38
+ * Props: `CanvasProps` - a `draw` callback handed a surface and a render
39
+ * context, and an `intrinsic` size for when the style does not fix one. Prefer
40
+ * composing `Box` and `Text` where you can: the layout engine can reason about
41
+ * those and cannot reason about this. The same node as `<canvas/>`.
42
+ */
43
+ export declare const Canvas: "canvas";
44
+ /**
45
+ * Empty space. Greedy by default, or a fixed number of cells.
46
+ *
47
+ * Props: `SpacerProps` - `size` in cells; leave it unset and it takes whatever
48
+ * is left, which is how two things end up at opposite ends of a row. The same
49
+ * node as `<spacer/>`.
50
+ *
51
+ * Between *every* child, `gap` on the container is shorter and does not need a
52
+ * node per space.
53
+ */
54
+ export declare const Spacer: "spacer";
55
+ export declare const PRIMITIVES: ComponentDefinition[];
56
+ //# sourceMappingURL=primitives.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"primitives.d.ts","sourceRoot":"","sources":["../../src/ui/primitives.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAG1E;;;;;;;;GAQG;AAwBH;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,GAAG,EAAG,KAAc,CAAC;AAElC;;;;;;;;;GASG;AACH,eAAO,MAAM,IAAI,EAAG,MAAe,CAAC;AAEpC;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,EAAG,QAAiB,CAAC;AAExC;;;;;;;;;GASG;AACH,eAAO,MAAM,MAAM,EAAG,QAAiB,CAAC;AAOxC,eAAO,MAAM,UAAU,EAAE,mBAAmB,EA6B3C,CAAC"}
@@ -0,0 +1,108 @@
1
+ /**
2
+ * The host primitives.
3
+ *
4
+ * There are four, and there is a reason not to add a fifth: the layout engine
5
+ * and the painter only reason about these shapes, so every component in the
6
+ * catalog composing them means layout has one implementation rather than
7
+ * dozens. Painting for `box`, `text` and `canvas` lives in the painter, which
8
+ * is why these carry no `paint` of their own.
9
+ */
10
+ /*
11
+ * The primitives under Capitalized names, for JSX.
12
+ *
13
+ * These are the strings, not wrappers around them. JSX resolves a Capitalized
14
+ * tag to the value in scope, and a value whose type is a string literal is an
15
+ * intrinsic - so `<Box margin={2}/>` compiles to `h('box', { margin: 2 })`,
16
+ * the identical node. No function to call, no extra depth in the tree, and
17
+ * `BoxProps` still checks the props: `<Box notAProp/>` is the same error
18
+ * `<box notAProp/>` is.
19
+ *
20
+ * They exist so a screen can be written in one case. Every other component is
21
+ * Capitalized already - it has to be, that is how JSX tells a registry lookup
22
+ * from a host tag - and the four primitives being the exception meant mixing
23
+ * `<Row>` and `<box>` in one file. The lowercase names remain what the node
24
+ * actually holds, and stay the spelling for a screen written as data.
25
+ *
26
+ * Each carries its own doc below rather than sharing this one, because a
27
+ * comment above a group attaches to the first declaration and leaves the rest
28
+ * hovering as nothing - and going to the definition of a name that turns out
29
+ * to be an undocumented string is worse than not going anywhere.
30
+ */
31
+ /**
32
+ * The container. Flex layout, background, border, title and footer.
33
+ *
34
+ * Props: `BoxProps`. The same node as `<box/>` - this constant is the string,
35
+ * so JSX resolves the tag as an intrinsic rather than as a component.
36
+ *
37
+ * ```tsx
38
+ * <Box border="round" padding={1} direction="column" gap={1}>
39
+ * <Text bold>Title</Text>
40
+ * </Box>
41
+ * ```
42
+ */
43
+ export const Box = 'box';
44
+ /**
45
+ * A run of text. Wraps, truncates and aligns within its box.
46
+ *
47
+ * Props: `TextProps` - `content`, or children as a shorthand, plus `truncate`
48
+ * and every style key. The same node as `<text/>`.
49
+ *
50
+ * ```tsx
51
+ * <Text bold fg="success">{count} tests passed</Text>
52
+ * ```
53
+ */
54
+ export const Text = 'text';
55
+ /**
56
+ * Direct cell painting. The escape hatch charts and gauges use.
57
+ *
58
+ * Props: `CanvasProps` - a `draw` callback handed a surface and a render
59
+ * context, and an `intrinsic` size for when the style does not fix one. Prefer
60
+ * composing `Box` and `Text` where you can: the layout engine can reason about
61
+ * those and cannot reason about this. The same node as `<canvas/>`.
62
+ */
63
+ export const Canvas = 'canvas';
64
+ /**
65
+ * Empty space. Greedy by default, or a fixed number of cells.
66
+ *
67
+ * Props: `SpacerProps` - `size` in cells; leave it unset and it takes whatever
68
+ * is left, which is how two things end up at opposite ends of a row. The same
69
+ * node as `<spacer/>`.
70
+ *
71
+ * Between *every* child, `gap` on the container is shorter and does not need a
72
+ * node per space.
73
+ */
74
+ export const Spacer = 'spacer';
75
+ const box = { name: 'box', container: true };
76
+ const text = { name: 'text', leaf: true };
77
+ const canvas = { name: 'canvas', leaf: true };
78
+ const spacer = { name: 'spacer', leaf: true };
79
+ export const PRIMITIVES = [
80
+ {
81
+ component: 'box',
82
+ category: 'layout',
83
+ description: 'The container. Flex layout, background, border, title and footer.',
84
+ renderer: { kind: 'host', host: box },
85
+ role: 'presentation',
86
+ },
87
+ {
88
+ component: 'text',
89
+ category: 'display',
90
+ description: 'A run of text. Wraps, truncates and aligns within its box.',
91
+ renderer: { kind: 'host', host: text },
92
+ role: 'presentation',
93
+ },
94
+ {
95
+ component: 'canvas',
96
+ category: 'display',
97
+ description: 'Direct cell painting. The escape hatch charts and gauges use.',
98
+ renderer: { kind: 'host', host: canvas },
99
+ role: 'presentation',
100
+ },
101
+ {
102
+ component: 'spacer',
103
+ category: 'layout',
104
+ description: 'Empty space. Sized, or greedy when given flex.',
105
+ renderer: { kind: 'host', host: spacer },
106
+ role: 'presentation',
107
+ },
108
+ ];
@@ -0,0 +1,23 @@
1
+ import type { BoxProps } from '../jsx/intrinsics.js';
2
+ import type { ComponentDefinition } from '../types/component-registry.js';
3
+ import type { RenderOutput } from '../types/render.js';
4
+ /**
5
+ * What the navigator mounts.
6
+ *
7
+ * A screen is not a special kind of node - it is a mount in a surface, so the
8
+ * shell arranges it, the layouts apply to it, and everything that reads the
9
+ * surface registry sees it. What this adds is the one thing a screen needs
10
+ * that a mount does not have: a focus scope of its own.
11
+ *
12
+ * That scope is what makes the stack behave. Tab order belongs to what is on
13
+ * screen rather than to the application, and `pop` can put focus back where it
14
+ * was because "where it was" is a question about this scope and not about
15
+ * every focusable that ever registered.
16
+ */
17
+ export interface ScreenProps extends BoxProps {
18
+ screenId: string;
19
+ children?: RenderOutput;
20
+ }
21
+ export declare const Screen: (props: ScreenProps) => RenderOutput;
22
+ export declare const SCREEN_COMPONENTS: ComponentDefinition[];
23
+ //# sourceMappingURL=screen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"screen.d.ts","sourceRoot":"","sources":["../../src/ui/screen.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIvD;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,WAAY,SAAQ,QAAQ;IAC3C,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,YAAY,CAAC;CACzB;AAED,eAAO,MAAM,MAAM,sCAOjB,CAAC;AAEH,eAAO,MAAM,iBAAiB,EAAE,mBAAmB,EAOlD,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { defineComponent, h } from '../jsx/factory.js';
2
+ import { useFocusScope } from '../runtime/hooks.js';
3
+ export const Screen = defineComponent('Screen', (props) => {
4
+ const { screenId, children, ...rest } = props;
5
+ // A screen takes focus when it arrives. Pushing one unmounts whatever held
6
+ // focus, so without this the new screen is one no key reaches - and what it
7
+ // is showing cannot even be scrolled.
8
+ useFocusScope({ id: `screen:${screenId}`, restore: true, autoFocus: true });
9
+ return h('box', { direction: 'column', flex: 1, ...rest }, children);
10
+ });
11
+ export const SCREEN_COMPONENTS = [
12
+ {
13
+ component: 'Screen',
14
+ category: 'layout',
15
+ renderer: { kind: 'function', render: Screen },
16
+ description: 'The navigator’s mount: one screen, in its own focus scope.',
17
+ },
18
+ ];
@@ -0,0 +1,6 @@
1
+ import type { Disposable, DisposableBag } from '../types/disposable.js';
2
+ export declare const NOOP_DISPOSABLE: Disposable;
3
+ export declare function toDisposable(fn: () => void): Disposable;
4
+ export declare function disposeAll(items: Iterable<Disposable>): void;
5
+ export declare function createBag(): DisposableBag;
6
+ //# sourceMappingURL=disposable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"disposable.d.ts","sourceRoot":"","sources":["../../src/util/disposable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAExE,eAAO,MAAM,eAAe,EAAE,UAA6B,CAAC;AAE5D,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,UAAU,CASvD;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,IAAI,CAW5D;AAED,wBAAgB,SAAS,IAAI,aAAa,CAoBzC"}
@@ -0,0 +1,49 @@
1
+ export const NOOP_DISPOSABLE = { dispose() { } };
2
+ export function toDisposable(fn) {
3
+ let done = false;
4
+ return {
5
+ dispose() {
6
+ if (done)
7
+ return;
8
+ done = true;
9
+ fn();
10
+ },
11
+ };
12
+ }
13
+ export function disposeAll(items) {
14
+ const errors = [];
15
+ for (const d of items) {
16
+ try {
17
+ d.dispose();
18
+ }
19
+ catch (err) {
20
+ errors.push(err);
21
+ }
22
+ }
23
+ if (errors.length === 1)
24
+ throw errors[0];
25
+ if (errors.length > 1)
26
+ throw new AggregateError(errors, 'dispose failed');
27
+ }
28
+ export function createBag() {
29
+ const items = new Set();
30
+ let disposed = false;
31
+ return {
32
+ add(d) {
33
+ if (disposed) {
34
+ d.dispose();
35
+ return d;
36
+ }
37
+ items.add(d);
38
+ return d;
39
+ },
40
+ dispose() {
41
+ if (disposed)
42
+ return;
43
+ disposed = true;
44
+ const copy = [...items];
45
+ items.clear();
46
+ disposeAll(copy);
47
+ },
48
+ };
49
+ }
@@ -0,0 +1,24 @@
1
+ import type { MarkdownLayoutOptions, MarkdownRow, MarkdownRun } from '../types/markdown.js';
2
+ /**
3
+ * Emphasis, code and links, as styled runs.
4
+ *
5
+ * Unmatched markers stay literal: a lone asterisk in prose is an asterisk, and
6
+ * a document that reformats itself as the closing one arrives is worse than
7
+ * one that never tried.
8
+ */
9
+ export declare function inlineRuns(text: string): MarkdownRun[];
10
+ /**
11
+ * Fold styled runs into lines that fit.
12
+ *
13
+ * `wrapText` wraps a string, and a string cannot carry which half of it was
14
+ * bold - so the wrap happens over runs, on cell widths rather than character
15
+ * counts. A word longer than the whole width is broken rather than allowed to
16
+ * decide the width of the pane it is in.
17
+ */
18
+ export declare function wrapRuns(runs: MarkdownRun[], width: number): MarkdownRun[][];
19
+ export declare function layoutMarkdown(source: string | string[], options: MarkdownLayoutOptions): MarkdownRow[];
20
+ /** Every run's text, for a measurement or a test that does not care how it looks. */
21
+ export declare function runsToText(runs: MarkdownRun[]): string;
22
+ /** Wrap plain text the way a row does, for callers that have no runs. */
23
+ export declare function wrapAt(text: string, width: number): string[];
24
+ //# sourceMappingURL=markdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/util/markdown.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAsC5F;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,EAAE,CAiBtD;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,WAAW,EAAE,EAAE,CA2C5E;AAwBD,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,EACzB,OAAO,EAAE,qBAAqB,GAC7B,WAAW,EAAE,CAsEf;AAED,qFAAqF;AACrF,wBAAgB,UAAU,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,MAAM,CAEtD;AAED,yEAAyE;AACzE,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAI5D"}