@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,224 @@
1
+ const OPERATORS = ['&&', '||', '==', '!=', '>=', '<=', '=~', '!', '>', '<', '(', ')'];
2
+ function tokenize(input) {
3
+ const out = [];
4
+ let i = 0;
5
+ while (i < input.length) {
6
+ const c = input[i];
7
+ if (/\s/.test(c)) {
8
+ i++;
9
+ continue;
10
+ }
11
+ if (c === '$' && input[i + 1] === '/') {
12
+ let j = i + 2;
13
+ while (j < input.length && /[A-Za-z0-9_\-./*]/.test(input[j]))
14
+ j++;
15
+ out.push({ t: 'path', v: input.slice(i, j) });
16
+ i = j;
17
+ continue;
18
+ }
19
+ if (c === "'" || c === '"') {
20
+ let j = i + 1;
21
+ let v = '';
22
+ while (j < input.length && input[j] !== c) {
23
+ if (input[j] === '\\')
24
+ j++;
25
+ v += input[j];
26
+ j++;
27
+ }
28
+ out.push({ t: 'string', v });
29
+ i = j + 1;
30
+ continue;
31
+ }
32
+ if (/[0-9]/.test(c)) {
33
+ let j = i;
34
+ while (j < input.length && /[0-9.]/.test(input[j]))
35
+ j++;
36
+ out.push({ t: 'number', v: Number(input.slice(i, j)) });
37
+ i = j;
38
+ continue;
39
+ }
40
+ const op = OPERATORS.find((o) => input.startsWith(o, i));
41
+ if (op) {
42
+ out.push({ t: 'op', v: op });
43
+ i += op.length;
44
+ continue;
45
+ }
46
+ if (/[A-Za-z_]/.test(c)) {
47
+ let j = i;
48
+ while (j < input.length && /[A-Za-z0-9_.:-]/.test(input[j]))
49
+ j++;
50
+ out.push({ t: 'ident', v: input.slice(i, j) });
51
+ i = j;
52
+ continue;
53
+ }
54
+ throw new SyntaxError(`unexpected character "${c}" in when clause: ${input}`);
55
+ }
56
+ return out;
57
+ }
58
+ function truthy(v) {
59
+ if (v === undefined || v === null)
60
+ return false;
61
+ if (typeof v === 'boolean')
62
+ return v;
63
+ if (typeof v === 'number')
64
+ return v !== 0;
65
+ if (typeof v === 'string')
66
+ return v !== '' && v !== 'false';
67
+ if (Array.isArray(v))
68
+ return v.length > 0;
69
+ return true;
70
+ }
71
+ class Parser {
72
+ tokens;
73
+ resolve;
74
+ pos = 0;
75
+ constructor(tokens, resolve) {
76
+ this.tokens = tokens;
77
+ this.resolve = resolve;
78
+ }
79
+ parse() {
80
+ const v = this.or();
81
+ if (this.pos < this.tokens.length) {
82
+ throw new SyntaxError('trailing tokens in when clause');
83
+ }
84
+ return v;
85
+ }
86
+ peek() {
87
+ return this.tokens[this.pos];
88
+ }
89
+ eat(op) {
90
+ const t = this.peek();
91
+ if (t && t.t === 'op' && t.v === op) {
92
+ this.pos++;
93
+ return true;
94
+ }
95
+ return false;
96
+ }
97
+ or() {
98
+ let left = this.and();
99
+ while (this.eat('||')) {
100
+ const right = this.and();
101
+ left = truthy(left) || truthy(right);
102
+ }
103
+ return left;
104
+ }
105
+ and() {
106
+ let left = this.comparison();
107
+ while (this.eat('&&')) {
108
+ const right = this.comparison();
109
+ left = truthy(left) && truthy(right);
110
+ }
111
+ return left;
112
+ }
113
+ comparison() {
114
+ const left = this.unary();
115
+ for (const op of ['==', '!=', '>=', '<=', '>', '<', '=~']) {
116
+ if (this.eat(op)) {
117
+ const right = this.unary();
118
+ switch (op) {
119
+ case '==': return looseEquals(left, right);
120
+ case '!=': return !looseEquals(left, right);
121
+ case '>': return Number(left) > Number(right);
122
+ case '>=': return Number(left) >= Number(right);
123
+ case '<': return Number(left) < Number(right);
124
+ case '<=': return Number(left) <= Number(right);
125
+ case '=~': return new RegExp(String(right)).test(String(left ?? ''));
126
+ }
127
+ }
128
+ }
129
+ return left;
130
+ }
131
+ unary() {
132
+ if (this.eat('!'))
133
+ return !truthy(this.unary());
134
+ return this.primary();
135
+ }
136
+ primary() {
137
+ if (this.eat('(')) {
138
+ const v = this.or();
139
+ if (!this.eat(')'))
140
+ throw new SyntaxError('missing ")" in when clause');
141
+ return v;
142
+ }
143
+ const t = this.peek();
144
+ if (!t)
145
+ throw new SyntaxError('unexpected end of when clause');
146
+ this.pos++;
147
+ switch (t.t) {
148
+ case 'string': return t.v;
149
+ case 'number': return t.v;
150
+ case 'path': return this.resolve(t.v, true);
151
+ case 'ident':
152
+ if (t.v === 'true')
153
+ return true;
154
+ if (t.v === 'false')
155
+ return false;
156
+ if (t.v === 'null')
157
+ return null;
158
+ return this.resolve(t.v, false);
159
+ default:
160
+ throw new SyntaxError(`unexpected "${t.v}" in when clause`);
161
+ }
162
+ }
163
+ }
164
+ function looseEquals(a, b) {
165
+ if (a === b)
166
+ return true;
167
+ if (a == null || b == null)
168
+ return false;
169
+ if (typeof a === 'number' || typeof b === 'number')
170
+ return Number(a) === Number(b);
171
+ return String(a) === String(b);
172
+ }
173
+ export class When {
174
+ store;
175
+ context = new Map();
176
+ cache = new Map();
177
+ constructor(store) {
178
+ this.store = store;
179
+ }
180
+ evaluate(clause, extra) {
181
+ if (!clause || clause.trim() === '')
182
+ return true;
183
+ try {
184
+ let tokens = this.cache.get(clause);
185
+ if (!tokens) {
186
+ tokens = tokenize(clause);
187
+ this.cache.set(clause, tokens);
188
+ }
189
+ const resolve = (name, isPath) => {
190
+ if (isPath)
191
+ return this.store.get(name);
192
+ if (extra && name in extra)
193
+ return extra[name];
194
+ return this.context.get(name);
195
+ };
196
+ return truthy(new Parser(tokens, resolve).parse());
197
+ }
198
+ catch (err) {
199
+ // A malformed clause is a programmer error, and hiding chrome silently
200
+ // is worse than showing it - fail loud, render visible.
201
+ console.error(`[textui/when] bad clause "${clause}"`, err);
202
+ return true;
203
+ }
204
+ }
205
+ dependencies(clause) {
206
+ try {
207
+ return tokenize(clause)
208
+ .filter((t) => t.t === 'path')
209
+ .map((t) => t.v);
210
+ }
211
+ catch {
212
+ return [];
213
+ }
214
+ }
215
+ setContext(key, value) {
216
+ this.context.set(key, value);
217
+ }
218
+ getContext(key) {
219
+ return this.context.get(key);
220
+ }
221
+ }
222
+ export function createWhen(store) {
223
+ return new When(store);
224
+ }
@@ -0,0 +1,49 @@
1
+ export * from './types/index.js';
2
+ export { h, Fragment, defineComponent, componentNameOf, toSerializable, nodeFunction } from './jsx/factory.js';
3
+ export type { BoxProps, TextProps, CanvasProps, SpacerProps, BaseProps } from './jsx/intrinsics.js';
4
+ export { createStore, Store } from './core/store.js';
5
+ export { createEvents, Events } from './core/events.js';
6
+ export { createWhen, When } from './core/when.js';
7
+ export { createComponents, Components } from './core/components.js';
8
+ export { createServices, Services } from './core/services.js';
9
+ export { createCommands, Commands } from './core/commands.js';
10
+ export { createKeybindings, Keybindings, strokeOf, splitStroke, normalizeStroke } from './core/keybindings.js';
11
+ export { createFocus, Focus, GLOBAL_SCOPE } from './core/focus.js';
12
+ export { createLayers, Layers } from './core/layers.js';
13
+ export { createAnimation, Animation } from './core/animation.js';
14
+ export { createI18n, I18nRegistry } from './core/i18n.js';
15
+ export { CLIPBOARD_PATH, readClipboard, writeClipboard } from './core/clipboard.js';
16
+ export { serviceKey } from './types/services.js';
17
+ export { Buffer, createBuffer } from './render/buffer.js';
18
+ export { diffFrame } from './render/diff.js';
19
+ export type { Frame, Run } from './render/diff.js';
20
+ export * from './render/color.js';
21
+ export { layout, measureBox, resolveEdges } from './render/layout.js';
22
+ export type { LayoutBox } from './render/layout.js';
23
+ export { renderOnce, renderToString, createStaticRuntime } from './render/static.js';
24
+ export type { StaticRenderOptions, StaticRenderResult } from './render/static.js';
25
+ export type { Runtime } from './runtime/runtime.js';
26
+ export type { Instance } from './runtime/instance.js';
27
+ export { renderTree, collectEffects, disposeTree } from './runtime/reconcile.js';
28
+ export { buildBoxes, paintTree, createRenderContext } from './runtime/paint.js';
29
+ export type { PaintEnv } from './runtime/paint.js';
30
+ export * from './runtime/style.js';
31
+ export * from './runtime/hooks.js';
32
+ export { Screen, SCREEN_COMPONENTS } from './ui/screen.js';
33
+ export type { ScreenProps } from './ui/screen.js';
34
+ export { App, createApp, WRITER_KEY } from './app/app.js';
35
+ export type { FrameWriter } from './app/app.js';
36
+ export { createSurfaces, createLayouts, createShells, SURFACE_NAMES } from './core/surfaces.js';
37
+ export { createNavigation, Navigation } from './core/navigation.js';
38
+ export { createResources, Resources } from './core/resources.js';
39
+ export { createSyntax, Syntax, nameOf, plainTokens, tokensFromSpans, spanHighlighter, } from './core/syntax.js';
40
+ export { createManifests, Manifests } from './core/manifest.js';
41
+ export * from './themes/index.js';
42
+ export { PRIMITIVES, Box, Text, Canvas, Spacer } from './ui/primitives.js';
43
+ export * from './adapters/index.js';
44
+ export * from './util/text.js';
45
+ export * from './util/markdown.js';
46
+ export * from './util/paths.js';
47
+ export * from './util/stream.js';
48
+ export { createBag, toDisposable, disposeAll, NOOP_DISPOSABLE } from './util/disposable.js';
49
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,kBAAkB,CAAC;AAGjC,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,eAAe,EAAE,eAAe,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC/G,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGpG,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAA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dist/index.js ADDED
@@ -0,0 +1,54 @@
1
+ // Contracts
2
+ export * from './types/index.js';
3
+ // JSX
4
+ export { h, Fragment, defineComponent, componentNameOf, toSerializable, nodeFunction } from './jsx/factory.js';
5
+ // Core
6
+ export { createStore, Store } from './core/store.js';
7
+ export { createEvents, Events } from './core/events.js';
8
+ export { createWhen, When } from './core/when.js';
9
+ export { createComponents, Components } from './core/components.js';
10
+ export { createServices, Services } from './core/services.js';
11
+ export { createCommands, Commands } from './core/commands.js';
12
+ export { createKeybindings, Keybindings, strokeOf, splitStroke, normalizeStroke } from './core/keybindings.js';
13
+ export { createFocus, Focus, GLOBAL_SCOPE } from './core/focus.js';
14
+ export { createLayers, Layers } from './core/layers.js';
15
+ export { createAnimation, Animation } from './core/animation.js';
16
+ export { createI18n, I18nRegistry } from './core/i18n.js';
17
+ export { CLIPBOARD_PATH, readClipboard, writeClipboard } from './core/clipboard.js';
18
+ export { serviceKey } from './types/services.js';
19
+ // Render
20
+ export { Buffer, createBuffer } from './render/buffer.js';
21
+ export { diffFrame } from './render/diff.js';
22
+ export * from './render/color.js';
23
+ export { layout, measureBox, resolveEdges } from './render/layout.js';
24
+ export { renderOnce, renderToString, createStaticRuntime } from './render/static.js';
25
+ export { renderTree, collectEffects, disposeTree } from './runtime/reconcile.js';
26
+ export { buildBoxes, paintTree, createRenderContext } from './runtime/paint.js';
27
+ export * from './runtime/style.js';
28
+ export * from './runtime/hooks.js';
29
+ export { Screen, SCREEN_COMPONENTS } from './ui/screen.js';
30
+ // The application
31
+ export { App, createApp, WRITER_KEY } from './app/app.js';
32
+ // Registries
33
+ export { createSurfaces, createLayouts, createShells, SURFACE_NAMES } from './core/surfaces.js';
34
+ export { createNavigation, Navigation } from './core/navigation.js';
35
+ export { createResources, Resources } from './core/resources.js';
36
+ export { createSyntax, Syntax, nameOf, plainTokens, tokensFromSpans, spanHighlighter, } from './core/syntax.js';
37
+ export { createManifests, Manifests } from './core/manifest.js';
38
+ // Themes
39
+ export * from './themes/index.js';
40
+ // The host primitives.
41
+ //
42
+ // Not the catalog - that is `@textui/widgets`. These four are what the layout
43
+ // engine and the painter actually reason about, so they belong to the runtime
44
+ // that reasons about them. `Box`, `Text` and `Canvas` are the Capitalized
45
+ // spellings, and they are the strings themselves.
46
+ export { PRIMITIVES, Box, Text, Canvas, Spacer } from './ui/primitives.js';
47
+ // Adapters
48
+ export * from './adapters/index.js';
49
+ // Utilities
50
+ export * from './util/text.js';
51
+ export * from './util/markdown.js';
52
+ export * from './util/paths.js';
53
+ export * from './util/stream.js';
54
+ export { createBag, toDisposable, disposeAll, NOOP_DISPOSABLE } from './util/disposable.js';
@@ -0,0 +1,27 @@
1
+ import type { ComponentNode } from '../types/graph.js';
2
+ import type { FunctionComponent, RenderOutput } from '../types/render.js';
3
+ /** The registry name for a function component, assigning one if needed. */
4
+ export declare function componentNameOf(fn: FunctionComponent): string;
5
+ /** Name a component explicitly. Do this for anything the registry exposes. */
6
+ export declare function defineComponent<P>(name: string, fn: (props: P) => RenderOutput): (props: P) => RenderOutput;
7
+ export declare function isNamed(fn: unknown): boolean;
8
+ export declare const Fragment: (props: {
9
+ children?: unknown;
10
+ }) => RenderOutput;
11
+ export type ElementType = string | FunctionComponent;
12
+ /**
13
+ * Build a node. `key` is lifted out of props because it is reconciliation
14
+ * identity, not data the component receives.
15
+ */
16
+ export declare function h(type: ElementType, props?: (Record<string, unknown> & {
17
+ key?: string | number;
18
+ }) | null, ...children: unknown[]): ComponentNode;
19
+ /** The function behind a node built from a function component, if any. */
20
+ export declare function nodeFunction(node: ComponentNode): FunctionComponent | undefined;
21
+ /**
22
+ * Strip everything unserializable so a node can be persisted or sent. Closures
23
+ * (`$meta.fn`, `{ handler }` actions, function props) are dropped, which is
24
+ * exactly the set of things that only mean something in this process.
25
+ */
26
+ export declare function toSerializable(node: ComponentNode): ComponentNode;
27
+ //# sourceMappingURL=factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/jsx/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAa,MAAM,mBAAmB,CAAC;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AA2B1E,2EAA2E;AAC3E,wBAAgB,eAAe,CAAC,EAAE,EAAE,iBAAiB,GAAG,MAAM,CAW7D;AAED,8EAA8E;AAC9E,wBAAgB,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,YAAY,GAAG,CAAC,KAAK,EAAE,CAAC,KAAK,YAAY,CAI3G;AAED,wBAAgB,OAAO,CAAC,EAAE,EAAE,OAAO,GAAG,OAAO,CAE5C;AAED,eAAO,MAAM,QAAQ;eAAgC,OAAO;MAVoC,YAY9F,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,iBAAiB,CAAC;AAErD;;;GAGG;AACH,wBAAgB,CAAC,CACf,IAAI,EAAE,WAAW,EACjB,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC,GAAG,IAAI,EACpE,GAAG,QAAQ,EAAE,OAAO,EAAE,GACrB,aAAa,CAcf;AAED,0EAA0E;AAC1E,wBAAgB,YAAY,CAAC,IAAI,EAAE,aAAa,GAAG,iBAAiB,GAAG,SAAS,CAG/E;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,aAAa,GAAG,aAAa,CAWjE"}
@@ -0,0 +1,102 @@
1
+ /**
2
+ * JSX compiles to component nodes.
3
+ *
4
+ * `<Row gap={1}/>` and `{ component: 'Row', gap: 1 }` are the same value, so a
5
+ * screen written in TypeScript, loaded from JSON or generated by something
6
+ * else all reach the runtime as one shape. That is the whole trick, and it is
7
+ * why every prop should stay serializable: a closure in a node is legal but
8
+ * marks the node as in-process only.
9
+ *
10
+ * The naming rule mirrors HTML's: **lowercase is a host primitive**
11
+ * (`box`, `text`, `canvas`, `spacer`), **Capitalized is a registered
12
+ * component** resolved through the registry at mount time.
13
+ */
14
+ const NAME = Symbol.for('textui.componentName');
15
+ let anonymousCounter = 0;
16
+ /** The registry name for a function component, assigning one if needed. */
17
+ export function componentNameOf(fn) {
18
+ const f = fn;
19
+ const existing = f[NAME];
20
+ if (existing)
21
+ return existing;
22
+ const inferred = f.displayName || f.name;
23
+ const name = inferred && inferred !== 'anonymous'
24
+ ? inferred
25
+ : `Anonymous${++anonymousCounter}`;
26
+ f[NAME] = name;
27
+ return name;
28
+ }
29
+ /** Name a component explicitly. Do this for anything the registry exposes. */
30
+ export function defineComponent(name, fn) {
31
+ fn[NAME] = name;
32
+ fn.displayName = name;
33
+ return fn;
34
+ }
35
+ export function isNamed(fn) {
36
+ return typeof fn === 'function' && fn[NAME] !== undefined;
37
+ }
38
+ export const Fragment = defineComponent('Fragment', (props) => {
39
+ return (props.children ?? null);
40
+ });
41
+ /**
42
+ * Build a node. `key` is lifted out of props because it is reconciliation
43
+ * identity, not data the component receives.
44
+ */
45
+ export function h(type, props, ...children) {
46
+ const { key, ...rest } = props ?? {};
47
+ const node = typeof type === 'string'
48
+ ? { component: type, ...rest }
49
+ : { component: componentNameOf(type), ...rest, $meta: { fn: type } };
50
+ if (children.length > 0) {
51
+ node.children = (children.length === 1 ? children[0] : children);
52
+ }
53
+ if (key !== undefined)
54
+ node.key = key;
55
+ return node;
56
+ }
57
+ /** The function behind a node built from a function component, if any. */
58
+ export function nodeFunction(node) {
59
+ const fn = node.$meta?.fn;
60
+ return typeof fn === 'function' ? fn : undefined;
61
+ }
62
+ /**
63
+ * Strip everything unserializable so a node can be persisted or sent. Closures
64
+ * (`$meta.fn`, `{ handler }` actions, function props) are dropped, which is
65
+ * exactly the set of things that only mean something in this process.
66
+ */
67
+ export function toSerializable(node) {
68
+ const out = { component: node.component };
69
+ if (node.id !== undefined)
70
+ out.id = node.id;
71
+ if (node.key !== undefined)
72
+ out.key = node.key;
73
+ for (const [k, v] of Object.entries(node)) {
74
+ if (k === 'component' || k === 'id' || k === 'key' || k === '$meta')
75
+ continue;
76
+ const clean = cleanValue(v);
77
+ if (clean !== undefined)
78
+ out[k] = clean;
79
+ }
80
+ return out;
81
+ }
82
+ function cleanValue(v) {
83
+ if (typeof v === 'function')
84
+ return undefined;
85
+ if (v === null || typeof v !== 'object')
86
+ return v;
87
+ if (Array.isArray(v)) {
88
+ const arr = v.map(cleanValue).filter((x) => x !== undefined);
89
+ return arr;
90
+ }
91
+ if ('component' in v)
92
+ return toSerializable(v);
93
+ if ('handler' in v)
94
+ return undefined;
95
+ const out = {};
96
+ for (const [k, val] of Object.entries(v)) {
97
+ const clean = cleanValue(val);
98
+ if (clean !== undefined)
99
+ out[k] = clean;
100
+ }
101
+ return out;
102
+ }
@@ -0,0 +1,96 @@
1
+ import type { Style, StyleInput } from '../types/style.js';
2
+ import type { SemanticRole } from '../types/component-registry.js';
3
+ import type { KeyEvent, MouseEvent } from '../types/input.js';
4
+ import type { PaintSurface, RenderContext } from '../types/render.js';
5
+ import type { Action } from '../types/graph.js';
6
+ /**
7
+ * Props every node accepts.
8
+ *
9
+ * Style arrives three ways on purpose: the full `style` object for anything
10
+ * stateful, a merged list for composition, and the individual style keys
11
+ * inline as convenience props - `<box gap={1} border="single">` rather than
12
+ * `<box style={{ gap: 1, border: 'single' }}>` for the common case.
13
+ */
14
+ export interface BaseProps extends Style {
15
+ id?: string;
16
+ key?: string | number;
17
+ style?: StyleInput;
18
+ /** Semantic metadata. Drives the test harness, and future a11y work. */
19
+ role?: SemanticRole;
20
+ label?: string;
21
+ description?: string;
22
+ disabled?: boolean;
23
+ selected?: boolean;
24
+ /** Participates in tab order. Implied by an interactive role. */
25
+ focusable?: boolean;
26
+ /** The focus scope this node belongs to. */
27
+ focusScope?: string;
28
+ autoFocus?: boolean;
29
+ /**
30
+ * `onKey` runs whether or not this node is focused.
31
+ *
32
+ * For a node that wraps something else and wants the keys that thing
33
+ * declines - a dropdown panel taking left and right while the menu inside it
34
+ * keeps up and down. Without this a handler only runs while focused, which
35
+ * is what focus means.
36
+ */
37
+ global?: boolean;
38
+ onKey?(event: KeyEvent): boolean | void;
39
+ onFocus?(): void;
40
+ onBlur?(): void;
41
+ onMouse?(event: MouseEvent): boolean | void;
42
+ onClick?: Action | ((event: MouseEvent) => void);
43
+ onHover?(hovering: boolean): void;
44
+ /** OSC 8 link target, where the terminal supports hyperlinks. */
45
+ link?: string;
46
+ /** Below this width the node renders `compact`; below that, `minimal`. */
47
+ breakpoints?: {
48
+ compact?: number;
49
+ minimal?: number;
50
+ };
51
+ }
52
+ export interface BoxProps extends BaseProps {
53
+ children?: unknown;
54
+ /** Header text drawn into the top border. Needs a border to land on. */
55
+ title?: string;
56
+ titleAlign?: 'left' | 'center' | 'right';
57
+ /**
58
+ * A second label on the top border, hard against the right.
59
+ *
60
+ * For the short thing that belongs beside a heading rather than under it - a
61
+ * count, a shortcut, a state. It takes its space first and `title` gets what
62
+ * is left, so the two never collide and the title is the one that truncates.
63
+ */
64
+ rightTitle?: string;
65
+ /** Footer text drawn into the bottom border. */
66
+ footer?: string;
67
+ footerAlign?: 'left' | 'center' | 'right';
68
+ /** Scroll offset in cells, when overflow is 'scroll'. */
69
+ scrollTop?: number;
70
+ scrollLeft?: number;
71
+ }
72
+ export interface TextProps extends BaseProps {
73
+ children?: unknown;
74
+ /** The string to draw. `children` is accepted as a shorthand. */
75
+ content?: string;
76
+ /** Where to cut when the text does not fit. */
77
+ truncate?: 'end' | 'start' | 'middle' | false;
78
+ ellipsis?: string;
79
+ }
80
+ export interface CanvasProps extends BaseProps {
81
+ /**
82
+ * Paint directly. The escape hatch charts and gauges use; everything else
83
+ * should compose `box` and `text` so the layout engine can reason about it.
84
+ */
85
+ draw(surface: PaintSurface, ctx: RenderContext): void;
86
+ /** Intrinsic size when the style does not fix one. */
87
+ intrinsic?: {
88
+ width?: number;
89
+ height?: number;
90
+ };
91
+ }
92
+ export interface SpacerProps extends BaseProps {
93
+ /** Cells to take. Unset means "take whatever is left", the same as `flex: 1`. */
94
+ size?: number;
95
+ }
96
+ //# sourceMappingURL=intrinsics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intrinsics.d.ts","sourceRoot":"","sources":["../../src/jsx/intrinsics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;;;;;;GAOG;AACH,MAAM,WAAW,SAAU,SAAQ,KAAK;IACtC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,UAAU,CAAC;IAEnB,wEAAwE;IACxE,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,iEAAiE;IACjE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,4CAA4C;IAC5C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB,KAAK,CAAC,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,GAAG,IAAI,CAA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G;IACH,IAAI,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,aAAa,GAAG,IAAI,CAAC;IACtD,sDAAsD;IACtD,SAAS,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACjD;AAED,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,iFAAiF;IACjF,IAAI,CAAC,EAAE,MAAM,CAAC;CACf"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ import type { ComponentNode } from '../types/graph.js';
2
+ import type { FunctionComponent } from '../types/render.js';
3
+ import { Fragment, type JSX } from './jsx-runtime.js';
4
+ export { Fragment };
5
+ export type { JSX };
6
+ export declare function jsxDEV(type: string | FunctionComponent, props: Record<string, unknown> & {
7
+ children?: unknown;
8
+ }, key: string | number | undefined, _isStatic: boolean, source?: {
9
+ fileName: string;
10
+ lineNumber: number;
11
+ columnNumber: number;
12
+ }): ComponentNode;
13
+ //# sourceMappingURL=jsx-dev-runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsx-dev-runtime.d.ts","sourceRoot":"","sources":["../../src/jsx/jsx-dev-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAO,QAAQ,EAAE,KAAK,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAE3D,OAAO,EAAE,QAAQ,EAAE,CAAC;AACpB,YAAY,EAAE,GAAG,EAAE,CAAC;AAEpB,wBAAgB,MAAM,CACpB,IAAI,EAAE,MAAM,GAAG,iBAAiB,EAChC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,EACvD,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,EAChC,SAAS,EAAE,OAAO,EAClB,MAAM,CAAC,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,GACtE,aAAa,CASf"}
@@ -0,0 +1,12 @@
1
+ import { jsx, Fragment } from './jsx-runtime.js';
2
+ export { Fragment };
3
+ export function jsxDEV(type, props, key, _isStatic, source) {
4
+ const node = jsx(type, props, key);
5
+ if (source) {
6
+ node.$meta = {
7
+ ...node.$meta,
8
+ source: { file: source.fileName, line: source.lineNumber, column: source.columnNumber },
9
+ };
10
+ }
11
+ return node;
12
+ }
@@ -0,0 +1,42 @@
1
+ import type { ComponentNode } from '../types/graph.js';
2
+ import type { FunctionComponent } from '../types/render.js';
3
+ import type { RenderOutput } from '../types/render.js';
4
+ import { Fragment } from './factory.js';
5
+ import type { BoxProps, CanvasProps, SpacerProps, TextProps } from './intrinsics.js';
6
+ export { Fragment };
7
+ export type { BoxProps, TextProps, CanvasProps, SpacerProps };
8
+ type Props = Record<string, unknown> & {
9
+ children?: unknown;
10
+ };
11
+ export declare function jsx(type: string | FunctionComponent, props: Props, key?: string | number): ComponentNode;
12
+ export declare function jsxs(type: string | FunctionComponent, props: Props, key?: string | number): ComponentNode;
13
+ export declare namespace JSX {
14
+ type Element = ComponentNode;
15
+ /**
16
+ * What may appear as a JSX tag.
17
+ *
18
+ * A component returns `RenderOutput` - a node, a list, a string, or nothing -
19
+ * rather than exactly one element. Without this, TypeScript insists every
20
+ * component return a single node, and `return null` stops compiling.
21
+ */
22
+ type ElementType = string | ((props: never) => RenderOutput);
23
+ interface ElementChildrenAttribute {
24
+ children: unknown;
25
+ }
26
+ /**
27
+ * Lowercase names are host primitives - the only three shapes the layout
28
+ * engine reasons about, plus a spacer. Everything Capitalized is a component
29
+ * you import, which is what gives it prop types.
30
+ */
31
+ interface IntrinsicElements {
32
+ box: BoxProps;
33
+ text: TextProps;
34
+ canvas: CanvasProps;
35
+ spacer: SpacerProps;
36
+ }
37
+ interface IntrinsicAttributes {
38
+ key?: string | number;
39
+ id?: string;
40
+ }
41
+ }
42
+ //# sourceMappingURL=jsx-runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsx-runtime.d.ts","sourceRoot":"","sources":["../../src/jsx/jsx-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAmB,QAAQ,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAErF,OAAO,EAAE,QAAQ,EAAE,CAAC;AACpB,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC;AAE9D,KAAK,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAe9D,wBAAgB,GAAG,CACjB,IAAI,EAAE,MAAM,GAAG,iBAAiB,EAChC,KAAK,EAAE,KAAK,EACZ,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,GACpB,aAAa,CAEf;AAED,wBAAgB,IAAI,CAClB,IAAI,EAAE,MAAM,GAAG,iBAAiB,EAChC,KAAK,EAAE,KAAK,EACZ,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,GACpB,aAAa,CAEf;AAKD,MAAM,CAAC,OAAO,WAAW,GAAG,CAAC;IAC3B,KAAK,OAAO,GAAG,aAAa,CAAC;IAE7B;;;;;;OAMG;IACH,KAAK,WAAW,GAAG,MAAM,GAAG,CAAC,CAAC,KAAK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