@kayjs/kay 1.108.0 → 1.109.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 (543) hide show
  1. package/dist/eslint.js +1790 -3751
  2. package/editors/zed/extension.toml +2 -2
  3. package/llms/action-protection.md +1 -1
  4. package/llms/actions-from-islands.md +4 -4
  5. package/llms/actions-refused-fields.md +4 -4
  6. package/llms/api-from-islands.md +6 -6
  7. package/llms/browser-only.md +2 -2
  8. package/llms/cdn-caching.md +1 -1
  9. package/llms/checks.md +1 -1
  10. package/llms/code-lints.md +1 -2
  11. package/llms/component-library-conventions.md +1 -1
  12. package/llms/components.md +4 -4
  13. package/llms/deprecated-lints.md +1 -6
  14. package/llms/effects.md +1 -1
  15. package/llms/errors.md +2 -2
  16. package/llms/events.md +1 -1
  17. package/llms/guards.md +1 -1
  18. package/llms/head.md +1 -1
  19. package/llms/hooks.md +2 -2
  20. package/llms/images.md +1 -1
  21. package/llms/island-and-form-lints.md +2 -1
  22. package/llms/island-sources.md +1 -1
  23. package/llms/islands-state-to-ids.md +2 -2
  24. package/llms/islands.md +4 -2
  25. package/llms/lints.md +1 -1
  26. package/llms/live-values.md +3 -3
  27. package/llms/local-collections.md +1 -1
  28. package/llms/locales.md +1 -1
  29. package/llms/mcp.md +2 -2
  30. package/llms/metrics.md +1 -1
  31. package/llms/navigation-from-code.md +6 -6
  32. package/llms/prerendering.md +1 -0
  33. package/llms/production.md +2 -2
  34. package/llms/project-new-and-add.md +1 -1
  35. package/llms/project.md +4 -4
  36. package/llms/proxy-and-security.md +1 -1
  37. package/llms/queues.md +1 -1
  38. package/llms/rate-limits.md +4 -4
  39. package/llms/rendering.md +1 -1
  40. package/llms/server-islands.md +2 -2
  41. package/llms/server.md +1 -1
  42. package/llms/stores.md +1 -1
  43. package/llms/styles-and-assets.md +1 -1
  44. package/llms/testing-mount.md +49 -0
  45. package/llms/testing.md +4 -45
  46. package/llms/upgrading-1-105-config.md +13 -13
  47. package/llms/upgrading-archive.md +42 -82
  48. package/llms/upgrading.md +91 -63
  49. package/llms/whats-new.md +9 -0
  50. package/llms.txt +5 -6
  51. package/package.json +6 -10
  52. package/src/build/route-sizes.ts +2 -3
  53. package/src/check/browser-global-reads.ts +2 -2
  54. package/src/check/config-objects.ts +1 -1
  55. package/src/check/diagnose.ts +0 -22
  56. package/src/check/export-homes.ts +1 -1
  57. package/src/check/guards.ts +3 -3
  58. package/src/check/index.ts +2 -7
  59. package/src/check/moved-keys.ts +1 -1
  60. package/src/check/project.ts +3 -8
  61. package/src/check/shadow-types.ts +0 -86
  62. package/src/commands/check.ts +2 -2
  63. package/src/commands/env.ts +25 -3
  64. package/src/compiler/ast.ts +18 -16
  65. package/src/compiler/browser.ts +2 -14
  66. package/src/compiler/class-items.ts +16 -0
  67. package/src/compiler/codegen.ts +8 -8
  68. package/src/compiler/deprecated-library.ts +0 -12
  69. package/src/compiler/deprecated-lints.ts +3 -495
  70. package/src/compiler/deprecated-ui-props.ts +5 -5
  71. package/src/compiler/errors.ts +2 -2
  72. package/src/compiler/fence-checks.ts +2 -121
  73. package/src/compiler/hand-parts.ts +55 -0
  74. package/src/compiler/helper-imports.ts +2 -2
  75. package/src/compiler/image-attributes.ts +1 -3
  76. package/src/compiler/index.ts +20 -21
  77. package/src/compiler/island-arguments.ts +8 -95
  78. package/src/compiler/island-cause.ts +7 -7
  79. package/src/compiler/island-declaration.ts +2 -8
  80. package/src/compiler/island-lints.ts +12 -0
  81. package/src/compiler/island-marker.ts +3 -3
  82. package/src/compiler/island-problems.ts +25 -0
  83. package/src/compiler/jsx-class.ts +1 -25
  84. package/src/compiler/jsx.ts +2 -2
  85. package/src/compiler/kay-exports.ts +0 -2
  86. package/src/compiler/link-flags.ts +9 -38
  87. package/src/compiler/lints.ts +7 -14
  88. package/src/compiler/markup.ts +23 -26
  89. package/src/compiler/module-signals.ts +2 -2
  90. package/src/compiler/names.ts +1 -1
  91. package/src/compiler/page-settings.ts +11 -0
  92. package/src/compiler/parser.ts +6 -8
  93. package/src/compiler/plan.ts +1 -3
  94. package/src/compiler/rewrite.ts +3 -18
  95. package/src/compiler/script-server.ts +8 -3
  96. package/src/compiler/validate.ts +3 -8
  97. package/src/config-loader.ts +14 -4
  98. package/src/config-resolve.ts +18 -142
  99. package/src/config-shape.ts +44 -34
  100. package/src/config.ts +10 -114
  101. package/src/dev/preload.ts +4 -1
  102. package/src/lsp/server.ts +4 -0
  103. package/src/migrate/markup.ts +4 -1
  104. package/src/runtime/action-call.ts +0 -8
  105. package/src/runtime/action-encode.ts +26 -0
  106. package/src/runtime/action-error.ts +3 -11
  107. package/src/runtime/action-protection.ts +2 -2
  108. package/src/runtime/action-run.ts +2 -27
  109. package/src/runtime/action-shared.ts +14 -37
  110. package/src/runtime/action-stream.ts +0 -1
  111. package/src/runtime/action.ts +1 -1
  112. package/src/runtime/call-result.ts +2 -10
  113. package/src/runtime/checks.ts +11 -11
  114. package/src/runtime/client.ts +2 -2
  115. package/src/runtime/core.ts +5 -23
  116. package/src/runtime/dom.ts +1 -1
  117. package/src/runtime/html.ts +1 -1
  118. package/src/runtime/i18n.client.ts +1 -4
  119. package/src/runtime/i18n.server.ts +1 -4
  120. package/src/runtime/i18n.ts +3 -3
  121. package/src/runtime/index.ts +2 -2
  122. package/src/runtime/island.server.ts +18 -5
  123. package/src/runtime/live-resource.server.ts +0 -1
  124. package/src/runtime/live-value.server.ts +2 -2
  125. package/src/runtime/live-value.shared.ts +7 -20
  126. package/src/runtime/live.ts +1 -12
  127. package/src/runtime/local-types.ts +1 -11
  128. package/src/runtime/local.ts +4 -14
  129. package/src/runtime/navigate-api.ts +2 -5
  130. package/src/runtime/navigation-state.ts +0 -12
  131. package/src/runtime/page-swap.ts +6 -6
  132. package/src/runtime/persist.ts +11 -3
  133. package/src/runtime/persisted.ts +4 -30
  134. package/src/runtime/presence.ts +6 -7
  135. package/src/runtime/query-param.ts +20 -12
  136. package/src/runtime/reactive.ts +3 -1
  137. package/src/runtime/refuse.ts +3 -17
  138. package/src/runtime/store-base.ts +4 -6
  139. package/src/runtime/swap-fetch.ts +1 -1
  140. package/src/runtime/values.ts +40 -23
  141. package/src/runtime/with-query.ts +9 -0
  142. package/src/server/action-hooks.ts +8 -8
  143. package/src/server/actions.ts +13 -14
  144. package/src/server/api-modules.ts +2 -3
  145. package/src/server/app-stages.ts +15 -33
  146. package/src/server/app.ts +10 -5
  147. package/src/server/auth-mails.ts +0 -2
  148. package/src/server/env-state.ts +40 -10
  149. package/src/server/flash.ts +1 -1
  150. package/src/server/guard-requirement.ts +4 -4
  151. package/src/server/image.ts +2 -2
  152. package/src/server/index.ts +0 -2
  153. package/src/server/job-context.ts +3 -3
  154. package/src/server/jobs-page.ts +1 -1
  155. package/src/server/jobs.ts +5 -9
  156. package/src/server/kept-exports.ts +0 -2
  157. package/src/server/kv.ts +11 -14
  158. package/src/server/library.ts +1 -3
  159. package/src/server/live.ts +2 -2
  160. package/src/server/mcp.ts +3 -9
  161. package/src/server/metrics.ts +2 -4
  162. package/src/server/page-settings.ts +10 -19
  163. package/src/server/prerender.ts +19 -2
  164. package/src/server/protection.ts +15 -18
  165. package/src/server/queue.ts +3 -6
  166. package/src/server/rate-limit.ts +0 -3
  167. package/src/server/render-document.ts +1 -1
  168. package/src/server/routes.ts +7 -3
  169. package/src/server/scope.ts +3 -2
  170. package/src/server/session.ts +5 -6
  171. package/src/server/setup.ts +1 -1
  172. package/src/server/signals.ts +17 -7
  173. package/src/server/signed.ts +1 -3
  174. package/src/server/source.ts +20 -4
  175. package/src/server/speculation.ts +1 -1
  176. package/src/server/storage.ts +3 -8
  177. package/src/server/validate.ts +1 -1
  178. package/src/server/vitals.ts +1 -3
  179. package/src/server/work-scope.ts +2 -4
  180. package/src/server/work.ts +1 -1
  181. package/src/server/workflow.ts +1 -1
  182. package/src/test/index.ts +2 -1
  183. package/src/test/site-actions.ts +16 -6
  184. package/src/test/site-keys.ts +10 -15
  185. package/src/test/site-socket.ts +1 -2
  186. package/src/test/site-types.ts +0 -8
  187. package/types/build/route-sizes.d.ts.map +1 -1
  188. package/types/check/diagnose.d.ts.map +1 -1
  189. package/types/check/index.d.ts +1 -2
  190. package/types/check/index.d.ts.map +1 -1
  191. package/types/check/project.d.ts.map +1 -1
  192. package/types/check/shadow-types.d.ts.map +1 -1
  193. package/types/commands/env.d.ts.map +1 -1
  194. package/types/compiler/ast.d.ts +1 -2
  195. package/types/compiler/ast.d.ts.map +1 -1
  196. package/types/compiler/browser.d.ts.map +1 -1
  197. package/types/compiler/class-items.d.ts +7 -0
  198. package/types/compiler/class-items.d.ts.map +1 -0
  199. package/types/compiler/deprecated-library.d.ts.map +1 -1
  200. package/types/compiler/deprecated-lints.d.ts +0 -551
  201. package/types/compiler/deprecated-lints.d.ts.map +1 -1
  202. package/types/compiler/deprecated-ui-props.d.ts +1 -8
  203. package/types/compiler/deprecated-ui-props.d.ts.map +1 -1
  204. package/types/compiler/errors.d.ts +2 -2
  205. package/types/compiler/errors.d.ts.map +1 -1
  206. package/types/compiler/fence-checks.d.ts +0 -1
  207. package/types/compiler/fence-checks.d.ts.map +1 -1
  208. package/types/compiler/hand-parts.d.ts +7 -0
  209. package/types/compiler/hand-parts.d.ts.map +1 -0
  210. package/types/compiler/image-attributes.d.ts +0 -1
  211. package/types/compiler/image-attributes.d.ts.map +1 -1
  212. package/types/compiler/index.d.ts.map +1 -1
  213. package/types/compiler/island-arguments.d.ts +2 -11
  214. package/types/compiler/island-arguments.d.ts.map +1 -1
  215. package/types/compiler/island-cause.d.ts +1 -1
  216. package/types/compiler/island-cause.d.ts.map +1 -1
  217. package/types/compiler/island-declaration.d.ts +1 -3
  218. package/types/compiler/island-declaration.d.ts.map +1 -1
  219. package/types/compiler/island-lints.d.ts +10 -0
  220. package/types/compiler/island-lints.d.ts.map +1 -0
  221. package/types/compiler/island-problems.d.ts +7 -0
  222. package/types/compiler/island-problems.d.ts.map +1 -0
  223. package/types/compiler/jsx-class.d.ts +1 -2
  224. package/types/compiler/jsx-class.d.ts.map +1 -1
  225. package/types/compiler/kay-exports.d.ts.map +1 -1
  226. package/types/compiler/link-flags.d.ts +0 -6
  227. package/types/compiler/link-flags.d.ts.map +1 -1
  228. package/types/compiler/lints.d.ts +11 -563
  229. package/types/compiler/lints.d.ts.map +1 -1
  230. package/types/compiler/markup.d.ts +1 -1
  231. package/types/compiler/markup.d.ts.map +1 -1
  232. package/types/compiler/module-signals.d.ts.map +1 -1
  233. package/types/compiler/names.d.ts.map +1 -1
  234. package/types/compiler/page-settings.d.ts +4 -0
  235. package/types/compiler/page-settings.d.ts.map +1 -1
  236. package/types/compiler/parser.d.ts.map +1 -1
  237. package/types/compiler/plan.d.ts.map +1 -1
  238. package/types/compiler/script-server.d.ts.map +1 -1
  239. package/types/compiler/validate.d.ts.map +1 -1
  240. package/types/config-loader.d.ts.map +1 -1
  241. package/types/config-resolve.d.ts.map +1 -1
  242. package/types/config-shape.d.ts +1 -1
  243. package/types/config-shape.d.ts.map +1 -1
  244. package/types/config.d.ts +5 -105
  245. package/types/config.d.ts.map +1 -1
  246. package/types/dev/preload.d.ts.map +1 -1
  247. package/types/lsp/server.d.ts.map +1 -1
  248. package/types/migrate/markup.d.ts.map +1 -1
  249. package/types/runtime/action-call.d.ts.map +1 -1
  250. package/types/runtime/action-encode.d.ts +1 -0
  251. package/types/runtime/action-encode.d.ts.map +1 -1
  252. package/types/runtime/action-error.d.ts +1 -2
  253. package/types/runtime/action-error.d.ts.map +1 -1
  254. package/types/runtime/action-run.d.ts.map +1 -1
  255. package/types/runtime/action-shared.d.ts +1 -27
  256. package/types/runtime/action-shared.d.ts.map +1 -1
  257. package/types/runtime/action-stream.d.ts.map +1 -1
  258. package/types/runtime/action.d.ts +1 -1
  259. package/types/runtime/action.d.ts.map +1 -1
  260. package/types/runtime/call-result.d.ts +0 -10
  261. package/types/runtime/call-result.d.ts.map +1 -1
  262. package/types/runtime/checks.d.ts +6 -9
  263. package/types/runtime/checks.d.ts.map +1 -1
  264. package/types/runtime/core.d.ts +2 -20
  265. package/types/runtime/core.d.ts.map +1 -1
  266. package/types/runtime/dom.d.ts +1 -1
  267. package/types/runtime/dom.d.ts.map +1 -1
  268. package/types/runtime/html.d.ts +1 -1
  269. package/types/runtime/html.d.ts.map +1 -1
  270. package/types/runtime/i18n.client.d.ts +0 -1
  271. package/types/runtime/i18n.client.d.ts.map +1 -1
  272. package/types/runtime/i18n.d.ts +1 -1
  273. package/types/runtime/i18n.d.ts.map +1 -1
  274. package/types/runtime/i18n.server.d.ts +0 -1
  275. package/types/runtime/i18n.server.d.ts.map +1 -1
  276. package/types/runtime/index.d.ts +2 -2
  277. package/types/runtime/index.d.ts.map +1 -1
  278. package/types/runtime/island.server.d.ts +1 -0
  279. package/types/runtime/island.server.d.ts.map +1 -1
  280. package/types/runtime/live-resource.server.d.ts.map +1 -1
  281. package/types/runtime/live-value.shared.d.ts +7 -15
  282. package/types/runtime/live-value.shared.d.ts.map +1 -1
  283. package/types/runtime/live.d.ts +0 -11
  284. package/types/runtime/live.d.ts.map +1 -1
  285. package/types/runtime/local-types.d.ts +0 -14
  286. package/types/runtime/local-types.d.ts.map +1 -1
  287. package/types/runtime/navigate-api.d.ts +0 -4
  288. package/types/runtime/navigate-api.d.ts.map +1 -1
  289. package/types/runtime/navigation-state.d.ts +0 -4
  290. package/types/runtime/navigation-state.d.ts.map +1 -1
  291. package/types/runtime/page-swap.d.ts.map +1 -1
  292. package/types/runtime/persist.d.ts +1 -0
  293. package/types/runtime/persist.d.ts.map +1 -1
  294. package/types/runtime/persisted.d.ts +0 -15
  295. package/types/runtime/persisted.d.ts.map +1 -1
  296. package/types/runtime/presence.d.ts +0 -2
  297. package/types/runtime/presence.d.ts.map +1 -1
  298. package/types/runtime/query-param.d.ts.map +1 -1
  299. package/types/runtime/reactive.d.ts +2 -1
  300. package/types/runtime/reactive.d.ts.map +1 -1
  301. package/types/runtime/refuse.d.ts +0 -7
  302. package/types/runtime/refuse.d.ts.map +1 -1
  303. package/types/runtime/store-base.d.ts +1 -2
  304. package/types/runtime/store-base.d.ts.map +1 -1
  305. package/types/runtime/values.d.ts +2 -1
  306. package/types/runtime/values.d.ts.map +1 -1
  307. package/types/runtime/with-query.d.ts +2 -0
  308. package/types/runtime/with-query.d.ts.map +1 -1
  309. package/types/server/action-hooks.d.ts +4 -4
  310. package/types/server/action-hooks.d.ts.map +1 -1
  311. package/types/server/actions.d.ts.map +1 -1
  312. package/types/server/api-modules.d.ts +0 -1
  313. package/types/server/api-modules.d.ts.map +1 -1
  314. package/types/server/app-stages.d.ts +5 -13
  315. package/types/server/app-stages.d.ts.map +1 -1
  316. package/types/server/app.d.ts +3 -8
  317. package/types/server/app.d.ts.map +1 -1
  318. package/types/server/auth-mails.d.ts +0 -5
  319. package/types/server/auth-mails.d.ts.map +1 -1
  320. package/types/server/env-state.d.ts +1 -0
  321. package/types/server/env-state.d.ts.map +1 -1
  322. package/types/server/guard-requirement.d.ts +0 -1
  323. package/types/server/guard-requirement.d.ts.map +1 -1
  324. package/types/server/image.d.ts +0 -1
  325. package/types/server/image.d.ts.map +1 -1
  326. package/types/server/index.d.ts +0 -2
  327. package/types/server/index.d.ts.map +1 -1
  328. package/types/server/job-context.d.ts +1 -1
  329. package/types/server/job-context.d.ts.map +1 -1
  330. package/types/server/jobs.d.ts +0 -4
  331. package/types/server/jobs.d.ts.map +1 -1
  332. package/types/server/kept-exports.d.ts.map +1 -1
  333. package/types/server/kv.d.ts +4 -4
  334. package/types/server/kv.d.ts.map +1 -1
  335. package/types/server/library.d.ts +1 -3
  336. package/types/server/library.d.ts.map +1 -1
  337. package/types/server/mcp.d.ts +0 -1
  338. package/types/server/mcp.d.ts.map +1 -1
  339. package/types/server/metrics.d.ts +0 -5
  340. package/types/server/metrics.d.ts.map +1 -1
  341. package/types/server/page-settings.d.ts +3 -3
  342. package/types/server/page-settings.d.ts.map +1 -1
  343. package/types/server/prerender.d.ts.map +1 -1
  344. package/types/server/protection.d.ts +6 -6
  345. package/types/server/protection.d.ts.map +1 -1
  346. package/types/server/queue.d.ts +1 -3
  347. package/types/server/queue.d.ts.map +1 -1
  348. package/types/server/rate-limit.d.ts +0 -2
  349. package/types/server/rate-limit.d.ts.map +1 -1
  350. package/types/server/routes.d.ts +1 -1
  351. package/types/server/routes.d.ts.map +1 -1
  352. package/types/server/scope.d.ts.map +1 -1
  353. package/types/server/session.d.ts +1 -1
  354. package/types/server/session.d.ts.map +1 -1
  355. package/types/server/signals.d.ts.map +1 -1
  356. package/types/server/signed.d.ts +0 -2
  357. package/types/server/signed.d.ts.map +1 -1
  358. package/types/server/source.d.ts +1 -1
  359. package/types/server/source.d.ts.map +1 -1
  360. package/types/server/storage.d.ts +0 -4
  361. package/types/server/storage.d.ts.map +1 -1
  362. package/types/server/vitals.d.ts +0 -1
  363. package/types/server/vitals.d.ts.map +1 -1
  364. package/types/server/work-scope.d.ts +0 -2
  365. package/types/server/work-scope.d.ts.map +1 -1
  366. package/types/server/workflow.d.ts +1 -1
  367. package/types/server/workflow.d.ts.map +1 -1
  368. package/types/test/index.d.ts.map +1 -1
  369. package/types/test/site-actions.d.ts +1 -1
  370. package/types/test/site-actions.d.ts.map +1 -1
  371. package/types/test/site-keys.d.ts +1 -1
  372. package/types/test/site-keys.d.ts.map +1 -1
  373. package/types/test/site-socket.d.ts +1 -1
  374. package/types/test/site-socket.d.ts.map +1 -1
  375. package/types/test/site-types.d.ts +0 -8
  376. package/types/test/site-types.d.ts.map +1 -1
  377. package/llms/deprecated-lints-1-105-libraries.md +0 -32
  378. package/llms/deprecated-lints-1-105.md +0 -58
  379. package/src/check/action-readers.ts +0 -115
  380. package/src/check/action-type.ts +0 -44
  381. package/src/check/ai-language.ts +0 -56
  382. package/src/check/app-hooks.ts +0 -90
  383. package/src/check/auth-methods.ts +0 -85
  384. package/src/check/auth-rate-limits.ts +0 -99
  385. package/src/check/call-result.ts +0 -242
  386. package/src/check/client-keys.ts +0 -10
  387. package/src/check/cms-options.ts +0 -81
  388. package/src/check/config-groups.ts +0 -22
  389. package/src/check/config-switches.ts +0 -38
  390. package/src/check/context-import.ts +0 -51
  391. package/src/check/env-files.ts +0 -31
  392. package/src/check/format-duration.ts +0 -75
  393. package/src/check/guard-options.ts +0 -58
  394. package/src/check/handler-events.ts +0 -149
  395. package/src/check/hook-context.ts +0 -94
  396. package/src/check/hook-names.ts +0 -104
  397. package/src/check/i18n-keys.ts +0 -50
  398. package/src/check/images-keys.ts +0 -54
  399. package/src/check/job-shapes.ts +0 -273
  400. package/src/check/link-flag-tests.ts +0 -130
  401. package/src/check/live-api.ts +0 -137
  402. package/src/check/mail-api.ts +0 -67
  403. package/src/check/one-state-api.ts +0 -357
  404. package/src/check/pages-options.ts +0 -35
  405. package/src/check/rate-enforce.ts +0 -53
  406. package/src/check/refusal-calls.ts +0 -185
  407. package/src/check/retired-lints.ts +0 -49
  408. package/src/check/route-keys.ts +0 -166
  409. package/src/check/secret-keys.ts +0 -83
  410. package/src/check/socket-frames.ts +0 -102
  411. package/src/check/source-readers.ts +0 -257
  412. package/src/check/store-ms.ts +0 -72
  413. package/src/check/store-names.ts +0 -88
  414. package/src/check/test-helpers.ts +0 -98
  415. package/src/check/ttl-names.ts +0 -142
  416. package/src/compiler/deprecated-ai-labels.ts +0 -97
  417. package/src/compiler/deprecated-ai-links.ts +0 -63
  418. package/src/compiler/deprecated-allow.ts +0 -50
  419. package/src/compiler/deprecated-auth-lints.ts +0 -14
  420. package/src/compiler/deprecated-auth-signed.ts +0 -29
  421. package/src/compiler/deprecated-children.ts +0 -66
  422. package/src/compiler/deprecated-image.ts +0 -116
  423. package/src/compiler/deprecated-island.ts +0 -155
  424. package/src/compiler/deprecated-lints-1-105.ts +0 -41
  425. package/src/compiler/deprecated-page.ts +0 -125
  426. package/src/compiler/deprecated-parts.ts +0 -22
  427. package/src/compiler/deprecated-typed-lints.ts +0 -23
  428. package/src/compiler/deprecated-ui-callbacks.ts +0 -66
  429. package/src/compiler/deprecated-ui-input.ts +0 -97
  430. package/src/compiler/deprecated-ui-items.ts +0 -47
  431. package/src/compiler/old-parts.ts +0 -84
  432. package/src/runtime/mount.compat.ts +0 -8
  433. package/src/server/moved-exports.ts +0 -17
  434. package/types/check/action-readers.d.ts +0 -3
  435. package/types/check/action-readers.d.ts.map +0 -1
  436. package/types/check/action-type.d.ts +0 -3
  437. package/types/check/action-type.d.ts.map +0 -1
  438. package/types/check/ai-language.d.ts +0 -3
  439. package/types/check/ai-language.d.ts.map +0 -1
  440. package/types/check/app-hooks.d.ts +0 -3
  441. package/types/check/app-hooks.d.ts.map +0 -1
  442. package/types/check/auth-methods.d.ts +0 -3
  443. package/types/check/auth-methods.d.ts.map +0 -1
  444. package/types/check/auth-rate-limits.d.ts +0 -3
  445. package/types/check/auth-rate-limits.d.ts.map +0 -1
  446. package/types/check/call-result.d.ts +0 -7
  447. package/types/check/call-result.d.ts.map +0 -1
  448. package/types/check/client-keys.d.ts +0 -3
  449. package/types/check/client-keys.d.ts.map +0 -1
  450. package/types/check/cms-options.d.ts +0 -3
  451. package/types/check/cms-options.d.ts.map +0 -1
  452. package/types/check/config-groups.d.ts +0 -3
  453. package/types/check/config-groups.d.ts.map +0 -1
  454. package/types/check/config-switches.d.ts +0 -3
  455. package/types/check/config-switches.d.ts.map +0 -1
  456. package/types/check/context-import.d.ts +0 -3
  457. package/types/check/context-import.d.ts.map +0 -1
  458. package/types/check/env-files.d.ts +0 -3
  459. package/types/check/env-files.d.ts.map +0 -1
  460. package/types/check/format-duration.d.ts +0 -5
  461. package/types/check/format-duration.d.ts.map +0 -1
  462. package/types/check/guard-options.d.ts +0 -3
  463. package/types/check/guard-options.d.ts.map +0 -1
  464. package/types/check/handler-events.d.ts +0 -9
  465. package/types/check/handler-events.d.ts.map +0 -1
  466. package/types/check/hook-context.d.ts +0 -3
  467. package/types/check/hook-context.d.ts.map +0 -1
  468. package/types/check/hook-names.d.ts +0 -3
  469. package/types/check/hook-names.d.ts.map +0 -1
  470. package/types/check/i18n-keys.d.ts +0 -3
  471. package/types/check/i18n-keys.d.ts.map +0 -1
  472. package/types/check/images-keys.d.ts +0 -3
  473. package/types/check/images-keys.d.ts.map +0 -1
  474. package/types/check/job-shapes.d.ts +0 -6
  475. package/types/check/job-shapes.d.ts.map +0 -1
  476. package/types/check/link-flag-tests.d.ts +0 -4
  477. package/types/check/link-flag-tests.d.ts.map +0 -1
  478. package/types/check/live-api.d.ts +0 -3
  479. package/types/check/live-api.d.ts.map +0 -1
  480. package/types/check/mail-api.d.ts +0 -3
  481. package/types/check/mail-api.d.ts.map +0 -1
  482. package/types/check/one-state-api.d.ts +0 -9
  483. package/types/check/one-state-api.d.ts.map +0 -1
  484. package/types/check/pages-options.d.ts +0 -3
  485. package/types/check/pages-options.d.ts.map +0 -1
  486. package/types/check/rate-enforce.d.ts +0 -3
  487. package/types/check/rate-enforce.d.ts.map +0 -1
  488. package/types/check/refusal-calls.d.ts +0 -3
  489. package/types/check/refusal-calls.d.ts.map +0 -1
  490. package/types/check/retired-lints.d.ts +0 -3
  491. package/types/check/retired-lints.d.ts.map +0 -1
  492. package/types/check/route-keys.d.ts +0 -3
  493. package/types/check/route-keys.d.ts.map +0 -1
  494. package/types/check/secret-keys.d.ts +0 -3
  495. package/types/check/secret-keys.d.ts.map +0 -1
  496. package/types/check/socket-frames.d.ts +0 -3
  497. package/types/check/socket-frames.d.ts.map +0 -1
  498. package/types/check/source-readers.d.ts +0 -3
  499. package/types/check/source-readers.d.ts.map +0 -1
  500. package/types/check/store-ms.d.ts +0 -3
  501. package/types/check/store-ms.d.ts.map +0 -1
  502. package/types/check/store-names.d.ts +0 -3
  503. package/types/check/store-names.d.ts.map +0 -1
  504. package/types/check/test-helpers.d.ts +0 -3
  505. package/types/check/test-helpers.d.ts.map +0 -1
  506. package/types/check/ttl-names.d.ts +0 -3
  507. package/types/check/ttl-names.d.ts.map +0 -1
  508. package/types/compiler/deprecated-ai-labels.d.ts +0 -5
  509. package/types/compiler/deprecated-ai-labels.d.ts.map +0 -1
  510. package/types/compiler/deprecated-ai-links.d.ts +0 -5
  511. package/types/compiler/deprecated-ai-links.d.ts.map +0 -1
  512. package/types/compiler/deprecated-allow.d.ts +0 -5
  513. package/types/compiler/deprecated-allow.d.ts.map +0 -1
  514. package/types/compiler/deprecated-auth-lints.d.ts +0 -12
  515. package/types/compiler/deprecated-auth-lints.d.ts.map +0 -1
  516. package/types/compiler/deprecated-auth-signed.d.ts +0 -5
  517. package/types/compiler/deprecated-auth-signed.d.ts.map +0 -1
  518. package/types/compiler/deprecated-children.d.ts +0 -4
  519. package/types/compiler/deprecated-children.d.ts.map +0 -1
  520. package/types/compiler/deprecated-image.d.ts +0 -5
  521. package/types/compiler/deprecated-image.d.ts.map +0 -1
  522. package/types/compiler/deprecated-island.d.ts +0 -9
  523. package/types/compiler/deprecated-island.d.ts.map +0 -1
  524. package/types/compiler/deprecated-lints-1-105.d.ts +0 -39
  525. package/types/compiler/deprecated-lints-1-105.d.ts.map +0 -1
  526. package/types/compiler/deprecated-page.d.ts +0 -4
  527. package/types/compiler/deprecated-page.d.ts.map +0 -1
  528. package/types/compiler/deprecated-parts.d.ts +0 -3
  529. package/types/compiler/deprecated-parts.d.ts.map +0 -1
  530. package/types/compiler/deprecated-typed-lints.d.ts +0 -21
  531. package/types/compiler/deprecated-typed-lints.d.ts.map +0 -1
  532. package/types/compiler/deprecated-ui-callbacks.d.ts +0 -5
  533. package/types/compiler/deprecated-ui-callbacks.d.ts.map +0 -1
  534. package/types/compiler/deprecated-ui-input.d.ts +0 -5
  535. package/types/compiler/deprecated-ui-input.d.ts.map +0 -1
  536. package/types/compiler/deprecated-ui-items.d.ts +0 -5
  537. package/types/compiler/deprecated-ui-items.d.ts.map +0 -1
  538. package/types/compiler/old-parts.d.ts +0 -9
  539. package/types/compiler/old-parts.d.ts.map +0 -1
  540. package/types/runtime/mount.compat.d.ts +0 -7
  541. package/types/runtime/mount.compat.d.ts.map +0 -1
  542. package/types/server/moved-exports.d.ts +0 -12
  543. package/types/server/moved-exports.d.ts.map +0 -1
