@kayjs/kay 1.105.0 → 1.107.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 (467) hide show
  1. package/README.md +2 -2
  2. package/dist/eslint.js +777 -210
  3. package/editors/zed/extension.toml +2 -2
  4. package/llms/action-protection.md +2 -2
  5. package/llms/actions-from-islands.md +2 -2
  6. package/llms/actions-refused-fields.md +22 -0
  7. package/llms/actions.md +24 -41
  8. package/llms/analytics.md +1 -1
  9. package/llms/api-from-islands.md +1 -1
  10. package/llms/api-routes.md +6 -6
  11. package/llms/browser-only.md +1 -1
  12. package/llms/check-and-tools.md +1 -1
  13. package/llms/code-lints.md +2 -2
  14. package/llms/compiler-api.md +1 -1
  15. package/llms/component-libraries.md +1 -0
  16. package/llms/components.md +1 -1
  17. package/llms/content-cms.md +1 -1
  18. package/llms/content-markdown-to-caching.md +1 -1
  19. package/llms/content-preview.md +2 -2
  20. package/llms/content.md +21 -21
  21. package/llms/deprecated-lints-1-105-libraries.md +2 -0
  22. package/llms/deprecated-lints-1-105.md +3 -3
  23. package/llms/deprecated-lints.md +4 -4
  24. package/llms/dev-tool.md +2 -2
  25. package/llms/environment.md +22 -22
  26. package/llms/files.md +5 -5
  27. package/llms/island-and-form-lints.md +1 -0
  28. package/llms/islands-state-to-ids.md +2 -1
  29. package/llms/islands.md +10 -1
  30. package/llms/local-collections.md +2 -2
  31. package/llms/mcp.md +2 -1
  32. package/llms/navigation-from-code.md +1 -1
  33. package/llms/notifications.md +4 -2
  34. package/llms/project-new-and-add.md +1 -1
  35. package/llms/project.md +3 -3
  36. package/llms/rate-limits.md +1 -1
  37. package/llms/recipes.md +16 -16
  38. package/llms/rooms.md +4 -4
  39. package/llms/routing-endpoints-and-base.md +1 -1
  40. package/llms/routing.md +5 -5
  41. package/llms/schemas.md +14 -7
  42. package/llms/server.md +7 -7
  43. package/llms/site.md +9 -9
  44. package/llms/sitemap-search-fonts.md +2 -0
  45. package/llms/styles-and-assets.md +2 -1
  46. package/llms/templates-elements-slots-snippets.md +2 -2
  47. package/llms/testing-browser.md +20 -0
  48. package/llms/testing.md +1 -1
  49. package/llms/upgrading-1-105-config.md +2 -2
  50. package/llms/upgrading.md +37 -4
  51. package/llms/whats-new-archive.md +35 -66
  52. package/llms/whats-new.md +47 -28
  53. package/llms.txt +1 -1
  54. package/package.json +24 -11
  55. package/src/add.ts +1 -1
  56. package/src/build/class-table.ts +2 -2
  57. package/src/build/client.ts +27 -30
  58. package/src/build/entry-files.ts +19 -0
  59. package/src/build/lazy-components.ts +130 -0
  60. package/src/build/lazy-manifest.ts +56 -0
  61. package/src/build/lazy-stubs.ts +31 -0
  62. package/src/build/plugin.ts +16 -11
  63. package/src/build/runtime-chunk.ts +1 -1
  64. package/src/build/styles.ts +3 -3
  65. package/src/build/transform.ts +19 -7
  66. package/src/build/ui-layers.ts +30 -0
  67. package/src/build/ui.ts +108 -11
  68. package/src/build/variants.ts +125 -46
  69. package/src/build/worker-bundle.ts +6 -0
  70. package/src/check/action-options.ts +56 -0
  71. package/src/check/boot.ts +22 -1
  72. package/src/check/call-result.ts +242 -0
  73. package/src/check/config-objects.ts +17 -2
  74. package/src/check/diagnose.ts +22 -0
  75. package/src/check/handler-events.ts +149 -0
  76. package/src/check/index.ts +6 -2
  77. package/src/check/link-flag-tests.ts +130 -0
  78. package/src/check/project.ts +4 -3
  79. package/src/check/refusal-calls.ts +2 -2
  80. package/src/check/regroup.ts +5 -3
  81. package/src/check/renamed-packages.ts +58 -14
  82. package/src/check/schema-builders.ts +256 -0
  83. package/src/check/schema-json.ts +226 -0
  84. package/src/check/secret-keys.ts +15 -2
  85. package/src/check/shadow-types.ts +13 -9
  86. package/src/check/template-hints.ts +1 -1
  87. package/src/check/tool-labels.ts +11 -9
  88. package/src/check/ui-types.ts +4 -3
  89. package/src/check/ui.ts +14 -11
  90. package/src/commands/env-declare.ts +18 -6
  91. package/src/commands/routes.ts +1 -1
  92. package/src/compiler/a11y.ts +8 -1
  93. package/src/compiler/ast.ts +1 -1
  94. package/src/compiler/bound-props.ts +1 -1
  95. package/src/compiler/codegen.ts +13 -23
  96. package/src/compiler/deprecated-lints-1-105.ts +41 -0
  97. package/src/compiler/deprecated-lints-1-106.ts +14 -0
  98. package/src/compiler/deprecated-lints-1-107.ts +14 -0
  99. package/src/compiler/deprecated-lints.ts +17 -60
  100. package/src/compiler/deprecated-typed-lints.ts +23 -0
  101. package/src/compiler/dom-here.ts +72 -0
  102. package/src/compiler/dom.ts +23 -23
  103. package/src/compiler/fence-checks.ts +12 -11
  104. package/src/compiler/field-described.ts +2 -2
  105. package/src/compiler/helper-imports.ts +1 -1
  106. package/src/compiler/html-fields.ts +92 -0
  107. package/src/compiler/html-initial.ts +5 -3
  108. package/src/compiler/html.ts +14 -31
  109. package/src/compiler/import-edits.ts +15 -0
  110. package/src/compiler/index.ts +10 -3
  111. package/src/compiler/island-declaration.ts +15 -0
  112. package/src/compiler/items.ts +5 -5
  113. package/src/compiler/kay-exports.ts +1 -0
  114. package/src/compiler/lazy-imports.ts +357 -0
  115. package/src/compiler/link-flags.ts +6 -5
  116. package/src/compiler/lints.ts +12 -12
  117. package/src/compiler/parser.ts +2 -2
  118. package/src/compiler/rest-omits.ts +15 -0
  119. package/src/compiler/route-lints.ts +2 -0
  120. package/src/compiler/schema-lints.ts +13 -0
  121. package/src/compiler/script-server.ts +6 -3
  122. package/src/config-loader.ts +10 -2
  123. package/src/config-resolve.ts +3 -1
  124. package/src/config-shape.ts +2 -2
  125. package/src/config.ts +20 -4
  126. package/src/content/markdown.ts +2 -3
  127. package/src/content/validate.ts +1 -1
  128. package/src/generate-resource.ts +9 -9
  129. package/src/generate.ts +1 -1
  130. package/src/mcp/guards.ts +1 -1
  131. package/src/mcp/tools.ts +1 -1
  132. package/src/migrate/content.ts +61 -55
  133. package/src/new.ts +6 -2
  134. package/src/runtime/action-shared.ts +2 -2
  135. package/src/runtime/action.ts +51 -4
  136. package/src/runtime/client.ts +10 -0
  137. package/src/runtime/dom-lazy.ts +276 -0
  138. package/src/runtime/field-errors.ts +58 -0
  139. package/src/runtime/field-refusal.ts +179 -0
  140. package/src/runtime/form-types.ts +99 -0
  141. package/src/runtime/form.ts +25 -9
  142. package/src/runtime/html.ts +42 -6
  143. package/src/runtime/index.ts +2 -0
  144. package/src/runtime/island.server.ts +36 -2
  145. package/src/runtime/markdown-autolink.ts +69 -0
  146. package/src/runtime/markdown-render.client.ts +39 -3
  147. package/src/runtime/markdown.client.ts +6 -3
  148. package/src/runtime/markdown.server.ts +6 -3
  149. package/src/runtime/markdown.ts +125 -1
  150. package/src/runtime/navigate-api.ts +10 -5
  151. package/src/runtime/persist.ts +7 -7
  152. package/src/runtime/query-param.ts +1 -1
  153. package/src/runtime/reactive.ts +14 -0
  154. package/src/runtime/sanitize.ts +3 -1
  155. package/src/runtime/schema-record.ts +32 -0
  156. package/src/runtime/schema.client.ts +101 -14
  157. package/src/runtime/schema.ts +328 -26
  158. package/src/runtime/standard-schema.ts +32 -0
  159. package/src/runtime/swap-focus.ts +59 -11
  160. package/src/runtime/validate-run.client.ts +179 -0
  161. package/src/runtime/validate.client.ts +11 -0
  162. package/src/runtime/validate.ts +4 -137
  163. package/src/server/action-module.ts +16 -0
  164. package/src/server/actions.ts +54 -57
  165. package/src/server/answer.ts +102 -0
  166. package/src/server/api-input.ts +166 -0
  167. package/src/server/api-modules.ts +1 -1
  168. package/src/server/api.ts +12 -32
  169. package/src/server/app-stages.ts +38 -26
  170. package/src/server/app.ts +5 -2
  171. package/src/server/client.ts +2 -0
  172. package/src/server/dev-ui.ts +2 -2
  173. package/src/server/dev.ts +7 -9
  174. package/src/server/env-state.ts +1 -1
  175. package/src/server/env.ts +11 -3
  176. package/src/server/favicon.ts +47 -1
  177. package/src/server/file-limit.ts +7 -1
  178. package/src/server/forms.ts +1 -1
  179. package/src/server/host-allowlist.ts +7 -7
  180. package/src/server/image-metadata-bmff.ts +1 -1
  181. package/src/server/index.ts +2 -0
  182. package/src/server/kay-routes.ts +221 -0
  183. package/src/server/kay-server.ts +228 -0
  184. package/src/server/kept-exports.ts +1 -0
  185. package/src/server/kept-pages.ts +3 -3
  186. package/src/server/library.ts +2 -2
  187. package/src/server/mcp.ts +14 -13
  188. package/src/server/notifications.ts +4 -2
  189. package/src/server/offline.ts +24 -7
  190. package/src/server/openapi.ts +12 -3
  191. package/src/server/phases.ts +249 -0
  192. package/src/server/protection.ts +6 -6
  193. package/src/server/proxy-key.ts +8 -8
  194. package/src/server/push-settings.ts +16 -2
  195. package/src/server/push.ts +12 -4
  196. package/src/server/query.ts +17 -31
  197. package/src/server/receive.ts +43 -0
  198. package/src/server/render-document.ts +13 -3
  199. package/src/server/render.ts +1 -1
  200. package/src/server/request-context.ts +137 -0
  201. package/src/server/schema-check.ts +1 -1
  202. package/src/server/scope.ts +20 -13
  203. package/src/server/signals.ts +4 -4
  204. package/src/server/socket.ts +19 -47
  205. package/src/server/stream.ts +1 -1
  206. package/src/server/validate.ts +346 -0
  207. package/src/template-ws.ts +1 -1
  208. package/src/test/a11y-dom.ts +70 -0
  209. package/src/test/html-snapshot.ts +103 -0
  210. package/src/test/index.ts +2 -1
  211. package/src/test/mount.ts +14 -3
  212. package/src/test/page-checks.ts +12 -0
  213. package/src/test/screenshot-match.ts +2 -2
  214. package/src/test/shared-modules.ts +27 -5
  215. package/src/test/site-types.ts +5 -1
  216. package/types/build/class-table.d.ts +1 -1
  217. package/types/build/class-table.d.ts.map +1 -1
  218. package/types/build/client.d.ts +3 -2
  219. package/types/build/client.d.ts.map +1 -1
  220. package/types/build/entry-files.d.ts +4 -0
  221. package/types/build/entry-files.d.ts.map +1 -0
  222. package/types/build/lazy-components.d.ts +6 -0
  223. package/types/build/lazy-components.d.ts.map +1 -0
  224. package/types/build/lazy-manifest.d.ts +19 -0
  225. package/types/build/lazy-manifest.d.ts.map +1 -0
  226. package/types/build/lazy-stubs.d.ts +5 -0
  227. package/types/build/lazy-stubs.d.ts.map +1 -0
  228. package/types/build/plugin.d.ts +1 -0
  229. package/types/build/plugin.d.ts.map +1 -1
  230. package/types/build/transform.d.ts +4 -1
  231. package/types/build/transform.d.ts.map +1 -1
  232. package/types/build/ui-layers.d.ts +5 -0
  233. package/types/build/ui-layers.d.ts.map +1 -0
  234. package/types/build/ui.d.ts +7 -0
  235. package/types/build/ui.d.ts.map +1 -1
  236. package/types/build/variants.d.ts +1 -1
  237. package/types/build/variants.d.ts.map +1 -1
  238. package/types/build/worker-bundle.d.ts +1 -0
  239. package/types/build/worker-bundle.d.ts.map +1 -1
  240. package/types/check/action-options.d.ts +3 -0
  241. package/types/check/action-options.d.ts.map +1 -0
  242. package/types/check/boot.d.ts.map +1 -1
  243. package/types/check/call-result.d.ts +7 -0
  244. package/types/check/call-result.d.ts.map +1 -0
  245. package/types/check/config-objects.d.ts.map +1 -1
  246. package/types/check/diagnose.d.ts.map +1 -1
  247. package/types/check/handler-events.d.ts +9 -0
  248. package/types/check/handler-events.d.ts.map +1 -0
  249. package/types/check/index.d.ts +1 -0
  250. package/types/check/index.d.ts.map +1 -1
  251. package/types/check/link-flag-tests.d.ts +4 -0
  252. package/types/check/link-flag-tests.d.ts.map +1 -0
  253. package/types/check/project.d.ts.map +1 -1
  254. package/types/check/regroup.d.ts +1 -1
  255. package/types/check/regroup.d.ts.map +1 -1
  256. package/types/check/renamed-packages.d.ts +1 -0
  257. package/types/check/renamed-packages.d.ts.map +1 -1
  258. package/types/check/schema-builders.d.ts +3 -0
  259. package/types/check/schema-builders.d.ts.map +1 -0
  260. package/types/check/schema-json.d.ts +3 -0
  261. package/types/check/schema-json.d.ts.map +1 -0
  262. package/types/check/secret-keys.d.ts.map +1 -1
  263. package/types/check/shadow-types.d.ts.map +1 -1
  264. package/types/check/template-hints.d.ts +1 -0
  265. package/types/check/template-hints.d.ts.map +1 -1
  266. package/types/check/tool-labels.d.ts.map +1 -1
  267. package/types/check/ui-types.d.ts.map +1 -1
  268. package/types/check/ui.d.ts.map +1 -1
  269. package/types/commands/env-declare.d.ts.map +1 -1
  270. package/types/compiler/a11y.d.ts.map +1 -1
  271. package/types/compiler/bound-props.d.ts +1 -0
  272. package/types/compiler/bound-props.d.ts.map +1 -1
  273. package/types/compiler/codegen.d.ts +3 -0
  274. package/types/compiler/codegen.d.ts.map +1 -1
  275. package/types/compiler/deprecated-lints-1-105.d.ts +39 -0
  276. package/types/compiler/deprecated-lints-1-105.d.ts.map +1 -0
  277. package/types/compiler/deprecated-lints-1-106.d.ts +12 -0
  278. package/types/compiler/deprecated-lints-1-106.d.ts.map +1 -0
  279. package/types/compiler/deprecated-lints-1-107.d.ts +12 -0
  280. package/types/compiler/deprecated-lints-1-107.d.ts.map +1 -0
  281. package/types/compiler/deprecated-lints.d.ts +41 -22
  282. package/types/compiler/deprecated-lints.d.ts.map +1 -1
  283. package/types/compiler/deprecated-typed-lints.d.ts +21 -0
  284. package/types/compiler/deprecated-typed-lints.d.ts.map +1 -0
  285. package/types/compiler/dom-here.d.ts +14 -0
  286. package/types/compiler/dom-here.d.ts.map +1 -0
  287. package/types/compiler/dom.d.ts +1 -0
  288. package/types/compiler/dom.d.ts.map +1 -1
  289. package/types/compiler/fence-checks.d.ts.map +1 -1
  290. package/types/compiler/field-described.d.ts +1 -1
  291. package/types/compiler/field-described.d.ts.map +1 -1
  292. package/types/compiler/html-fields.d.ts +19 -0
  293. package/types/compiler/html-fields.d.ts.map +1 -0
  294. package/types/compiler/html-initial.d.ts +3 -2
  295. package/types/compiler/html-initial.d.ts.map +1 -1
  296. package/types/compiler/html.d.ts.map +1 -1
  297. package/types/compiler/import-edits.d.ts +1 -0
  298. package/types/compiler/import-edits.d.ts.map +1 -1
  299. package/types/compiler/index.d.ts +3 -0
  300. package/types/compiler/index.d.ts.map +1 -1
  301. package/types/compiler/island-declaration.d.ts +5 -0
  302. package/types/compiler/island-declaration.d.ts.map +1 -1
  303. package/types/compiler/items.d.ts +4 -1
  304. package/types/compiler/items.d.ts.map +1 -1
  305. package/types/compiler/kay-exports.d.ts.map +1 -1
  306. package/types/compiler/lazy-imports.d.ts +33 -0
  307. package/types/compiler/lazy-imports.d.ts.map +1 -0
  308. package/types/compiler/link-flags.d.ts +6 -0
  309. package/types/compiler/link-flags.d.ts.map +1 -1
  310. package/types/compiler/lints.d.ts +61 -34
  311. package/types/compiler/lints.d.ts.map +1 -1
  312. package/types/compiler/rest-omits.d.ts +4 -0
  313. package/types/compiler/rest-omits.d.ts.map +1 -0
  314. package/types/compiler/route-lints.d.ts +8 -0
  315. package/types/compiler/route-lints.d.ts.map +1 -1
  316. package/types/compiler/schema-lints.d.ts +11 -0
  317. package/types/compiler/schema-lints.d.ts.map +1 -0
  318. package/types/compiler/script-server.d.ts.map +1 -1
  319. package/types/config-loader.d.ts.map +1 -1
  320. package/types/config-resolve.d.ts.map +1 -1
  321. package/types/config.d.ts +15 -2
  322. package/types/config.d.ts.map +1 -1
  323. package/types/content/markdown.d.ts.map +1 -1
  324. package/types/migrate/content.d.ts.map +1 -1
  325. package/types/new.d.ts +1 -0
  326. package/types/new.d.ts.map +1 -1
  327. package/types/runtime/action-shared.d.ts +1 -1
  328. package/types/runtime/action-shared.d.ts.map +1 -1
  329. package/types/runtime/action.d.ts +29 -1
  330. package/types/runtime/action.d.ts.map +1 -1
  331. package/types/runtime/client.d.ts.map +1 -1
  332. package/types/runtime/dom-lazy.d.ts +6 -0
  333. package/types/runtime/dom-lazy.d.ts.map +1 -0
  334. package/types/runtime/field-errors.d.ts +4 -0
  335. package/types/runtime/field-errors.d.ts.map +1 -0
  336. package/types/runtime/field-refusal.d.ts +37 -0
  337. package/types/runtime/field-refusal.d.ts.map +1 -0
  338. package/types/runtime/form-types.d.ts +6 -0
  339. package/types/runtime/form-types.d.ts.map +1 -0
  340. package/types/runtime/form.d.ts +4 -2
  341. package/types/runtime/form.d.ts.map +1 -1
  342. package/types/runtime/html.d.ts +3 -0
  343. package/types/runtime/html.d.ts.map +1 -1
  344. package/types/runtime/index.d.ts +2 -0
  345. package/types/runtime/index.d.ts.map +1 -1
  346. package/types/runtime/island.server.d.ts +2 -0
  347. package/types/runtime/island.server.d.ts.map +1 -1
  348. package/types/runtime/markdown-autolink.d.ts +11 -0
  349. package/types/runtime/markdown-autolink.d.ts.map +1 -0
  350. package/types/runtime/markdown-render.client.d.ts +2 -1
  351. package/types/runtime/markdown-render.client.d.ts.map +1 -1
  352. package/types/runtime/markdown.client.d.ts +3 -1
  353. package/types/runtime/markdown.client.d.ts.map +1 -1
  354. package/types/runtime/markdown.d.ts +11 -0
  355. package/types/runtime/markdown.d.ts.map +1 -1
  356. package/types/runtime/markdown.server.d.ts +3 -1
  357. package/types/runtime/markdown.server.d.ts.map +1 -1
  358. package/types/runtime/navigate-api.d.ts +1 -1
  359. package/types/runtime/navigate-api.d.ts.map +1 -1
  360. package/types/runtime/persist.d.ts +2 -2
  361. package/types/runtime/persist.d.ts.map +1 -1
  362. package/types/runtime/reactive.d.ts +3 -0
  363. package/types/runtime/reactive.d.ts.map +1 -1
  364. package/types/runtime/sanitize.d.ts.map +1 -1
  365. package/types/runtime/schema-record.d.ts +9 -0
  366. package/types/runtime/schema-record.d.ts.map +1 -0
  367. package/types/runtime/schema.client.d.ts.map +1 -1
  368. package/types/runtime/schema.d.ts +99 -10
  369. package/types/runtime/schema.d.ts.map +1 -1
  370. package/types/runtime/standard-schema.d.ts +37 -0
  371. package/types/runtime/standard-schema.d.ts.map +1 -0
  372. package/types/runtime/swap-focus.d.ts.map +1 -1
  373. package/types/runtime/validate-run.client.d.ts +4 -0
  374. package/types/runtime/validate-run.client.d.ts.map +1 -0
  375. package/types/runtime/validate.client.d.ts +4 -0
  376. package/types/runtime/validate.client.d.ts.map +1 -0
  377. package/types/runtime/validate.d.ts +1 -21
  378. package/types/runtime/validate.d.ts.map +1 -1
  379. package/types/server/action-module.d.ts +2 -0
  380. package/types/server/action-module.d.ts.map +1 -0
  381. package/types/server/actions.d.ts +1 -0
  382. package/types/server/actions.d.ts.map +1 -1
  383. package/types/server/answer.d.ts +6 -0
  384. package/types/server/answer.d.ts.map +1 -0
  385. package/types/server/api-input.d.ts +19 -0
  386. package/types/server/api-input.d.ts.map +1 -0
  387. package/types/server/api.d.ts.map +1 -1
  388. package/types/server/app-stages.d.ts +7 -3
  389. package/types/server/app-stages.d.ts.map +1 -1
  390. package/types/server/app.d.ts +2 -0
  391. package/types/server/app.d.ts.map +1 -1
  392. package/types/server/client.d.ts +1 -0
  393. package/types/server/client.d.ts.map +1 -1
  394. package/types/server/dev.d.ts +1 -1
  395. package/types/server/dev.d.ts.map +1 -1
  396. package/types/server/env-state.d.ts.map +1 -1
  397. package/types/server/env.d.ts +5 -1
  398. package/types/server/env.d.ts.map +1 -1
  399. package/types/server/favicon.d.ts +3 -1
  400. package/types/server/favicon.d.ts.map +1 -1
  401. package/types/server/file-limit.d.ts.map +1 -1
  402. package/types/server/host-allowlist.d.ts +3 -3
  403. package/types/server/host-allowlist.d.ts.map +1 -1
  404. package/types/server/index.d.ts +2 -0
  405. package/types/server/index.d.ts.map +1 -1
  406. package/types/server/kay-routes.d.ts +47 -0
  407. package/types/server/kay-routes.d.ts.map +1 -0
  408. package/types/server/kay-server.d.ts +25 -0
  409. package/types/server/kay-server.d.ts.map +1 -0
  410. package/types/server/kept-exports.d.ts.map +1 -1
  411. package/types/server/kept-pages.d.ts +1 -1
  412. package/types/server/kept-pages.d.ts.map +1 -1
  413. package/types/server/library.d.ts +2 -1
  414. package/types/server/library.d.ts.map +1 -1
  415. package/types/server/mcp.d.ts +1 -1
  416. package/types/server/mcp.d.ts.map +1 -1
  417. package/types/server/notifications.d.ts +2 -1
  418. package/types/server/notifications.d.ts.map +1 -1
  419. package/types/server/offline.d.ts.map +1 -1
  420. package/types/server/openapi.d.ts.map +1 -1
  421. package/types/server/phases.d.ts +36 -0
  422. package/types/server/phases.d.ts.map +1 -0
  423. package/types/server/protection.d.ts +3 -2
  424. package/types/server/protection.d.ts.map +1 -1
  425. package/types/server/proxy-key.d.ts +3 -3
  426. package/types/server/proxy-key.d.ts.map +1 -1
  427. package/types/server/push-settings.d.ts +1 -1
  428. package/types/server/push-settings.d.ts.map +1 -1
  429. package/types/server/push.d.ts +1 -0
  430. package/types/server/push.d.ts.map +1 -1
  431. package/types/server/query.d.ts.map +1 -1
  432. package/types/server/receive.d.ts +9 -0
  433. package/types/server/receive.d.ts.map +1 -0
  434. package/types/server/render-document.d.ts.map +1 -1
  435. package/types/server/request-context.d.ts +29 -0
  436. package/types/server/request-context.d.ts.map +1 -0
  437. package/types/server/schema-check.d.ts +1 -0
  438. package/types/server/schema-check.d.ts.map +1 -1
  439. package/types/server/scope.d.ts +1 -1
  440. package/types/server/scope.d.ts.map +1 -1
  441. package/types/server/socket.d.ts +3 -5
  442. package/types/server/socket.d.ts.map +1 -1
  443. package/types/server/validate.d.ts +26 -0
  444. package/types/server/validate.d.ts.map +1 -0
  445. package/types/test/a11y-dom.d.ts +20 -0
  446. package/types/test/a11y-dom.d.ts.map +1 -0
  447. package/types/test/html-snapshot.d.ts +4 -0
  448. package/types/test/html-snapshot.d.ts.map +1 -0
  449. package/types/test/index.d.ts.map +1 -1
  450. package/types/test/mount.d.ts +3 -0
  451. package/types/test/mount.d.ts.map +1 -1
  452. package/types/test/page-checks.d.ts +6 -0
  453. package/types/test/page-checks.d.ts.map +1 -0
  454. package/types/test/screenshot-match.d.ts +1 -1
  455. package/types/test/screenshot-match.d.ts.map +1 -1
  456. package/types/test/shared-modules.d.ts.map +1 -1
  457. package/types/test/site-types.d.ts +3 -1
  458. package/types/test/site-types.d.ts.map +1 -1
  459. package/src/check/schema-type.ts +0 -9
  460. package/src/compiler/deprecated-script-fence.ts +0 -26
  461. package/src/server/field-errors.ts +0 -136
  462. package/types/check/schema-type.d.ts +0 -3
  463. package/types/check/schema-type.d.ts.map +0 -1
  464. package/types/compiler/deprecated-script-fence.d.ts +0 -3
  465. package/types/compiler/deprecated-script-fence.d.ts.map +0 -1
  466. package/types/server/field-errors.d.ts +0 -6
  467. package/types/server/field-errors.d.ts.map +0 -1
