knobkit 0.0.1

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 (361) hide show
  1. package/LICENSE +21 -0
  2. package/dist/assets/cell-renderer-CLTRlCa5-DIlwS99c.js +1 -0
  3. package/dist/assets/chart-D8ctp-_1.js +36 -0
  4. package/dist/assets/code-BMuLQBYq.js +2 -0
  5. package/dist/assets/column.service-C6hByxPy-XG9X0y3N.js +1 -0
  6. package/dist/assets/debounce-PCRWZliA-BjJpj_P7.js +32 -0
  7. package/dist/assets/dimension.helpers-CGKwSvw6-D_czicbS.js +1 -0
  8. package/dist/assets/dist-1hsZpGRf.js +23 -0
  9. package/dist/assets/dist-B-y4Etc5.js +1 -0
  10. package/dist/assets/dist-B8BXgMDk.js +10 -0
  11. package/dist/assets/dist-BJlXPLNt.js +1 -0
  12. package/dist/assets/dist-ByhR2UY_.js +1 -0
  13. package/dist/assets/dist-C0bxYHYH.js +2 -0
  14. package/dist/assets/dist-C8dagUDy.js +6 -0
  15. package/dist/assets/dist-CtLpohkg.js +1 -0
  16. package/dist/assets/dist-D00mNtIr.js +1 -0
  17. package/dist/assets/dist-Dh1Dvy3h.js +1 -0
  18. package/dist/assets/dist-DlwQ1Qqm.js +1 -0
  19. package/dist/assets/dist-DtZDI7jp.js +1 -0
  20. package/dist/assets/dist-thZFs69d.js +9 -0
  21. package/dist/assets/edit.utils-Dnnbd0xG-OAxDw8WC.js +1 -0
  22. package/dist/assets/events-BvSmBueA-4kqQ57iN.js +1 -0
  23. package/dist/assets/filter.button-BFwo1uvz-CyvQhOO5.js +1 -0
  24. package/dist/assets/header-cell-renderer-BMmXRsd_-BHbC7fao.js +1 -0
  25. package/dist/assets/index-Db3qZoW5-peeY7EGw.js +1 -0
  26. package/dist/assets/markdown-dDCgur7g.js +29 -0
  27. package/dist/assets/revo-grid.entry-CfI6s-uT.js +1 -0
  28. package/dist/assets/revogr-attribution_7.entry-6fUjzImt.js +1 -0
  29. package/dist/assets/revogr-clipboard_3.entry-DmI7LkER.js +2 -0
  30. package/dist/assets/revogr-data_4.entry-CYZIiXNw.js +1 -0
  31. package/dist/assets/revogr-filter-panel.entry-TmQHTQxw.js +1 -0
  32. package/dist/assets/table-Zn7rpfG-.js +1 -0
  33. package/dist/assets/text-editor-C3RUSwH5-DuDr9wKc.js +1 -0
  34. package/dist/assets/theme.service-BmnDvr6P-DftEgmbe.js +3 -0
  35. package/dist/assets/throttle-CaUDyxyU-Djj__DCp.js +1 -0
  36. package/dist/assets/viewport.helpers-CoCAvmZs-ByVRjjkF.js +1 -0
  37. package/dist/assets/viewport.store-_c579YyM-B_ZSqqka.js +1 -0
  38. package/dist/cli/config.d.ts +5 -0
  39. package/dist/cli/config.js +82 -0
  40. package/dist/cli/index.d.ts +2 -0
  41. package/dist/cli/index.js +77 -0
  42. package/dist/cli/mount.d.ts +2 -0
  43. package/dist/cli/mount.js +26 -0
  44. package/dist/cli/serve.d.ts +1 -0
  45. package/dist/cli/serve.js +21 -0
  46. package/dist/client/app.d.ts +8 -0
  47. package/dist/client/app.js +40 -0
  48. package/dist/client/context.d.ts +2 -0
  49. package/dist/client/context.js +16 -0
  50. package/dist/client/mount.d.ts +3 -0
  51. package/dist/client/mount.js +42 -0
  52. package/dist/client/runtime.d.ts +19 -0
  53. package/dist/client/runtime.js +88 -0
  54. package/dist/client/view.d.ts +12 -0
  55. package/dist/client/view.js +1 -0
  56. package/dist/client/widgets/accordion/index.d.ts +5 -0
  57. package/dist/client/widgets/accordion/index.js +8 -0
  58. package/dist/client/widgets/annotated-image/index.d.ts +8 -0
  59. package/dist/client/widgets/annotated-image/index.js +34 -0
  60. package/dist/client/widgets/audio/index.d.ts +5 -0
  61. package/dist/client/widgets/audio/index.js +5 -0
  62. package/dist/client/widgets/button/index.d.ts +4 -0
  63. package/dist/client/widgets/button/index.js +5 -0
  64. package/dist/client/widgets/chart/index.d.ts +5 -0
  65. package/dist/client/widgets/chart/index.js +23 -0
  66. package/dist/client/widgets/chart/lazy.d.ts +3 -0
  67. package/dist/client/widgets/chart/lazy.js +9 -0
  68. package/dist/client/widgets/chat/index.d.ts +6 -0
  69. package/dist/client/widgets/chat/index.js +77 -0
  70. package/dist/client/widgets/checkbox/index.d.ts +6 -0
  71. package/dist/client/widgets/checkbox/index.js +9 -0
  72. package/dist/client/widgets/checkbox-group/index.d.ts +6 -0
  73. package/dist/client/widgets/checkbox-group/index.js +12 -0
  74. package/dist/client/widgets/code/index.d.ts +5 -0
  75. package/dist/client/widgets/code/index.js +101 -0
  76. package/dist/client/widgets/code/lazy.d.ts +3 -0
  77. package/dist/client/widgets/code/lazy.js +10 -0
  78. package/dist/client/widgets/dropdown/index.d.ts +5 -0
  79. package/dist/client/widgets/dropdown/index.js +9 -0
  80. package/dist/client/widgets/file/index.d.ts +6 -0
  81. package/dist/client/widgets/file/index.js +7 -0
  82. package/dist/client/widgets/frame/index.d.ts +6 -0
  83. package/dist/client/widgets/frame/index.js +11 -0
  84. package/dist/client/widgets/gallery/index.d.ts +6 -0
  85. package/dist/client/widgets/gallery/index.js +8 -0
  86. package/dist/client/widgets/highlighted-text/index.d.ts +7 -0
  87. package/dist/client/widgets/highlighted-text/index.js +20 -0
  88. package/dist/client/widgets/html/index.d.ts +4 -0
  89. package/dist/client/widgets/html/index.js +8 -0
  90. package/dist/client/widgets/image/index.d.ts +4 -0
  91. package/dist/client/widgets/image/index.js +4 -0
  92. package/dist/client/widgets/json/index.d.ts +4 -0
  93. package/dist/client/widgets/json/index.js +4 -0
  94. package/dist/client/widgets/label/index.d.ts +7 -0
  95. package/dist/client/widgets/label/index.js +8 -0
  96. package/dist/client/widgets/layout/index.d.ts +4 -0
  97. package/dist/client/widgets/layout/index.js +7 -0
  98. package/dist/client/widgets/log/index.d.ts +4 -0
  99. package/dist/client/widgets/log/index.js +4 -0
  100. package/dist/client/widgets/mic/index.d.ts +6 -0
  101. package/dist/client/widgets/mic/index.js +70 -0
  102. package/dist/client/widgets/number/index.d.ts +5 -0
  103. package/dist/client/widgets/number/index.js +8 -0
  104. package/dist/client/widgets/output/index.d.ts +6 -0
  105. package/dist/client/widgets/output/index.js +13 -0
  106. package/dist/client/widgets/output/markdown.d.ts +3 -0
  107. package/dist/client/widgets/output/markdown.js +8 -0
  108. package/dist/client/widgets/progress/index.d.ts +6 -0
  109. package/dist/client/widgets/progress/index.js +6 -0
  110. package/dist/client/widgets/radio/index.d.ts +6 -0
  111. package/dist/client/widgets/radio/index.js +10 -0
  112. package/dist/client/widgets/registry.d.ts +2 -0
  113. package/dist/client/widgets/registry.js +69 -0
  114. package/dist/client/widgets/slider/index.d.ts +6 -0
  115. package/dist/client/widgets/slider/index.js +9 -0
  116. package/dist/client/widgets/table/index.d.ts +6 -0
  117. package/dist/client/widgets/table/index.js +72 -0
  118. package/dist/client/widgets/table/lazy.d.ts +3 -0
  119. package/dist/client/widgets/table/lazy.js +16 -0
  120. package/dist/client/widgets/tabs/index.d.ts +5 -0
  121. package/dist/client/widgets/tabs/index.js +10 -0
  122. package/dist/client/widgets/text/index.d.ts +6 -0
  123. package/dist/client/widgets/text/index.js +10 -0
  124. package/dist/client/widgets/upload/index.d.ts +6 -0
  125. package/dist/client/widgets/upload/index.js +16 -0
  126. package/dist/client/widgets/video/index.d.ts +5 -0
  127. package/dist/client/widgets/video/index.js +5 -0
  128. package/dist/client/widgets/webcam/index.d.ts +6 -0
  129. package/dist/client/widgets/webcam/index.js +62 -0
  130. package/dist/client.css +1 -0
  131. package/dist/client.js +11 -0
  132. package/dist/knobkit.browser.css +2 -0
  133. package/dist/knobkit.browser.js +151 -0
  134. package/dist/lib/bound.d.ts +12 -0
  135. package/dist/lib/bound.js +10 -0
  136. package/dist/lib/controls.d.ts +9 -0
  137. package/dist/lib/controls.js +35 -0
  138. package/dist/lib/ctx.d.ts +9 -0
  139. package/dist/lib/ctx.js +22 -0
  140. package/dist/lib/declare.d.ts +18 -0
  141. package/dist/lib/declare.js +43 -0
  142. package/dist/lib/event.d.ts +2 -0
  143. package/dist/lib/event.js +9 -0
  144. package/dist/lib/index.d.ts +10 -0
  145. package/dist/lib/index.js +6 -0
  146. package/dist/lib/knobkit.d.ts +19 -0
  147. package/dist/lib/knobkit.js +48 -0
  148. package/dist/lib/on.d.ts +2 -0
  149. package/dist/lib/on.js +1 -0
  150. package/dist/lib/stream.d.ts +1 -0
  151. package/dist/lib/stream.js +33 -0
  152. package/dist/lib/types.d.ts +48 -0
  153. package/dist/lib/types.js +1 -0
  154. package/dist/lib/widget.d.ts +7 -0
  155. package/dist/lib/widget.js +4 -0
  156. package/dist/lib/widgets/annotated-image.d.ts +14 -0
  157. package/dist/lib/widgets/annotated-image.js +16 -0
  158. package/dist/lib/widgets/audio.d.ts +10 -0
  159. package/dist/lib/widgets/audio.js +13 -0
  160. package/dist/lib/widgets/button.d.ts +11 -0
  161. package/dist/lib/widgets/button.js +17 -0
  162. package/dist/lib/widgets/chart.d.ts +20 -0
  163. package/dist/lib/widgets/chart.js +24 -0
  164. package/dist/lib/widgets/chat.d.ts +26 -0
  165. package/dist/lib/widgets/chat.js +24 -0
  166. package/dist/lib/widgets/checkbox-group.d.ts +4 -0
  167. package/dist/lib/widgets/checkbox-group.js +5 -0
  168. package/dist/lib/widgets/checkbox.d.ts +4 -0
  169. package/dist/lib/widgets/checkbox.js +4 -0
  170. package/dist/lib/widgets/code.d.ts +5 -0
  171. package/dist/lib/widgets/code.js +10 -0
  172. package/dist/lib/widgets/dropdown.d.ts +4 -0
  173. package/dist/lib/widgets/dropdown.js +4 -0
  174. package/dist/lib/widgets/embed.d.ts +5 -0
  175. package/dist/lib/widgets/embed.js +23 -0
  176. package/dist/lib/widgets/file.d.ts +11 -0
  177. package/dist/lib/widgets/file.js +15 -0
  178. package/dist/lib/widgets/frame.d.ts +18 -0
  179. package/dist/lib/widgets/frame.js +25 -0
  180. package/dist/lib/widgets/gallery.d.ts +12 -0
  181. package/dist/lib/widgets/gallery.js +17 -0
  182. package/dist/lib/widgets/highlighted-text.d.ts +12 -0
  183. package/dist/lib/widgets/highlighted-text.js +15 -0
  184. package/dist/lib/widgets/html.d.ts +9 -0
  185. package/dist/lib/widgets/html.js +12 -0
  186. package/dist/lib/widgets/image.d.ts +7 -0
  187. package/dist/lib/widgets/image.js +12 -0
  188. package/dist/lib/widgets/index.d.ts +31 -0
  189. package/dist/lib/widgets/index.js +31 -0
  190. package/dist/lib/widgets/json.d.ts +7 -0
  191. package/dist/lib/widgets/json.js +12 -0
  192. package/dist/lib/widgets/label.d.ts +15 -0
  193. package/dist/lib/widgets/label.js +18 -0
  194. package/dist/lib/widgets/layout.d.ts +21 -0
  195. package/dist/lib/widgets/layout.js +29 -0
  196. package/dist/lib/widgets/log.d.ts +8 -0
  197. package/dist/lib/widgets/log.js +15 -0
  198. package/dist/lib/widgets/mic.d.ts +19 -0
  199. package/dist/lib/widgets/mic.js +28 -0
  200. package/dist/lib/widgets/number.d.ts +5 -0
  201. package/dist/lib/widgets/number.js +4 -0
  202. package/dist/lib/widgets/output.d.ts +10 -0
  203. package/dist/lib/widgets/output.js +13 -0
  204. package/dist/lib/widgets/progress.d.ts +10 -0
  205. package/dist/lib/widgets/progress.js +15 -0
  206. package/dist/lib/widgets/radio.d.ts +4 -0
  207. package/dist/lib/widgets/radio.js +5 -0
  208. package/dist/lib/widgets/slider.d.ts +6 -0
  209. package/dist/lib/widgets/slider.js +6 -0
  210. package/dist/lib/widgets/table.d.ts +32 -0
  211. package/dist/lib/widgets/table.js +36 -0
  212. package/dist/lib/widgets/text.d.ts +4 -0
  213. package/dist/lib/widgets/text.js +4 -0
  214. package/dist/lib/widgets/upload.d.ts +3 -0
  215. package/dist/lib/widgets/upload.js +5 -0
  216. package/dist/lib/widgets/value.d.ts +9 -0
  217. package/dist/lib/widgets/value.js +20 -0
  218. package/dist/lib/widgets/video.d.ts +12 -0
  219. package/dist/lib/widgets/video.js +14 -0
  220. package/dist/lib/widgets/webcam.d.ts +21 -0
  221. package/dist/lib/widgets/webcam.js +29 -0
  222. package/dist/server/context.d.ts +2 -0
  223. package/dist/server/context.js +10 -0
  224. package/dist/server/serve.d.ts +5 -0
  225. package/dist/server/serve.js +131 -0
  226. package/package.json +71 -0
  227. package/src/cli/config.ts +83 -0
  228. package/src/cli/index.ts +82 -0
  229. package/src/cli/mount.ts +25 -0
  230. package/src/cli/serve.ts +22 -0
  231. package/src/client/app.test.tsx +70 -0
  232. package/src/client/app.tsx +62 -0
  233. package/src/client/browser-runtime.test.ts +22 -0
  234. package/src/client/browser.ts +3 -0
  235. package/src/client/context.ts +17 -0
  236. package/src/client/embed.test.tsx +58 -0
  237. package/src/client/entry.tsx +25 -0
  238. package/src/client/mount.test.tsx +36 -0
  239. package/src/client/mount.tsx +48 -0
  240. package/src/client/runtime.test.ts +64 -0
  241. package/src/client/runtime.ts +112 -0
  242. package/src/client/serve-stub.ts +3 -0
  243. package/src/client/styles.css +131 -0
  244. package/src/client/view.ts +16 -0
  245. package/src/client/widgets/accordion/accordion.css +35 -0
  246. package/src/client/widgets/accordion/index.tsx +17 -0
  247. package/src/client/widgets/annotated-image/annotated-image.css +62 -0
  248. package/src/client/widgets/annotated-image/index.tsx +73 -0
  249. package/src/client/widgets/audio/audio.css +6 -0
  250. package/src/client/widgets/audio/index.tsx +6 -0
  251. package/src/client/widgets/button/button.css +25 -0
  252. package/src/client/widgets/button/index.tsx +11 -0
  253. package/src/client/widgets/chart/chart.css +12 -0
  254. package/src/client/widgets/chart/index.tsx +63 -0
  255. package/src/client/widgets/chart/lazy.tsx +15 -0
  256. package/src/client/widgets/chat/chat.css +97 -0
  257. package/src/client/widgets/chat/index.tsx +121 -0
  258. package/src/client/widgets/checkbox/checkbox.css +15 -0
  259. package/src/client/widgets/checkbox/index.tsx +15 -0
  260. package/src/client/widgets/checkbox-group/checkbox-group.css +20 -0
  261. package/src/client/widgets/checkbox-group/index.tsx +22 -0
  262. package/src/client/widgets/code/code.css +31 -0
  263. package/src/client/widgets/code/index.tsx +108 -0
  264. package/src/client/widgets/code/lazy.tsx +16 -0
  265. package/src/client/widgets/dropdown/dropdown.css +0 -0
  266. package/src/client/widgets/dropdown/index.tsx +19 -0
  267. package/src/client/widgets/file/file.css +26 -0
  268. package/src/client/widgets/file/index.tsx +12 -0
  269. package/src/client/widgets/frame/frame.css +17 -0
  270. package/src/client/widgets/frame/index.tsx +15 -0
  271. package/src/client/widgets/gallery/gallery.css +26 -0
  272. package/src/client/widgets/gallery/index.tsx +18 -0
  273. package/src/client/widgets/highlighted-text/highlighted-text.css +21 -0
  274. package/src/client/widgets/highlighted-text/index.tsx +42 -0
  275. package/src/client/widgets/html/index.tsx +8 -0
  276. package/src/client/widgets/image/index.tsx +5 -0
  277. package/src/client/widgets/json/index.tsx +5 -0
  278. package/src/client/widgets/json/json.css +0 -0
  279. package/src/client/widgets/label/index.tsx +20 -0
  280. package/src/client/widgets/label/label.css +39 -0
  281. package/src/client/widgets/layout/index.tsx +14 -0
  282. package/src/client/widgets/log/index.tsx +5 -0
  283. package/src/client/widgets/log/log.css +0 -0
  284. package/src/client/widgets/mic/index.tsx +85 -0
  285. package/src/client/widgets/mic/mic.css +8 -0
  286. package/src/client/widgets/number/index.tsx +10 -0
  287. package/src/client/widgets/number/number.css +0 -0
  288. package/src/client/widgets/output/index.tsx +19 -0
  289. package/src/client/widgets/output/markdown.tsx +12 -0
  290. package/src/client/widgets/output/output.css +75 -0
  291. package/src/client/widgets/progress/index.tsx +14 -0
  292. package/src/client/widgets/progress/progress.css +26 -0
  293. package/src/client/widgets/radio/index.tsx +20 -0
  294. package/src/client/widgets/radio/radio.css +20 -0
  295. package/src/client/widgets/registry.tsx +71 -0
  296. package/src/client/widgets/slider/index.tsx +23 -0
  297. package/src/client/widgets/slider/slider.css +18 -0
  298. package/src/client/widgets/table/index.tsx +95 -0
  299. package/src/client/widgets/table/lazy.tsx +23 -0
  300. package/src/client/widgets/table/table.css +15 -0
  301. package/src/client/widgets/tabs/index.tsx +28 -0
  302. package/src/client/widgets/tabs/tabs.css +30 -0
  303. package/src/client/widgets/text/index.tsx +16 -0
  304. package/src/client/widgets/text/text.css +21 -0
  305. package/src/client/widgets/upload/index.tsx +30 -0
  306. package/src/client/widgets/upload/upload.css +30 -0
  307. package/src/client/widgets/video/index.tsx +10 -0
  308. package/src/client/widgets/video/video.css +8 -0
  309. package/src/client/widgets/webcam/index.tsx +81 -0
  310. package/src/client/widgets/webcam/webcam.css +46 -0
  311. package/src/css.d.ts +1 -0
  312. package/src/env.d.ts +1 -0
  313. package/src/lib/bound.ts +30 -0
  314. package/src/lib/controls.ts +36 -0
  315. package/src/lib/ctx.ts +31 -0
  316. package/src/lib/declare.test.ts +46 -0
  317. package/src/lib/declare.ts +74 -0
  318. package/src/lib/event.ts +12 -0
  319. package/src/lib/index.ts +21 -0
  320. package/src/lib/knobkit.ts +57 -0
  321. package/src/lib/on.ts +3 -0
  322. package/src/lib/stream.ts +38 -0
  323. package/src/lib/types.ts +63 -0
  324. package/src/lib/widget.ts +11 -0
  325. package/src/lib/widgets/annotated-image.ts +34 -0
  326. package/src/lib/widgets/audio.ts +20 -0
  327. package/src/lib/widgets/button.ts +27 -0
  328. package/src/lib/widgets/chart.ts +44 -0
  329. package/src/lib/widgets/chat.ts +43 -0
  330. package/src/lib/widgets/checkbox-group.ts +6 -0
  331. package/src/lib/widgets/checkbox.ts +5 -0
  332. package/src/lib/widgets/code.ts +11 -0
  333. package/src/lib/widgets/dropdown.ts +5 -0
  334. package/src/lib/widgets/embed.ts +26 -0
  335. package/src/lib/widgets/file.ts +23 -0
  336. package/src/lib/widgets/frame.ts +36 -0
  337. package/src/lib/widgets/gallery.ts +29 -0
  338. package/src/lib/widgets/highlighted-text.ts +29 -0
  339. package/src/lib/widgets/html.ts +18 -0
  340. package/src/lib/widgets/image.ts +18 -0
  341. package/src/lib/widgets/index.ts +31 -0
  342. package/src/lib/widgets/json.ts +18 -0
  343. package/src/lib/widgets/label.ts +29 -0
  344. package/src/lib/widgets/layout.ts +47 -0
  345. package/src/lib/widgets/log.ts +22 -0
  346. package/src/lib/widgets/mic.ts +42 -0
  347. package/src/lib/widgets/number.ts +5 -0
  348. package/src/lib/widgets/output.ts +20 -0
  349. package/src/lib/widgets/progress.ts +21 -0
  350. package/src/lib/widgets/radio.ts +6 -0
  351. package/src/lib/widgets/slider.ts +7 -0
  352. package/src/lib/widgets/table.ts +58 -0
  353. package/src/lib/widgets/text.ts +5 -0
  354. package/src/lib/widgets/upload.ts +6 -0
  355. package/src/lib/widgets/value.ts +28 -0
  356. package/src/lib/widgets/video.ts +22 -0
  357. package/src/lib/widgets/webcam.ts +46 -0
  358. package/src/server/context.ts +12 -0
  359. package/src/server/serve.test.ts +121 -0
  360. package/src/server/serve.ts +130 -0
  361. package/tsconfig.base.json +14 -0