@@ -61,7 +61,7 @@ for issue of todos.issues()
61
61
 
62
62
  ### What a collection is
63
63
 
64
- - `local({ key, read, put, remove?, version?, conflict?, onData?, onIssue?, onError? })` returns `data()`, `status()`, `pending()`, `error()`, `retry()`, `get(key)`, `put(row)`, `remove(key)`, `issues()`, `dismiss(id)`, `sync`, `clear()` and the hooks `onData`, `onIssue` and `onError` as methods. `data()`, `status()`, `pending()`, `error()`, `sync.status()`, `sync.queued()` and `issues()` are reactive; the rows come in key order. `data()`, `status()`, `pending()`, `error()`, `retry()`, `onData` and `onError` are what every source has ([Island sources](island-sources.md)): `status()` is `loading` until the browser's copy is read, then `ready`, or `failed` while `error()` is set, and `pending()` is true while it loads. What is a collection's own, its sync with the server, is under `sync`: `sync()` sends the queue and reads the server's rows again, `sync.status()` says where it stands and `sync.queued()` counts the writes the server has not taken. Before 1.105 `rows()`, `unsynced()`, `syncStatus()` and `onSync({ rows })` did these, and `pending()` and `status()` meant the count and the sync states; the first four work until 1.108 and `deprecated-source-readers` rewrites them.
64
+ - `local({ key, read, put, remove?, version?, conflict?, onData?, onIssue?, onError? })` returns `data()`, `status()`, `pending()`, `error()`, `retry()`, `get(key)`, `put(row)`, `remove(key)`, `issues()`, `dismiss(id)`, `sync`, `clear()` and the hooks `onData`, `onIssue` and `onError` as methods. `data()`, `status()`, `pending()`, `error()`, `sync.status()`, `sync.queued()` and `issues()` are reactive; the rows come in key order. `data()`, `status()`, `pending()`, `error()`, `retry()`, `onData` and `onError` are what every source has ([Island sources](island-sources.md)): `status()` is `loading` until the browser's copy is read, then `ready`, or `failed` while `error()` is set, and `pending()` is true while it loads. What is a collection's own, its sync with the server, is under `sync`: `sync()` sends the queue and reads the server's rows again, `sync.status()` says where it stands and `sync.queued()` counts the writes the server has not taken.
65
65
  - `key` names the field identifying a row, a string or a number. `put` is an action taking the row, `remove` an action taking `{ [key]: value }`, and `read` a function giving the server's rows (`call` or `resource`'s route, or any promise): all three are the app's own, so their guards, schemas, rate limits and cross-site checks apply as to any call.
