@lo-tek/interfaces 0.0.0-stage → 0.37.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 (456) hide show
  1. package/CHANGELOG.md +3254 -0
  2. package/LICENSE +21 -0
  3. package/README.md +129 -2
  4. package/agent/astro.md +400 -0
  5. package/agent/bundles.md +429 -0
  6. package/agent/datastar.md +409 -0
  7. package/agent/html.md +388 -0
  8. package/agent/react.md +440 -0
  9. package/agent/templates.md +472 -0
  10. package/core/lotek-core.wasm +0 -0
  11. package/core/lotek.wasm +0 -0
  12. package/dist/cli.d.ts +12 -0
  13. package/dist/cli.d.ts.map +1 -0
  14. package/dist/cli.js +14 -0
  15. package/dist/cli.js.map +1 -0
  16. package/dist/components/css/accordion/accordion.d.ts +37 -0
  17. package/dist/components/css/accordion/accordion.d.ts.map +1 -0
  18. package/dist/components/css/accordion/accordion.js +31 -0
  19. package/dist/components/css/accordion/accordion.js.map +1 -0
  20. package/dist/components/css/alert/alert.d.ts +35 -0
  21. package/dist/components/css/alert/alert.d.ts.map +1 -0
  22. package/dist/components/css/alert/alert.js +29 -0
  23. package/dist/components/css/alert/alert.js.map +1 -0
  24. package/dist/components/css/avatar/avatar.d.ts +40 -0
  25. package/dist/components/css/avatar/avatar.d.ts.map +1 -0
  26. package/dist/components/css/avatar/avatar.js +30 -0
  27. package/dist/components/css/avatar/avatar.js.map +1 -0
  28. package/dist/components/css/badge/badge.d.ts +24 -0
  29. package/dist/components/css/badge/badge.d.ts.map +1 -0
  30. package/dist/components/css/badge/badge.js +24 -0
  31. package/dist/components/css/badge/badge.js.map +1 -0
  32. package/dist/components/css/breadcrumbs/breadcrumbs.d.ts +26 -0
  33. package/dist/components/css/breadcrumbs/breadcrumbs.d.ts.map +1 -0
  34. package/dist/components/css/breadcrumbs/breadcrumbs.js +24 -0
  35. package/dist/components/css/breadcrumbs/breadcrumbs.js.map +1 -0
  36. package/dist/components/css/button/button.d.ts +26 -0
  37. package/dist/components/css/button/button.d.ts.map +1 -0
  38. package/dist/components/css/button/button.js +25 -0
  39. package/dist/components/css/button/button.js.map +1 -0
  40. package/dist/components/css/card/card.d.ts +36 -0
  41. package/dist/components/css/card/card.d.ts.map +1 -0
  42. package/dist/components/css/card/card.js +28 -0
  43. package/dist/components/css/card/card.js.map +1 -0
  44. package/dist/components/css/checkbox/checkbox.d.ts +32 -0
  45. package/dist/components/css/checkbox/checkbox.d.ts.map +1 -0
  46. package/dist/components/css/checkbox/checkbox.js +27 -0
  47. package/dist/components/css/checkbox/checkbox.js.map +1 -0
  48. package/dist/components/css/divider/divider.d.ts +29 -0
  49. package/dist/components/css/divider/divider.d.ts.map +1 -0
  50. package/dist/components/css/divider/divider.js +23 -0
  51. package/dist/components/css/divider/divider.js.map +1 -0
  52. package/dist/components/css/error-text/error-text.d.ts +24 -0
  53. package/dist/components/css/error-text/error-text.d.ts.map +1 -0
  54. package/dist/components/css/error-text/error-text.js +18 -0
  55. package/dist/components/css/error-text/error-text.js.map +1 -0
  56. package/dist/components/css/fieldset/fieldset.d.ts +55 -0
  57. package/dist/components/css/fieldset/fieldset.d.ts.map +1 -0
  58. package/dist/components/css/fieldset/fieldset.js +39 -0
  59. package/dist/components/css/fieldset/fieldset.js.map +1 -0
  60. package/dist/components/css/file-upload/file-upload.d.ts +41 -0
  61. package/dist/components/css/file-upload/file-upload.d.ts.map +1 -0
  62. package/dist/components/css/file-upload/file-upload.js +32 -0
  63. package/dist/components/css/file-upload/file-upload.js.map +1 -0
  64. package/dist/components/css/heading/heading.d.ts +29 -0
  65. package/dist/components/css/heading/heading.d.ts.map +1 -0
  66. package/dist/components/css/heading/heading.js +23 -0
  67. package/dist/components/css/heading/heading.js.map +1 -0
  68. package/dist/components/css/help-text/help-text.d.ts +24 -0
  69. package/dist/components/css/help-text/help-text.d.ts.map +1 -0
  70. package/dist/components/css/help-text/help-text.js +23 -0
  71. package/dist/components/css/help-text/help-text.js.map +1 -0
  72. package/dist/components/css/icon/icon.d.ts +34 -0
  73. package/dist/components/css/icon/icon.d.ts.map +1 -0
  74. package/dist/components/css/icon/icon.js +25 -0
  75. package/dist/components/css/icon/icon.js.map +1 -0
  76. package/dist/components/css/input/input.d.ts +40 -0
  77. package/dist/components/css/input/input.d.ts.map +1 -0
  78. package/dist/components/css/input/input.js +45 -0
  79. package/dist/components/css/input/input.js.map +1 -0
  80. package/dist/components/css/label/label.d.ts +33 -0
  81. package/dist/components/css/label/label.d.ts.map +1 -0
  82. package/dist/components/css/label/label.js +23 -0
  83. package/dist/components/css/label/label.js.map +1 -0
  84. package/dist/components/css/link/link.d.ts +28 -0
  85. package/dist/components/css/link/link.d.ts.map +1 -0
  86. package/dist/components/css/link/link.js +20 -0
  87. package/dist/components/css/link/link.js.map +1 -0
  88. package/dist/components/css/list/list.d.ts +31 -0
  89. package/dist/components/css/list/list.d.ts.map +1 -0
  90. package/dist/components/css/list/list.js +25 -0
  91. package/dist/components/css/list/list.js.map +1 -0
  92. package/dist/components/css/pagination/pagination.d.ts +27 -0
  93. package/dist/components/css/pagination/pagination.d.ts.map +1 -0
  94. package/dist/components/css/pagination/pagination.js +25 -0
  95. package/dist/components/css/pagination/pagination.js.map +1 -0
  96. package/dist/components/css/paragraph/paragraph.d.ts +36 -0
  97. package/dist/components/css/paragraph/paragraph.d.ts.map +1 -0
  98. package/dist/components/css/paragraph/paragraph.js +26 -0
  99. package/dist/components/css/paragraph/paragraph.js.map +1 -0
  100. package/dist/components/css/progress/progress.d.ts +53 -0
  101. package/dist/components/css/progress/progress.d.ts.map +1 -0
  102. package/dist/components/css/progress/progress.js +38 -0
  103. package/dist/components/css/progress/progress.js.map +1 -0
  104. package/dist/components/css/radio/radio.d.ts +32 -0
  105. package/dist/components/css/radio/radio.d.ts.map +1 -0
  106. package/dist/components/css/radio/radio.js +27 -0
  107. package/dist/components/css/radio/radio.js.map +1 -0
  108. package/dist/components/css/search/search.d.ts +34 -0
  109. package/dist/components/css/search/search.d.ts.map +1 -0
  110. package/dist/components/css/search/search.js +32 -0
  111. package/dist/components/css/search/search.js.map +1 -0
  112. package/dist/components/css/select/select.d.ts +40 -0
  113. package/dist/components/css/select/select.d.ts.map +1 -0
  114. package/dist/components/css/select/select.js +31 -0
  115. package/dist/components/css/select/select.js.map +1 -0
  116. package/dist/components/css/shared.d.ts +90 -0
  117. package/dist/components/css/shared.d.ts.map +1 -0
  118. package/dist/components/css/shared.js +167 -0
  119. package/dist/components/css/shared.js.map +1 -0
  120. package/dist/components/css/skeleton/skeleton.d.ts +29 -0
  121. package/dist/components/css/skeleton/skeleton.d.ts.map +1 -0
  122. package/dist/components/css/skeleton/skeleton.js +23 -0
  123. package/dist/components/css/skeleton/skeleton.js.map +1 -0
  124. package/dist/components/css/skip-link/skip-link.d.ts +18 -0
  125. package/dist/components/css/skip-link/skip-link.d.ts.map +1 -0
  126. package/dist/components/css/skip-link/skip-link.js +16 -0
  127. package/dist/components/css/skip-link/skip-link.js.map +1 -0
  128. package/dist/components/css/spinner/spinner.d.ts +33 -0
  129. package/dist/components/css/spinner/spinner.d.ts.map +1 -0
  130. package/dist/components/css/spinner/spinner.js +25 -0
  131. package/dist/components/css/spinner/spinner.js.map +1 -0
  132. package/dist/components/css/sr-only/sr-only.d.ts +17 -0
  133. package/dist/components/css/sr-only/sr-only.d.ts.map +1 -0
  134. package/dist/components/css/sr-only/sr-only.js +15 -0
  135. package/dist/components/css/sr-only/sr-only.js.map +1 -0
  136. package/dist/components/css/switch/switch.d.ts +37 -0
  137. package/dist/components/css/switch/switch.d.ts.map +1 -0
  138. package/dist/components/css/switch/switch.js +29 -0
  139. package/dist/components/css/switch/switch.js.map +1 -0
  140. package/dist/components/css/table/table.d.ts +76 -0
  141. package/dist/components/css/table/table.d.ts.map +1 -0
  142. package/dist/components/css/table/table.js +59 -0
  143. package/dist/components/css/table/table.js.map +1 -0
  144. package/dist/components/css/tag/tag.d.ts +35 -0
  145. package/dist/components/css/tag/tag.d.ts.map +1 -0
  146. package/dist/components/css/tag/tag.js +27 -0
  147. package/dist/components/css/tag/tag.js.map +1 -0
  148. package/dist/components/css/textarea/textarea.d.ts +23 -0
  149. package/dist/components/css/textarea/textarea.d.ts.map +1 -0
  150. package/dist/components/css/textarea/textarea.js +18 -0
  151. package/dist/components/css/textarea/textarea.js.map +1 -0
  152. package/dist/components/css/toggle-group/toggle-group.d.ts +31 -0
  153. package/dist/components/css/toggle-group/toggle-group.d.ts.map +1 -0
  154. package/dist/components/css/toggle-group/toggle-group.js +29 -0
  155. package/dist/components/css/toggle-group/toggle-group.js.map +1 -0
  156. package/dist/components/css/tooltip/tooltip.d.ts +31 -0
  157. package/dist/components/css/tooltip/tooltip.d.ts.map +1 -0
  158. package/dist/components/css/tooltip/tooltip.js +29 -0
  159. package/dist/components/css/tooltip/tooltip.js.map +1 -0
  160. package/dist/components/default-texts.d.ts +35 -0
  161. package/dist/components/default-texts.d.ts.map +1 -0
  162. package/dist/components/default-texts.js +35 -0
  163. package/dist/components/default-texts.js.map +1 -0
  164. package/dist/components/events.d.ts +77 -0
  165. package/dist/components/events.d.ts.map +1 -0
  166. package/dist/components/events.js +3 -0
  167. package/dist/components/events.js.map +1 -0
  168. package/dist/components/frame/dialog/dialog.d.ts +122 -0
  169. package/dist/components/frame/dialog/dialog.d.ts.map +1 -0
  170. package/dist/components/frame/dialog/dialog.js +112 -0
  171. package/dist/components/frame/dialog/dialog.js.map +1 -0
  172. package/dist/components/frame/dialog/lt-dialog.d.ts +104 -0
  173. package/dist/components/frame/dialog/lt-dialog.d.ts.map +1 -0
  174. package/dist/components/frame/dialog/lt-dialog.js +431 -0
  175. package/dist/components/frame/dialog/lt-dialog.js.map +1 -0
  176. package/dist/components/frame/error-summary/error-summary.d.ts +40 -0
  177. package/dist/components/frame/error-summary/error-summary.d.ts.map +1 -0
  178. package/dist/components/frame/error-summary/error-summary.js +32 -0
  179. package/dist/components/frame/error-summary/error-summary.js.map +1 -0
  180. package/dist/components/frame/error-summary/lt-error-summary.d.ts +82 -0
  181. package/dist/components/frame/error-summary/lt-error-summary.d.ts.map +1 -0
  182. package/dist/components/frame/error-summary/lt-error-summary.js +302 -0
  183. package/dist/components/frame/error-summary/lt-error-summary.js.map +1 -0
  184. package/dist/components/frame/field/field-core.d.ts +92 -0
  185. package/dist/components/frame/field/field-core.d.ts.map +1 -0
  186. package/dist/components/frame/field/field-core.js +63 -0
  187. package/dist/components/frame/field/field-core.js.map +1 -0
  188. package/dist/components/frame/field/lt-field.d.ts +173 -0
  189. package/dist/components/frame/field/lt-field.d.ts.map +1 -0
  190. package/dist/components/frame/field/lt-field.js +580 -0
  191. package/dist/components/frame/field/lt-field.js.map +1 -0
  192. package/dist/components/frame/popover/lt-popover.d.ts +132 -0
  193. package/dist/components/frame/popover/lt-popover.d.ts.map +1 -0
  194. package/dist/components/frame/popover/lt-popover.js +490 -0
  195. package/dist/components/frame/popover/lt-popover.js.map +1 -0
  196. package/dist/components/frame/popover/popover.d.ts +49 -0
  197. package/dist/components/frame/popover/popover.d.ts.map +1 -0
  198. package/dist/components/frame/popover/popover.js +64 -0
  199. package/dist/components/frame/popover/popover.js.map +1 -0
  200. package/dist/components/frame/session-timeout/lt-session-timeout.d.ts +198 -0
  201. package/dist/components/frame/session-timeout/lt-session-timeout.d.ts.map +1 -0
  202. package/dist/components/frame/session-timeout/lt-session-timeout.js +573 -0
  203. package/dist/components/frame/session-timeout/lt-session-timeout.js.map +1 -0
  204. package/dist/components/frame/session-timeout/session-timeout.d.ts +113 -0
  205. package/dist/components/frame/session-timeout/session-timeout.d.ts.map +1 -0
  206. package/dist/components/frame/session-timeout/session-timeout.js +101 -0
  207. package/dist/components/frame/session-timeout/session-timeout.js.map +1 -0
  208. package/dist/components/frame/suggestion/lt-suggestion.d.ts +361 -0
  209. package/dist/components/frame/suggestion/lt-suggestion.d.ts.map +1 -0
  210. package/dist/components/frame/suggestion/lt-suggestion.js +1152 -0
  211. package/dist/components/frame/suggestion/lt-suggestion.js.map +1 -0
  212. package/dist/components/frame/suggestion/suggestion.d.ts +143 -0
  213. package/dist/components/frame/suggestion/suggestion.d.ts.map +1 -0
  214. package/dist/components/frame/suggestion/suggestion.js +127 -0
  215. package/dist/components/frame/suggestion/suggestion.js.map +1 -0
  216. package/dist/components/frame/tabs/lt-tabs.d.ts +404 -0
  217. package/dist/components/frame/tabs/lt-tabs.d.ts.map +1 -0
  218. package/dist/components/frame/tabs/lt-tabs.js +1201 -0
  219. package/dist/components/frame/tabs/lt-tabs.js.map +1 -0
  220. package/dist/components/frame/tabs/tabs.d.ts +112 -0
  221. package/dist/components/frame/tabs/tabs.d.ts.map +1 -0
  222. package/dist/components/frame/tabs/tabs.js +107 -0
  223. package/dist/components/frame/tabs/tabs.js.map +1 -0
  224. package/dist/components/host-element.d.ts +135 -0
  225. package/dist/components/host-element.d.ts.map +1 -0
  226. package/dist/components/host-element.js +366 -0
  227. package/dist/components/host-element.js.map +1 -0
  228. package/dist/components/standalone/connection-status/connection-status.d.ts +28 -0
  229. package/dist/components/standalone/connection-status/connection-status.d.ts.map +1 -0
  230. package/dist/components/standalone/connection-status/connection-status.js +22 -0
  231. package/dist/components/standalone/connection-status/connection-status.js.map +1 -0
  232. package/dist/components/standalone/connection-status/lt-connection-status.d.ts +81 -0
  233. package/dist/components/standalone/connection-status/lt-connection-status.d.ts.map +1 -0
  234. package/dist/components/standalone/connection-status/lt-connection-status.js +216 -0
  235. package/dist/components/standalone/connection-status/lt-connection-status.js.map +1 -0
  236. package/dist/components/standalone/toast/lt-toast.d.ts +109 -0
  237. package/dist/components/standalone/toast/lt-toast.d.ts.map +1 -0
  238. package/dist/components/standalone/toast/lt-toast.js +256 -0
  239. package/dist/components/standalone/toast/lt-toast.js.map +1 -0
  240. package/dist/components/standalone/toast/toast.d.ts +52 -0
  241. package/dist/components/standalone/toast/toast.d.ts.map +1 -0
  242. package/dist/components/standalone/toast/toast.js +42 -0
  243. package/dist/components/standalone/toast/toast.js.map +1 -0
  244. package/dist/diagnostics/core.d.ts +137 -0
  245. package/dist/diagnostics/core.d.ts.map +1 -0
  246. package/dist/diagnostics/core.js +72 -0
  247. package/dist/diagnostics/core.js.map +1 -0
  248. package/dist/diagnostics/default-core.d.ts +10 -0
  249. package/dist/diagnostics/default-core.d.ts.map +1 -0
  250. package/dist/diagnostics/default-core.js +72 -0
  251. package/dist/diagnostics/default-core.js.map +1 -0
  252. package/dist/diagnostics/index.d.ts +84 -0
  253. package/dist/diagnostics/index.d.ts.map +1 -0
  254. package/dist/diagnostics/index.js +106 -0
  255. package/dist/diagnostics/index.js.map +1 -0
  256. package/dist/dom.d.ts +55 -0
  257. package/dist/dom.d.ts.map +1 -0
  258. package/dist/dom.js +162 -0
  259. package/dist/dom.js.map +1 -0
  260. package/dist/index.d.ts +97 -0
  261. package/dist/index.d.ts.map +1 -0
  262. package/dist/index.js +58 -0
  263. package/dist/index.js.map +1 -0
  264. package/dist/jsx/react.d.ts +180 -0
  265. package/dist/jsx/react.d.ts.map +1 -0
  266. package/dist/jsx/react.js +2 -0
  267. package/dist/jsx/react.js.map +1 -0
  268. package/dist/lotek.css +3617 -0
  269. package/dist/lt.d.ts +325 -0
  270. package/dist/lt.d.ts.map +1 -0
  271. package/dist/lt.js +183 -0
  272. package/dist/lt.js.map +1 -0
  273. package/dist/react.d.ts +492 -0
  274. package/dist/react.d.ts.map +1 -0
  275. package/dist/react.js +296 -0
  276. package/dist/react.js.map +1 -0
  277. package/dist/register.d.ts +17 -0
  278. package/dist/register.d.ts.map +1 -0
  279. package/dist/register.js +35 -0
  280. package/dist/register.js.map +1 -0
  281. package/dist/tokens/color.d.ts +43 -0
  282. package/dist/tokens/color.d.ts.map +1 -0
  283. package/dist/tokens/color.js +123 -0
  284. package/dist/tokens/color.js.map +1 -0
  285. package/dist/tokens/contract.d.ts +18 -0
  286. package/dist/tokens/contract.d.ts.map +1 -0
  287. package/dist/tokens/contract.js +18 -0
  288. package/dist/tokens/contract.js.map +1 -0
  289. package/dist/tokens/matrix-cells.d.ts +30 -0
  290. package/dist/tokens/matrix-cells.d.ts.map +1 -0
  291. package/dist/tokens/matrix-cells.js +273 -0
  292. package/dist/tokens/matrix-cells.js.map +1 -0
  293. package/dist/tokens/matrix.d.ts +18 -0
  294. package/dist/tokens/matrix.d.ts.map +1 -0
  295. package/dist/tokens/matrix.js +21 -0
  296. package/dist/tokens/matrix.js.map +1 -0
  297. package/dist/tokens/theme-check.d.ts +42 -0
  298. package/dist/tokens/theme-check.d.ts.map +1 -0
  299. package/dist/tokens/theme-check.js +10 -0
  300. package/dist/tokens/theme-check.js.map +1 -0
  301. package/dist/tokens/theme.d.ts +94 -0
  302. package/dist/tokens/theme.d.ts.map +1 -0
  303. package/dist/tokens/theme.js +14 -0
  304. package/dist/tokens/theme.js.map +1 -0
  305. package/dist/tokens/tokens.d.ts +122 -0
  306. package/dist/tokens/tokens.d.ts.map +1 -0
  307. package/dist/tokens/tokens.js +158 -0
  308. package/dist/tokens/tokens.js.map +1 -0
  309. package/dist/vocabulary/classes.d.ts +3 -0
  310. package/dist/vocabulary/classes.d.ts.map +1 -0
  311. package/dist/vocabulary/classes.js +1320 -0
  312. package/dist/vocabulary/classes.js.map +1 -0
  313. package/dist/vocabulary/elements.d.ts +3 -0
  314. package/dist/vocabulary/elements.d.ts.map +1 -0
  315. package/dist/vocabulary/elements.js +410 -0
  316. package/dist/vocabulary/elements.js.map +1 -0
  317. package/dist/vocabulary/types.d.ts +175 -0
  318. package/dist/vocabulary/types.d.ts.map +1 -0
  319. package/dist/vocabulary/types.js +11 -0
  320. package/dist/vocabulary/types.js.map +1 -0
  321. package/dist/wasi-host.d.ts +24 -0
  322. package/dist/wasi-host.d.ts.map +1 -0
  323. package/dist/wasi-host.js +140 -0
  324. package/dist/wasi-host.js.map +1 -0
  325. package/live-templates.xml +62 -0
  326. package/manifest/files.json +373 -0
  327. package/manifest/manifest.json +4965 -0
  328. package/manifest/manifest.schema.json +513 -0
  329. package/package.json +404 -4
  330. package/src/cli.ts +21 -0
  331. package/src/components/css/accordion/accordion.css +102 -0
  332. package/src/components/css/accordion/accordion.ts +50 -0
  333. package/src/components/css/alert/alert.css +53 -0
  334. package/src/components/css/alert/alert.ts +48 -0
  335. package/src/components/css/avatar/avatar.css +96 -0
  336. package/src/components/css/avatar/avatar.ts +57 -0
  337. package/src/components/css/badge/badge.css +42 -0
  338. package/src/components/css/badge/badge.ts +43 -0
  339. package/src/components/css/breadcrumbs/breadcrumbs.css +62 -0
  340. package/src/components/css/breadcrumbs/breadcrumbs.ts +30 -0
  341. package/src/components/css/button/button.css +128 -0
  342. package/src/components/css/button/button.ts +44 -0
  343. package/src/components/css/card/card.css +65 -0
  344. package/src/components/css/card/card.ts +50 -0
  345. package/src/components/css/checkbox/checkbox.css +114 -0
  346. package/src/components/css/checkbox/checkbox.ts +50 -0
  347. package/src/components/css/divider/divider.css +38 -0
  348. package/src/components/css/divider/divider.ts +42 -0
  349. package/src/components/css/error-text/error-text.css +21 -0
  350. package/src/components/css/error-text/error-text.ts +37 -0
  351. package/src/components/css/fieldset/fieldset.css +72 -0
  352. package/src/components/css/fieldset/fieldset.ts +87 -0
  353. package/src/components/css/file-upload/file-upload.css +102 -0
  354. package/src/components/css/file-upload/file-upload.ts +65 -0
  355. package/src/components/css/heading/heading.css +33 -0
  356. package/src/components/css/heading/heading.ts +42 -0
  357. package/src/components/css/help-text/help-text.css +24 -0
  358. package/src/components/css/help-text/help-text.ts +42 -0
  359. package/src/components/css/icon/icon.css +20 -0
  360. package/src/components/css/icon/icon.ts +44 -0
  361. package/src/components/css/input/input.css +145 -0
  362. package/src/components/css/input/input.ts +77 -0
  363. package/src/components/css/label/label.css +42 -0
  364. package/src/components/css/label/label.ts +51 -0
  365. package/src/components/css/link/link.css +38 -0
  366. package/src/components/css/link/link.ts +38 -0
  367. package/src/components/css/list/list.css +53 -0
  368. package/src/components/css/list/list.ts +44 -0
  369. package/src/components/css/pagination/pagination.css +95 -0
  370. package/src/components/css/pagination/pagination.ts +33 -0
  371. package/src/components/css/paragraph/paragraph.css +31 -0
  372. package/src/components/css/paragraph/paragraph.ts +53 -0
  373. package/src/components/css/progress/progress.css +161 -0
  374. package/src/components/css/progress/progress.ts +78 -0
  375. package/src/components/css/radio/radio.css +94 -0
  376. package/src/components/css/radio/radio.ts +50 -0
  377. package/src/components/css/search/search.css +50 -0
  378. package/src/components/css/search/search.ts +56 -0
  379. package/src/components/css/select/select.css +321 -0
  380. package/src/components/css/select/select.ts +63 -0
  381. package/src/components/css/shared.ts +199 -0
  382. package/src/components/css/skeleton/skeleton.css +62 -0
  383. package/src/components/css/skeleton/skeleton.ts +43 -0
  384. package/src/components/css/skip-link/skip-link.css +41 -0
  385. package/src/components/css/skip-link/skip-link.ts +22 -0
  386. package/src/components/css/spinner/spinner.css +48 -0
  387. package/src/components/css/spinner/spinner.ts +48 -0
  388. package/src/components/css/sr-only/sr-only.css +16 -0
  389. package/src/components/css/sr-only/sr-only.ts +21 -0
  390. package/src/components/css/switch/switch.css +105 -0
  391. package/src/components/css/switch/switch.ts +50 -0
  392. package/src/components/css/table/table.css +159 -0
  393. package/src/components/css/table/table.ts +107 -0
  394. package/src/components/css/tag/tag.css +58 -0
  395. package/src/components/css/tag/tag.ts +49 -0
  396. package/src/components/css/textarea/textarea.css +83 -0
  397. package/src/components/css/textarea/textarea.ts +40 -0
  398. package/src/components/css/toggle-group/toggle-group.css +92 -0
  399. package/src/components/css/toggle-group/toggle-group.ts +37 -0
  400. package/src/components/css/tooltip/tooltip.css +89 -0
  401. package/src/components/css/tooltip/tooltip.ts +37 -0
  402. package/src/components/default-texts.ts +34 -0
  403. package/src/components/events.ts +68 -0
  404. package/src/components/frame/dialog/dialog.css +306 -0
  405. package/src/components/frame/dialog/dialog.ts +166 -0
  406. package/src/components/frame/dialog/lt-dialog.ts +510 -0
  407. package/src/components/frame/error-summary/error-summary.css +47 -0
  408. package/src/components/frame/error-summary/error-summary.ts +56 -0
  409. package/src/components/frame/error-summary/lt-error-summary.ts +344 -0
  410. package/src/components/frame/field/field-core.ts +152 -0
  411. package/src/components/frame/field/field.css +17 -0
  412. package/src/components/frame/field/lt-field.ts +753 -0
  413. package/src/components/frame/popover/lt-popover.ts +555 -0
  414. package/src/components/frame/popover/popover.css +50 -0
  415. package/src/components/frame/popover/popover.ts +102 -0
  416. package/src/components/frame/session-timeout/lt-session-timeout.ts +681 -0
  417. package/src/components/frame/session-timeout/session-timeout.css +50 -0
  418. package/src/components/frame/session-timeout/session-timeout.ts +156 -0
  419. package/src/components/frame/suggestion/lt-suggestion.ts +1358 -0
  420. package/src/components/frame/suggestion/suggestion.css +132 -0
  421. package/src/components/frame/suggestion/suggestion.ts +172 -0
  422. package/src/components/frame/tabs/lt-tabs.ts +1319 -0
  423. package/src/components/frame/tabs/tabs.css +128 -0
  424. package/src/components/frame/tabs/tabs.ts +188 -0
  425. package/src/components/host-element.ts +400 -0
  426. package/src/components/standalone/connection-status/connection-status.css +41 -0
  427. package/src/components/standalone/connection-status/connection-status.ts +41 -0
  428. package/src/components/standalone/connection-status/lt-connection-status.ts +242 -0
  429. package/src/components/standalone/toast/lt-toast.ts +300 -0
  430. package/src/components/standalone/toast/toast.css +78 -0
  431. package/src/components/standalone/toast/toast.ts +70 -0
  432. package/src/diagnostics/core.ts +210 -0
  433. package/src/diagnostics/default-core.ts +81 -0
  434. package/src/diagnostics/index.ts +150 -0
  435. package/src/dom.ts +185 -0
  436. package/src/index.ts +218 -0
  437. package/src/jsx/react.ts +212 -0
  438. package/src/lt.ts +192 -0
  439. package/src/react.ts +411 -0
  440. package/src/register.ts +43 -0
  441. package/src/tailwind/tailwind.css +169 -0
  442. package/src/tokens/boundary.css +104 -0
  443. package/src/tokens/color-contract.json +231 -0
  444. package/src/tokens/color.ts +150 -0
  445. package/src/tokens/contract.ts +24 -0
  446. package/src/tokens/matrix-cells.ts +375 -0
  447. package/src/tokens/matrix.ts +32 -0
  448. package/src/tokens/theme-check.ts +51 -0
  449. package/src/tokens/theme.ts +104 -0
  450. package/src/tokens/tokens.css +569 -0
  451. package/src/tokens/tokens.ts +223 -0
  452. package/src/vocabulary/classes.ts +1322 -0
  453. package/src/vocabulary/elements.ts +412 -0
  454. package/src/vocabulary/types.ts +178 -0
  455. package/src/wasi-host.ts +155 -0
  456. package/web-types.json +800 -0