@@ -0,0 +1,23 @@
1
+ import { col } from "./layout.js";
2
+ export const SUBAPP = "__subapp";
3
+ export function embed(app) {
4
+ const ws = app.config.widgets;
5
+ const node = col(...(Array.isArray(ws) ? ws : [ws]));
6
+ node[SUBAPP] = app;
7
+ return node;
8
+ }
9
+ export function collectSubapps(widgets) {
10
+ const out = [];
11
+ const visit = (w) => {
12
+ const sub = w[SUBAPP];
13
+ if (sub) {
14
+ out.push(sub);
15
+ return;
16
+ }
17
+ for (const c of w.children ?? [])
18
+ visit(c);
19
+ };
20
+ for (const w of Array.isArray(widgets) ? widgets : [widgets])
21
+ visit(w);
22
+ return out;
23
+ }
@@ -0,0 +1,11 @@
1
+ import type { Widget } from "../types.js";
2
+ export interface FileWidget extends Widget<{
3
+ name: string;
4
+ url: string;
5
+ }> {
6
+ set(value: {
7
+ name?: string;
8
+ url: string;
9
+ } | string): void;
10
+ }
11
+ export declare function file(): FileWidget;
@@ -0,0 +1,15 @@
1
+ import { bound } from "../bound.js";
2
+ import { controls } from "../controls.js";
3
+ export function file() {
4
+ return {
5
+ type: "file",
6
+ state: { name: "", url: "" },
7
+ ...controls,
8
+ set(value) {
9
+ const v = typeof value === "string" ? { url: value } : value;
10
+ const b = bound(this);
11
+ b.edit(this, "set", ["url"], v.url);
12
+ b.edit(this, "set", ["name"], v.name ?? v.url.split("/").pop()?.split("?")[0] ?? "download");
13
+ },
14
+ };
15
+ }
@@ -0,0 +1,18 @@
1
+ import type { EventCtor, Widget } from "../types.js";
2
+ export interface FrameWidget extends Widget<{
3
+ src: string;
4
+ doc: string;
5
+ }> {
6
+ sandbox?: string;
7
+ title: string;
8
+ loaded: EventCtor;
9
+ load(url: string): void;
10
+ show(doc: string): void;
11
+ clear(): void;
12
+ }
13
+ export declare function frame(opts?: {
14
+ src?: string;
15
+ doc?: string;
16
+ sandbox?: string;
17
+ title?: string;
18
+ }): FrameWidget;
@@ -0,0 +1,25 @@
1
+ import { event } from "../event.js";
2
+ import { bound } from "../bound.js";
3
+ import { controls } from "../controls.js";
4
+ export function frame(opts = {}) {
5
+ return {
6
+ type: "frame",
7
+ state: { src: opts.src ?? "", doc: opts.doc ?? "" },
8
+ sandbox: opts.sandbox,
9
+ title: opts.title ?? "frame",
10
+ loaded: event("frame.loaded"),
11
+ ...controls,
12
+ load(url) {
13
+ bound(this).edit(this, "set", ["doc"], "");
14
+ bound(this).edit(this, "set", ["src"], url);
15
+ },
16
+ show(doc) {
17
+ bound(this).edit(this, "set", ["src"], "");
18
+ bound(this).edit(this, "set", ["doc"], doc);
19
+ },
20
+ clear() {
21
+ bound(this).edit(this, "set", ["src"], "");
22
+ bound(this).edit(this, "set", ["doc"], "");
23
+ },
24
+ };
25
+ }
@@ -0,0 +1,12 @@
1
+ import type { Widget } from "../types.js";
2
+ export interface GalleryItem {
3
+ src: string;
4
+ caption?: string;
5
+ }
6
+ export interface GalleryWidget extends Widget<{
7
+ items: GalleryItem[];
8
+ }> {
9
+ set(items: GalleryItem[]): void;
10
+ add(item: GalleryItem): void;
11
+ }
12
+ export declare function gallery(): GalleryWidget;
@@ -0,0 +1,17 @@
1
+ import { bound } from "../bound.js";
2
+ import { controls } from "../controls.js";
3
+ // A grid of images (the canonical output for batched image generation). Not a layout container — its
4
+ // `items` are image records, not child widget keys.
5
+ export function gallery() {
6
+ return {
7
+ type: "gallery",
8
+ state: { items: [] },
9
+ ...controls,
10
+ set(items) {
11
+ bound(this).edit(this, "set", ["items"], items);
12
+ },
13
+ add(item) {
14
+ bound(this).edit(this, "append", ["items"], item);
15
+ },
16
+ };
17
+ }
@@ -0,0 +1,12 @@
1
+ import type { Widget } from "../types.js";
2
+ export interface HighlightSpan {
3
+ text: string;
4
+ label?: string | null;
5
+ }
6
+ export interface HighlightedTextWidget extends Widget<{
7
+ value: HighlightSpan[];
8
+ colorMap: Record<string, string>;
9
+ }> {
10
+ set(value: HighlightSpan[], colorMap?: Record<string, string>): void;
11
+ }
12
+ export declare function highlightedText(): HighlightedTextWidget;
@@ -0,0 +1,15 @@
1
+ import { bound } from "../bound.js";
2
+ import { controls } from "../controls.js";
3
+ export function highlightedText() {
4
+ return {
5
+ type: "highlightedText",
6
+ state: { value: [], colorMap: {} },
7
+ ...controls,
8
+ set(value, colorMap) {
9
+ const b = bound(this);
10
+ if (colorMap !== undefined)
11
+ b.edit(this, "set", ["colorMap"], colorMap);
12
+ b.edit(this, "set", ["value"], value);
13
+ },
14
+ };
15
+ }
@@ -0,0 +1,9 @@
1
+ import type { Widget } from "../types.js";
2
+ export interface HtmlWidget extends Widget<{
3
+ value: string;
4
+ }> {
5
+ set(value: string): void;
6
+ }
7
+ export declare function html(opts?: {
8
+ value?: string;
9
+ }): HtmlWidget;
@@ -0,0 +1,12 @@
1
+ import { bound } from "../bound.js";
2
+ import { controls } from "../controls.js";
3
+ export function html(opts = {}) {
4
+ return {
5
+ type: "html",
6
+ state: { value: opts.value ?? "" },
7
+ ...controls,
8
+ set(value) {
9
+ bound(this).edit(this, "set", ["value"], value);
10
+ },
11
+ };
12
+ }
@@ -0,0 +1,7 @@
1
+ import type { Widget } from "../types.js";
2
+ export interface ImageWidget extends Widget<{
3
+ src: string;
4
+ }> {
5
+ set(value: string): void;
6
+ }
7
+ export declare function image(): ImageWidget;
@@ -0,0 +1,12 @@
1
+ import { bound } from "../bound.js";
2
+ import { controls } from "../controls.js";
3
+ export function image() {
4
+ return {
5
+ type: "image",
6
+ state: { src: "" },
7
+ ...controls,
8
+ set(value) {
9
+ bound(this).edit(this, "set", ["src"], value);
10
+ },
11
+ };
12
+ }
@@ -0,0 +1,31 @@
1
+ export * from "./text.js";
2
+ export * from "./number.js";
3
+ export * from "./slider.js";
4
+ export * from "./code.js";
5
+ export * from "./table.js";
6
+ export * from "./chart.js";
7
+ export * from "./dropdown.js";
8
+ export * from "./checkbox.js";
9
+ export * from "./checkbox-group.js";
10
+ export * from "./radio.js";
11
+ export * from "./gallery.js";
12
+ export * from "./video.js";
13
+ export * from "./label.js";
14
+ export * from "./highlighted-text.js";
15
+ export * from "./annotated-image.js";
16
+ export * from "./file.js";
17
+ export * from "./progress.js";
18
+ export * from "./html.js";
19
+ export * from "./frame.js";
20
+ export * from "./upload.js";
21
+ export * from "./image.js";
22
+ export * from "./button.js";
23
+ export * from "./mic.js";
24
+ export * from "./chat.js";
25
+ export * from "./output.js";
26
+ export * from "./json.js";
27
+ export * from "./log.js";
28
+ export * from "./audio.js";
29
+ export * from "./webcam.js";
30
+ export * from "./layout.js";
31
+ export { embed } from "./embed.js";
@@ -0,0 +1,31 @@
1
+ export * from "./text.js";
2
+ export * from "./number.js";
3
+ export * from "./slider.js";
4
+ export * from "./code.js";
5
+ export * from "./table.js";
6
+ export * from "./chart.js";
7
+ export * from "./dropdown.js";
8
+ export * from "./checkbox.js";
9
+ export * from "./checkbox-group.js";
10
+ export * from "./radio.js";
11
+ export * from "./gallery.js";
12
+ export * from "./video.js";
13
+ export * from "./label.js";
14
+ export * from "./highlighted-text.js";
15
+ export * from "./annotated-image.js";
16
+ export * from "./file.js";
17
+ export * from "./progress.js";
18
+ export * from "./html.js";
19
+ export * from "./frame.js";
20
+ export * from "./upload.js";
21
+ export * from "./image.js";
22
+ export * from "./button.js";
23
+ export * from "./mic.js";
24
+ export * from "./chat.js";
25
+ export * from "./output.js";
26
+ export * from "./json.js";
27
+ export * from "./log.js";
28
+ export * from "./audio.js";
29
+ export * from "./webcam.js";
30
+ export * from "./layout.js";
31
+ export { embed } from "./embed.js";
@@ -0,0 +1,7 @@
1
+ import type { Widget } from "../types.js";
2
+ export interface JsonWidget extends Widget<{
3
+ value: unknown;
4
+ }> {
5
+ set(value: unknown): void;
6
+ }
7
+ export declare function json(): JsonWidget;
@@ -0,0 +1,12 @@
1
+ import { bound } from "../bound.js";
2
+ import { controls } from "../controls.js";
3
+ export function json() {
4
+ return {
5
+ type: "json",
6
+ state: { value: null },
7
+ ...controls,
8
+ set(value) {
9
+ bound(this).edit(this, "set", ["value"], value);
10
+ },
11
+ };
12
+ }
@@ -0,0 +1,15 @@
1
+ import type { Widget } from "../types.js";
2
+ export interface LabelClass {
3
+ label: string;
4
+ score: number;
5
+ }
6
+ export interface LabelWidget extends Widget<{
7
+ label: string;
8
+ confidences: LabelClass[];
9
+ }> {
10
+ set(value: string | {
11
+ label?: string;
12
+ confidences?: LabelClass[];
13
+ }): void;
14
+ }
15
+ export declare function label(): LabelWidget;
@@ -0,0 +1,18 @@
1
+ import { bound } from "../bound.js";
2
+ import { controls } from "../controls.js";
3
+ export function label() {
4
+ return {
5
+ type: "label",
6
+ state: { label: "", confidences: [] },
7
+ ...controls,
8
+ set(value) {
9
+ const v = typeof value === "string" ? { label: value, confidences: [] } : value;
10
+ const b = bound(this);
11
+ if (v.confidences !== undefined)
12
+ b.edit(this, "set", ["confidences"], v.confidences);
13
+ const top = v.label ?? v.confidences?.reduce((a, c) => (c.score > a.score ? c : a), v.confidences[0])?.label;
14
+ if (top !== undefined)
15
+ b.edit(this, "set", ["label"], top);
16
+ },
17
+ };
18
+ }
@@ -0,0 +1,21 @@
1
+ import type { Widget } from "../types.js";
2
+ export interface LayoutWidget extends Widget<{
3
+ items: string[];
4
+ }> {
5
+ children: Widget<any>[];
6
+ add(child: Widget<any>): void;
7
+ remove(child: Widget<any>): Promise<void>;
8
+ }
9
+ export declare const row: (...children: Widget<any>[]) => LayoutWidget;
10
+ export declare const col: (...children: Widget<any>[]) => LayoutWidget;
11
+ export declare const grid: (children: Widget<any>[], opts?: {
12
+ cols?: number;
13
+ }) => LayoutWidget;
14
+ export declare const tabs: (panels: {
15
+ label: string;
16
+ content: Widget<any>;
17
+ }[]) => LayoutWidget;
18
+ export declare const accordion: (opts: {
19
+ label: string;
20
+ open?: boolean;
21
+ }, ...children: Widget<any>[]) => LayoutWidget;
@@ -0,0 +1,29 @@
1
+ import { bound } from "../bound.js";
2
+ import { controls } from "../controls.js";
3
+ function container(type, children, props = {}) {
4
+ return {
5
+ type,
6
+ state: { items: [] },
7
+ children,
8
+ ...controls,
9
+ add(child) {
10
+ const b = bound(this);
11
+ b.edit(this, "append", ["items"], b.key(child));
12
+ },
13
+ async remove(child) {
14
+ const b = bound(this);
15
+ const key = b.key(child);
16
+ const items = await b.read(this, ["items"]);
17
+ b.edit(this, "set", ["items"], items.filter((k) => k !== key));
18
+ },
19
+ ...props,
20
+ };
21
+ }
22
+ export const row = (...children) => container("row", children);
23
+ export const col = (...children) => container("col", children);
24
+ export const grid = (children, opts = {}) => container("grid", children, { cols: opts.cols ?? 2 });
25
+ // Tabbed container: each panel is a labelled child. `labels` rides alongside `items` (the child keys)
26
+ // in the same order; the active tab is view-local state, so switching tabs never round-trips.
27
+ export const tabs = (panels) => container("tabs", panels.map((p) => p.content), { labels: panels.map((p) => p.label) });
28
+ // A single collapsible section. `open` is the initial state; toggling it is view-local.
29
+ export const accordion = (opts, ...children) => container("accordion", children, { label: opts.label, open: opts.open ?? true });
@@ -0,0 +1,8 @@
1
+ import type { Widget } from "../types.js";
2
+ export interface LogWidget extends Widget<{
3
+ lines: string[];
4
+ }> {
5
+ push(line: string): void;
6
+ all(): Promise<string[]>;
7
+ }
8
+ export declare function log(): LogWidget;
@@ -0,0 +1,15 @@
1
+ import { bound } from "../bound.js";
2
+ import { controls } from "../controls.js";
3
+ export function log() {
4
+ return {
5
+ type: "log",
6
+ state: { lines: [] },
7
+ ...controls,
8
+ push(line) {
9
+ bound(this).edit(this, "append", ["lines"], line);
10
+ },
11
+ all() {
12
+ return bound(this).read(this, ["lines"]);
13
+ },
14
+ };
15
+ }
@@ -0,0 +1,19 @@
1
+ import type { EventCtor, Widget } from "../types.js";
2
+ export interface MicWidget extends Widget<{
3
+ live: boolean;
4
+ }> {
5
+ clip: EventCtor<Float32Array>;
6
+ toggled: EventCtor<boolean>;
7
+ every: number;
8
+ control: boolean;
9
+ hold: boolean;
10
+ start(): void;
11
+ stop(): void;
12
+ toggle(): Promise<void>;
13
+ live(): Promise<boolean>;
14
+ }
15
+ export declare function mic(opts?: {
16
+ every?: number;
17
+ control?: boolean;
18
+ hold?: boolean;
19
+ }): MicWidget;
@@ -0,0 +1,28 @@
1
+ import { event } from "../event.js";
2
+ import { bound } from "../bound.js";
3
+ import { controls } from "../controls.js";
4
+ export function mic(opts = {}) {
5
+ return {
6
+ type: "mic",
7
+ state: { live: false },
8
+ clip: event("mic.clip"),
9
+ toggled: event("mic.toggled"),
10
+ every: opts.every ?? 0,
11
+ control: opts.control ?? true,
12
+ hold: opts.hold ?? true,
13
+ ...controls,
14
+ start() {
15
+ bound(this).edit(this, "set", ["live"], true);
16
+ },
17
+ stop() {
18
+ bound(this).edit(this, "set", ["live"], false);
19
+ },
20
+ async toggle() {
21
+ const live = await bound(this).read(this, ["live"]);
22
+ bound(this).edit(this, "set", ["live"], !live);
23
+ },
24
+ live() {
25
+ return bound(this).read(this, ["live"]);
26
+ },
27
+ };
28
+ }
@@ -0,0 +1,5 @@
1
+ export declare function number(opts?: {
2
+ value?: number;
3
+ min?: number;
4
+ max?: number;
5
+ }): import("./value.js").ValueWidget<number>;
@@ -0,0 +1,4 @@
1
+ import { value } from "./value.js";
2
+ export function number(opts = {}) {
3
+ return value("number", opts.value ?? 0, { min: opts.min, max: opts.max });
4
+ }
@@ -0,0 +1,10 @@
1
+ import type { Widget } from "../types.js";
2
+ export interface OutputWidget extends Widget<{
3
+ value: string;
4
+ }> {
5
+ format: "text" | "markdown";
6
+ set(value: string): void;
7
+ }
8
+ export declare function output(opts?: {
9
+ format?: "text" | "markdown";
10
+ }): OutputWidget;
@@ -0,0 +1,13 @@
1
+ import { bound } from "../bound.js";
2
+ import { controls } from "../controls.js";
3
+ export function output(opts = {}) {
4
+ return {
5
+ type: "output",
6
+ state: { value: "" },
7
+ format: opts.format ?? "text",
8
+ ...controls,
9
+ set(value) {
10
+ bound(this).edit(this, "set", ["value"], value);
11
+ },
12
+ };
13
+ }
@@ -0,0 +1,10 @@
1
+ import type { Widget } from "../types.js";
2
+ export interface ProgressWidget extends Widget<{
3
+ value: number;
4
+ label: string;
5
+ }> {
6
+ set(value: number, label?: string): void;
7
+ }
8
+ export declare function progress(opts?: {
9
+ label?: string;
10
+ }): ProgressWidget;
@@ -0,0 +1,15 @@
1
+ import { bound } from "../bound.js";
2
+ import { controls } from "../controls.js";
3
+ export function progress(opts = {}) {
4
+ return {
5
+ type: "progress",
6
+ state: { value: 0, label: opts.label ?? "" },
7
+ ...controls,
8
+ set(value, label) {
9
+ const b = bound(this);
10
+ b.edit(this, "set", ["value"], value);
11
+ if (label !== undefined)
12
+ b.edit(this, "set", ["label"], label);
13
+ },
14
+ };
15
+ }
@@ -0,0 +1,4 @@
1
+ export declare function radio(opts: {
2
+ choices: string[];
3
+ value?: string;
4
+ }): import("./value.js").ValueWidget<string>;
@@ -0,0 +1,5 @@
1
+ import { value } from "./value.js";
2
+ // Single-select from a fixed set, like dropdown but rendered as radios.
3
+ export function radio(opts) {
4
+ return value("radio", opts.value ?? opts.choices[0], { choices: opts.choices });
5
+ }
@@ -0,0 +1,6 @@
1
+ export declare function slider(opts?: {
2
+ value?: number;
3
+ min?: number;
4
+ max?: number;
5
+ step?: number;
6
+ }): import("./value.js").ValueWidget<number>;
@@ -0,0 +1,6 @@
1
+ import { value } from "./value.js";
2
+ export function slider(opts = {}) {
3
+ const min = opts.min ?? 0;
4
+ const max = opts.max ?? 100;
5
+ return value("slider", opts.value ?? min, { min, max, step: opts.step ?? 1 });
6
+ }
@@ -0,0 +1,32 @@
1
+ import type { EventCtor, Widget } from "../types.js";
2
+ export interface Column {
3
+ key: string;
4
+ label?: string;
5
+ type?: "text" | "number";
6
+ width?: number;
7
+ }
8
+ export type Row = Record<string, unknown>;
9
+ export interface TableWidget extends Widget<{
10
+ columns: Column[];
11
+ rows: Row[];
12
+ }> {
13
+ edited: EventCtor<{
14
+ row: number;
15
+ key: string;
16
+ value: unknown;
17
+ }>;
18
+ editable: boolean;
19
+ maxHeight: number;
20
+ data(): Promise<Row[]>;
21
+ columnsOf(): Promise<Column[]>;
22
+ setRows(rows: Row[]): void;
23
+ setColumns(columns: Column[]): void;
24
+ addRow(row: Row): void;
25
+ setCell(row: number, key: string, value: unknown): void;
26
+ }
27
+ export declare function table(opts?: {
28
+ columns?: Column[];
29
+ rows?: Row[];
30
+ editable?: boolean;
31
+ maxHeight?: number;
32
+ }): TableWidget;
@@ -0,0 +1,36 @@
1
+ import { event } from "../event.js";
2
+ import { bound } from "../bound.js";
3
+ import { controls } from "../controls.js";
4
+ // A tabular widget rendered by RevoGrid (virtualized, range-select, copy/paste, in-cell editing). State
5
+ // is the uniform shape — `{ columns, rows }` — and every mutation is a structured edit by path, so a
6
+ // cell edit is `set ["rows", r, key]` and a new row is `append ["rows"]`; the grid stays controlled by
7
+ // the store on both tiers. Defaults to read-only (a display table); pass `editable: true` to let the
8
+ // user edit cells.
9
+ export function table(opts = {}) {
10
+ return {
11
+ type: "table",
12
+ state: { columns: opts.columns ?? [], rows: opts.rows ?? [] },
13
+ edited: event("table.edited"),
14
+ editable: opts.editable ?? false,
15
+ maxHeight: opts.maxHeight ?? 500,
16
+ ...controls,
17
+ data() {
18
+ return bound(this).read(this, ["rows"]);
19
+ },
20
+ columnsOf() {
21
+ return bound(this).read(this, ["columns"]);
22
+ },
23
+ setRows(rows) {
24
+ bound(this).edit(this, "set", ["rows"], rows);
25
+ },
26
+ setColumns(columns) {
27
+ bound(this).edit(this, "set", ["columns"], columns);
28
+ },
29
+ addRow(row) {
30
+ bound(this).edit(this, "append", ["rows"], row);
31
+ },
32
+ setCell(row, key, value) {
33
+ bound(this).edit(this, "set", ["rows", row, key], value);
34
+ },
35
+ };
36
+ }
@@ -0,0 +1,4 @@
1
+ export declare function text(opts?: {
2
+ placeholder?: string;
3
+ lines?: number;
4
+ }): import("./value.js").ValueWidget<string>;
@@ -0,0 +1,4 @@
1
+ import { value } from "./value.js";
2
+ export function text(opts = {}) {
3
+ return value("text", "", { placeholder: opts.placeholder, lines: opts.lines ?? 1 });
4
+ }
@@ -0,0 +1,3 @@
1
+ export declare function upload(opts?: {
2
+ accept?: string;
3
+ }): import("./value.js").ValueWidget<string | null>;
@@ -0,0 +1,5 @@
1
+ import { value } from "./value.js";
2
+ // state is the chosen image as a data URL
3
+ export function upload(opts = {}) {
4
+ return value("upload", null, { accept: opts.accept ?? "image/*" });
5
+ }