package/src/config.ts CHANGED
@@ -310,7 +310,7 @@ export interface EndpointsConfig {
310
310
  api?: string | undefined
311
311
  // Where the OpenAPI document is served, `/api/openapi.json` under the API prefix by default; its reference page is set in `openapi.reference`.
312
312
  openapi?: string | undefined
313
- // Where the MCP endpoint is served, `/_kay/mcp` by default. `/mcp`, where it was served before 1.105, redirects there with a 308 until 1.108 when this is not set.
313
+ // Where the MCP endpoint is served, `/_kay/mcp` by default. `/mcp`, where it was served before 1.105, is answered in place until 2.0 when this is not set.
314
314
  mcp?: string | undefined
315
315
  // Where the health check is served, `/_kay/health` by default.
316
316
  health?: string | undefined
@@ -439,6 +439,17 @@ export interface ManifestConfig {
439
439
  maskable?: string | undefined
440
440
  // The pages a launcher offers from the app's icon.
441
441
  shortcuts?: ManifestShortcut[] | undefined
442
+ // Lists the installed app among the apps a device's share sheet offers, the shared title, text, link and files posted to an action.
443
+ shareTarget?: ManifestShareTarget | undefined
444
+ }
445
+
446
+ export interface ManifestShareTarget {
447
+ // Where a share is posted: an action as `'src/routes/share.kay#receive'`, the page file relative to the root and the exported action's name, or a path of the site (`'/share'`) for a route of your own taking a POST. The action reads `title`, `text`, `url` and `files`, whichever the sharing app sent, all optional.
448
+ action: string
449
+ // The kinds of file the app takes, as MIME types or extensions (`['image/*', '.pdf']`); with some the share is posted as `multipart/form-data` and the action reads them as `files`, without any only text and a link are shared.
450
+ files?: string[] | undefined
451
+ // The field each part of a share is posted as, `title`, `text`, `url` and `files` by default.
452
+ params?: { title?: string | undefined, text?: string | undefined, url?: string | undefined, files?: string | undefined } | undefined
442
453
  }
443
454
 
444
455
  export interface ManifestShortcut {
@@ -626,8 +637,10 @@ export interface KayExtension<Server extends PluginInput = AnyElysia> {
626
637
  appFiles?: Record<string, string> | undefined
627
638
  // The server plugin named by the module that exports it, `{ path: './src/auth', export: 'auth' }` for `export const auth` (`default` by default): imported only as `pages()` builds the app, and baked into an executable `kay build --compile` makes, which a path built at run time inside a library could not be. The export is the plugin, a function building it, or an object carrying it as `plugin`, as a library's `authCore` result does. `kay check` types the locals off the module itself, and off the extension's `Server` argument when it has one; used beside `server`, the module wins. A path is relative to the project root. `prepare` runs with the export before the plugin is taken from it, for a library to hand the app's module what the extension was given; a throw stops the server.
628
639
  serverModule?: { path: string, export?: string | undefined, prepare?: ((exported: unknown) => void | Promise<void>) | undefined } | undefined
629
- // Config laid under the app's `kay.config.ts`: objects merged key by key, arrays joined with the extension's items first, any other value the app sets winning. Bun plugins the library's files need go in its `plugins`.
630
- config?: Omit<KayConfig, 'extensions'> | undefined
640
+ // Config laid under the app's `kay.config.ts`: objects merged key by key, arrays joined with the extension's items first, any other value the app sets winning. Bun plugins the library's files need go in its `plugins`. It takes what `kay.config.ts` does, the keys of before 1.105 included (`fonts`, `favicon`, `observe`...), which work until 1.108 under `deprecated-config-groups`.
641
+ config?: Omit<ConfigInput, 'extensions'> | undefined
642
+ // A module whose default export is `defineUi({ ... })`, written as `src/ui.ts` is (string and object literals only), absolute or relative to the project root: the parts and variants it sets for components, the app's own or a library's, reach every app listing the extension, under the app's own `src/ui.ts`. A part or a variant value the app sets replaces the extension's, and a later extension's replaces an earlier one's. Names and relative specifiers resolve from the app's `src/`.
643
+ ui?: string | undefined
631
644
  // A directory of `.kay` pages, layouts and guards laid over the app's routes under `prefix`, the root by default: a file of the app at the same path replaces the library's.
632
645
  // Its directories are absolute, as a library gives them from `import.meta.dir`, or relative to the project root.
633
646
  routes?: { dir: string, prefix?: string | undefined } | undefined
@@ -782,7 +795,10 @@ type CaseVariant<Key, Known> = { [Name in keyof Known & string]: Lowercase<Name>
782
795
  type Misspelled<Key, Known> = [CaseVariant<Key, Known>] extends [never] ? 'unknown option' : `unknown option, did you mean \`${CaseVariant<Key, Known> & string}\`?`
783
796
 
784
797
  // A symbol key is no option a config names, and an object a library returns may carry one, as `pgData()`'s `Symbol.asyncDispose` does.
785
- type UnknownKeys<Given, Known> = Given extends object ? { [Key in Exclude<keyof Given, keyof Known | symbol>]: Misspelled<Key, Known> } : unknown
798
+ type UnknownKeys<Given, Known> = Given extends object ? { [Key in Exclude<keyof Given, AllKeys<Known> | symbol>]: Misspelled<Key, Known> } : unknown
799
+
800
+ // The keys of every member of a union of object shapes (`{ env } | { file }`), where `keyof` keeps only the keys they share, none for that one.
801
+ type AllKeys<Known> = Known extends unknown ? keyof Known : never
786
802
 
787
803
  type Method = (...args: never[]) => unknown
788
804
 
@@ -102,8 +102,7 @@ export const LOADED_HTML: SanitizeOptions = { ...MARKDOWN_KEPT, relativeUrls: tr
102
102
  const LOADED: SanitizeOptions = { ...LOADED_HTML, attributes: { ...MARKDOWN_KEPT.attributes, h1: ['id'], h2: ['id'], h3: ['id'], h4: ['id'], h5: ['id'], h6: ['id'], code: ['class'] } }
103
103
  // A link the sanitizer wrote that stays on the site: its `href` names no http(s) URL.
104
104
  const OWN_LINK = /<a href="((?!https?:\/\/)[^"]*)" rel="nofollow ugc">/gi
105
- // The only class and id kept on a code block and a heading: the language Markdown writes, and a slug in its shape, so a loader's text cannot pick a utility class or a camelCase global name.
106
- const CODE_CLASS = /<code class="(?!language-[\w+#.-]+")[^"]*">/g
105
+ // The only id kept on a heading: a slug in its shape, so a loader's text cannot pick a camelCase global name (the sanitizer keeps no class on a code block but its language).
107
106
  const HEADING_ID = /<(h[1-6]) id="(?![\p{Ll}\p{N}][\p{Ll}\p{N}_-]*")[^"]*"/gu
108
107
  // The private characters standing for a component's placeholder while the sanitizer, which reads no tag name with a hyphen, goes over the rest.
109
108
  const HELD_PLACEHOLDER = /\uE010(\d+)\uE011|\uE012(\d+)\uE011|\uE013/g
@@ -241,7 +240,7 @@ export function countWords(html: string): number {
241
240
  function sanitizedComponents(html: string): string {
242
241
  const held = html.replace(PRIVATE_CHARS, char => `&#${char.codePointAt(0)};`).replace(PLACEHOLDER_TAG, (_, selfClosing: string | undefined, opening: string | undefined) => heldPlaceholder(selfClosing, opening))
243
242
 
244
- return withoutInnerRel(sanitizedMarkdown(held, LOADED, false).replace(CODE_CLASS, '<code>').replace(HEADING_ID, '<$1').replace(HELD_PLACEHOLDER, (_, selfClosing: string | undefined, opening: string | undefined) => restoredPlaceholder(selfClosing, opening)))
243
+ return withoutInnerRel(sanitizedMarkdown(held, LOADED, false).replace(HEADING_ID, '<$1').replace(HELD_PLACEHOLDER, (_, selfClosing: string | undefined, opening: string | undefined) => restoredPlaceholder(selfClosing, opening)))
245
244
  }
246
245
 
247
246
  // The sanitizer marks every link as a user's; a link to the site or to a heading is the entry's own, so only one leaving the site keeps its `rel`.
@@ -1,7 +1,7 @@
1
1
  import type { TSchema } from 'elysia'
2
2
  import type { RawEntry } from './load'
3
3
  import type { ComponentSegment, Segment } from './markdown'
4
- import { errorText } from '../server/field-errors'
4
+ import { errorText } from '../runtime/field-errors'
5
5
  import { compiledCheck, dottedPath, fieldOf, refusals, unescaped } from '../server/schema-check'
6
6
  import { entryRefusal, kayWord } from '../server/words'
7
7
  import { humanize } from './humanize'
@@ -33,14 +33,14 @@ interface TypeDescription {
33
33
  }
34
34
 
35
35
  // The range of a 4-byte column, which a bare integer schema would let a post exceed.
36
- const INT4 = '{ minimum: -2147483648, maximum: 2147483647 }'
36
+ const INT4 = '{ min: -2147483648, max: 2147483647 }'
37
37
 
38
38
  const TYPES: Record<FieldType, TypeDescription> = {
39
- string: { column: 'f.varchar(200)', schema: 's.String({ minLength: 1, maxLength: 200 })', sample: '\'First\'', posted: '\'First\'', shown: 'First' },
40
- text: { column: 'f.text()', schema: 's.String({ minLength: 1, maxLength: 10_000 })', sample: '\'Some text\'', posted: '\'Some text\'', shown: 'Some text' },
41
- int: { column: 'f.integer()', schema: `s.Integer(${INT4})`, sample: '42', posted: '\'42\'', shown: '42' },
42
- float: { column: 'f.doublePrecision()', schema: 's.Number()', sample: '4.25', posted: '\'4.25\'', shown: '4.25' },
43
- boolean: { column: 'f.boolean().default(false)', schema: 's.Boolean()', sample: 'true', posted: '\'on\'', shown: 'true' },
39
+ string: { column: 'f.varchar(200)', schema: 's.string({ min: 1, max: 200 })', sample: '\'First\'', posted: '\'First\'', shown: 'First' },
40
+ text: { column: 'f.text()', schema: 's.string({ min: 1, max: 10_000 })', sample: '\'Some text\'', posted: '\'Some text\'', shown: 'Some text' },
41
+ int: { column: 'f.integer()', schema: `s.int(${INT4})`, sample: '42', posted: '\'42\'', shown: '42' },
42
+ float: { column: 'f.doublePrecision()', schema: 's.number()', sample: '4.25', posted: '\'4.25\'', shown: '4.25' },
43
+ boolean: { column: 'f.boolean().default(false)', schema: 's.boolean()', sample: 'true', posted: '\'on\'', shown: 'true' },
44
44
  }
45
45
 
46
46
  const ALIASES: Record<string, FieldType> = { string: 'string', text: 'text', int: 'int', integer: 'int', float: 'float', number: 'float', boolean: 'boolean', bool: 'boolean' }
@@ -170,19 +170,19 @@ const fields = {
170
170
  ${schemas}
171
171
  }
172
172
 
173
- export const create = action(s.Object(fields), async (input, ctx) => {
173
+ export const create = action(fields, async (input, ctx) => {
174
174
  await db.repo(${names.pascal}).write.insertOne(input)
175
175
 
176
176
  return ctx.redirect('${list}')
177
177
  })
178
178
 
179
- export const update = action(s.Object({ id: s.Integer(${INT4}), ...fields }), async ({ id, ...values }, ctx) => {
179
+ export const update = action({ id: s.int(${INT4}), ...fields }, async ({ id, ...values }, ctx) => {
180
180
  await db.repo(${names.pascal}).write.updateOne(values, { id })
181
181
 
182
182
  return ctx.redirect('${list}')
183
183
  })
184
184
 
185
- export const remove = action(s.Object({ id: s.Integer(${INT4}) }), async ({ id }, ctx) => {
185
+ export const remove = action({ id: s.int(${INT4}) }, async ({ id }, ctx) => {
186
186
  await db.repo(${names.pascal}).write.deleteOne({ id })
187
187
 
188
188
  return ctx.redirect('${list}')
package/src/generate.ts CHANGED
@@ -21,7 +21,7 @@ const WORD_BREAK = /[-_]+/g
21
21
  // Words an action cannot be exported as, or that its own file already names: the `action` and `s` it calls, `title` its handler reads.
22
22
  const RESERVED = new Set(['action', 's', 'title', 'await', 'break', 'case', 'catch', 'class', 'const', 'continue', 'debugger', 'default', 'delete', 'do', 'else', 'enum', 'export', 'extends', 'false', 'finally', 'for', 'function', 'if', 'import', 'in', 'instanceof', 'let', 'new', 'null', 'return', 'static', 'super', 'switch', 'this', 'throw', 'true', 'try', 'typeof', 'var', 'void', 'while', 'with', 'yield', 'implements', 'interface', 'package', 'private', 'protected', 'public', 'eval', 'arguments'])
23
23
  // The action added to an `_actions.kay`, or printed for the author to add when the file holds more than a server fence.
24
- const ACTION_BODY = (name: string) => `export const ${name} = action(\n s.Object({ title: s.String({ minLength: 1, maxLength: 200 }) }),\n ({ title }) => title,\n)\n`
24
+ const ACTION_BODY = (name: string) => `export const ${name} = action(\n { title: s.string({ min: 1, max: 200 }) },\n ({ title }) => title,\n)\n`
25
25
  const LINE_BREAK = /\r?\n/
26
26
  const LINE_BREAKS = /\r?\n/g
27
27
  const TABLES_FILE = 'src/db/tables.ts'
package/src/mcp/guards.ts CHANGED
@@ -50,7 +50,7 @@ export function optionalString(value: unknown, name: string): string | undefined
50
50
  return undefined
51
51
 
52
52
  if (typeof value !== 'string')
53
- throw new Error(`${name} takes a string`)
53
+ throw new TypeError(`${name} takes a string`)
54
54
 
55
55
  return value
56
56
  }
package/src/mcp/tools.ts CHANGED
@@ -216,7 +216,7 @@ function tools(root: string, write: boolean): Tool[] {
216
216
  return []
217
217
 
218
218
  if (typeof value !== 'number' || !Number.isInteger(value))
219
- throw new Error(`${name} takes a whole number of pixels`)
219
+ throw new TypeError(`${name} takes a whole number of pixels`)
220
220
 
221
221
  return [`--${name}=${value}`]
222
222
  })
@@ -5,11 +5,11 @@ import { parseProgram, positionOf } from '../compiler/estree'
5
5
  // An Astro content config, `defineCollection` with a zod schema, as kay's: `collection(folder, { schema })` with the schema in `s`.
6
6
 
7
7
  // zod's types and the `s` builder each becomes, for those that take their arguments the same way.
8
- const SAME: Record<string, string> = { string: 'String', number: 'Number', boolean: 'Boolean', date: 'Date', array: 'Array', object: 'Object', literal: 'Literal', any: 'Any', unknown: 'Unknown', null: 'Null' }
9
- // zod's string checks and the `s.String` option each becomes.
10
- const STRING_CHECKS: Record<string, string> = { min: 'minLength', max: 'maxLength', email: 'format', url: 'format', regex: 'pattern' }
8
+ const SAME: Record<string, string> = { string: 'string', number: 'number', boolean: 'boolean', date: 'date', literal: 'literal' }
9
+ // zod's string checks and the `s.string` option each becomes.
10
+ const STRING_CHECKS: Record<string, string> = { min: 'min', max: 'max', email: 'format', url: 'format', regex: 'pattern' }
11
11
  const LEADING_DOT_SLASH = /^\.\//
12
- const NUMBER_CHECKS: Record<string, string> = { min: 'minimum', max: 'maximum', gte: 'minimum', lte: 'maximum' }
12
+ const NUMBER_CHECKS: Record<string, string> = { min: 'min', max: 'max', gte: 'min', lte: 'max' }
13
13
  const CHECKS_BY_KIND = new Map([['string', STRING_CHECKS], ['number', NUMBER_CHECKS]])
14
14
 
15
15
  class SchemaTranslator {
@@ -39,7 +39,7 @@ class SchemaTranslator {
39
39
 
40
40
  // The schema helper Astro passes, `schema: ({ image }) => z.object(...)`.
41
41
  if (current.type === 'CallExpression' && current.callee.type === 'Identifier' && current.callee.name === 'image')
42
- return chain.length === 0 ? 's.String()' : this.modifiers('s.String()', chain, node)
42
+ return this.image(chain, node)
43
43
 
44
44
  const base = chain.shift()
45
45
 
@@ -48,74 +48,80 @@ class SchemaTranslator {
48
48
 
49
49
  const kind = base.callee.property.name
50
50
  const args = base.arguments
51
- let built: string
52
- let integer = false
53
- const options: string[] = []
54
- const checks = CHECKS_BY_KIND.get(kind)
55
- const rest: CallExpression[] = []
56
-
57
- for (const call of chain) {
58
- const name = call.callee.type === 'MemberExpression' && call.callee.property.type === 'Identifier' ? call.callee.property.name : ''
59
- const option = checks?.[name]
51
+ const { options, integer, rest } = this.chain(kind, chain)
60
52
 
61
- if (option === 'format')
62
- options.push(`format: '${name === 'url' ? 'uri' : 'email'}'`)
63
- else if (option === 'pattern' && call.arguments[0]?.type === 'Literal' && 'regex' in call.arguments[0])
64
- options.push(`pattern: ${JSON.stringify((call.arguments[0] as { regex: { pattern: string } }).regex.pattern)}`)
65
- else if (option !== undefined && call.arguments[0])
66
- options.push(`${option}: ${this.text(call.arguments[0])}`)
67
- else if (kind === 'number' && name === 'int')
68
- integer = true
69
- else
70
- rest.push(call)
71
- }
53
+ if (rest[0])
54
+ return this.untranslated(node, `.${methodName(rest[0])}() has no \`s\` counterpart kay migrate knows`)
72
55
 
73
56
  if (kind === 'object' && args[0]?.type === 'ObjectExpression') {
74
57
  const fields = args[0].properties.map(property => isPlain(property) ? `${this.text(property.key)}: ${this.schema(property.value)}` : this.untranslated(property, 'a spread in an object schema'))
75
58
 
76
- built = `s.Object({ ${fields.join(', ')} })`
77
- }
78
- else if (kind === 'array' && args[0]) {
79
- built = `s.Array(${this.schema(args[0])}${options.length > 0 ? `, { ${options.join(', ')} }` : ''})`
59
+ return this.call('s.object', [`{ ${fields.join(', ')} }`], options)
80
60
  }
81
- else if (kind === 'enum' && args[0]?.type === 'ArrayExpression') {
82
- built = `s.Union([${args[0].elements.map(element => element ? `s.Literal(${this.text(element)})` : '').join(', ')}])`
83
- }
84
- else if (kind === 'union' && args[0]?.type === 'ArrayExpression') {
85
- built = `s.Union([${args[0].elements.map(element => element ? this.schema(element) : '').join(', ')}])`
86
- }
87
- else if (kind === 'coerce' || !(kind in SAME)) {
61
+
62
+ if (kind === 'array' && args[0])
63
+ return this.call('s.list', [this.schema(args[0])], options)
64
+
65
+ if (kind === 'enum' && args[0]?.type === 'ArrayExpression')
66
+ return this.call('s.enum', [this.text(args[0])], options)
67
+
68
+ if (kind === 'union' && args[0]?.type === 'ArrayExpression')
69
+ return this.call('s.union', [`[${args[0].elements.map(element => element ? this.schema(element) : '').join(', ')}]`], options)
70
+
71
+ if (kind === 'coerce' || !(kind in SAME))
88
72
  return this.untranslated(node, `z.${kind} has no \`s\` counterpart kay migrate knows`)
89
- }
90
- else {
91
- const builder = integer ? 's.Integer' : `s.${SAME[kind]}`
92
73
 
93
- built = `${builder}(${[...args.map(arg => this.text(arg)), ...options.length > 0 ? [`{ ${options.join(', ')} }`] : []].join(', ')})`
94
- }
74
+ return this.call(integer ? 's.int' : `s.${SAME[kind]}`, args.map(arg => this.text(arg)), options)
75
+ }
76
+
77
+ // The `image()` helper: a string, whatever follows it in the chain.
78
+ private image(chain: CallExpression[], node: Node): string {
79
+ const { options, rest } = this.chain('image', chain)
95
80
 
96
- return this.modifiers(built, rest, node)
81
+ return rest[0] ? this.untranslated(node, `.${methodName(rest[0])}() has no \`s\` counterpart kay migrate knows`) : this.call('s.string', [], options)
97
82
  }
98
83
 
99
- private modifiers(built: string, calls: CallExpression[], node: Node): string {
100
- let result = built
84
+ // `s.string({ min: 1 })`: the builder, its arguments, then the options when there are any.
85
+ private call(builder: string, args: string[], options: string[]): string {
86
+ return `${builder}(${[...args, ...options.length > 0 ? [`{ ${options.join(', ')} }`] : []].join(', ')})`
87
+ }
88
+
89
+ // The calls after a zod type: the checks that are options of the builder, `.optional()` and `.default()`, and what has no counterpart.
90
+ private chain(kind: string, chain: CallExpression[]): { options: string[], integer: boolean, rest: CallExpression[] } {
91
+ const checks = CHECKS_BY_KIND.get(kind)
92
+ const options: string[] = []
93
+ const rest: CallExpression[] = []
94
+ let integer = false
101
95
 
102
- for (const call of calls) {
103
- const name = call.callee.type === 'MemberExpression' && call.callee.property.type === 'Identifier' ? call.callee.property.name : ''
96
+ for (const call of chain) {
97
+ const name = methodName(call)
98
+ const option = checks?.[name]
99
+ const first = call.arguments[0]
104
100
 
105
- if (name === 'optional' || name === 'nullish')
106
- result = `s.Optional(${result})`
107
- else if (name === 'nullable')
108
- result = `s.Nullable(${result})`
109
- else if (name === 'default' && call.arguments[0])
110
- result = result.endsWith(')') && !result.startsWith('s.Optional(') ? `${result.slice(0, -1)}${result.endsWith('()') ? '' : ', '}{ default: ${this.text(call.arguments[0])} })` : this.untranslated(node, '`.default` on a schema already given options')
101
+ if (option === 'format')
102
+ options.push(`format: '${name === 'url' ? 'uri' : 'email'}'`)
103
+ else if (option === 'pattern' && first?.type === 'Literal' && 'regex' in first)
104
+ options.push(`pattern: ${JSON.stringify((first as { regex: { pattern: string } }).regex.pattern)}`)
105
+ else if (option !== undefined && first)
106
+ options.push(`${option}: ${this.text(first)}`)
107
+ else if (kind === 'number' && name === 'int')
108
+ integer = true
109
+ else if (name === 'optional' || name === 'nullish')
110
+ options.push('optional: true')
111
+ else if (name === 'default' && first)
112
+ options.push(`default: ${this.text(first)}`)
111
113
  else
112
- return this.untranslated(node, `.${name}() has no \`s\` counterpart kay migrate knows`)
114
+ rest.push(call)
113
115
  }
114
116
 
115
- return result
117
+ return { options, integer, rest }
116
118
  }
117
119
  }
118
120
 
121
+ function methodName(call: CallExpression): string {
122
+ return call.callee.type === 'MemberExpression' && call.callee.property.type === 'Identifier' ? call.callee.property.name : ''
123
+ }
124
+
119
125
  function literalKey(key: Node): string | undefined {
120
126
  if (key.type === 'Identifier')
121
127
  return key.name
@@ -235,7 +241,7 @@ function collectionsOf(object: ObjectExpression, declared: Map<string, CallExpre
235
241
  if (folder === undefined)
236
242
  notes.push({ line: positionOf(source, call.start).line, message: `the collection ${name} uses a loader other than \`glob({ base })\`: kay reads a folder of files, so give it the folder` })
237
243
 
238
- result.push(`export const ${name} = collection('${folder ?? `content/${name}`}', {\n schema: ${schema ? translator.schema(schema) : 's.Object({})'},\n})`)
244
+ result.push(`export const ${name} = collection('${folder ?? `content/${name}`}', {\n schema: ${schema ? translator.schema(schema) : 's.object({})'},\n})`)
239
245
  }
240
246
 
241
247
  return result
package/src/new.ts CHANGED
@@ -227,13 +227,17 @@ async function librariesDryRun(files: Record<string, string>, libraries: readonl
227
227
  }
228
228
  }
229
229
 
230
+ // The range a new project pins kay to: a 1.x minor may break, so it takes patches only (`~`), and from 2.0.0 a breaking change is a major, so it takes minors too (`^`).
231
+ export function kayRange(version: string): string {
232
+ return Number.parseInt(version, 10) >= 2 ? `^${version}` : `~${version}`
233
+ }
234
+
230
235
  // Every file of a project with these features in `dir`, named after it; run from a checkout of kay, packs it into `dir/vendor` for the project to depend on.
231
236
  export async function projectFiles(dir: string, features: ReadonlySet<Feature>, kayDependency?: string | undefined, settings: ConfigSettings = {}, host?: Host, runner?: string): Promise<Record<string, string>> {
232
237
  const has = holds(features)
233
238
  const name = packageName(basename(resolve(dir)))
234
239
  const kay = await Bun.file(join(KAY_ROOT, 'package.json')).json() as { name: string, version: string, dependencies: Record<string, string>, devDependencies: Record<string, string>, peerDependencies: Record<string, string> }
235
- // A kay minor may break, so the project takes its patches only.
236
- const dependency = kayDependency ?? (existsSync(join(KAY_ROOT, '.git')) ? await packKay(join(dir, 'vendor')) : `npm:${kay.name}@~${kay.version}`)
240
+ const dependency = kayDependency ?? (existsSync(join(KAY_ROOT, '.git')) ? await packKay(join(dir, 'vendor')) : `npm:${kay.name}@${kayRange(kay.version)}`)
237
241
  const scripts = {
238
242
  'dev': 'kay dev',
239
243
  ...has('server') ? { build: 'kay build', compile: 'kay build --compile server', start: 'kay start' } : { build: 'kay build --static' },
@@ -242,9 +242,9 @@ export interface ActionContext<Params extends Readonly<Record<string, unknown>>
242
242
  fail: <const Data = undefined, const Status extends number = number>(status: Status & ErrorStatus<Status>, data?: Data, errors?: FieldErrors<Field>) => Failure<Data>
243
243
  }
244
244
 
245
- // `ctx.deny` of an action: a refusal with `data` or `errors` is typed as a `Failure`, one with a message alone (or none) is `never`, so it narrows what follows as a guard's does.
245
+ // `ctx.deny` of an action: a refusal with a `message`, `data` or `errors` is typed as a `Failure`, one with no options is `never`, so it narrows what follows as a guard's does.
246
246
  export interface ActionDeny<Field extends string = string> {
247
- <const Status extends number = number>(status?: Status & ErrorStatus<Status>, options?: { message?: string | undefined, errors?: undefined, data?: undefined }): never
247
+ <const Status extends number = number>(status?: Status & ErrorStatus<Status>, options?: { message?: undefined, errors?: undefined, data?: undefined }): never
248
248
  <const Data = undefined, const Status extends number = number>(status: Status & ErrorStatus<Status>, options: DenyOptions<Data, Field>): Failure<Data>
249
249
  // What a helper taking the guard's `deny` sees: an action's context passes as one.
250
250
  <const Status extends number = number>(status?: Status & ErrorStatus<Status>, options?: DenyOptions<ErrorData>): never
@@ -1,12 +1,16 @@
1
1
  import type { t } from 'elysia'
2
2
  import type { ActionContext, ActionProtection, Answer, Called, CallOptions, OutputSchema, ServerAction, Settled, Success } from './action-shared'
3
3
  import type { RouteParams } from './checks'
4
- import type { Schema, Static } from './schema'
4
+ import type { Schema, StandardAs, Static } from './schema'
5
+ import type { ObjectOf, SchemaShape } from './schema-record'
6
+ import type { StandardSchema } from './standard-schema'
5
7
  import { callable } from './action-call'
6
8
  import { minTimeOf, resolveProtection, workOf } from './action-protection'
7
9
  import { ACTION, isAction } from './action-shared'
8
10
  import { durationSeconds } from './duration'
9
11
  import { KayError } from './kay-error'
12
+ import { isSchema, schemaOf } from './schema-record'
13
+ import { isStandardSchema } from './standard-schema'
10
14
  import { ACTION_PREFIX } from './wire'
11
15
 
12
16
  export { actionStub, OUTCOME_SCRIPT, setRequestOutcome } from './action-call'
@@ -42,15 +46,27 @@ const emptySchema = () => ({ [Symbol.for('TypeBox.Kind')]: 'Object', type: 'obje
42
46
 
43
47
  // `action` as `kay check` reads it in a page's server fence, whose `ctx.params` are those of the page's route: not something to write.
44
48
  export interface ActionFor<Params extends Readonly<Record<string, unknown>>, Guarded extends object = object> {
49
+ <const Honeypot extends string = never, Output = never, Shape extends OutputSchema = OutputSchema>(options: ActionProtection<Honeypot, Success<Settled<Output>>, Shape> & { input?: undefined }, handler: (ctx: ActionContext<Params, string, Guarded>, ctxAfterEmptyInput: ActionContext<Params, string, Guarded>) => Output | Promise<Output>): NoInputAction<Settled<Output>, Honeypot>
50
+ <Spec extends Schema, Output, const Honeypot extends string = never, Shape extends OutputSchema = OutputSchema>(options: ActionProtection<Honeypot, Success<Settled<Output>>, Shape> & { input: Spec }, handler: (input: Static<Spec>, ctx: ActionContext<Params, Extract<keyof Static<Spec>, string>, Guarded>) => Output | Promise<Output>): ServerAction<Spec, Settled<Output>, Honeypot>
51
+ <Validator extends StandardSchema, Output, const Honeypot extends string = never, Shape extends OutputSchema = OutputSchema>(options: ActionProtection<Honeypot, Success<Settled<Output>>, Shape> & { input: Validator }, handler: (input: Static<StandardAs<Validator>>, ctx: ActionContext<Params, Extract<keyof Static<StandardAs<Validator>>, string>, Guarded>) => Output | Promise<Output>): ServerAction<StandardAs<Validator>, Settled<Output>, Honeypot>
52
+ <const Fields extends SchemaShape, Output, const Honeypot extends string = never, Shape extends OutputSchema = OutputSchema>(options: ActionProtection<Honeypot, Success<Settled<Output>>, Shape> & { input: Fields }, handler: (input: Static<ObjectOf<Fields>>, ctx: ActionContext<Params, Extract<keyof Static<ObjectOf<Fields>>, string>, Guarded>) => Output | Promise<Output>): ServerAction<ObjectOf<Fields>, Settled<Output>, Honeypot>
45
53
  <Output, const Honeypot extends string = never, Shape extends OutputSchema = OutputSchema>(handler: (ctx: ActionContext<Params, string, Guarded>) => Output | Promise<Output>, protection?: ActionProtection<Honeypot, Success<Settled<Output>>, Shape>): NoInputAction<Settled<Output>, Honeypot>
46
54
  <Spec extends Schema, Output, const Honeypot extends string = never, Shape extends OutputSchema = OutputSchema>(schema: Spec, handler: (input: Static<Spec>, ctx: ActionContext<Params, Extract<keyof Static<Spec>, string>, Guarded>) => Output | Promise<Output>, protection?: ActionProtection<Honeypot, Success<Settled<Output>>, Shape>): ServerAction<Spec, Settled<Output>, Honeypot>
55
+ <const Fields extends SchemaShape, Output, const Honeypot extends string = never, Shape extends OutputSchema = OutputSchema>(fields: Fields, handler: (input: Static<ObjectOf<Fields>>, ctx: ActionContext<Params, Extract<keyof Static<ObjectOf<Fields>>, string>, Guarded>) => Output | Promise<Output>, protection?: ActionProtection<Honeypot, Success<Settled<Output>>, Shape>): ServerAction<ObjectOf<Fields>, Settled<Output>, Honeypot>
47
56
  }
48
57
 
49
- // Declares a server action in a page's `--- server` fence: Elysia validates the input against `schema` before `handler` runs.
50
- // Without a schema the action takes no input, as with an empty object schema, and its handler gets the context alone.
58
+ // Declares a server action in a page's `--- server` fence: the options come first, as an API route's do, `input` a plain record of fields or any schema that kay checks the post against before `handler` runs.
59
+ // Without an `input` the action takes no input, as with an empty object schema, and its handler gets the context alone.
60
+ // The form before 1.107, `action(schema, handler, options)`, works until 2.0: the `deprecated-action-options` lint rewrites it.
51
61
  // kept: free, it registers a route answering a POST, which the page's own render never runs, and a kept page is refreshed after the first request that can write.
62
+ // A handler of two parameters is the form before 1.107, `action({}, (input, ctx) => ...)`, handed the empty input first: its second is the context, as the first of one taking the context alone is.
63
+ export function action<const Honeypot extends string = never, Output = never, Shape extends OutputSchema = OutputSchema>(options: ActionProtection<Honeypot, Success<Settled<Output>>, Shape> & { input?: undefined }, handler: (ctx: ActionContext, ctxAfterEmptyInput: ActionContext) => Output | Promise<Output>): NoInputAction<Settled<Output>, Honeypot>
64
+ export function action<Spec extends Schema, Output, const Honeypot extends string = never, Shape extends OutputSchema = OutputSchema>(options: ActionProtection<Honeypot, Success<Settled<Output>>, Shape> & { input: Spec }, handler: (input: Static<Spec>, ctx: ActionContext<RouteParams, Extract<keyof Static<Spec>, string>>) => Output | Promise<Output>): ServerAction<Spec, Settled<Output>, Honeypot>
65
+ export function action<Validator extends StandardSchema, Output, const Honeypot extends string = never, Shape extends OutputSchema = OutputSchema>(options: ActionProtection<Honeypot, Success<Settled<Output>>, Shape> & { input: Validator }, handler: (input: Static<StandardAs<Validator>>, ctx: ActionContext<RouteParams, Extract<keyof Static<StandardAs<Validator>>, string>>) => Output | Promise<Output>): ServerAction<StandardAs<Validator>, Settled<Output>, Honeypot>
66
+ export function action<const Fields extends SchemaShape, Output, const Honeypot extends string = never, Shape extends OutputSchema = OutputSchema>(options: ActionProtection<Honeypot, Success<Settled<Output>>, Shape> & { input: Fields }, handler: (input: Static<ObjectOf<Fields>>, ctx: ActionContext<RouteParams, Extract<keyof Static<ObjectOf<Fields>>, string>>) => Output | Promise<Output>): ServerAction<ObjectOf<Fields>, Settled<Output>, Honeypot>
52
67
  export function action<Output, const Honeypot extends string = never, Shape extends OutputSchema = OutputSchema>(handler: (ctx: ActionContext) => Output | Promise<Output>, protection?: ActionProtection<Honeypot, Success<Settled<Output>>, Shape>): NoInputAction<Settled<Output>, Honeypot>
53
68
  export function action<Spec extends Schema, Output, const Honeypot extends string = never, Shape extends OutputSchema = OutputSchema>(schema: Spec, handler: (input: Static<Spec>, ctx: ActionContext<RouteParams, Extract<keyof Static<Spec>, string>>) => Output | Promise<Output>, protection?: ActionProtection<Honeypot, Success<Settled<Output>>, Shape>): ServerAction<Spec, Settled<Output>, Honeypot>
69
+ export function action<const Fields extends SchemaShape, Output, const Honeypot extends string = never, Shape extends OutputSchema = OutputSchema>(fields: Fields, handler: (input: Static<ObjectOf<Fields>>, ctx: ActionContext<RouteParams, Extract<keyof Static<ObjectOf<Fields>>, string>>) => Output | Promise<Output>, protection?: ActionProtection<Honeypot, Success<Settled<Output>>, Shape>): ServerAction<ObjectOf<Fields>, Settled<Output>, Honeypot>
54
70
  export function action(first: unknown, second?: unknown, third?: ActionProtection<string>): unknown {
55
71
  if (typeof first === 'function') {
56
72
  const handler = first as (ctx: ActionContext) => unknown
@@ -58,7 +74,38 @@ export function action(first: unknown, second?: unknown, third?: ActionProtectio
58
74
  return declare(emptySchema(), (_input, ctx) => handler(ctx), second as ActionProtection<string> | undefined)
59
75
  }
60
76
 
61
- return declare(first as Schema, second as (input: unknown, ctx: ActionContext) => unknown, third)
77
+ if (third === undefined && isOptions(first)) {
78
+ const { input, ...options } = first as { input?: Schema | SchemaShape }
79
+ const handler = second as (...args: unknown[]) => unknown
80
+
81
+ // Without an `input` the handler takes the context alone, though an empty record before 1.107 gave it `(input, ctx)`.
82
+ return declare(input === undefined ? emptySchema() : schemaOf(input), input === undefined && handler.length < 2 ? (_input, ctx) => handler(ctx) : handler, options)
83
+ }
84
+
85
+ return declare(schemaOf(first as Schema | SchemaShape), second as (input: unknown, ctx: ActionContext) => unknown, third)
86
+ }
87
+
88
+ // Whether the first argument is the options of the form since 1.107, not the schema or the record of fields of the form before: an object that names an `input` which is a record or an object schema, or names no field at all.
89
+ function isOptions(first: unknown): boolean {
90
+ if (typeof first !== 'object' || first === null || isSchema(first) || isStandardSchema(first))
91
+ return false
92
+
93
+ const entries = Object.entries(first)
94
+
95
+ if ('input' in first) {
96
+ const { input } = first
97
+
98
+ // An `input` that is a schema or a record is options; so is one left undefined. A legacy record holding a field called `input` has a schema beside it, which options never do.
99
+ if (input === undefined)
100
+ return true
101
+
102
+ if (typeof input !== 'object' || input === null)
103
+ return false
104
+
105
+ return !entries.some(([name, value]) => name !== 'input' && (isSchema(value) || isStandardSchema(value)))
106
+ }
107
+
108
+ return !entries.some(([, value]) => isSchema(value) || isStandardSchema(value))
62
109
  }
63
110
 
64
111
  export function declare(schema: Schema, handler: (input: unknown, ctx: ActionContext) => unknown, options: ActionProtection<string> | undefined): ServerAction<Schema, unknown> {
@@ -229,6 +229,12 @@ async function hydrateIsland(registry: IslandRegistry, element: HTMLElement): Pr
229
229
 
230
230
  try {
231
231
  loaded = await Promise.all([load(), staticSlots(registry, element), livePropsOf(element), reviveActionsIn(element.dataset.props)])
232
+
233
+ // What the server drew of its lazy components loads first, so the markup is claimed as it stands.
234
+ const drawn = (globalThis as { $kayLoadDrawn?: (island: HTMLElement) => Promise<void> }).$kayLoadDrawn
235
+
236
+ if (drawn !== undefined)
237
+ await drawn(element)
232
238
  }
233
239
  catch (error) {
234
240
  // A chunk that failed to load is dropped like a missing one.
@@ -355,6 +361,10 @@ async function hotSwap(registry: IslandRegistry, swap: HotSwap): Promise<boolean
355
361
  const chunk = withBase(chunks[0]!)
356
362
 
357
363
  if (!document.querySelector(`${ISLAND}[data-component="${CSS.escape(id)}"]`)) {
364
+ // An island's code an island loaded lazily is not in the page as an island of its own, and keeps the version it loaded: only a reload brings the new one.
365
+ if ((globalThis as { $kayLazyLoaded?: boolean }).$kayLazyLoaded === true)
366
+ return false
367
+
358
368
  // Not on this page: a later one rendering it loads the new chunk, unless that would bring code the page runs again.
359
369
  if (fits(chunks))
360
370
  registry[id] = async () => import(chunk) as ReturnType<IslandRegistry[string]>