@@ -0,0 +1,42 @@
1
+ import { attributes } from "../../css/shared.js";
2
+ import { DEFAULT_TEXTS } from "../../default-texts.js";
3
+ /**
4
+ * The class on the host, that is, the region the messages are in.
5
+ *
6
+ * Until 0.28.0 this was the class on each message, and the region was styled
7
+ * by its element name. Registered under another name, with
8
+ * `defineLtToast("my-toast")`, it then lost its position.
9
+ */
10
+ export const TOAST_CLASS = "lt-toast";
11
+ export const TOAST_MESSAGE_CLASS = "lt-toast__message";
12
+ export const TOAST_CLOSE_CLASS = "lt-toast__close";
13
+ /**
14
+ * The attributes for the toast region.
15
+ *
16
+ * The region is `role="status"` and not `role="alert"`. A message that comes
17
+ * because something went well should not interrupt what the screen reader is
18
+ * doing.
19
+ *
20
+ * `data-ignore-morph` is not optional. `<lt-toast>` creates and removes its
21
+ * message elements inside the region, and without the attribute the Datastar
22
+ * morph tears them away at the next patch, because the server's version of
23
+ * the region is empty. The attribute must be in the HTML the server sends:
24
+ * the component cannot set it on itself, since the morph reads it from the
25
+ * server's node.
26
+ */
27
+ export const toast = ({ label = DEFAULT_TEXTS.toastRegion, closeLabel, } = {}) => ({
28
+ host: attributes({
29
+ class: TOAST_CLASS,
30
+ role: "status",
31
+ "aria-live": "polite",
32
+ // `status` is atomic by default, and then the whole stack is announced
33
+ // again for every message that is added.
34
+ "aria-atomic": "false",
35
+ "aria-label": label,
36
+ "close-label": closeLabel,
37
+ "data-ignore-morph": "",
38
+ }),
39
+ message: attributes({ class: TOAST_MESSAGE_CLASS }),
40
+ close: attributes({ class: TOAST_CLOSE_CLASS }),
41
+ });
42
+ //# sourceMappingURL=toast.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toast.js","sourceRoot":"","sources":["../../../../src/components/standalone/toast/toast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAEtD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,UAAmB,CAAA;AAC9C,MAAM,CAAC,MAAM,mBAAmB,GAAG,mBAA4B,CAAA;AAC/D,MAAM,CAAC,MAAM,iBAAiB,GAAG,iBAA0B,CAAA;AA0B3D;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,EACpB,KAAK,GAAG,aAAa,CAAC,WAAW,EACjC,UAAU,MACM,EAAE,EAAmB,EAAE,CAAC,CAAC;IACzC,IAAI,EAAE,UAAU,CAAC;QACf,KAAK,EAAE,WAAW;QAClB,IAAI,EAAE,QAAiB;QACvB,WAAW,EAAE,QAAiB;QAC9B,uEAAuE;QACvE,yCAAyC;QACzC,aAAa,EAAE,OAAgB;QAC/B,YAAY,EAAE,KAAK;QACnB,aAAa,EAAE,UAAU;QACzB,mBAAmB,EAAE,EAAW;KACjC,CAAC;IACF,OAAO,EAAE,UAAU,CAAC,EAAE,KAAK,EAAE,mBAAmB,EAAE,CAAC;IACnD,KAAK,EAAE,UAAU,CAAC,EAAE,KAAK,EAAE,iBAAiB,EAAE,CAAC;CAChD,CAAC,CAAA"}
@@ -0,0 +1,137 @@
1
+ /**
2
+ * The core: LO-TEK's check and theme generator, written in Rust and built to
3
+ * a single WebAssembly module.
4
+ *
5
+ * The same module runs here, in VS Code, on the JVM (Chicory) and in
6
+ * IntelliJ, and gives the same answer everywhere. The module has no imports,
7
+ * so it needs no glue: the loader writes the text in as UTF-8 and reads the
8
+ * answer out as JSON, as every host language does.
9
+ *
10
+ * The core carries no data. The vocabulary and the colour contract are given
11
+ * to it with `loadManifest` and `loadContract`, from the files in the package.
12
+ *
13
+ * `diagnoseMarkup` and `diagnosePage` in `index.ts` load the module and the
14
+ * files from the package themselves. `loadCore` is for anyone who has the
15
+ * module some other way, such as an extension that bundles it, or a browser:
16
+ *
17
+ * ```ts
18
+ * const core = loadCore(await WebAssembly.compileStreaming(fetch(url)))
19
+ * core.loadManifest(await (await fetch(manifestUrl)).text())
20
+ * core.diagnosePage(html)
21
+ * ```
22
+ *
23
+ * Synchronous, because Node, Bun and VS Code allow it. In the browser the
24
+ * module must be compiled with `WebAssembly.compile` first, and the compiled
25
+ * module passed here.
26
+ */
27
+ export type Severity = "error" | "warning";
28
+ /** One edit in a fix: replace the text from `start` to `end` with `text`. */
29
+ export type Edit = {
30
+ start: number;
31
+ end: number;
32
+ text: string;
33
+ };
34
+ /**
35
+ * A fix the editor can offer: one or more edits that belong together, such
36
+ * as `id` on the field and `for` on the label. They are in text order and do
37
+ * not overlap; apply them from the end, so the positions hold. `preferred`
38
+ * marks the safe one, such as `onlinetext` to `online-text`: the same
39
+ * letters, only written differently. A suggestion at a distance is a
40
+ * suggestion.
41
+ */
42
+ export type Fix = {
43
+ title: string;
44
+ edits: Edit[];
45
+ preferred?: boolean;
46
+ };
47
+ export type Finding = {
48
+ /** Where the finding starts, as an index into the text (UTF-16, like a `string`). */
49
+ start: number;
50
+ end: number;
51
+ /** The line the finding starts on, from 1. */
52
+ line: number;
53
+ /** The column the finding starts at, from 1, in UTF-16 units. */
54
+ column: number;
55
+ message: string;
56
+ severity: Severity;
57
+ /** The name of the rule, such as `unknown-class`. That is what `lotek-ignore-next` takes. */
58
+ rule: string;
59
+ /** The component page, as a link in the message. */
60
+ link: string;
61
+ fix?: Fix;
62
+ };
63
+ export type CoreVersion = {
64
+ /** The version of the core. */
65
+ core: string;
66
+ /** The version of `@lo-tek/interfaces` the manifest was written from, or `null` without a manifest. */
67
+ manifest: string | null;
68
+ /** The manifest format the core understands. */
69
+ schemaVersion: number;
70
+ };
71
+ /** A promise in the colour contract that does not hold. */
72
+ export type Violation = {
73
+ family: string;
74
+ promise: string;
75
+ ratio: number;
76
+ required: number;
77
+ };
78
+ /** The theme `buildTheme` returns: the tokens per appearance, the promises that break, and the CSS. */
79
+ export type CoreTheme = {
80
+ light: Record<string, string>;
81
+ dark: Record<string, string>;
82
+ /** Promises that do not hold. Empty when the theme is sound. */
83
+ violations: Violation[];
84
+ css: string;
85
+ };
86
+ /** What `inspectTheme` found in a theme the consumer has written by hand. */
87
+ export type CoreThemeReport = {
88
+ problems: {
89
+ selector: string;
90
+ message: string;
91
+ }[];
92
+ /** Blocks that were actually read. */
93
+ blocks: number;
94
+ /** Values the consumer wrote, and that were understood. */
95
+ declarations: number;
96
+ /** Promises that were actually checked. */
97
+ promises: number;
98
+ };
99
+ /** What `inspectStyles` found in a stylesheet. */
100
+ export type CoreStyles = {
101
+ /** Every class that appears in a selector. */
102
+ classes: string[];
103
+ /** Every class with an attribute, and the value when the selector requires one. */
104
+ attributes: {
105
+ class: string;
106
+ attribute: string;
107
+ value?: string;
108
+ }[];
109
+ /** The URLs in `@import`. */
110
+ imports: string[];
111
+ };
112
+ export type Core = {
113
+ /** Checks a template or a fragment. Throws without a manifest. */
114
+ diagnoseMarkup(html: string): Finding[];
115
+ /** Checks a whole page, including the wiring. Throws without a manifest. */
116
+ diagnosePage(html: string): Finding[];
117
+ /** Gives the core the vocabulary. Throws with the core's explanation if it cannot be read. */
118
+ loadManifest(json: string): void;
119
+ /** Gives the core the colour contract. Throws with the core's explanation if it cannot be read. */
120
+ loadContract(json: string): void;
121
+ version(): CoreVersion;
122
+ /** Builds a theme from the recipe. Throws without a colour contract, or when the recipe cannot be used. */
123
+ buildTheme(recipe: unknown): CoreTheme;
124
+ /** Checks every promise in a theme written as CSS. Throws without a colour contract. */
125
+ inspectTheme(css: string): CoreThemeReport;
126
+ /** The classes and attribute values a stylesheet styles, read with the core's CSS reader. */
127
+ inspectStyles(css: string): CoreStyles;
128
+ /**
129
+ * The check with the stylesheets as well: a class none of them styles, and
130
+ * a value without a rule. `page` checks as `diagnosePage`, otherwise as
131
+ * `diagnoseMarkup`. Throws without a manifest.
132
+ */
133
+ diagnoseStyled(html: string, css: string[], page: boolean): Finding[];
134
+ };
135
+ /** Loads the core from the module's bytes or an already compiled module. */
136
+ export declare function loadCore(source: BufferSource | WebAssembly.Module): Core;
137
+ //# sourceMappingURL=core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/diagnostics/core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAA;AAE1C,6EAA6E;AAC7E,MAAM,MAAM,IAAI,GAAG;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,GAAG,GAAG;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,IAAI,EAAE,CAAA;IACb,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,OAAO,GAAG;IACpB,qFAAqF;IACrF,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IACX,8CAA8C;IAC9C,IAAI,EAAE,MAAM,CAAA;IACZ,iEAAiE;IACjE,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,QAAQ,CAAA;IAClB,6FAA6F;IAC7F,IAAI,EAAE,MAAM,CAAA;IACZ,oDAAoD;IACpD,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,GAAG,CAAA;CACV,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,uGAAuG;IACvG,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,gDAAgD;IAChD,aAAa,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,2DAA2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,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IAChC,mGAAmG;IACnG,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IAChC,OAAO,IAAI,WAAW,CAAA;IACtB,2GAA2G;IAC3G,UAAU,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,CAAA;IACtC,wFAAwF;IACxF,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,CAAA;IAC1C,6FAA6F;IAC7F,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAA;IACtC;;;;OAIG;IACH,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,EAAE,CAAA;CACtE,CAAA;AAkBD,4EAA4E;AAC5E,wBAAgB,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG,WAAW,CAAC,MAAM,GAAG,IAAI,CAsDxE"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * The core: LO-TEK's check and theme generator, written in Rust and built to
3
+ * a single WebAssembly module.
4
+ *
5
+ * The same module runs here, in VS Code, on the JVM (Chicory) and in
6
+ * IntelliJ, and gives the same answer everywhere. The module has no imports,
7
+ * so it needs no glue: the loader writes the text in as UTF-8 and reads the
8
+ * answer out as JSON, as every host language does.
9
+ *
10
+ * The core carries no data. The vocabulary and the colour contract are given
11
+ * to it with `loadManifest` and `loadContract`, from the files in the package.
12
+ *
13
+ * `diagnoseMarkup` and `diagnosePage` in `index.ts` load the module and the
14
+ * files from the package themselves. `loadCore` is for anyone who has the
15
+ * module some other way, such as an extension that bundles it, or a browser:
16
+ *
17
+ * ```ts
18
+ * const core = loadCore(await WebAssembly.compileStreaming(fetch(url)))
19
+ * core.loadManifest(await (await fetch(manifestUrl)).text())
20
+ * core.diagnosePage(html)
21
+ * ```
22
+ *
23
+ * Synchronous, because Node, Bun and VS Code allow it. In the browser the
24
+ * module must be compiled with `WebAssembly.compile` first, and the compiled
25
+ * module passed here.
26
+ */
27
+ /** Loads the core from the module's bytes or an already compiled module. */
28
+ export function loadCore(source) {
29
+ const module = source instanceof WebAssembly.Module
30
+ ? source
31
+ : new WebAssembly.Module(source);
32
+ const e = new WebAssembly.Instance(module, {}).exports;
33
+ const encoder = new TextEncoder();
34
+ const decoder = new TextDecoder();
35
+ /** Writes the text into the module's memory and returns the pointer and length. */
36
+ const write = (text) => {
37
+ const bytes = encoder.encode(text);
38
+ const pointer = e.alloc(bytes.length);
39
+ // The memory can grow on every call, so the view is created after `alloc`.
40
+ new Uint8Array(e.memory.buffer, pointer, bytes.length).set(bytes);
41
+ return [pointer, bytes.length];
42
+ };
43
+ const read = () => JSON.parse(decoder.decode(new Uint8Array(e.memory.buffer, e.result_ptr(), e.result_len())));
44
+ /** The answer from a call that can be rejected: the value, or the core's explanation as an error. */
45
+ const answer = (status) => {
46
+ if (status !== 0)
47
+ throw new Error(read().error);
48
+ return read();
49
+ };
50
+ return {
51
+ diagnoseMarkup: (html) => answer(e.diagnose_markup_raw(...write(html))),
52
+ diagnosePage: (html) => answer(e.diagnose_page_raw(...write(html))),
53
+ loadManifest: (json) => {
54
+ answer(e.load_manifest_raw(...write(json)));
55
+ },
56
+ loadContract: (json) => {
57
+ answer(e.load_contract_raw(...write(json)));
58
+ },
59
+ version: () => {
60
+ e.version_raw();
61
+ return read();
62
+ },
63
+ buildTheme: (recipe) => answer(e.build_theme_raw(...write(JSON.stringify(recipe)))),
64
+ inspectTheme: (css) => answer(e.inspect_theme_raw(...write(css))),
65
+ inspectStyles: (css) => {
66
+ e.inspect_styles_raw(...write(css));
67
+ return read();
68
+ },
69
+ diagnoseStyled: (html, css, page) => answer(e.diagnose_styled_raw(...write(JSON.stringify({ html, css, page })))),
70
+ };
71
+ }
72
+ //# sourceMappingURL=core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/diagnostics/core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;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AAM,CACJ,CAAC,CAAC,mBAAmB,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CACrE;KACJ,CAAA;AACH,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The core from the package itself, loaded the first time it is needed, with
3
+ * the package's manifest and colour contract, which sit next to the module.
4
+ *
5
+ * Both the check (`@lo-tek/interfaces/diagnostics`) and the theme
6
+ * (`@lo-tek/interfaces/theme` and `theme-check`) use the same instance.
7
+ */
8
+ import { type Core } from "./core.js";
9
+ export declare function defaultCore(): Core;
10
+ //# sourceMappingURL=default-core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-core.d.ts","sourceRoot":"","sources":["../../src/diagnostics/default-core.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,KAAK,IAAI,EAAY,MAAM,WAAW,CAAA;AAoB/C,wBAAgB,WAAW,IAAI,IAAI,CAoDlC"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * The core from the package itself, loaded the first time it is needed, with
3
+ * the package's manifest and colour contract, which sit next to the module.
4
+ *
5
+ * Both the check (`@lo-tek/interfaces/diagnostics`) and the theme
6
+ * (`@lo-tek/interfaces/theme` and `theme-check`) use the same instance.
7
+ */
8
+ import { loadCore } from "./core.js";
9
+ /** The files in the package, seen from both `src/diagnostics/` and `dist/diagnostics/`. */
10
+ const MODULE = new URL("../../core/lotek-core.wasm", import.meta.url);
11
+ const MANIFEST = new URL("../../manifest/manifest.json", import.meta.url);
12
+ const CONTRACT = new URL("../../src/tokens/color-contract.json", import.meta.url);
13
+ let core;
14
+ /*
15
+ * Loaded the first time it is needed, not when the module is imported:
16
+ * anyone who only wants the types, or `loadCore`, should not pay for it.
17
+ *
18
+ * `node:fs` is fetched with `process.getBuiltinModule` instead of an import,
19
+ * so the file can be bundled for the browser without the bundler looking
20
+ * for `fs`.
21
+ */
22
+ export function defaultCore() {
23
+ if (core)
24
+ return core;
25
+ const fs = globalThis.process?.getBuiltinModule?.("node:fs");
26
+ if (!fs) {
27
+ // `getBuiltinModule` arrived in Node 20.16 and 22.3, so Node 21 and 22.0
28
+ // to 22.2 are excluded even though they are newer than 20.16. `engines`
29
+ // in package.json says the same. A Node without it is still Node, and
30
+ // should be told that the version is wrong, with both limits, so Node
31
+ // 22.1 is not told it is older than 20.16.
32
+ const node = globalThis.process?.versions?.node;
33
+ throw new Error(node
34
+ ? `LO-TEK requires Node 20.16 or later in the 20 series, or Node 22.3 or later, and this is Node ${node}.`
35
+ : "LO-TEK reads the core from the package, which requires Node, Bun or Deno. In the browser, load lotek-core.wasm yourself, pass it to loadCore, and give the core manifest.json with loadManifest and color-contract.json with loadContract.");
36
+ }
37
+ let bytes;
38
+ try {
39
+ bytes = fs.readFileSync(MODULE);
40
+ }
41
+ catch {
42
+ throw new Error(`Could not find the core at ${MODULE.pathname}. In the repository it is built with "bun run core" in interfaces/, which requires Rust.`);
43
+ }
44
+ // The manifest is only needed by the check, and the colour contract only
45
+ // by the theme. Each is read the first time a call needs it.
46
+ const loaded = loadCore(bytes);
47
+ let manifest = false;
48
+ let contract = false;
49
+ const withManifest = () => {
50
+ if (!manifest)
51
+ loaded.loadManifest(fs.readFileSync(MANIFEST, "utf8"));
52
+ manifest = true;
53
+ return loaded;
54
+ };
55
+ const withContract = () => {
56
+ if (!contract)
57
+ loaded.loadContract(fs.readFileSync(CONTRACT, "utf8"));
58
+ contract = true;
59
+ return loaded;
60
+ };
61
+ core = {
62
+ ...loaded,
63
+ diagnoseMarkup: (html) => withManifest().diagnoseMarkup(html),
64
+ diagnosePage: (html) => withManifest().diagnosePage(html),
65
+ diagnoseStyled: (html, css, page) => withManifest().diagnoseStyled(html, css, page),
66
+ version: () => withManifest().version(),
67
+ buildTheme: (recipe) => withContract().buildTheme(recipe),
68
+ inspectTheme: (css) => withContract().inspectTheme(css),
69
+ };
70
+ return core;
71
+ }
72
+ //# sourceMappingURL=default-core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-core.js","sourceRoot":"","sources":["../../src/diagnostics/default-core.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAa,QAAQ,EAAE,MAAM,WAAW,CAAA;AAE/C,2FAA2F;AAC3F,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,4BAA4B,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACrE,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,8BAA8B,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACzE,MAAM,QAAQ,GAAG,IAAI,GAAG,CACtB,sCAAsC,EACtC,MAAM,CAAC,IAAI,CAAC,GAAG,CAChB,CAAA;AAED,IAAI,IAAsB,CAAA;AAE1B;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW;IACzB,IAAI,IAAI;QAAE,OAAO,IAAI,CAAA;IACrB,MAAM,EAAE,GAAG,UAAU,CAAC,OAAO,EAAE,gBAAgB,EAAE,CAAC,SAAS,CAE9C,CAAA;IACb,IAAI,CAAC,EAAE,EAAE,CAAC;QACR,yEAAyE;QACzE,wEAAwE;QACxE,sEAAsE;QACtE,sEAAsE;QACtE,2CAA2C;QAC3C,MAAM,IAAI,GAAG,UAAU,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAA;QAC/C,MAAM,IAAI,KAAK,CACb,IAAI;YACF,CAAC,CAAC,iGAAiG,IAAI,GAAG;YAC1G,CAAC,CAAC,4OAA4O,CACjP,CAAA;IACH,CAAC;IACD,IAAI,KAAiB,CAAA;IACrB,IAAI,CAAC;QACH,KAAK,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,CAAA;IACjC,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CACb,8BAA8B,MAAM,CAAC,QAAQ,0FAA0F,CACxI,CAAA;IACH,CAAC;IACD,yEA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AACb,CAAC"}
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Checks markup against LO-TEK, outside the browser.
3
+ *
4
+ * `diagnoseMarkup(html)` is the same check the editor extensions run while
5
+ * you type, and that `lotek check` runs on the command line. It is here
6
+ * because markup produced without JavaScript, in a Go template, a Kotlin
7
+ * string or a Razor view, has no compiler looking at the attributes. A test
8
+ * in the app can then run it over the HTML the server actually sends:
9
+ *
10
+ * ```ts
11
+ * import { diagnosePage } from "@lo-tek/interfaces/diagnostics"
12
+ *
13
+ * expect(diagnosePage(html)).toEqual([])
14
+ * ```
15
+ *
16
+ * The check is the core, written in Rust and built to WebAssembly (see
17
+ * `core.ts`). The module ships with the package, and is loaded the first
18
+ * time one of the functions is called, in Node, Bun and Deno. In the
19
+ * browser, or where the module is bundled some other way, `loadCore` loads
20
+ * it.
21
+ */
22
+ import type { Finding } from "./core.js";
23
+ export type { Manifest } from "../vocabulary/types.js";
24
+ export { type Core, type CoreStyles, type CoreTheme, type CoreThemeReport, type CoreVersion, type Finding, type Fix, loadCore, type Severity, type Violation, } from "./core.js";
25
+ /** Options for the check. */
26
+ export type DiagnoseOptions = {
27
+ /**
28
+ * The stylesheets the page loads, as text. With them the check also
29
+ * reports a class none of them styles, as when the component's stylesheet
30
+ * is not loaded, and a value without a rule, such as a variant added to a
31
+ * taken-over component without the CSS getting it.
32
+ */
33
+ css?: string[];
34
+ };
35
+ /** Every finding in the text: the vocabulary, for a template or a fragment of a page. */
36
+ export declare function diagnoseMarkup(text: string, options?: DiagnoseOptions): Finding[];
37
+ /**
38
+ * Every finding on a whole page: what `diagnoseMarkup` finds, and also that
39
+ * every `for`, `aria-describedby`, `aria-labelledby` and `aria-controls`
40
+ * points to an id that exists, that no id appears twice, and that every
41
+ * LO-TEK field and every help text and error text is wired.
42
+ *
43
+ * Use it on the HTML the server sends, not on a template: in a template split
44
+ * into pieces, the id can be in another file.
45
+ *
46
+ * ```ts
47
+ * const html = await (await fetch("http://localhost:8080/form")).text()
48
+ * expect(diagnosePage(html)).toEqual([])
49
+ * ```
50
+ */
51
+ export declare function diagnosePage(text: string, options?: DiagnoseOptions): Finding[];
52
+ /** What `diagnoseRendered` needs from a page: `evaluate`, as in Playwright. */
53
+ export type RenderedPage = {
54
+ evaluate<T>(script: () => Promise<T>): Promise<T>;
55
+ };
56
+ /**
57
+ * Reads the rendered page in the browser: the DOM as it stands now, and the
58
+ * text of every stylesheet, with what they import. A stylesheet from another
59
+ * origin, such as a CDN, cannot be read through the CSSOM without
60
+ * `crossorigin`, and is then fetched again with `fetch`.
61
+ *
62
+ * The function runs in the browser, and cannot use anything outside itself.
63
+ */
64
+ export declare const READ_RENDERED_PAGE: () => Promise<{
65
+ html: string;
66
+ css: string[];
67
+ }>;
68
+ /**
69
+ * Checks the page as the browser has rendered it, with the stylesheets it
70
+ * has loaded: what `diagnosePage` finds, and what the stylesheets do not
71
+ * style. Markup the web components have added, and a class JavaScript has
72
+ * set, are included.
73
+ *
74
+ * ```ts
75
+ * import { diagnoseRendered } from "@lo-tek/interfaces/diagnostics"
76
+ *
77
+ * await page.goto("http://localhost:8080/form")
78
+ * expect(await diagnoseRendered(page)).toEqual([])
79
+ * ```
80
+ *
81
+ * `page` is a Playwright page, or anything with `evaluate`.
82
+ */
83
+ export declare function diagnoseRendered(page: RenderedPage): Promise<Finding[]>;
84
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/diagnostics/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAExC,YAAY,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AAItD,OAAO,EACL,KAAK,IAAI,EACT,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,KAAK,GAAG,EACR,QAAQ,EACR,KAAK,QAAQ,EACb,KAAK,SAAS,GACf,MAAM,WAAW,CAAA;AAElB,6BAA6B;AAC7B,MAAM,MAAM,eAAe,GAAG;IAC5B;;;;;OAKG;IACH,GAAG,CAAC,EAAE,MAAM,EAAE,CAAA;CACf,CAAA;AAED,yFAAyF;AACzF,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,eAAoB,GAC5B,OAAO,EAAE,CAIX;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,eAAoB,GAC5B,OAAO,EAAE,CAIX;AAED,+EAA+E;AAC/E,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;CAClD,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,QAAa,OAAO,CAAC;IAClD,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,EAAE,CAAA;CACd,CA4BA,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAG7E"}
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Checks markup against LO-TEK, outside the browser.
3
+ *
4
+ * `diagnoseMarkup(html)` is the same check the editor extensions run while
5
+ * you type, and that `lotek check` runs on the command line. It is here
6
+ * because markup produced without JavaScript, in a Go template, a Kotlin
7
+ * string or a Razor view, has no compiler looking at the attributes. A test
8
+ * in the app can then run it over the HTML the server actually sends:
9
+ *
10
+ * ```ts
11
+ * import { diagnosePage } from "@lo-tek/interfaces/diagnostics"
12
+ *
13
+ * expect(diagnosePage(html)).toEqual([])
14
+ * ```
15
+ *
16
+ * The check is the core, written in Rust and built to WebAssembly (see
17
+ * `core.ts`). The module ships with the package, and is loaded the first
18
+ * time one of the functions is called, in Node, Bun and Deno. In the
19
+ * browser, or where the module is bundled some other way, `loadCore` loads
20
+ * it.
21
+ */
22
+ import { defaultCore } from "./default-core.js";
23
+ export { loadCore, } from "./core.js";
24
+ /** Every finding in the text: the vocabulary, for a template or a fragment of a page. */
25
+ export function diagnoseMarkup(text, options = {}) {
26
+ return options.css
27
+ ? defaultCore().diagnoseStyled(text, options.css, false)
28
+ : defaultCore().diagnoseMarkup(text);
29
+ }
30
+ /**
31
+ * Every finding on a whole page: what `diagnoseMarkup` finds, and also that
32
+ * every `for`, `aria-describedby`, `aria-labelledby` and `aria-controls`
33
+ * points to an id that exists, that no id appears twice, and that every
34
+ * LO-TEK field and every help text and error text is wired.
35
+ *
36
+ * Use it on the HTML the server sends, not on a template: in a template split
37
+ * into pieces, the id can be in another file.
38
+ *
39
+ * ```ts
40
+ * const html = await (await fetch("http://localhost:8080/form")).text()
41
+ * expect(diagnosePage(html)).toEqual([])
42
+ * ```
43
+ */
44
+ export function diagnosePage(text, options = {}) {
45
+ return options.css
46
+ ? defaultCore().diagnoseStyled(text, options.css, true)
47
+ : defaultCore().diagnosePage(text);
48
+ }
49
+ /**
50
+ * Reads the rendered page in the browser: the DOM as it stands now, and the
51
+ * text of every stylesheet, with what they import. A stylesheet from another
52
+ * origin, such as a CDN, cannot be read through the CSSOM without
53
+ * `crossorigin`, and is then fetched again with `fetch`.
54
+ *
55
+ * The function runs in the browser, and cannot use anything outside itself.
56
+ */
57
+ export const READ_RENDERED_PAGE = async () => {
58
+ const sheets = [
59
+ ...document.styleSheets,
60
+ ...document.adoptedStyleSheets,
61
+ ];
62
+ const css = [];
63
+ const read = async (sheet) => {
64
+ let rules;
65
+ try {
66
+ rules = sheet.cssRules;
67
+ }
68
+ catch {
69
+ if (!sheet.href)
70
+ return;
71
+ const answer = await fetch(sheet.href);
72
+ if (!answer.ok)
73
+ throw new Error(`The stylesheet ${sheet.href} could not be read, and answered ${answer.status} when it was fetched again.`);
74
+ css.push(await answer.text());
75
+ return;
76
+ }
77
+ for (const rule of rules)
78
+ if (rule instanceof CSSImportRule && rule.styleSheet)
79
+ await read(rule.styleSheet);
80
+ css.push([...rules].map((rule) => rule.cssText).join("\n"));
81
+ };
82
+ for (const sheet of sheets)
83
+ await read(sheet);
84
+ const doctype = document.doctype ? `<!DOCTYPE ${document.doctype.name}>` : "";
85
+ return { html: doctype + document.documentElement.outerHTML, css };
86
+ };
87
+ /**
88
+ * Checks the page as the browser has rendered it, with the stylesheets it
89
+ * has loaded: what `diagnosePage` finds, and what the stylesheets do not
90
+ * style. Markup the web components have added, and a class JavaScript has
91
+ * set, are included.
92
+ *
93
+ * ```ts
94
+ * import { diagnoseRendered } from "@lo-tek/interfaces/diagnostics"
95
+ *
96
+ * await page.goto("http://localhost:8080/form")
97
+ * expect(await diagnoseRendered(page)).toEqual([])
98
+ * ```
99
+ *
100
+ * `page` is a Playwright page, or anything with `evaluate`.
101
+ */
102
+ export async function diagnoseRendered(page) {
103
+ const { html, css } = await page.evaluate(READ_RENDERED_PAGE);
104
+ return defaultCore().diagnoseStyled(html, css, true);
105
+ }
106
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/diagnostics/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAMH,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAE/C,OAAO,EAQL,QAAQ,GAGT,MAAM,WAAW,CAAA;AAalB,yFAAyF;AACzF,MAAM,UAAU,cAAc,CAC5B,IAAY,EACZ,UAA2B,EAAE;IAE7B,OAAO,OAAO,CAAC,GAAG;QAChB,CAAC,CAAC,WAAW,EAAE,CAAC,cAAc,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC;QACxD,CAAC,CAAC,WAAW,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,CAAA;AACxC,CAAC;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C,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IAC7D,CAAC,CAAA;IACD,KAAK,MAAM,KAAK,IAAI,MAAM;QAAE,MAAM,IAAI,CAAC,KAAK,CAAC,CAAA;IAC7C,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,aAAa,QAAQ,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,CAAA;IAC7E,OAAO,EAAE,IAAI,EAAE,OAAO,GAAG,QAAQ,CAAC,eAAe,CAAC,SAAS,EAAE,GAAG,EAAE,CAAA;AACpE,CAAC,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,IAAkB;IACvD,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAA;IAC7D,OAAO,WAAW,EAAE,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,CAAA;AACtD,CAAC"}
package/dist/dom.d.ts ADDED
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Applying the attributes to an element in the plain DOM.
3
+ *
4
+ * In JSX you spread the object straight onto the element. Without JSX you
5
+ * would have to loop through it yourself, and take care to remove attributes
6
+ * from the previous state. When a field goes from invalid to valid, the
7
+ * builder function leaves out `data-state`, and a `setAttribute` alone would
8
+ * have left the old value in place.
9
+ */
10
+ /**
11
+ * The values a builder function can output.
12
+ *
13
+ * `true` and `false` are included because several of them are boolean HTML
14
+ * attributes: `disabled` on a switch, `multiple` on a file field, `hidden` on
15
+ * an error text. In HTML such an attribute is true as long as it exists,
16
+ * whatever its value, so `true` is set as the empty string and `false`
17
+ * removes it.
18
+ */
19
+ export type Attributes = Record<string, string | boolean | undefined>;
20
+ /**
21
+ * Sets the attributes from an `lt` function on an element.
22
+ *
23
+ * ```ts
24
+ * import { lt } from "@lo-tek/interfaces"
25
+ *
26
+ * const field = document.querySelector("input")
27
+ * lt.setAttributes(field, lt.input({ type: "email", state: "invalid" }))
28
+ * ```
29
+ *
30
+ * Call it again to change state. What the builder function manages and is
31
+ * not in the new set is removed, and the `lt-` classes are replaced. A
32
+ * builder function manages the attributes it has an option for:
33
+ * `lt.spinner()` has `label`, and so manages `role` and `aria-label`. What it
34
+ * has no option for stays as it is: `lt.button()` has never written
35
+ * `disabled`, so a disabled button is still disabled afterwards. `id` and
36
+ * `for` are never removed.
37
+ *
38
+ * When two sets go on the same element, pass them separately, not spread
39
+ * together:
40
+ *
41
+ * ```ts
42
+ * lt.setAttributes(field, lt.input({ type: "email" }), wiring.control)
43
+ * ```
44
+ *
45
+ * A spread object is a new object, and then the function does not know which
46
+ * builder function it came from. It is set correctly, but only `data-*` is
47
+ * cleaned up. An explicit `false` in a handwritten set removes the attribute.
48
+ *
49
+ * It accepts `null`, and then does nothing. `document.querySelector()`
50
+ * returns `Element | null`, so without that every call site in a `strict` app
51
+ * would need a guard or an exclamation mark around a lookup that almost
52
+ * always succeeds. It is the same trade-off as `element?.classList`.
53
+ */
54
+ export declare function setAttributes(element: Element | null | undefined, ...sets: Attributes[]): void;
55
+ //# sourceMappingURL=dom.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../src/dom.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA0CH;;;;;;;;GAQG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAA;AAErE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,EACnC,GAAG,IAAI,EAAE,UAAU,EAAE,GACpB,IAAI,CAsDN"}