66
66
  - The collection is named by its `put` action's URL, so declare it once per action; two islands declaring it share one mirror.
67
67
  - On the server, and in a browser without IndexedDB, `local()` gives an empty collection: `sync.status()` is `'loading'` on the server and `'unavailable'` where the browser keeps nothing, and a write there throws. Nothing loads on a page that does not import it.
package/llms/locales.md CHANGED
@@ -217,7 +217,7 @@ export default defineMessages({
217
217
  - Using it makes the component an island.
218
218
  - `T` renders a message holding markup, such as a link mid-sentence: see [Messages holding markup](#messages-holding-markup).
219
219
  - `formatNumber(value, options)` and `formatDate(value, options)` format through `Intl` for the request's locale, and so do `formatRelativeTime(date)`, a date relative to now in the largest unit it reaches, `3 days ago`, `yesterday` or `in 2 hours`, `formatRelativeTime(2, 'week')` in the unit given, and `formatList(['Ada', 'Grace'])`, `Ada and Grace`. Outside a request, in a job, an alert or a push, these and `direction()` use the site's default locale (`en` when the site names none) instead of throwing, so a page and a mail format the same date alike. Each takes a `locale` among its options (`formatDate(date, { locale: user.locale })`) that wins over the request's, for a mail written in its reader's language. `formatDate` options that name no part of the date (none, a `locale`, a lone `timeZone` or `calendar`) give the medium date, as no options do.
220
- - `formatBytes(1536)` is `1.5 kB` (a `ByteSize`: bytes or `'1.5kb'`) and `formatDuration('125m')` (a `Duration`, `'7500s'`, `'2h'`) is `2 hr 5 min`, a number of milliseconds being deprecated since 1.105 (`deprecated-format-duration`), each in the page's locale with a `locale` option of its own, `unitDisplay: 'long'` for the unit in full. `timeZone: 'Europe/Paris'` in kay.config.ts is the zone every `formatDate`, a message's date placeholder, `RelativeTime`'s tooltip write in; a chart's labels keep the machine's zone, on the server and in the islands alike, unless a call names its own `timeZone`, so on the server a time of day built from an instant is written in the server's zone until the island rewrites it in the visitor's, and `timeZone()` from `kay/i18n` reads it.
220
+ - `formatBytes(1536)` is `1.5 kB` (a `ByteSize`: bytes or `'1.5kb'`) and `formatDuration('125m')` (a `Duration`, `'7500s'`, `'2h'`) is `2 hr 5 min`, a number of milliseconds being no duration, each in the page's locale with a `locale` option of its own, `unitDisplay: 'long'` for the unit in full. `timeZone: 'Europe/Paris'` in kay.config.ts is the zone every `formatDate`, a message's date placeholder, `RelativeTime`'s tooltip write in; a chart's labels keep the machine's zone, on the server and in the islands alike, unless a call names its own `timeZone`, so on the server a time of day built from an instant is written in the server's zone until the island rewrites it in the visitor's, and `timeZone()` from `kay/i18n` reads it.
221
221
  - In an island, give `formatRelativeTime` the moment it is relative to, `{ now }`, from the server, so the browser renders what the server did, or use `relativeTime`.
222
222
  - `locales()` is the configured locales in `i18n`'s order, only the page's own without `i18n`; `localeName('fr')` is `Français`, `localeName('pt-BR')` is `Português (Brasil)`, each in its own language through `Intl.DisplayNames`, first letter capitalized, a code `Intl` cannot read as written.
223
223
  - `direction()` is `rtl` or `ltr`, for the request's locale or the one given.
package/llms/mcp.md CHANGED
@@ -47,10 +47,10 @@ expect(await site.mcp.call('add_note', { title: 'Milk' })).toMatchObject({ isErr
47
47
  - An `onRequest` hook that throws, the app's own Elysia one, a param matcher, `rewrite` or an extension's, is answered like a handler that throws: logged, handed to `onError`, and a 500 with `Internal Server Error` in production, the message in development, instead of Elysia's 200; a GET asking for HTML gets the routes directory's `_error.kay` (or kay's error page) in the default locale, any other request plain text. A `Response` the hook throws is answered as given, and an `onError` registered before `pages()` answers first. An `_error.kay` drawn for it reads in `ctx.locals` what a `derive` added before it threw.
48
48
  - `honeypot`, `minTime` and `proofOfWork` are skipped, as only a form a person filled in can pass them; a marker only the endpoint sets, a per-process secret no request can send, says so, and `rateLimit` still counts.
49
49
  - A path param is one segment: it is percent-encoded and an empty one, `.` or `..` is refused, so no value reaches another route.
50
- - A refused call is a result with `isError`: the schema's field errors, the `ctx.fail` data and status as `{ status, errors, data }` JSON, a route's own refusal text, a redirect naming where it leads. The agent corrects and calls again.
50
+ - A refused call is a result with `isError`: the schema's field errors, the `ctx.deny` data and status as `{ status, errors, data }` JSON, a route's own refusal text, a redirect naming where it leads. The agent corrects and calls again.
51
51
  - A guard answering 401 makes the endpoint answer 401 with `WWW-Authenticate: Bearer resource_metadata="<site>/.well-known/oauth-protected-resource"`, how a client learns to sign in (kay serves that document when kayjs-auth's OAuth server is on: see its "OAuth server for MCP clients"); any other refusal, 403 included, is a result. Only a guard's 401 does: a route answering 401 itself is a result too. A refused `tools/list` answers the same way (a redirect counting as a 401), as a JSON-RPC error. It keeps the guard's response headers, `Retry-After` of a 429 among them. A `tools/call` of a name no tool has is refused the same way, so names cannot be probed; a call to a tool runs its own guards.
52
52
  - A result is JSON as text, and `structuredContent` when an object; any other type read as its size. A route's object `response` is the tool's `outputSchema`, with no `detail.tool.output` ([action protection](action-protection.md#offering-an-action-to-agents)).
53
- - Until 2.0, an app that did not set `endpoints.mcp` is answered at `/mcp` as well, in place, under the same limits, key and checks, unless a page, endpoint or file serves `/mcp`, which keeps it. Only a POST is taken there, so a `[...rest]` or `[slug]` page still answers GET and DELETE; only an exact route at `/mcp` takes POST from kay.
53
+ - The endpoint was at `/mcp` before 1.105; that path stopped answering in 1.109.
54
54
  - `/_kay/mcp` (`endpoints.mcp`) is claimed like a route: a page, endpoint or file serving it stops the boot, and `kay check` reports it.
55
55
  - `unguarded-tool` warns, with `mcp`, of a tool action with a `honeypot`, `minTime` or `proofOfWork` that no guard covers: an agent calls it without the form those protections ask of a person. A `...spread` in the options counts as one of them, so it warns; options that are not an object literal, `action(schema, run, options)`, are not read, so the action is not taken for a tool.
56
56
  - `site.mcp.initialize()` resolves with `{ serverInfo, instructions }` of the `initialize` answer, `instructions` being `mcp: { instructions }` or undefined.
package/llms/metrics.md CHANGED
@@ -16,7 +16,7 @@ Prometheus or any compatible collector scrapes `/_kay/metrics` with `Authorizati
16
16
 
17
17
  ## Reference
18
18
 
19
- - `ops: { metrics: true }` in kay.config.ts serves `/_kay/metrics` in the Prometheus text format, for Prometheus or any compatible collector (Grafana Alloy, the OpenTelemetry collector's Prometheus receiver): `endpoints: { metrics: '/_internal/metrics' }` moves it. Before 1.105 it was `/metrics`, which answers as well until 1.108 while `endpoints.metrics` is not set (unless the app serves something there). It is off by default, and a server run by `kay dev` or a static export serves none.
19
+ - `ops: { metrics: true }` in kay.config.ts serves `/_kay/metrics` in the Prometheus text format, for Prometheus or any compatible collector (Grafana Alloy, the OpenTelemetry collector's Prometheus receiver): `endpoints: { metrics: '/_internal/metrics' }` moves it. Before 1.105 it was `/metrics`, which stopped answering in 1.109. It is off by default, and a server run by `kay dev` or a static export serves none.
20
20
  - It holds `kay_http_requests_total{method,route,status}` and the histogram `kay_http_request_duration_seconds{method,route}`, `kay_queue_runs_total{queue,result}` (`ok`, `retried`, `failed`; a workflow is `workflow:<name>`), `kay_job_runs_total{schedule,result}` (`ok`, `failed`, `skipped` when another process held the lock), `kay_session_events_total{event}` (`created`, `destroyed`), `kay_file_events_total{event}` (`written`, `deleted`), `kay_cache_reads_total{result}` (`hit` or `miss` of `cached` and `cache`), `kay_live_connections`, `kay_process_resident_memory_bytes` and `kay_process_uptime_seconds`.
21
21
  - A page counts under its pattern, `/shop/:item`, an API route under its route, and a path nothing serves under `unmatched`, so a scan adds no series; at most 500 routes are kept, the rest read `other`. The scrape itself and the health route are not counted, nor a request an earlier hook answers (a redirect, a refusal by `proxy.key`), and a method no server knows reads `OTHER`.
22
22
  - It is never public by default: only a request that reached the socket from this machine or a private network (a collector in the same compose network, a sidecar) and carries no `X-Forwarded-*`, `X-Real-IP`, `Forwarded`, `Via` or `CF-Connecting-IP` header, nor the headers `proxy.header` and `proxy.key.header` name, is answered; every other gets 403, a trailing slash, a query or the `base` in the path included. Do not forward the path from the reverse proxy: one that adds none of those headers cannot be told from a collector.
@@ -45,7 +45,7 @@ const dispose = mount(Panel, document.querySelector('#panel')!, { title: 'Ticket
45
45
  ### Navigating from code
46
46
 
47
47
  - `navigate('/todos/1')`, imported from `kay`, goes to a page as a link would (the mount point and the current locale's prefix put on as on any `href`, `/todos/1` on a French page going to `/fr/todos/1`, a path already prefixed or another site's URL left as written; a module that gets `navigate` through a dynamic `import('kay')` is not covered, so import it statically), `{ replace: true }` taking the current history entry's place, `{ scroll: 'keep' }` leaving the window scrolled where it is instead of going to the top, `{ transition: false }` swapping without a view transition; another site's page loads, so a `?next=` param goes through `localPath()` as a redirect's does, and a `javascript:` URL throws, as it would run in the page; `mailto:`, `tel:` and other schemes go to the browser as a link would. A link or `navigate()` that a redirect takes to another site loads that page fully rather than swapping it in.
48
- - `navigate.query({ sort: 'name', page: null })` goes to the current page with those params set (a list sets one param once per item, `{ tag: ['a', 'b'] }` giving `?tag=a&tag=b`) and a null, undefined or empty one dropped, the others and the path kept and the hash left out, keeping the scroll and the focus as `refresh()` does: a filter or a sort picked in place. It takes the options of `navigate()` and resolves as it does. `navigate({ query })`, which did this under the name that goes to a page, works until 1.108, `kay upgrade` rewriting it (`deprecated-navigate-query`). A query that is state of the page, not a one-off change, is a `queryParam` signal ([state](islands-state-to-ids.md#shared-and-persisted-state)).
48
+ - `navigate.query({ sort: 'name', page: null })` goes to the current page with those params set (a list sets one param once per item, `{ tag: ['a', 'b'] }` giving `?tag=a&tag=b`) and a null, undefined or empty one dropped, the others and the path kept and the hash left out, keeping the scroll and the focus as `refresh()` does: a filter or a sort picked in place. It takes the options of `navigate()` and resolves as it does. A query that is state of the page, not a one-off change, is a `queryParam` signal ([state](islands-state-to-ids.md#shared-and-persisted-state)).
49
49
  - `withQuery({ page: 2, sort: null })` from `kay`, in a server fence, a template or an island (where it follows the address, so the link is built again after each `navigate.query()`, swap, Back and `queryParam` write), returns the path of the current page with those params set by the rule of `navigate.query()`, the other params kept and the hash left out, to link to it with one filter changed: `a(href={withQuery({ page: 2 })}) Next`. The path is the site's own, so `base`, `trailingSlash` and the locale prefix are put on by the link as on any `href`; in a fence it reads the request, so it throws in a page rendered once at build time.
50
50
  - `refresh()` from `kay` runs the current page's loads again and shows what they return, keeping the scroll, the focus and every island whose props did not change, as a call to an action does by itself once it went through.
51
51
  - `refresh('cart')` or `refresh(['cart', 'user'])` sends and swaps only the elements of the page reading the loads of its fence that bind those names, and leaves the rest of the page as it is: [rendering](rendering.md#refreshing-some-loads).
@@ -75,8 +75,8 @@ const dispose = mount(Panel, document.querySelector('#panel')!, { title: 'Ticket
75
75
  - `navigation.onBeforeNavigate(({ url, from }) => ...)`, called in an island's script, is asked with the URL going to and the page left before a link of the app, `navigate()` or going back or forward leaves the page, for as long as the island lives, and returns what removes it sooner. Returning `false`, or a promise of it, keeps the page (`navigate()` resolves `false`, a refused Back or Forward is undone as under `guardLeave`); anything else lets it go. A handler that throws, here and in `onNavigate`, is logged and the navigation goes on, as a browser hook is never a security boundary. It answers before the `guardLeave` guards, which are not asked when it refuses.
76
76
  - It is asked for a navigation kay swaps in place only: not for a post's redirect, a form's or an island action's (the `guardLeave` guards still ask), as the action already ran, nor for a refresh, a link or `navigate()` to another site, an API or `/_kay` path or a site with `navigation: false` (loaded fully), nor a reload.
77
77
  - While a handler is registered, every Back and Forward goes back to the page left first, as under a guard holding changes, and is made again once the handlers allow it: two history traversals, the scroll restored as for any traversal.
78
- - `navigation.onNavigate(({ url }) => ...)` runs with the URL of each page a swap shows, once it is in place, for as long as the island lives, returning what removes it sooner; it is `kay:navigate` for an island, and fires for a refresh as that does. The two hooks are the methods of `navigation`, as `resource` has `onData`, taking one object and returning what removes them; the functions `navigation.onBeforeNavigate` and `onNavigate` of `kay`, which did the same, work until 1.108 and `kay upgrade` rewrites them (`deprecated-navigation-hooks`).
79
- - `navigation.onStart(({ url }) => ...)` runs when a swap to another page begins, `navigation.onError(({ url, error }) => ...)` when it gives up (`error` an `ApiError` of status 0 with kay's message and the browser's as `cause`, as `error()` reads it) and `navigation.onStall(({ url }) => ...)` when a streamed page sent nothing for `pageTimeout`; with `onNavigate` they take one object, end with the island and return what removes them. They are the island's form of the `kay:navigate-start`, `kay:navigate-error`, `kay:navigate-stall` and `kay:navigate` events on `document` (`detail.url`, and `detail.error`, an `Error`), which a plain script listens to (see [Navigation](navigation.md#navigation)); `listen(() => document, 'kay:navigate', ...)` in an island is `deprecated-island-events`, which rewrites a handler with no parameter. A refresh fires `kay:navigate` alone.
78
+ - `navigation.onNavigate(({ url }) => ...)` runs with the URL of each page a swap shows, once it is in place, for as long as the island lives, returning what removes it sooner; it is `kay:navigate` for an island, and fires for a refresh as that does. The two hooks are the methods of `navigation`, as `resource` has `onData`, taking one object and returning what removes them.
79
+ - `navigation.onStart(({ url }) => ...)` runs when a swap to another page begins, `navigation.onError(({ url, error }) => ...)` when it gives up (`error` an `ApiError` of status 0 with kay's message and the browser's as `cause`, as `error()` reads it) and `navigation.onStall(({ url }) => ...)` when a streamed page sent nothing for `pageTimeout`; with `onNavigate` they take one object, end with the island and return what removes them. They are the island's form of the `kay:navigate-start`, `kay:navigate-error`, `kay:navigate-stall` and `kay:navigate` events on `document` (`detail.url`, and `detail.error`, an `Error`), which a plain script listens to (see [Navigation](navigation.md#navigation)). A refresh fires `kay:navigate` alone.
80
80
  - `guardLeave(dirty, { confirm })` is the preset of `navigation.onBeforeNavigate` for unsaved changes: it asks `confirm(url)`, `window.confirm` by default, while `dirty()` holds, where the hook is asked for every leave; it also covers what no hook is asked for (a reload, closing the tab, a form's or an action's redirect), and is the one to write for that case.
81
81
 
82
82
  ### Full loads and prefetching
@@ -90,13 +90,13 @@ const dispose = mount(Panel, document.querySelector('#panel')!, { title: 'Ticket
90
90
  - A page in another locale, or one built against another client build, loads fully too, as does a page setting `reload: true` in its `page` or its layout's, and one whose cross-origin isolation differs from the current page's, which a document cannot change in place.
91
91
  - Such a page still swaps itself in place: a link to it with another query, `navigate.query()` and `refresh()` on it.
92
92
  - The swap prefetches as the speculation rules would, on the timing the `prefetch` setting gives (see [Project setup](project.md#project-setup)), and a page loading it carries that setting alone, not the rules, so each page is fetched once: a hovered link's page is kept for 30 seconds and taken as the link is followed.
93
- - `data-prefetch="false"`, on the link or a container, opts a link out (`data-no-prefetch` does until 1.108, `deprecated-link-flags`); `data-prefetch="eager|moderate|conservative"` gives it its own level, read by the swap's code only (a page without kay's script keeps the page's level). `eager` fetches the links scrolled into view, three at a time, from the page's load on, those added later by an island, a stream or a scroll included. The nearest `data-prefetch` wins, and it does nothing under `prefetch: false`, which ships no prefetch code.
93
+ - `data-prefetch="false"`, on the link or a container, opts a link out; `data-prefetch="eager|moderate|conservative"` gives it its own level, read by the swap's code only (a page without kay's script keeps the page's level). `eager` fetches the links scrolled into view, three at a time, from the page's load on, those added later by an island, a stream or a scroll included. The nearest `data-prefetch` wins, and it does nothing under `prefetch: false`, which ships no prefetch code.
94
94
  - A visitor asking for less data (`Save-Data: on`) gets a lighter site with no setting: the image route answers the next width down of the ladder (see [Images](images.md#responsive-images)), font preloads, speculation rules and any other `rel="preload" as="font"` link leave the page, its fonts show only when cached (`font-display: optional`), and the swap prefetches nothing. In the browser, `prefers-reduced-data: reduce` and `navigator.connection.saveData` stop the swap's prefetch alone, as no media query can drop a preload.
95
95
  - Pages say `Vary: Save-Data`, so a cache or CDN keeps the two copies apart; a prerendered page is served to that visitor from its plain HTML, not the compressed copies the build wrote, its head changed on the way out. A static export has no header to read: the prefetch and the islands' wait still follow the browser, but the preloads stay.
96
96
  - Islands wait too: those with no `hydrate` hydrate once they scroll near, and the page preloads none of their chunks when the request says `Save-Data` (see [Islands](islands.md#hydration)).
97
97
  - A page streaming `await` blocks is swapped in once its first part is in, with the `pending` branches: `navigation.status()` is `'idle'` and `kay:navigate` fires then, once, while blocks may still be arriving, and each block replaces its branch in place later, firing nothing, its islands hydrating as it lands. A navigation to another page ends the stream. If the stream sends no byte for `pageTimeout` (the server writes a keep-alive every 5 s, so keep it above that) the blocks still pending stay as they are, the console gets a warning and `kay:navigate-stall` fires on `document` with `event.detail.url`, once, for an app to offer a retry; the page is not requested again, and `kay:navigate-error` is not fired.
98
98
  - `client: { saveData: false }` in `kay.config.ts` or `pages()` gives everyone the same page and image, with no `Vary`.
99
- - A link, or one inside an element, with `data-scroll="keep"` swaps without scrolling to the top, and with `data-transition="false"` without a view transition, named as `navigate()`'s `scroll: 'keep'` and `transition: false` are; going back still restores the position saved, and a hash in the URL is not scrolled to while the scroll is kept. The nearest `data-scroll` to the link decides, so `data-scroll="top"` on a link, or on an element between it and a keeping one, scrolls to the top as a plain link does, and the nearest `data-transition` likewise (`data-transition` alone turns it back on inside a `"false"`). `data-scroll`, `data-transition`, `data-prefetch` and `data-reload` are typed on every element, a value outside their words a `kay check` error, and a `data-` name one letter from one of them (`data-prefech`) is the `unknown-link-flag` error. `data-keep-scroll`, `data-no-transition` and `data-no-prefetch` work until 1.108, `kay check --fix` writing the new names (`deprecated-link-flags`).
99
+ - A link, or one inside an element, with `data-scroll="keep"` swaps without scrolling to the top, and with `data-transition="false"` without a view transition, named as `navigate()`'s `scroll: 'keep'` and `transition: false` are; going back still restores the position saved, and a hash in the URL is not scrolled to while the scroll is kept. The nearest `data-scroll` to the link decides, so `data-scroll="top"` on a link, or on an element between it and a keeping one, scrolls to the top as a plain link does, and the nearest `data-transition` likewise (`data-transition` alone turns it back on inside a `"false"`). `data-scroll`, `data-transition`, `data-prefetch` and `data-reload` are typed on every element, a value outside their words a `kay check` error, and a `data-` name one letter from one of them (`data-prefech`) is the `unknown-link-flag` error.
100
100
  - A stylesheet holding `@view-transition { navigation: auto; }` animates the swap where the browser has view transitions, as it animates full loads, the rule standing at the top level or inside an `@media` or `@supports` that holds.
101
101
  - A visitor asking for reduced motion (`prefers-reduced-motion: reduce`) gets no animation from the swap whatever the stylesheet says; a full load animates for them unless the rule sits in `@media (prefers-reduced-motion: no-preference)`, as the one `kay new` writes does.
102
102
  - `client: { navigation: false }` in `kay.config.ts` or `pages()` turns it off: pages load fully, and only pages with islands ship a script.
@@ -106,7 +106,7 @@ const dispose = mount(Panel, document.querySelector('#panel')!, { title: 'Ticket
106
106
 
107
107
  - A page another server or tool bundles, such as an HTML file `Bun.serve` imports, renders `.kay` components too.
108
108
  - The plugin `kay` from `kay/bun` compiles them, for the browser in a browser build: list `"kay/bun"` under `[serve.static] plugins` in `bunfig.toml`, which `Bun.serve` reads from the directory it starts in, or pass `kay({ root })` to `Bun.build`'s `plugins`, `root` being where `.kay/` goes, the working directory by default.
109
- - `mount(Component, element, props)` from `kay` (`kay/mount` still exports it until 1.108, `deprecated-import-path` moving the import) renders one into an element, as an island renders but with no server markup to hydrate, and returns a handle, which disposes it when called, ending its effects and removing only the nodes it rendered, so several components mounted into one element are disposed one at a time and the rest of the element stays as it was.
109
+ - `mount(Component, element, props)` from `kay` renders one into an element, as an island renders but with no server markup to hydrate, and returns a handle, which disposes it when called, ending its effects and removing only the nodes it rendered, so several components mounted into one element are disposed one at a time and the rest of the element stays as it was.
110
110
  - `props` may be left out for a component taking none.
111
111
  - The handle is `{ update(props), dispose }` as well as the disposer: `handle.update({ title: 'Done' })` gives the mounted component its next props, which it reads reactively as an island does (a prop left out reads `undefined`), and `handle.dispose()` is `handle()`. `update` after a dispose does nothing.
112
112
  - `props` may be a function, `mount(Panel, el, () => ({ title: title() }))`, read as an effect reads: the mount follows the signals it uses, so a widget keeps current with no `update` call; an `update` on such a mount holds until a signal the function reads changes. The component reads a copy of the props, one getter each, not the object passed, and a function that throws on the first read throws out of `mount` with nothing left in the element. A prop changes when it is another value (`Object.is`).
@@ -158,3 +158,4 @@ export const pageWeight: KayExtension = {
158
158
  - With `i18n.mode: 'always'`, each unprefixed path sends the browser to the default locale's copy.
159
159
  - Locales by domain need a server.
160
160
  - The directory is cleared first, only when the last export wrote it: kay refuses one holding other files, and the project itself.
161
+ - A page is rendered once, at the default query, and served at every query (`/page?tab=b` is `page.html`). An island reading a `queryParam` is marked `data-query` by that render: the browser draws it again from the address when the page is opened with a query, rather than claiming markup made for the default one, so it shows `?tab=b` with no mismatch. The page's own markup outside islands stays the default's, as does the island's before its JavaScript runs, so read the query in an island, never in the page, and the build warns naming each page holding such an island. The same holds for any `prerender: true` page.
@@ -4,7 +4,7 @@
4
4
 
5
5
  ### Log requests as JSON for a log collector
6
6
 
7
- `ops: { observe: { log: { format: 'json' } } }` in kay.config.ts writes one JSON object per line, requests included, on stdout for info and on stderr for warnings and errors; `log: { sink }` hands each entry to a function instead, and `requests: false` keeps kay's messages and logs no request line (`log: 'json'` and a bare function work until 1.108, `deprecated-app-hooks` rewrites them):
7
+ `ops: { observe: { log: { format: 'json' } } }` in kay.config.ts writes one JSON object per line, requests included, on stdout for info and on stderr for warnings and errors; `log: { sink }` hands each entry to a function instead, and `requests: false` keeps kay's messages and logs no request line (`log: 'json'` and a bare function are refused):
8
8
 
9
9
  ```ts
10
10
  import { defineConfig } from 'kay/server'
@@ -121,7 +121,7 @@ Then `await welcomeMails.enqueue({ to: email })` in an action, or `enqueue(paylo
121
121
  - A library logs through the same setting with `logFrom` from `kay`: `const log = logFrom('kayjs-mail')`, then `log.info(message)`, `log.warn(message)` or `log.error(message, error)`.
122
122
  - Its lines read `kayjs-mail: ` and the message, headed by the request being answered as kay's are, in a page, an action, an endpoint or a guard, though not in an API module's handler or a socket, which Elysia runs outside any call kay makes, and carry `from: 'kayjs-mail'` as JSON or in the entry a log function receives.
123
123
  - Outside a server, in the browser or a script, they go to the console as `[kayjs-mail] message`.
124
- - Every response carries its request's id as `X-Request-Id`, time-ordered, made by kay unless `proxy` is set and the proxy passed one on in that header; `observe: { requestIdHeader: 'x-correlation-id' }` in kay.config.ts names another header for both.
124
+ - Every response carries its request's id as `X-Request-Id`, time-ordered, made by kay unless `proxy` is set and the proxy passed one on in that header; `ops: { observe: { requestIdHeader: 'x-correlation-id' } }` in kay.config.ts names another header for both.
125
125
  - An error logged while answering a request is headed by the request, `kay: GET /blog/hello, request AZnLe0vUe9qD0uXq9vLwZw`, then its stack, so a line from a user or a log search finds both.
126
126
  - `requestId(request)` from `kay/server` gives it, in `onError` or a route, and a server span carries it as `kay.request.id` ([Tracing](tracing.md)).
127
127
 
@@ -57,7 +57,7 @@ kay generate resource post title:string body:text published:boolean
57
57
  - `kay generate <page|component|island|action|api|guard|resource> <name> [field:type...] [dir] [--dir <dir>] [--plural <name>] [--dry-run] [--format text|json] [--quiet]`:
58
58
  - Writes a starter file into the project in `dir` (the current directory by default), by `<name>`, and never over a file that exists: one that does stops it with `kay generate: nothing was written`.
59
59
  - `page pricing` writes `src/routes/pricing.kay` (`blog/[slug]` and `(group)/about` are routes too; its `h1` takes Tailwind's shorthand classes when the project has Tailwind), `component card` and `island likes` write `src/components/card.kay` (a `label` prop) and `src/components/likes.kay` (a signal and a button), `api notes` writes `src/api/notes.ts` (`api().get('/')`), `guard admin` writes `src/routes/admin/_guard.ts` (`/` for the root one; its function does nothing, for you to write the rule in) and `action team/removeTissue` writes the action `removeTissue` into `src/routes/team/_actions.kay` (a schema and a handler). An `_actions.kay` that holds a server fence alone gets the action appended (`import { s } from 'kay'` added when it lacks it); one already exporting that name stops the command, and one with a template or other fences is left alone and the command prints the action to add by hand.
60
- - A project with `tests` (`bunfig.toml`) also gets `tests/<name>.test.ts` for a page (it visits the URL, a project with `auth` expecting the redirect to sign in), `tests/action-<name>.test.ts` for an action (`site.call` and `site.refusal`) and `tests/api-<name>.test.ts` for an API module (`site.api`) and `tests/guard-<name>.test.ts` for a guard with a page below its folder (it visits the shallowest one, a project with `auth` expecting the redirect to sign in), a `/` in the name written `-`; none for a component or an island, nor for a guard with no page below, nor for a page with a param, and none for an action or API module in a project with `auth`, whose guard answers first.
60
+ - A project with `tests` (`bunfig.toml`) also gets `tests/<name>.test.ts` for a page (it visits the URL, a project with `auth` expecting the redirect to sign in), `tests/action-<name>.test.ts` for an action (`site.call` and `site.expectRefused`) and `tests/api-<name>.test.ts` for an API module (`site.api`) and `tests/guard-<name>.test.ts` for a guard with a page below its folder (it visits the shallowest one, a project with `auth` expecting the redirect to sign in), a `/` in the name written `-`; none for a component or an island, nor for a guard with no page below, nor for a page with a param, and none for an action or API module in a project with `auth`, whose guard answers first.
61
61
  - `resource post title:string body:text` (a project with `postgres`, else it stops naming `kay add postgres`; the fields are `name:type` and every argument after the name is one, the project folder being `--dir <dir>` (cwd by default), the type `string` (varchar 200), `text`, `int`, `float` or `boolean`, all required, and `name`, written `blog-post` or `blogPost`, gives the table `blog_post`, `BlogPost` and the folder `src/routes/blog-posts`; a last word ending in a single `s` (`news`, `ideas`, `menus`) is a plural already, except a known singular such as `status` or `bus`, and `person` gives `people`, so `--plural <name>` names the plural of the whole name, such as `blog-geese`, for any other word) writes the pg-orm table `src/db/<name>.ts`, added to `tables` in `src/db/tables.ts`, an `_actions.kay` with `create`, `update` and `remove` over `s` schemas built from the fields (each redirecting to the list), the list at `/blog-posts` and the edit page `[id=integer]/edit.kay` with a delete button. With kayjs-ui installed the list is a `Table` in `src/components/blog-posts-table.kay`, the create form a `FormDialog` in `src/components/new-blog-post.kay` and the edit page a `SaveForm`; else the list is a plain `table`, with a `new.kay` page of `form`s. A project with tests gets `tests/blog-posts.test.ts`, which creates a row and reads the list, edits and deletes it, and refuses a create with an empty text field (a word for a number when there is none). A `tables` list holding a comment or an index is left alone and the command stops, naming what to add. Run `bun run db:generate` and `bun run db:migrate` for the new table.
62
62
  - What it writes passes `kay check` and the lint. `--dry-run` lists the files and writes none, and `--format json` prints `{ kind, name, written, dryRun }`.
63
63
  - `kay add <features> [dir] [--no-install] [--dry-run] [--format text|json] [--quiet]`:
package/llms/project.md CHANGED
@@ -78,7 +78,7 @@ export const app = new Elysia()
78
78
  - A key kay does not know in `kay.config.ts`, at its top or in any option bag (`security`, `i18n`, `assets`, `markdown`, `ops`, `cors`, `client` and the rest), stops every command with the nearest known name (`` `trailingslash`, did you mean `trailingSlash`? ``), and `defineConfig` types it as an error, since a mistyped key would otherwise leave kay's default in place with nothing said.
79
79
  - A value that is not the kind its key takes (`trailingSlash: 'sometimes'`, `compress: 7`, `lang: 5`, a `default` locale outside the `locales`) stops them the same way, once, as the config loads: `` `trailingSlash` is "sometimes", expected one of "never", "always" or "ignore" ``, the path through bags and lists, with the nearest allowed value for a mistyped text. The options of `pages()` and `testSite()` are checked as they merge, and an extension's `config` as it loads.
80
80
  - `auth()`, `cms()`, `mail()` and `ai()` refuse an option they do not take with the nearest one, as `kay.config.ts` does; a library adds the same to its own factory with `checkOptionKeys` from `kay/library`, over a `Record<keyof ItsOptions, true>`.
81
- - Project settings live in an optional `kay.config.ts` at the root, read by `pages()` and every command; the `config` passed to `pages({ config })` or `testSite({ config })` wins over it key by key, an `undefined` key leaving the file's value (the config's keys written beside `root` work until 1.108, `deprecated-pages-options` rewrites them), and in an executable `kay build --compile` wrote, the root, routes and public directory it was built with win over both.
81
+ - Project settings live in an optional `kay.config.ts` at the root, read by `pages()` and every command; the `config` passed to `pages({ config })` or `testSite({ config })` wins over it key by key, an `undefined` key leaving the file's value (the config's keys written beside `root` are refused: write them in `config`), and in an executable `kay build --compile` wrote, the root, routes and public directory it was built with win over both.
82
82
  - It must `export default` its config, or the command fails with a message saying so.
83
83
 
84
84
  ```ts
@@ -97,8 +97,8 @@ export default defineConfig({
97
97
 
98
98
  - A feature key is `false` for off, `true` for its defaults or an object of options: `robots`, `sitemap`, `assets.favicon`, `security`, `ops.health`, `preview`, `client.offline`, `ops.metrics`, `openapi`, `mcp`, `proxy`, `assets.images.formats.avif` and the rate limits. `defineConfig` refuses a key it does not know in any option bag, as a type error.
99
99
  - A list that may come from a CMS or a database is the list, or a function returning it (or a promise of it): `cors.origins`, `security.hosts`, `assets.images.remote.hosts`, `proxy.trusted`, `redirects`, `robots.disallow`, `robots.allow` and `i18n.paths`. Kay calls it once as the config loads, `kay dev` again after a change to the file.
100
- - Keys are grouped by concern: `client` (what the browser is given: `links`, `offline`, `search`, ...), `assets` (`images`, `fonts`, `favicon`, `manifest`, `publicCache`), `ops` (`observe`, `health`, `metrics`, `jobs`), `endpoints` (where the app's API and each feature are served) and `i18n: { locales, default, mode }`, where `mode` is `'prefix'` (the default locale unprefixed), `'always'` or `{ domains }`. The old top-level keys work until 1.108 (`deprecated-client-keys`, `deprecated-config-groups`, `deprecated-i18n-keys` rewrite them).
101
- - `endpoints` holds every route the config moves, in one place: `{ api: '/api', openapi: '/api/openapi.json', mcp: '/_kay/mcp', health: '/_kay/health', metrics: '/_kay/metrics', jobs: '/_kay/jobs' }`, each an absolute path of plain segments with no trailing slash, and `api`, `openapi` and `mcp` none under `/_kay` when you set them. Every default is under `/_kay` but the app's API (and its OpenAPI document and reference page, which follow it). The reference page is `openapi: { reference: true }` or `{ reference: { path } }`. `serve.apiPrefix` and the `path` of `openapi`, `mcp`, `health`, `metrics` and `jobs`, and `openapi.referencePath`, work until 1.108 (`deprecated-route-keys` rewrites them). An app that did not move `mcp` or `metrics` keeps `/metrics` answering as well until 1.108, and `/mcp` answers the MCP endpoint in place (not redirected) until 2.0.
100
+ - Keys are grouped by concern: `client` (what the browser is given: `links`, `offline`, `search`, ...), `assets` (`images`, `fonts`, `favicon`, `manifest`, `publicCache`), `ops` (`observe`, `health`, `metrics`, `jobs`), `endpoints` (where the app's API and each feature are served) and `i18n: { locales, default, mode }`, where `mode` is `'prefix'` (the default locale unprefixed), `'always'` or `{ domains }`. A top-level key of before 1.105 is refused, naming where it moved (the old `i18n` keys are refused, naming `default` and `mode`).
101
+ - `endpoints` holds every route the config moves, in one place: `{ api: '/api', openapi: '/api/openapi.json', mcp: '/_kay/mcp', health: '/_kay/health', metrics: '/_kay/metrics', jobs: '/_kay/jobs' }`, each an absolute path of plain segments with no trailing slash, and `api`, `openapi` and `mcp` none under `/_kay` when you set them. Every default is under `/_kay` but the app's API (and its OpenAPI document and reference page, which follow it). The reference page is `openapi: { reference: true }` or `{ reference: { path } }`. `serve.apiPrefix` and the `path` of `openapi`, `mcp`, `health`, `metrics` and `jobs`, and `openapi.referencePath`, are refused, each naming where it moved (see `llms/upgrading-1-105-config.md`). An app that did not move `mcp` or `metrics` keeps `/metrics` answering as well until 1.108, and `/mcp` answers the MCP endpoint in place (not redirected) until 2.0.
102
102
  - `assets.images` is `{ remote: { hosts, maxSize, timeout }, formats: { quality, webp, avif }, limits: { variants, queue }, rateLimit, ttl, widths, ... }`; `remote: [...]` is hosts alone.
103
103
  - A duration key is `ttl` for how long data lives, `timeout` for how long to wait and `maxAge` only for the HTTP or cookie attribute of that name.
104
104
  - `proxy: false` is none, `proxy: true` is one proxy in front, `proxy: { hops: 2 }` two, `{ header }` a header the proxy sets, `{ key: { header: 'x-upstream-key' }, open }` refuses requests without the shared key ([Production](proxy-and-security.md#behind-a-proxy)).
@@ -130,7 +130,7 @@ export default defineConfig({
130
130
 
131
131
  - `kay/html`, `kay/dom`, `kay/dom-loop`, `kay/dom-await`, `kay/dom-lazy`, `kay/dom-try`, `kay/dom-spread`, `kay/dom-image`, `kay/pending`, `kay/i18n-links`, `kay/island`, `kay/await`, `kay/client`, `kay/arrival`, `kay/internal`, `kay/internal/title` and `kay/internal/server` are what compiled `.kay` files and kay's generated entries import, and `kay/jsx-runtime` is where TypeScript finds the JSX types of `jsxImportSource: "kay"`: the compiler's output contract rather than API, free to change in any release, never imported by an app. The root `kay` export also holds the compile-time types behind the generated shadow types, none of them for an app to name: `BindableMark`, `IslandBrand`, `HandedPart`, `HandsPart`, `HandedSignal`, `UnresolvedParameter`, `WidenedProps`, `CheckedHref`, `CheckedHtml`, `CheckedComputedHtml`, `BoundProp`, `BoundValue`, `PlainIslandProp`, `FunctionProp`, `Inferred`, `TemplateHelpers`, `TemplateValues` and `Truthy`, free to change in any release too.
132
132
  - A few entries also hold plumbing no page tells an app to call, free to change in any release: the paths, providers and tracker tags of `kay/analytics` (`ANALYTICS_PATH`, `ANALYTICS_SCRIPT_PATH`, `ANALYTICS_PROVIDERS`, `CUSTOM_COLLECT_PATH`, `CUSTOM_SCRIPT_PATH`, `NOTICE_SCRIPT_PATH`, `INTEGRITY`, `TRACKER_TAGS`, `isGated`, `LazyGuard`), the collection marker, publish times and cache key of `kay/content`, and the preview session reader of `kay/server`.
133
- - A name has one home: an entry beside a package's root exists for browser safety (`@kayjs/auth/rules`, `@kayjs/cms/form`, which an island imports without the server) and the root does not repeat its names. The copies in `kay/mount` and `kay/server` that 1.105 moved (`mount`, `s`, `RateLimit`, `sqliteCache`) stay as deprecated shims until 1.108.
133
+ - A name has one home: an entry beside a package's root exists for browser safety (`@kayjs/auth/rules`, `@kayjs/cms/form`, which an island imports without the server) and the root does not repeat its names.
134
134
  - `kay/library` is what kay's own libraries (kayjs-auth, kayjs-ui, kayjs-mail, kayjs-cms, kayjs-ai) share with kay for their server code, such as the sanitizer's lists, sealing, locale matching, escaping and the user a library names for a request (`nameUser(request, () => id)`, read back by `userOf(request)`: kayjs-auth names the signed-in user and kayjs-ai counts them) and `configError(option, value, takes)`, the `config-invalid` `KayError` a library throws for a setting it refuses at boot, so neither keeps a copy: not API either, free to change with any minor, never imported by an app. The libraries are released in lockstep with kay, each one's peer range on kay's minor, so the same holds for what a library imports from it.
135
135
 
136
136
  ### Reserved paths
@@ -71,7 +71,7 @@ export default defineConfig({
71
71
  })
72
72
  ```
73
73
 
74
- - `proxy: false` is none, as left out; `proxy: true` is one proxy in front, `{ hops: 2 }` two; a bare `proxy: 2` still works until 1.108, `deprecated-config-switch` rewriting it.
74
+ - `proxy: false` is none, as left out; `proxy: true` is one proxy in front, `{ hops: 2 }` two; a bare `proxy: 2` is refused, write `{ hops: 2 }`.
75
75
  - `hops` is the number of proxies in front, each appending the address it was reached from to `X-Forwarded-For`, so the visitor is the entry `hops` from its end: 1 for nginx or Caddy alone, 2 for Cloudflare then nginx.
76
76
  - A request with fewer entries skipped an outer proxy, and its first entry is who reached the inner one.
77
77
  - `header` names a header a proxy sets to the visitor's address, read instead: `{ header: 'cf-connecting-ip' }`, or `{ header: 'x-real-ip' }` for nginx's `proxy_set_header X-Real-IP $remote_addr`.
package/llms/queues.md CHANGED
@@ -103,6 +103,6 @@ await onboarding.send(userId, 'visited')
103
103
  - `remove(id)` removes a job, and `remove(match)` every waiting or failed job whose payload `match` returns true for, such as a person's mails once they asked to be erased, resolving with how many went; an app's own `JobStore` takes a function only when it has `jobs(queue)`.
104
104
  - An idle queue looks at the store from one worker, which is how a job another process enqueued is noticed: 1 second after a job, then twice as long after each empty look up to `idlePoll`, 10 seconds by default, so such a job waits 10 seconds at worst. On Postgres it is told within a second. A job enqueued in this process, or delayed to a time the store knows, still runs at once, and a retry is picked up when due. `idlePoll: '1s'` looks every second, `'30s'` asks the database less often; it takes at least `1s`. A custom `JobStore` may have `prune(queue, before)` to drop the expired failed jobs in one call.
105
105
  - A store that fails, a SQLite file locked past its timeout say, is logged once as the outage starts and once as it ends, its workers asking it again later and later meanwhile, up to a minute apart.
106
- - `ctx.signal` aborts at `timeout` (`lostAfter` until 1.108), so a handler passing it on stops instead of running beside the retry, and as the server stops, when a job it gives up on is released with `release(id, until)` of the `JobStore`, clearing the hold only while `until`, the one it was claimed with, is still the job's (optional): back without waiting out `timeout`, its attempt not counted, instead of held until `timeout` and retried after its backoff. Without `release` the job is retried as before.
106
+ - `ctx.signal` aborts at `timeout`, so a handler passing it on stops instead of running beside the retry, and as the server stops, when a job it gives up on is released with `release(id, until)` of the `JobStore`, clearing the hold only while `until`, the one it was claimed with, is still the job's (optional): back without waiting out `timeout`, its attempt not counted, instead of held until `timeout` and retried after its backoff. Without `release` the job is retried as before.
107
107
  - A process that dies running a job leaves it held: it runs again once `timeout` has passed since it started, 10 minutes by default. A run still going as `timeout` ends counts as a failed attempt, so its worker moves on, its handler's signal aborted, so a handler ignoring it runs on beside the retry, and a job longer than `timeout` needs a longer one, and a job whose process died during each of its `attempts` is kept as failed without running again, rather than crash every process that takes it.
108
108
  - `drain()` runs every job whose time has come, here and now, until none is left, and waits for a run a worker already took (up to its `timeout` for one that never ends), except inside a job, which includes work the job spawned (a timer, a promise left running) and then does not wait, and a run counts once however many drains waited for it; in tests `site.runJobs()` from `kay/test` does it for every queue.
@@ -67,7 +67,7 @@ The object `rateLimit()` returns is a limit: give it to `protect: { rateLimit: v
67
67
  ### On an action
68
68
 
69
69
  - `rateLimit` lets one client post `max` times every `window`, then answers 429 with `Retry-After` and `errors['']` saying when to retry.
70
- - It counts every attempt, valid or not, unless it says `count: 'succeeded'`: then only the posts whose handler returned without `ctx.fail`, an error or a refusal count, so typos and a mail server failing lock no one out, a redirect from the handler counting as gone through.
70
+ - It counts every attempt, valid or not, unless it says `count: 'succeeded'`: then only the posts whose handler returned without `ctx.deny`, an error or a refusal count, so typos and a mail server failing lock no one out, a redirect from the handler counting as gone through.
71
71
  - Posts arriving together all read the count before any adds to it, so a burst may pass `max` by a few.
72
72
  - Several limits all apply, each counting every attempt it is meant to count whichever refuses it, the longest wait the one told: `rateLimit: [{ max: 30, window: '10m' }, { max: 5, window: '10m', count: 'succeeded' }]` slows a script hammering the form and lets five messages through, each limit counting under its place in the list.
73
73
  - The client is the address the request came from, or the one the proxies in front passed on once `proxy` says how to read it (see [Behind a proxy](proxy-and-security.md#behind-a-proxy)).
@@ -78,7 +78,7 @@ The object `rateLimit()` returns is a limit: give it to `protect: { rateLimit: v
78
78
  - A limit whose store throws or rejects counts in this process's memory instead, logged once per limit and store until the store answers again, so no request fails for it; a store taking over 8 seconds is also passed over for ten seconds, so a hanging one holds one request, not every one. This holds for an action's limits, an API route's, `rateLimit()`, the proof-of-work solutions and kay's own routes, whether the store is the limit's or the app's `store.rates`, and for kayjs-auth's attempts; kayjs-ai refuses an ask instead, as a paid chat must not run on a count it cannot read.
79
79
  - `store: sqliteData(path)` in kay.config.ts (or `store: { rates }`) is where every limit naming no `store` counts, kay's own login-less routes aside, so one line shares the counts of all of them between replicas.
80
80
  - `rateLimit: { max: 5, window: '1m', store: sqliteRates('data/rates.sqlite') }`, `sqliteRates` from `kay/server`, counts every process of the machine opening that file together, which stores each key pseudonymised as an HMAC keyed by the session's, the app's (`secret`, `KAY_SECRET`) or the preview's secret once one is set, else by a random key in `<path>.key` beside the file.
81
- - `RateStore`, a `hit(key, window, weight)` method, `window` a `Duration` for a store with `durations: true` (milliseconds for one written before 1.105, until 1.108; `lengthMs(window)` from `kay` reads both), adding `weight` (one unless given) to the count and giving `{ count, resetAt }` and, for a limit counting what went through, a `peek(key)` giving the open window without counting or `undefined`, is the shape of an app's own. An optional `refund(key, resetAt)` takes one attempt back off the window closing at `resetAt`, never below zero and not once that window is gone: kay calls it for a call that started no work (kayjs-ai's resume of a reply it keeps), and a store without it keeps the attempt counted; kay's own stores, memory, SQLite and Postgres, have it. An optional `reset(key)` forgets the window under `key`: kayjs-auth clears a count with it once a sign-in succeeds; kay's own stores have it too.
81
+ - `RateStore`, a `hit(key, window, weight)` method, `window` a `Duration` (`lengthMs(window)` from `kay` reads its milliseconds), adding `weight` (one unless given) to the count and giving `{ count, resetAt }` and, for a limit counting what went through, a `peek(key)` giving the open window without counting or `undefined`, is the shape of an app's own. An optional `refund(key, resetAt)` takes one attempt back off the window closing at `resetAt`, never below zero and not once that window is gone: kay calls it for a call that started no work (kayjs-ai's resume of a reply it keeps), and a store without it keeps the attempt counted; kay's own stores, memory, SQLite and Postgres, have it. An optional `reset(key)` forgets the window under `key`: kayjs-auth clears a count with it once a sign-in succeeds; kay's own stores have it too.
82
82
  - A store needs only `hit`: `limiter` derives `peek` (a `hit` of weight 0, which on a store holding no window opens an empty one the next hit joins) and `reset` (a `hit` of minus the open count, which leaves an empty window open, and needs a store that adds a negative weight as it adds any), so no limit, action or library refuses or warns of a store for lacking them.
83
83
 
84
84
  ### `limiter`
@@ -91,7 +91,7 @@ The object `rateLimit()` returns is a limit: give it to `protect: { rateLimit: v
91
91
  ### Outside an action
92
92
 
93
93
  - A guard, an API route or a library limits attempts the same way with `rateLimit(name, { max, window, store })` from `kay/server`: `await limit.hit(request)` counts one from the request's client and gives the seconds to wait once over the limit, else `undefined`.
94
- - `limiter().enforce(key, weight?)` counts under a key and answers the seconds to wait, refusing nothing; `rateLimit().check(ctx, message?)` is the guard's call, which refuses (`rateLimit().enforce(ctx)` was its name until 1.105, `deprecated-rate-enforce`).
94
+ - `limiter().enforce(key, weight?)` counts under a key and answers the seconds to wait, refusing nothing; `rateLimit().check(ctx, message?)` is the guard's call, which refuses.
95
95
  - `await limit.check(ctx, message?)` takes a guard's `ctx`, counts under the limit's `key` or the client's address, and past the limit sets `Retry-After` and calls `ctx.deny(429, message)`, `message` a text or a function of the seconds to wait.
96
96
  - `onLimit(refusal)` on a limit (`RateLimitRefusal`: `name`, the key counted, `wait` in seconds, `request` when there is one) runs for each request an action, a page, an API route, `check` or `hit` refused, beside the answer, which never waits for it; one that throws or rejects is logged. A limit object from `rateLimit()` shared with an action reports the action's URL as `name`.
97
97
  - `await limit.count(request)` counts as `hit` does and gives the window, `{ count, resetAt, wait }`, `wait` the seconds to wait once over `max`, else `undefined`: for an app that shows the count or decides itself.
@@ -115,5 +115,5 @@ Each kind of route counts at one place, and a refusal there is the 429:
115
115
 
116
116
  - Every limit is one `RateLimit` (from `kay`, `kay/server` and `kay/library`): `{ max, window, store?, key?, onLimit? }`. Every `rateLimit` option takes one or a list of them, each counted apart, and `false` lifts a default one. kayjs-auth, kayjs-ai, `basicAuth` and kay's own routes (`images`, `mcp`, `live`) count under keys or the address of their own and take no `key`; a `key` there is refused at boot, a `store` and an `onLimit` are taken.
117
117
  - kayjs-ai takes `ai({ rateLimit, budget, key })` and `ask(messages, { key })`, see [Limits and the token budget](../../ai/llms/limits.md).
118
- - kayjs-auth takes `authCore({ rateLimit: { signIn: { ip, account, accountAll } } })`, one entry per feature, each part a limit or a list of them (`{ ip, account }` on `resend`, `forgot`, `magicLink`, `emailChange`, `twoFactor` and `emailCode`, `invite: { sender, address }`, `oauth: { register, registerAll, document, token }`, a bare limit for `register`, `reprove`, `link`, `export` and `organization`; the flat keys of before 1.105 work until 1.108, `deprecated-auth-rate-limits`), see [Limits](../../auth/llms/hardening-and-testing.md#limits).
118
+ - kayjs-auth takes `authCore({ rateLimit: { signIn: { ip, account, accountAll } } })`, one entry per feature, each part a limit or a list of them (`{ ip, account }` on `resend`, `forgot`, `magicLink`, `emailChange`, `twoFactor` and `emailCode`, `invite: { sender, address }`, `oauth: { register, registerAll, document, token }`, a bare limit for `register`, `reprove`, `link`, `export` and `organization`), see [Limits](../../auth/llms/hardening-and-testing.md#limits).
119
119
  - kayjs-mail's contact form takes the action's `protection: { rateLimit }` ([Contact form](../../mail/llms/contact-form-and-testing.md)); `smtp({ rateLimit: { max: 5, window: '1s' } })` caps the mails sent, a throttle on the transport with no client to count, so `{ max, window }` alone (no list, `store`, `key` or `onLimit`), and `MAIL_RATE_LIMIT=5/1s` is read into that same `{ max, window }`.
package/llms/rendering.md CHANGED
@@ -183,7 +183,7 @@ const reviews = await cached('reviews', '1d', fetchReviews, { store: disk })
183
183
  - A store that fails to write, locked or full, is logged and the value kept in memory.
184
184
  - Rows are never swept, since a stale one is still served: `invalidate` keys a site stops using, such as those of deleted posts.
185
185
  - The value goes through devalue, as session data does: dates, maps and sets survive, and a value holding a function or a class instance throws on its first load, keeping nothing; on a refresh, it is logged and the stale value kept.
186
- - `sqliteCache` comes from `kay/cache`, its one home; `kay/server` exports it too until 1.108, and `deprecated-import-path` moves the import.
186
+ - `sqliteCache` comes from `kay/cache`, its one home.
187
187
  - `sqliteCache` is server-only: in the browser, `kay/cache` has `cached`, `cache`, `cacheTag` and `invalidate` alone, and `kay check` reports `invalidatePage` or `sqliteCache` imported by an island's script, a browser-only component, or a component only islands render, or a `.ts` module any of them imports, directly or through others (`server-only-import`); a name read off a namespace import or destructured from one is reported too.
188
188
  - `CacheStore` is the shape of a store, synchronous for a file (`sqliteCache`) so that `invalidate` is done when it returns, any call answering with a promise for a network one (`pgData(db).cache`), whose `invalidate` drops the stored rows in the background, a `cached` read waiting for them: `get(key)` giving `{ text, freshUntil }`, `set(key, text, freshUntil)`, `delete(key)` and `keys()`, plus, optionally, `publish(message)` and `subscribe(listener)` carrying invalidations between processes, as a Redis channel would (a message may also carry the clock of the sender, so replicas on machines whose clocks differ still date a live page's invalidation after its read; relay every message as it is, never to its sender), and `dependencies()` giving a `Map` of the keys a stored value was built from, so `invalidate` reads those and calls `get` for no row it holds nowhere in memory (`sqliteCache` keeps them in a table of their own); `text` is opaque, to be given back as `set` received it (a value built from a collection or another key starts with a line naming them).
189
189
  - In the `server` and `app` templates' image the app runs as `nobody`, so the store's directory is a mounted volume it can write.
@@ -67,14 +67,14 @@ Section(title="Contact")
67
67
 
68
68
  - `server` renders it on every GET and splices it into the prerendered page: it arrives with the page and needs no JavaScript.
69
69
  - Only the island is rendered and compressed, the rest of the page being deflated once; the page then goes out as gzip, never brotli, with `Cache-Control: private, no-store` and no ETag.
70
- - `defer` is a bare word beside `server`: `defer` alone, or with a value, is a prop of the component, which may have one of its own. It was `server="defer"`, which `kay upgrade` rewrites (`deprecated-island-attributes`) and which works until 1.108.
70
+ - `defer` is a bare word beside `server`: `defer` alone, or with a value, is a prop of the component, which may have one of its own. `server="defer"` is an error.
71
71
  - `server defer` serves the page as any prerendered page, brotli and ETag included, and the browser fetches the island a screen before it scrolls into view, or once the page is idle, then hydrates what it brought.
72
72
  - Until then the page shows the component as the build rendered it, inert and with its forms' field names and actions taken out, so it keeps its place and size and a bot has nothing to post. Pick it for what sits low on the page.
73
73
  - A page deferring an island ships kay's browser entry; with `navigation: false` and no island the build fails.
74
74
  - The island's URL is the page's with `?kay_island=N`: fetched by kay, it answers the island alone; visited, as from a link, it answers the page with every island in place, with `X-Robots-Tag: noindex`.
75
75
  - A browser without JavaScript keeps the inert copy of a deferred island.
76
76
  - A fetch that times out (10 s), gets no answer or fails with a 5xx, 408 or 429 is retried at 1 s and 3 s; a lost one keeps the inert copy, sets `data-kay-failed` and dispatches `kay:server-island-error` (`detail.error`, `detail.retry()`), a success `kay:server-island`; a page swap aborts it.
77
- - `@failed` under the use (`ContactForm(server defer)` with an `@failed` block below it) is rendered hidden beside the inert copy and shown on `data-kay-failed`; a control inside it with `data-kay-retry` retries the island with no script, and the block hides again while it loads. A component declares its own with a root `@failed` block, as a `--- client` one declares its `@fallback`; a use's block wins. It is no prop of the component, is rendered without running the script (static markup and imports only, a script value or prop it reads is reported) and an inline `server` refuses it, as it does a server island, a handler or an action form inside it. It is never a prop, even for a component with a `failed` slot prop. Shown, it is a `role="alert"` and a failed retry gives the focus back to its retry control. A deferred island with a block has `<slot data-kay-server><slot inert>copy</slot><slot data-kay-failure hidden>block</slot></slot>`, the copy inert on its own so the block's control clicks.
77
+ - `@failed` under the use (`ContactForm(server defer)` with an `@failed` block below it) is rendered hidden beside the inert copy and shown on `data-kay-failed`; a control inside it with `data-kay-retry` retries the island with no script, and the block hides again while it loads. A component declares its own with a root `@failed` block, as a client-only one declares its `@fallback`; a use's block wins. It is no prop of the component, is rendered without running the script (static markup and imports only, a script value or prop it reads is reported) and an inline `server` refuses it, as it does a server island, a handler or an action form inside it. It is never a prop, even for a component with a `failed` slot prop. Shown, it is a `role="alert"` and a failed retry gives the focus back to its retry control. A deferred island with a block has `<slot data-kay-server><slot inert>copy</slot><slot data-kay-failure hidden>block</slot></slot>`, the copy inert on its own so the block's control clicks.
78
78
  - `noscript` beside the mark, such as `ContactForm(server defer noscript="Show the contact form")`, adds a link with that text leading to the page with every island in place.
79
79
  - It is off by default: leave it off when what the island does is reachable without it, as an email address beside a contact form.
80
80
  - A form post rendering the page, refused or coming back with how it went, renders it whole, islands included.
package/llms/server.md CHANGED
@@ -227,7 +227,7 @@ export default defineConfig({ guards: { default: 'closed' } }) // 'open' keeps e
227
227
  - With a store, the cookie carries only a sealed id, and `destroy()` deletes the session itself. A cookie sealed with its data before the app had a store opens no session, so adding one signs everyone out once: a copy of such a cookie, which a sign-out could not end, is worth nothing from then on.
228
228
  - `memorySessions()` from `kay/server` keeps sessions in the process, gone on restart, the oldest going past 100,000.
229
229
  - `sqliteSessions(path)`, for a `session({ store })` kept apart from the app's store, keeps them in a SQLite file shared by the processes on one machine, creating its directory, as `sqliteRates`, `sqliteCache` and `sqliteJobs` do; under `NODE_ENV=test`, which `bun test` sets, it keeps them in memory and writes no file; it opens its file on first use, so a process only loading the module naming it writes nothing; called again with the same file, it gives the store already open. A file deleted or replaced under a running server is noticed within seconds and opened afresh; a file put in its place takes its `-wal` and `-shm` along, or none, as SQLite would otherwise replay the old ones over it.
230
- - Any object with `get(id)`, `set(id, data, maxAge)` and `delete(id)`, each sync or async, `maxAge` a `Duration` (`durations: true`, [Stores](stores.md); milliseconds for a store written before 1.105), is a store too, such as one over Redis.
230
+ - Any object with `get(id)`, `set(id, data, maxAge)` and `delete(id)`, each sync or async, `maxAge` a `Duration` ([Stores](stores.md)), is a store too, such as one over Redis.
231
231
  - `deleteWhere(match)` on `memorySessions()` and `sqliteSessions(path)` (with `store: sqliteData(path)`, `sqliteSessions` of the same path is its store, or `sqliteData(path).sessions`) deletes every session whose data `match` accepts (`{ userId }`, fields held equal and narrowed in SQL best by a string or a long number, or a function over the data, read 500 at a time), a person's once they asked to be erased or changed their password say, resolving with how many went; `sqliteSessions` also drops expired sessions every hour.
232
232
  - Values cross as island props do, Dates, Maps, Sets and bigints included.
233
233
  - The cookie, `kay_session` unless `cookie` names another, is `HttpOnly`, `SameSite=Lax`, `Path=/`, and over https `Secure` and named `__Host-kay_session`, so no other host of the site can set it; code reading kay's session cookie by hand looks for that name over https.
package/llms/stores.md CHANGED
@@ -31,7 +31,7 @@
31
31
  - Every factory is imported from `kay/server`, such as `import { memoryKv, memoryNotifications, memoryPush, memoryRates, memoryRooms, sqliteKv, sqliteLive, sqliteNotifications, sqlitePush } from 'kay/server'`. A factory is `<backend><Thing>`: the backend is `memory`, `sqlite`, `pg`, `disk` or `s3`, the thing the store's key in the plural form the table shows. `sqliteData(path)` and `pgData(db)` make every kind over one file or database, neither with the files.
32
32
  - Every interface extends `StoreBase` from `kay/server`, as `store` does: `ping()` and `close()`, both optional, either may return a promise. `health` runs each store's `ping` beside the route's `check`, under `ops.health.timeout` and its 3 s cache, and answers 503 when one rejects. A stop calls each store's `close()` once, `store`'s own last, so a `pgData` closes its connection after the rooms let go of their members. A store with neither costs nothing.
33
33
  - A store method answers `MaybePromise<T>` (the value at once, or a promise of it; `MaybePromise` is exported from `kay/library`), so a store over memory or a file answers at once, one over a database later, and a caller `await`s every call. A room's `state` and `update` answer promises only, and `members`, `add`, `remove`, `publish` and `subscribe` of a room store are synchronous, as they are mirrored in memory.
34
- - A store receives a length as a `Duration`, as every option does: `SessionStore.set`'s `maxAge`, `RateStore.hit`'s `window`, `KvStore`'s `ttl` and `LiveStore.endAll`'s `ttl`. A store of your own says so with `durations: true` (a `StoreBase` member) and reads it with `lengthMs(value)` from `kay`, which gives the milliseconds of a `Duration` or a number. A store written before 1.105 has no `durations`, and kay keeps handing it milliseconds as a number until 1.108, so it works as it is; its parameter types still accept both, and `deprecated-store-ms` rewrites a `kv` call written with milliseconds. kay's own stores take both forms.
34
+ - A store receives a length as a `Duration`, as every option does: `SessionStore.set`'s `maxAge`, `RateStore.hit`'s `window`, `KvStore`'s `ttl` and `LiveStore.endAll`'s `ttl`. A store of your own reads it with `lengthMs(value)` from `kay`, which gives the milliseconds of a `Duration`; `kv(ns).set(key, value, 60_000)` written with milliseconds is a type error, `'60s'`.
35
35
  - `kv(namespace)` from `kay/server` is what a library or an app uses for a value under a key that is not a count: `get(key)`, `set(key, value, ttl?)` (a string, kept until `ttl` has passed, a `Duration` such as `'10m'`, or until deleted without it), `delete(key)` (whether there was one) and `once(key, ttl)`, which takes a key for `ttl` and resolves true for the one call that took it, however many processes ask at once: a ticket spent once, a sweep run by one replica. Keys are kept apart per namespace. It reads `store.kv`, which `sqliteData` and `pgData` fill, else this process's memory (`kv(namespace, store)` names a store). kayjs-ai's approval tickets, kayjs-cms's signed-out cookies (`passwordGuard({ kv })`) and kayjs-auth's cached OAuth client documents use it, where they counted or held a `Map` through `store.rates` before.
36
36
  - One verb per job: `delete` removes one record by its key and answers whether there was one (`FileStore`, `PushStore`, a user store), `erase(user)` removes everything a user owns and answers the count, `prune(before)` removes what is old and answers the count (`JobStore.prune`, the audit log), and `remove` is left to a member of a list (`RoomStore.remove`, `JobStore.remove`). `SessionStore`, `CacheStore` and `LiveStore` `delete` stay without an answer, as nothing reads it.
37
37
  - `pgData(db).ping()` is a round trip to the database, and `await pgData(url).close()` or `await using store = pgData(url)` closes a store opened in a script or a test; closing twice is the same as once.
@@ -51,7 +51,7 @@ section.rounded.border
51
51
 
52
52
  - A part renders `data-part="head"`, for selectors and `data-[part=head]:` utilities; one name may sit on several elements, every row of a `for`, and inside an `if` or a slot.
53
53
  - A part that is a component, `Button(part="action")`, hands its entry to it, a string or an object of its parts: `parts={{ action: { icon: 'size-5' } }}`. `data-part` reaches its root through the spread. Names after the first, `Busy(part="root spinner")`, hand those parts of this component on too, under the same names, for a part inside the called component. `kay check` reports a handed part the called component does not name, types its entry as that part takes it, and refuses one in a page or a layout, which has no class to hand from.
54
- - `parts` sits beside a shorthand, a spread and a `class` on the call, `Card.mt-4(parts={{ head: 'p-6' }})`. Until 1.108 a `class` literal of before 1.105 is handed on as `parts`: word keys, each value a string, template, conditional or array of those, or a nested literal (`deprecated-parts-class` writes `parts`). Any other `class` object is conditions; a held one is a type error naming `parts`.
54
+ - `parts` sits beside a shorthand, a spread and a `class` on the call, `Card.mt-4(parts={{ head: 'p-6' }})`. `class` is a string, an array or an object of conditions, so an object of strings in it is a type error: write `parts`.
55
55
  - `kay check` reports a part named by an expression, an unknown part at a call, a string `class` on a template with several top elements and no `part="root"`, and a component that also destructures `class` or `parts`, which the compiler owns. `...rest` leaves them out.
56
56
  - A page or a layout has no `class` prop: its parts render `data-part` only.
57
57
 
@@ -0,0 +1,49 @@
1
+ # Testing components and helpers
2
+
3
+ Mounting a component in `bun test` and the helpers for a test of its own, for the tests in [Testing](testing.md).
4
+
5
+ ## Common tasks
6
+
7
+ ### Mount a component
8
+
9
+ - `mountComponent(Component, props)` from `kay/test` renders one component built for the browser, as an island renders, into `document`, and resolves with `{ root, unmount, setProps }` once its effects ran: for what handlers and effects do, such as a dialog opening on a click.
10
+ - `Component` is the one the test imports, whose props are typed; the browser build is made from its file.
11
+ - `await setProps({ tiles })` gives the mounted component new values for some of its props, as a parent that re-rendered would (the others keep theirs, a prop it was mounted without can be given), then settles: for a component that follows a prop.
12
+ - The mount also has `type(selector, text)`, `click(selector)` and `press(key)`, firing what a browser fires, then settling: `type` focuses an input or textarea and puts the text in it with an `input` event (a `select` takes the option whose value or label is the text, with `input` and `change`), `click` sends the pointer events and the click to the element and focuses it, a disabled one doing nothing, and `press` sends `keydown` and `keyup` to the focused element, Enter committing a text field with its `change` and submitting its form, Enter or Space (`press(' ')`) clicking a button. A text field's `change` also comes when another gesture leaves it. They work on kayjs-ui's TextInput, Select and Segmented.
13
+ - On a French site (a `lang` or locale of `fr`) it writes the non-breaking spaces an island does, once `document.documentElement.lang` is `fr`; the other client defines (`KAY_BROWSER`, `KAY_STATIC_EXPORT`) are left out.
14
+ - Props may be functions, and the component runs on the test's reactive core, so a signal the test creates reaches it as a prop (`{ read: level }`) and stays live.
15
+ - A library's settings apply as `kay.config.ts` sets them.
16
+ - A component may `call()` or `resource()` a route of an API module, the project's or an extension's: it is bundled as in the browser, knowing the module only by where it is served, so the call goes out as `fetch` (stub it in the test).
17
+ - The modules the component imports from the project and from packages are the test's own, not copies: `import { count } from '../src/store'` in the test and the component's import are one instance, a store of `signal()` or `persisted.cookie()` included, so `count.set(1)` before or after the mount is what the component shows and what it writes is what the test reads. `mock.module('../src/lazy', () => ({ ... }))` or `mock.module('ms', ...)` before the mount reaches the component's static and dynamic imports, and mutating an exported object (`Object.assign(loaders, ...)`) is seen by the component too.
18
+ - One instance means the state outlives the mount, across the mounts and tests of a file and the files one worker runs: a test resets what it mutates (`count.set(0)` in `afterEach`). `mock.module()` lasts for the whole process and `mock.restore()` does not undo it: keep the real exports first (`const real = { ...await import('../src/lazy') }`) and mock them back. A persisted signal of such a module reads storage when first read, so `writePersisted` before the first mount, then `set` it; it needs the DOM to exist when the module loads (`kay/test/dom` imported first), and an app module reading `document` or `localStorage` at load is shared too, keeping the first file's happy-dom document: read them lazily.
19
+ - A module reaching a `.kay` file (through a barrel too), an API module, a server builtin or an entry kay builds for the browser (`kay/island`), a package choosing its entry by the `browser` condition, and kay's libraries (kayjs-ui, kayjs-cms) stay in the bundle, built for the browser and run afresh by each mount, as does a component's own file: a persisted signal declared there reads storage as it is at each mount, and a library's toasts start empty.
20
+ - A test reading `document` before its first mount imports `kay/test/dom` (last, where the preset sorts it), which registers the DOM at once; listed after `kay/test/preload` under `[test] preload`, it registers it for every file.
21
+ - It shims the popover API happy-dom lacks: `showPopover`, `hidePopover` and `togglePopover` fire `toggle` as a browser does, and `matches(':popover-open')` reads whether one is shown.
22
+ - It leaves `fetch`, `Request`, `Response`, `Headers`, `Blob`, `File`, `URL`, `URLSearchParams`, `AbortController`, `AbortSignal` and `WebSocket` as Bun's, and `FormData` is Bun's class that also reads a form element (a file input keeps its file), so a test serving with `Bun.serve` and fetching it works beside the DOM.
23
+ - A test may register the DOM itself instead, such as `GlobalRegistrator.register({ url: 'http://localhost/' })` for a document whose cookies the page reads.
24
+ - A DOM left registered for the rest of the run does not reach `testSite`, whose app runs on Bun's own `Request`, `Response` and the rest, so a file mounting components and one visiting pages share one `bun test` run, as long as `kay/test/preload` comes before any preload registering a DOM.
25
+ - A function the test stubbed, such as `fetch`, stays its stub there, and a streamed page under a DOM is read through `visit`, `site.fetch` handing back a body read later.
26
+ - A `persisted.local(key, initial)` signal keeps its value encoded as island props are, not as JSON: `writePersisted(key, value)` and `readPersisted(key)` from `kay/test` set one before a mount and read one back, `undefined` when none was kept; `'session'` as their last argument does the same for a `persisted.session` signal's sessionStorage.
27
+ - After an interaction, `await settle()` lets effects land before the DOM is read.
28
+
29
+ ## Reference
30
+
31
+ ### Helpers for a test of its own
32
+
33
+ - `cookieJar()` from `kay/test` keeps a browser's cookies for a test driving an Elysia app or a handler of its own rather than `testSite`, which keeps its own as `site.cookies`.
34
+ - `jar.send(handle, request)` sends the cookies kept so far through `handle`, such as `app.handle`, keeps those the response sets and drops those it expires; `jar.header()` is the `cookie` header it sends, `''` when it holds none, and `jar.cookies` the `Bun.CookieMap`.
35
+ - `solveWork(challenge)` from `kay/test` solves a proof-of-work challenge, such as one `workChallenge()` signs, as kay's script does, for a test posting a form field by hand, or `undefined` for text that is no challenge.
36
+ - `scratchDir(prefix)` from `kay/test` makes a fresh directory under the project's `.kay/scratch` and resolves with its absolute path: inside the project, so a file written there imports the project's packages, and under `.kay`, which no build or check reads, so another test file building beside it never meets it.
37
+ - `scratchDir(prefix, root)` puts it under another project's `.kay/scratch`; the test removes the directory once done with it.
38
+ - `overrideEnv(env, { MEDIA_DIR: dir })` from `kay/test` gives a `defineEnv` value other variables, `undefined` unsetting an optional one, until `restore()` or the end of a `using`, never `process.env`; only an `env.X` read at call time sees it, not a value copied at import, a value given is not checked against the schema, restores run in reverse order, tests running at once share the one `env`, and `publicEnv` is read apart.
39
+
40
+ ```ts
41
+ import { expect } from 'bun:test'
42
+ import { cookieJar } from 'kay/test'
43
+ import { app } from './app'
44
+
45
+ const jar = cookieJar()
46
+
47
+ await jar.send(app.handle, new Request('http://localhost/sign-in', { method: 'POST' }))
48
+ expect(jar.cookies.has('kay_session')).toBe(true)
49
+ ```
package/llms/testing.md CHANGED
@@ -203,16 +203,16 @@ it('shows why a todo was refused', async () => {
203
203
  - A path as `from` is visited first, so a `workChallenge` field of the form on that page is solved as it is for a page: one extra GET per submit.
204
204
  - So `site.submit(add, fields, { from: refused })` posts again from the page a refused post answered, as a visitor fixing the form does.
205
205
  - A post to an action with `minTime` goes through as if its form had been open long enough, with a page or without, so a test of something else needs no waiting.
206
- - A page older than `maxAge` is still refused as expired.
207
- - A post or a call to an action with `proofOfWork` carries a solved challenge, unless `headers` gives its own `x-kay-work`, `''` for none.
206
+ - A page older than `maxAge` is still refused as expired. A post or a call to an action with `proofOfWork` carries a solved challenge, unless `headers` gives its own `x-kay-work`, `''` for none.
208
207
  - A test of the minimum itself says how long the form was open: `site.submit(contact, fields, { from: '/', openedFor: 0 })` posts as soon as the page loaded and `openedFor: '2d'` two days after.
209
208
  - `visit.stamp(action)` reads the stamp the visit's form for `action` rendered with, and `{ from: visit, stamp }` posts it as it is, so a test checking that the refused page keeps the stamp its form rendered with compares `refused.stamp(contact)` to `page.stamp(contact)`; a `stamp` such as `'forged'`, or a `kay_since` among the fields, is posted as given and wins over `openedFor` and the clock.
210
209
  - Both `visit` and `submit` resolve with `{ url, status, headers, html }`, which also reads the page as a crawler does (see below).
211
210
  - `site.call(action, input)` calls an action as an island does, `input` its typed input or a `FormData`, left out for an action with no input or only optional fields: `site.call(signOut)`.
212
211
  - `{ from: '/orgs/acme' }` names the page a call is made on, for an action reading its params.
212
+ - An action given fields with `with` sends them in `site.call` and `site.submit`, `from` a path or a page.
213
213
  - `site.call` resolves with the action's result, throws `ActionError` when it fails and `ActionRedirectError` with `location` when it redirects, the path under the site's `base` when it has one.
214
214
  - A handler returning an async iterable gives every value once its stream ended, `[1, 2, 3]`, and throws when the stream failed.
215
- - `site.expectRefused(action, input)` makes the same call expecting it refused: it resolves with the `ActionError`, `data` typed from the handler and `message` the `ctx.fail` text or the schema's messages, and fails the test when the call went through.
215
+ - `site.expectRefused(action, input)` makes the same call expecting it refused: it resolves with the `ActionError`, `data` typed from the handler and `message` the refusal's text or the schema's messages, and fails the test when the call went through.
216
216
  - `await site.expectRefused(add, { title: '' })` reads `{ status: 422, errors: { title: 'Write a title' } }`.
217
217
  - `site.mcp.initialize()`, `site.mcp.tools()` and `site.mcp.call(name, args)` test an app's MCP endpoint: [MCP endpoint](mcp.md).
218
218
 
@@ -231,48 +231,7 @@ it('shows why a todo was refused', async () => {
231
231
 
232
232
  Requests, jobs, sockets and sessions are in [Testing requests, jobs, sockets and sessions](testing-requests-jobs-sockets.md).
233
233
 
234
- ### Mounting a component
235
-
236
- - `mountComponent(Component, props)` from `kay/test` renders one component built for the browser, as an island renders, into `document`, and resolves with `{ root, unmount, setProps }` once its effects ran: for what handlers and effects do, such as a dialog opening on a click.
237
- - `Component` is the one the test imports, whose props are typed; the browser build is made from its file.
238
- - `await setProps({ tiles })` gives the mounted component new values for some of its props, as a parent that re-rendered would (the others keep theirs, a prop it was mounted without can be given), then settles: for a component that follows a prop.
239
- - The mount also has `type(selector, text)`, `click(selector)` and `press(key)`, firing what a browser fires, then settling: `type` focuses an input or textarea and puts the text in it with an `input` event (a `select` takes the option whose value or label is the text, with `input` and `change`), `click` sends the pointer events and the click to the element and focuses it, a disabled one doing nothing, and `press` sends `keydown` and `keyup` to the focused element, Enter committing a text field with its `change` and submitting its form, Enter or Space (`press(' ')`) clicking a button. A text field's `change` also comes when another gesture leaves it. They work on kayjs-ui's TextInput, Select and Segmented.
240
- - On a French site (a `lang` or locale of `fr`) it writes the non-breaking spaces an island does, once `document.documentElement.lang` is `fr`; the other client defines (`KAY_BROWSER`, `KAY_STATIC_EXPORT`) are left out.
241
- - Props may be functions, and the component runs on the test's reactive core, so a signal the test creates reaches it as a prop (`{ read: level }`) and stays live.
242
- - A library's settings apply as `kay.config.ts` sets them.
243
- - A component may `call()` or `resource()` a route of an API module, the project's or an extension's: it is bundled as in the browser, knowing the module only by where it is served, so the call goes out as `fetch` (stub it in the test).
244
- - The modules the component imports from the project and from packages are the test's own, not copies: `import { count } from '../src/store'` in the test and the component's import are one instance, a store of `signal()` or `persisted.cookie()` included, so `count.set(1)` before or after the mount is what the component shows and what it writes is what the test reads. `mock.module('../src/lazy', () => ({ ... }))` or `mock.module('ms', ...)` before the mount reaches the component's static and dynamic imports, and mutating an exported object (`Object.assign(loaders, ...)`) is seen by the component too.
245
- - One instance means the state outlives the mount, across the mounts and tests of a file and the files one worker runs: a test resets what it mutates (`count.set(0)` in `afterEach`). `mock.module()` lasts for the whole process and `mock.restore()` does not undo it: keep the real exports first (`const real = { ...await import('../src/lazy') }`) and mock them back. A persisted signal of such a module reads storage when first read, so `writePersisted` before the first mount, then `set` it; it needs the DOM to exist when the module loads (`kay/test/dom` imported first), and an app module reading `document` or `localStorage` at load is shared too, keeping the first file's happy-dom document: read them lazily.
246
- - A module reaching a `.kay` file (through a barrel too), an API module, a server builtin or an entry kay builds for the browser (`kay/island`), a package choosing its entry by the `browser` condition, and kay's libraries (kayjs-ui, kayjs-cms) stay in the bundle, built for the browser and run afresh by each mount, as does a component's own file: a persisted signal declared there reads storage as it is at each mount, and a library's toasts start empty.
247
- - A test reading `document` before its first mount imports `kay/test/dom` (last, where the preset sorts it), which registers the DOM at once; listed after `kay/test/preload` under `[test] preload`, it registers it for every file.
248
- - It shims the popover API happy-dom lacks: `showPopover`, `hidePopover` and `togglePopover` fire `toggle` as a browser does, and `matches(':popover-open')` reads whether one is shown.
249
- - It leaves `fetch`, `Request`, `Response`, `Headers`, `Blob`, `File`, `URL`, `URLSearchParams`, `AbortController`, `AbortSignal` and `WebSocket` as Bun's, and `FormData` is Bun's class that also reads a form element (a file input keeps its file), so a test serving with `Bun.serve` and fetching it works beside the DOM.
250
- - A test may register the DOM itself instead, such as `GlobalRegistrator.register({ url: 'http://localhost/' })` for a document whose cookies the page reads.
251
- - A DOM left registered for the rest of the run does not reach `testSite`, whose app runs on Bun's own `Request`, `Response` and the rest, so a file mounting components and one visiting pages share one `bun test` run, as long as `kay/test/preload` comes before any preload registering a DOM.
252
- - A function the test stubbed, such as `fetch`, stays its stub there, and a streamed page under a DOM is read through `visit`, `site.fetch` handing back a body read later.
253
- - A `persisted.local(key, initial)` signal keeps its value encoded as island props are, not as JSON: `writePersisted(key, value)` and `readPersisted(key)` from `kay/test` set one before a mount and read one back, `undefined` when none was kept; `'session'` as their last argument does the same for a `persisted.session` signal's sessionStorage.
254
- - After an interaction, `await settle()` lets effects land before the DOM is read.
255
-
256
- ### Helpers for a test of its own
257
-
258
- - `cookieJar()` from `kay/test` keeps a browser's cookies for a test driving an Elysia app or a handler of its own rather than `testSite`, which keeps its own as `site.cookies`.
259
- - `jar.send(handle, request)` sends the cookies kept so far through `handle`, such as `app.handle`, keeps those the response sets and drops those it expires; `jar.header()` is the `cookie` header it sends, `''` when it holds none, and `jar.cookies` the `Bun.CookieMap`.
260
- - `solveWork(challenge)` from `kay/test` solves a proof-of-work challenge, such as one `workChallenge()` signs, as kay's script does, for a test posting a form field by hand, or `undefined` for text that is no challenge.
261
- - `scratchDir(prefix)` from `kay/test` makes a fresh directory under the project's `.kay/scratch` and resolves with its absolute path: inside the project, so a file written there imports the project's packages, and under `.kay`, which no build or check reads, so another test file building beside it never meets it.
262
- - `scratchDir(prefix, root)` puts it under another project's `.kay/scratch`; the test removes the directory once done with it.
263
- - `overrideEnv(env, { MEDIA_DIR: dir })` from `kay/test` gives a `defineEnv` value other variables, `undefined` unsetting an optional one, until `restore()` or the end of a `using`, never `process.env`; only an `env.X` read at call time sees it, not a value copied at import, a value given is not checked against the schema, restores run in reverse order, tests running at once share the one `env`, and `publicEnv` is read apart.
264
-
265
- ```ts
266
- import { expect } from 'bun:test'
267
- import { cookieJar } from 'kay/test'
268
- import { app } from './app'
269
-
270
- const jar = cookieJar()
271
-
272
- await jar.send(app.handle, new Request('http://localhost/sign-in', { method: 'POST' }))
273
- expect(jar.cookies.has('kay_session')).toBe(true)
274
- ```
275
-
234
+ Mounting a component with `mountComponent`, and the helpers for a test of its own (`cookieJar`, `solveWork`, `scratchDir`, `overrideEnv`), are in [Testing components and helpers](testing-mount.md).
276
235
 
277
236
  ### Databases and setup
278
237