@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/check/boot.ts CHANGED
@@ -16,7 +16,7 @@ import { basePath } from '../server/base'
16
16
  import { checkRequestIdHeader, checkTimeZone, healthTimeoutMs, imageLimits, liveLimits, loadBudgetMs, remoteLimits, shutdownSeconds, timeoutMs } from '../server/config-limits'
17
17
  import { claimEndpoints } from '../server/endpoint-claims'
18
18
  import { PUBLIC_ENV_PATH } from '../server/env-state'
19
- import { faviconSource, svgFaviconProblems } from '../server/favicon'
19
+ import { faviconSource, shareActionProblem, svgFaviconProblems } from '../server/favicon'
20
20
  import { defaultLocaleTranslations, localeSettings, refuseLocaleClashes } from '../server/i18n'
21
21
  import { mcpKeySetting } from '../server/mcp-key'
22
22
  import { pageFlags } from '../server/page-flags'
@@ -179,6 +179,8 @@ export async function bootProblems(root: string, options: CheckOptions, feeds: C
179
179
 
180
180
  diagnostics.push(...await actionClashes(root, [...new Set(routes.flatMap(route => [...route.layouts, ...route.actionModules ?? [], route.file]))]))
181
181
 
182
+ diagnostics.push(...await shareTargetProblems(root, options, config, [...new Set(routes.flatMap(route => [...route.layouts, ...route.actionModules ?? [], route.file]))]))
183
+
182
184
  diagnostics.push(...await queryClashes(routes))
183
185
 
184
186
  diagnostics.push(...await pageHeadLints(options, routes, routesDir, publicDir, listed))
@@ -209,6 +211,25 @@ export async function actionClashes(root: string, files: string[]): Promise<Chec
209
211
  return diagnostics
210
212
  }
211
213
 
214
+ // A manifest share target naming a page file that is no page of the app, or an export that is no action of it, which the server refuses to boot on.
215
+ async function shareTargetProblems(root: string, options: CheckOptions, config: string, files: string[]): Promise<CheckDiagnostic[]> {
216
+ const share = options.assets?.manifest?.shareTarget
217
+
218
+ if (share === undefined)
219
+ return []
220
+
221
+ const actions = new Set<string>()
222
+
223
+ for (const file of files) {
224
+ for (const name of serverFacts(file, await Bun.file(file).text()).server?.actionNames ?? [])
225
+ actions.add(actionUrl(islandId(file, root), name))
226
+ }
227
+
228
+ const problem = shareActionProblem(share, actions, new Set(files.map(file => islandId(file, root))))
229
+
230
+ return problem === undefined ? [] : [{ file: config, line: 1, column: 1, message: problem, help: 'name a page file and the action it exports, as `src/routes/share.kay#receive`, or a path of the site' }]
231
+ }
232
+
212
233
  // What a page lists in `prerender`, as its source writes it.
213
234
  async function prerenderOf(file: string): Promise<string | undefined> {
214
235
  return (await pageFlags(file)).prerender?.trim()
@@ -0,0 +1,242 @@
1
+ import type { CheckDiagnostic } from '.'
2
+ import type { Span } from '../compiler/ast'
3
+ import type { Node, Program } from '../compiler/estree'
4
+ import type { LintLevels } from '../compiler/lints'
5
+ import type { OldFormLint } from './handler-events'
6
+ import { parseProgram } from '../compiler/estree'
7
+ import { lintLevels } from '../compiler/lints'
8
+ import { offsetAt } from '../compiler/mapping'
9
+ import { parseKay } from '../compiler/parser'
10
+ import { childrenOf } from './ast'
11
+
12
+ // A result narrowed by a read of `ok` is named by its members, `{ ok: true; data: ... }`.
13
+ const MISSING = /^Property '[^']+' does not exist on type '(?:CallResult<|\{ ok: (?:true|false); )/
14
+ const MODULE = /\.[cm]?tsx?$/
15
+ const MISMATCH = /^(?:Type|Argument of type) 'CallResult</
16
+ // What a result has of its own: a use of one of these means the code already reads a `CallResult`.
17
+ const RESULT_KEYS = new Set(['ok', 'data', 'error', 'errors', 'status', 'message', 'orThrow'])
18
+
19
+ // The spans of a `.kay` file's script, server and module fences, or the whole file for a module.
20
+ function codeSpans(source: string, kay: boolean): Span[] {
21
+ if (!kay)
22
+ return [{ start: 0, end: source.length }]
23
+
24
+ const file = parseKay(source)
25
+
26
+ return [file.script, file.server, file.module].filter(span => span !== undefined)
27
+ }
28
+
29
+ function parsed(source: string, kay: boolean, at: number): Program | undefined {
30
+ const span = codeSpans(source, kay).find(({ start, end }) => at >= start && at <= end)
31
+
32
+ return span === undefined ? undefined : parseProgram(source.slice(span.start, span.end), { lang: kay ? 'tsx' : 'ts', recover: true, offset: span.start }).program
33
+ }
34
+
35
+ interface Walked {
36
+ node: Node
37
+ parent: Node | undefined
38
+ }
39
+
40
+ function nodes(program: Program): Walked[] {
41
+ const found: Walked[] = []
42
+ const visit = (node: Node, parent: Node | undefined): void => {
43
+ found.push({ node, parent })
44
+
45
+ for (const child of childrenOf(node))
46
+ visit(child, node)
47
+ }
48
+
49
+ visit(program, undefined)
50
+
51
+ return found
52
+ }
53
+
54
+ // The names the program imports, which a call written on one of them is a kay call.
55
+ function importedNames(program: Program): Set<string> {
56
+ const names = new Set<string>()
57
+
58
+ for (const statement of program.body) {
59
+ if (statement.type === 'ImportDeclaration') {
60
+ for (const specifier of statement.specifiers) {
61
+ names.add(specifier.local.name)
62
+ }
63
+ }
64
+ }
65
+
66
+ return names
67
+ }
68
+
69
+ function rootName(callee: Node): string | undefined {
70
+ let node = callee
71
+
72
+ while (node.type === 'MemberExpression')
73
+ node = node.object
74
+
75
+ return node.type === 'Identifier' ? node.name : undefined
76
+ }
77
+
78
+ // The `await` a read of the result is made on: written there, or in a `const` the name was bound by.
79
+ function awaitedBy(all: Walked[], subject: Node, at: number): Node | undefined {
80
+ if (subject.type === 'AwaitExpression')
81
+ return subject
82
+
83
+ if (subject.type !== 'Identifier')
84
+ return undefined
85
+
86
+ const declarations = all.filter(({ node }) => node.type === 'VariableDeclarator' && node.id.type === 'Identifier' && node.id.name === subject.name && node.end <= at).map(({ node }) => node)
87
+ const declarator = declarations.at(-1)
88
+
89
+ return declarator?.type === 'VariableDeclarator' && declarator.init?.type === 'AwaitExpression' ? declarator.init : undefined
90
+ }
91
+
92
+ // The nodes that bind a name: a declaration, a parameter, a destructured name or a catch parameter.
93
+ function bindingNodes(all: Walked[]): Set<Node> {
94
+ const found = new Set<Node>()
95
+ const add = (node: Node | null | undefined): void => {
96
+ if (node)
97
+ found.add(node)
98
+ }
99
+
100
+ for (const { node } of all) {
101
+ const holder = node as unknown as { params?: Node[], param?: Node, left?: Node, argument?: Node, elements?: (Node | null)[], properties?: Node[] }
102
+
103
+ if (node.type === 'VariableDeclarator') {
104
+ add(node.id)
105
+ }
106
+ else if (node.type === 'ObjectPattern') {
107
+ for (const property of holder.properties ?? [])
108
+ add(property.type === 'Property' ? property.value : property)
109
+ }
110
+ else if (node.type === 'ArrayPattern') {
111
+ for (const element of holder.elements ?? [])
112
+ add(element)
113
+ }
114
+ else if (node.type === 'AssignmentPattern') {
115
+ add(holder.left)
116
+ }
117
+ else if (node.type === 'RestElement') {
118
+ add(holder.argument)
119
+ }
120
+ else if (node.type === 'CatchClause') {
121
+ add(holder.param)
122
+ }
123
+ else {
124
+ for (const param of holder.params ?? [])
125
+ add(param)
126
+ }
127
+ }
128
+
129
+ return found
130
+ }
131
+
132
+ // Whether the name is bound more than once in the file, so a read of it may be of another binding than the nearest declaration.
133
+ function boundTwice(all: Walked[], name: string): boolean {
134
+ const bindings = bindingNodes(all)
135
+
136
+ return all.filter(({ node }) => node.type === 'Identifier' && node.name === name && bindings.has(node)).length > 1
137
+ }
138
+
139
+ // Whether the code uses the name the `await` is bound to in any way but reading a field a result has no key of (`list.items`), or the pattern it is destructured by names a result's key: `list.ok`, `list['ok']`, `list[key]`, `const { ok } = list` or `list` handed on, so `.orThrow()` could take away what is read.
140
+ function readsResult(all: Walked[], bound: Node | undefined): boolean {
141
+ if (bound === undefined)
142
+ return false
143
+
144
+ if (bound.type === 'Identifier') {
145
+ const bindings = bindingNodes(all)
146
+
147
+ return all.some(({ node, parent }) => {
148
+ if (node.type !== 'Identifier' || node.name !== bound.name || node === bound || bindings.has(node))
149
+ return false
150
+
151
+ if (parent?.type === 'MemberExpression' && parent.property === node && !parent.computed)
152
+ return false
153
+
154
+ if (parent?.type === 'Property' && parent.key === node && !parent.computed && !parent.shorthand)
155
+ return false
156
+
157
+ return !(parent?.type === 'MemberExpression' && parent.object === node && !parent.computed && parent.property.type === 'Identifier' && !RESULT_KEYS.has(parent.property.name))
158
+ })
159
+ }
160
+
161
+ return bound.type === 'ObjectPattern' && bound.properties.some(property => property.type !== 'Property' || property.computed || (property.key.type === 'Identifier' && RESULT_KEYS.has(property.key.name)))
162
+ }
163
+
164
+ // A read on a call's answer that is no field of a `CallResult`, an island call awaited as data as it was before 1.105: the answer is `{ ok: true, data }` or `{ ok: false, error }` since, so `.orThrow()` after the call gives the data and throws a refusal as it did.
165
+ // Fixed where the call is written on a name the file imports and nothing reads `ok`, `data` or `error` of the answer; offered, not applied, otherwise.
166
+ export function callResultLint(message: string, source: string, span: Span | undefined, kay: boolean): OldFormLint | undefined {
167
+ const missing = MISSING.test(message)
168
+
169
+ if (span === undefined || (!missing && !MISMATCH.test(message)))
170
+ return undefined
171
+
172
+ const program = parsed(source, kay, span.start)
173
+
174
+ if (program === undefined)
175
+ return undefined
176
+
177
+ const all = nodes(program)
178
+ let subject: Node | undefined
179
+ let bound: Node | undefined
180
+
181
+ for (const { node, parent } of all) {
182
+ if (missing && node.type === 'MemberExpression' && !node.computed && node.property.start === span.start) {
183
+ subject = node.object
184
+ bound = node.object
185
+ }
186
+ else if (missing && node.type === 'Property' && parent?.type === 'ObjectPattern' && node.key.start === span.start) {
187
+ const declarator = all.find(({ node: other }) => other.type === 'VariableDeclarator' && other.id === parent)?.node
188
+
189
+ subject = declarator?.type === 'VariableDeclarator' ? declarator.init ?? undefined : undefined
190
+ bound = parent
191
+ }
192
+ else if (!missing && (node.type === 'AwaitExpression' || node.type === 'Identifier') && node.start === span.start) {
193
+ subject = node
194
+ bound = node
195
+ }
196
+
197
+ if (subject !== undefined)
198
+ break
199
+ }
200
+
201
+ const awaited = subject === undefined ? undefined : awaitedBy(all, subject, span.start)
202
+ const call = awaited?.type === 'AwaitExpression' && awaited.argument.type === 'CallExpression' ? awaited.argument : undefined
203
+ const report = {
204
+ message: 'An island\'s call answers a `CallResult` since 1.105, `{ ok: true, data }` or `{ ok: false, error }`, not its data',
205
+ help: 'read `data` after checking `ok`, or write `.orThrow()` after the call: it resolves with the data and throws a refusal as the call did before 1.105',
206
+ span,
207
+ }
208
+
209
+ if (call === undefined)
210
+ return report
211
+
212
+ const known = importedNames(program)
213
+ const name = rootName(call.callee)
214
+ const safe = name !== undefined && known.has(name) && !readsResult(all, bound) && !(bound?.type === 'Identifier' && boundTwice(all, bound.name))
215
+
216
+ return { ...report, fixes: [{ title: 'Write `.orThrow()` after the call', safe, edits: [{ start: call.end, end: call.end, text: '.orThrow()' }] }] }
217
+ }
218
+
219
+ // The same for a type error in a module of the project, which has no shadow file: the message tells what it is, and the file is read for the call it names.
220
+ export async function moduleCallResult(diagnostic: CheckDiagnostic, levels: LintLevels | undefined): Promise<Pick<CheckDiagnostic, 'code' | 'severity' | 'message' | 'help' | 'fixes'> | undefined> {
221
+ if (!(MISSING.test(diagnostic.message) || MISMATCH.test(diagnostic.message)) || !MODULE.test(diagnostic.file))
222
+ return undefined
223
+
224
+ let source: string
225
+
226
+ try {
227
+ source = await Bun.file(diagnostic.file).text()
228
+ }
229
+ catch {
230
+ return undefined
231
+ }
232
+
233
+ const start = offsetAt(source, diagnostic)
234
+ const found = callResultLint(diagnostic.message, source, { start, end: start + 1 }, false)
235
+
236
+ if (found === undefined)
237
+ return undefined
238
+
239
+ const level = lintLevels(source, levels)('deprecated-call-result', start)
240
+
241
+ return level === 'allow' ? undefined : { code: 'deprecated-call-result', severity: level === 'warn' ? 'warning' : 'error', message: found.message, help: found.help, ...found.fixes && { fixes: found.fixes } }
242
+ }
@@ -2,7 +2,7 @@ import type { Node, NodeOfType, Program } from '../compiler/estree'
2
2
  import type { Property } from './regroup'
3
3
  import { basename } from 'node:path'
4
4
  import { constBindings, exportedObject, keyName, objectOf } from '../compiler/object-literal'
5
- import { importsOf, walk } from './ast'
5
+ import { importedName, importsOf, walk } from './ast'
6
6
  import { nameOf } from './regroup'
7
7
 
8
8
  type ObjectExpression = NodeOfType<'ObjectExpression'>
@@ -38,7 +38,12 @@ export function featureProperties(object: ObjectExpression, bindings: ReturnType
38
38
  return [...propertiesOf(object, name).slice(0, 1), ...held === undefined ? [] : propertiesOf(held, name).slice(0, 1)]
39
39
  }
40
40
 
41
- // The objects of a file that are written as config: kay.config.ts's export, and in any file the options handed to `pages()` or `testSite()` with the `config` object of each.
41
+ // Whether a file names the `KayExtension` type, as one writing an extension does.
42
+ function namesExtension(ast: Program): boolean {
43
+ return ast.body.some(statement => statement.type === 'ImportDeclaration' && statement.specifiers.some(specifier => specifier.type === 'ImportSpecifier' && importedName(specifier) === 'KayExtension'))
44
+ }
45
+
46
+ // The objects of a file that are written as config: kay.config.ts's export, the `config` of an extension a file typed `KayExtension` writes, and in any file the options handed to `pages()` or `testSite()` with the `config` object of each.
42
47
  export function configObjects(file: string, ast: Program): ConfigObject[] {
43
48
  const bindings = constBindings(ast)
44
49
  const found: ConfigObject[] = []
@@ -50,6 +55,16 @@ export function configObjects(file: string, ast: Program): ConfigObject[] {
50
55
  found.push({ object: exported, others: [] })
51
56
  }
52
57
 
58
+ if (namesExtension(ast)) {
59
+ walk(ast, (node) => {
60
+ const config = node.type === 'ObjectExpression' && propertyOf(node, 'name') !== undefined ? propertyOf(node, 'config') : undefined
61
+ const inner = config === undefined ? undefined : objectOf(config.value, bindings)
62
+
63
+ if (inner !== undefined && inner === config?.value)
64
+ found.push({ object: inner, others: [] })
65
+ })
66
+ }
67
+
53
68
  const calls = (['pages', 'testSite'] as const).map(name => ({ name, ...importsOf(ast, name === 'pages' ? FROM_SERVER : FROM_TEST, name) })).filter(call => call.locals.size > 0 || call.namespaces.size > 0)
54
69
 
55
70
  if (calls.length === 0)
@@ -4,6 +4,7 @@ import type { Fix, Span } from '../compiler/ast'
4
4
  import type { LintLevel, LintName } from '../compiler/lints'
5
5
  import type { I18nConfig } from '../config'
6
6
  import type { RouteMount } from '../server/routes'
7
+ import type { OldFormLint } from './handler-events'
7
8
  import type { ShadowFile } from './shadow'
8
9
  import { existsSync, realpathSync } from 'node:fs'
9
10
  import { basename, dirname, relative, resolve, sep } from 'node:path'
@@ -17,7 +18,9 @@ import { WRITABLE } from '../compiler/names'
17
18
  import { parseKay } from '../compiler/parser'
18
19
  import { UNSERVED_MESSAGE } from '../runtime/checks'
19
20
  import { localePrefixes, localeSettings } from '../server/i18n'
21
+ import { callResultLint } from './call-result'
20
22
  import { unknownNameHelp } from './export-homes'
23
+ import { handlerEventLint } from './handler-events'
21
24
  import { loopIndexFix, positionalKeyFix } from './loop-index-fix'
22
25
  import { sourceSpan } from './shadow'
23
26
  import { lastOverload, richCallHint, templateHint } from './template-hints'
@@ -128,6 +131,18 @@ function blockWithoutParameters(diagnostic: TsgoDiagnostic, source: string, span
128
131
  return `the component calls \`@${name}\` with (${parameters}): write it with them, as \`@${name}(${[...parameters.matchAll(PARAMETER_NAME)].map(match => `${match[1] ?? ''}${match[2]}`).join(', ')})\``
129
132
  }
130
133
 
134
+ // What the types say of a callback given a function written for its arguments before 1.105, or of an island's call read as data: the deprecated lint that names it, with its fix.
135
+ function oldForm(message: string, source: string, span: Span | undefined): (OldFormLint & { code: LintName }) | undefined {
136
+ const handler = handlerEventLint(message, source, span)
137
+
138
+ if (handler !== undefined)
139
+ return { code: 'deprecated-callback-handler', ...handler }
140
+
141
+ const result = callResultLint(message, source, span, true)
142
+
143
+ return result && { code: 'deprecated-call-result', ...result }
144
+ }
145
+
131
146
  // A diagnostic in a .kay file's shadow TSX, read at the levels its source gives the lints.
132
147
  export function diagnoseShadow(shadow: ShadowFile, reported: TsgoDiagnostic, levelAt: (lint: LintName, offset: number) => LintLevel, messageKeys: readonly string[] = []): Diagnosed | undefined {
133
148
  const span = sourceSpan(shadow, reported.start, reported.end, 'loose')
@@ -149,6 +164,13 @@ export function diagnoseShadow(shadow: ShadowFile, reported: TsgoDiagnostic, lev
149
164
  return level === 'allow' ? undefined : { ...lint, severity: severityOf(level), span, ...offered }
150
165
  }
151
166
 
167
+ // A type error that is an old form of before 1.105, with the fix that writes the new one.
168
+ const old = oldForm(diagnostic.message, shadow.source, span)
169
+ const oldLevel = old === undefined ? 'allow' : levelAt(old.code, offset)
170
+
171
+ if (old !== undefined && oldLevel !== 'allow')
172
+ return { ...old, severity: severityOf(oldLevel) }
173
+
152
174
  // Unread code is the `unread-name` lint; a name kay generated, which the template reads in a way it does not spell out, is no code of the user's.
153
175
  if (diagnostic.code !== undefined && UNUSED_CODES.has(diagnostic.code)) {
154
176
  const level = shadow.map.isExact(diagnostic.start) ? levelAt('unread-name', offset) : 'allow'
@@ -0,0 +1,149 @@
1
+ import type { Fix, Span } from '../compiler/ast'
2
+ import { attributeNamed } from './template-hints'
3
+
4
+ // `Type '(next: boolean) => void' is not assignable to type '(event: { checked: boolean; }) => unknown'.` and the incompatible parameter that follows.
5
+ const EVENT_CALLBACK = /^Type '([\s\S]+?)' is not assignable to type '\(event: \{ ([\s\S]*?) \}\) => unknown'\.\n\s+Types of parameters '[^']*' and 'event' are incompatible\.\n([\s\S]*)$/
6
+ const PARAMETER_TYPE = /(?:to type|from type) '([\s\S]*?)'(?:\.|:)/
7
+ const FIELD = /^(\w+)\??:/
8
+ const CALLBACK_NAME = /^on[A-Z]\w*$/
9
+ const HANDLER_NAME = /^[A-Z_$][\w$]*(?:\??\.[A-Z_$][\w$]*)*$/i
10
+ // An object literal type or a named type, which no old argument was apart from a `File`: the handler may be written for the event already.
11
+ const OBJECT_TYPE = /^(?:\{|object\b|(?!File\b)[A-Z])/
12
+ const COMPONENT = /^([A-Z][\w$]*)(?:[.#][^\s(]*)?\(/
13
+ const NAME_AT = /^[\w$]+/
14
+ const EVENT_WORD = /\bevent\b/
15
+ const ELEMENT = /^[a-z.#][^\s(]*\(/
16
+
17
+ // What an old-form lint of the type check reports.
18
+ export interface OldFormLint {
19
+ message: string
20
+ help: string
21
+ span: Span
22
+ fixes?: Fix[]
23
+ }
24
+
25
+ // The segments of a type's text between its top-level `separator`s.
26
+ function splitTop(text: string, separator: string): string[] {
27
+ const parts: string[] = []
28
+ let depth = 0
29
+ let from = 0
30
+
31
+ for (const [index, char] of [...text].entries()) {
32
+ if ('{([<'.includes(char)) {
33
+ depth++
34
+ }
35
+ else if ('})]'.includes(char) || (char === '>' && text[index - 1] !== '=')) {
36
+ depth--
37
+ }
38
+ else if (char === separator && depth === 0) {
39
+ parts.push(text.slice(from, index))
40
+ from = index + 1
41
+ }
42
+ }
43
+
44
+ parts.push(text.slice(from))
45
+
46
+ return parts.map(part => part.trim()).filter(part => part !== '')
47
+ }
48
+
49
+ // How many parameters a function type written as `(a: A, b: B) => R` takes, 1 for any other type, as a signal's `Setter<T>` takes one.
50
+ function parameterCount(type: string): number {
51
+ if (!type.startsWith('('))
52
+ return 1
53
+
54
+ let depth = 0
55
+
56
+ for (const [index, char] of [...type].entries()) {
57
+ if (char === '(')
58
+ depth++
59
+ else if (char === ')' && --depth === 0)
60
+ return splitTop(type.slice(1, index), ',').length
61
+ }
62
+
63
+ return 1
64
+ }
65
+
66
+ // Whether the first parameter of a function type written as `(a: A, b: B) => R` is typed as an object, a literal or a named type.
67
+ function takesObject(type: string): boolean {
68
+ if (!type.startsWith('('))
69
+ return false
70
+
71
+ const first = splitTop(type.slice(1), ',')[0] ?? ''
72
+
73
+ // A destructured parameter takes an object whatever its type is called.
74
+ if (first.startsWith('{'))
75
+ return true
76
+
77
+ const colon = first.indexOf(':')
78
+
79
+ return colon !== -1 && OBJECT_TYPE.test(first.slice(colon + 1).trim())
80
+ }
81
+
82
+ // The component an attribute is written on, read off its line or, for an attribute on a line of its own, the line above it that opens the call.
83
+ function componentAt(source: string, at: number): string | undefined {
84
+ const lineEnd = source.indexOf('\n', at)
85
+ const [own, ...above] = source.slice(0, lineEnd === -1 ? source.length : lineEnd).split('\n').toReversed()
86
+ const opened = COMPONENT.exec(own!.trimStart())
87
+
88
+ if (opened !== null)
89
+ return opened[1]
90
+
91
+ if (ELEMENT.test(own!.trimStart()))
92
+ return undefined
93
+
94
+ const indent = own!.length - own!.trimStart().length
95
+
96
+ for (const line of above) {
97
+ const trimmed = line.trimStart()
98
+
99
+ if (trimmed !== '' && line.length - trimmed.length < indent)
100
+ return COMPONENT.exec(trimmed)?.[1]
101
+ }
102
+
103
+ return undefined
104
+ }
105
+
106
+ // A callback a component of a kayjs library takes as one event object since 1.105, given a function written for its positional arguments: the handler of `onValueChange={query.set}`, `onCheckedChange={toggle}` or `onFiles={upload}`.
107
+ // The fix wraps a handler written as a name, `event => query.set(event.value)`, passing the fields the handler took, first ones first. It is applied where the handler's parameter is no object, which the old arguments were; a handler taking an object may be written for the event already, so its fix is offered.
108
+ export function handlerEventLint(message: string, source: string, span: Span | undefined): OldFormLint | undefined {
109
+ const found = EVENT_CALLBACK.exec(message)
110
+
111
+ if (found === null || span === undefined)
112
+ return undefined
113
+
114
+ const name = NAME_AT.exec(source.slice(span.start))?.[0]
115
+
116
+ if (name === undefined || !CALLBACK_NAME.test(name))
117
+ return undefined
118
+
119
+ const component = componentAt(source, span.start)
120
+
121
+ if (component === undefined || !new RegExp(`^import\\b[^\\n]*\\b${component}\\b[^\\n]*from\\s+['"]@kayjs/`, 'm').test(source))
122
+ return undefined
123
+
124
+ const [, handlerType, eventFields, rest] = found
125
+ const fields = splitTop(eventFields!, ';').flatMap(segment => FIELD.exec(segment)?.[1] ?? [])
126
+
127
+ if (fields.length === 0)
128
+ return undefined
129
+
130
+ const object = takesObject(handlerType!) || PARAMETER_TYPE.exec(rest!)?.[1]?.startsWith('{') === true
131
+ const taken = fields.slice(0, Math.max(1, Math.min(parameterCount(handlerType!), fields.length)))
132
+ const attribute = attributeNamed(source, { start: span.start, end: source.length }, name)
133
+ const value = attribute === undefined ? undefined : source.slice(attribute.start + name.length + 1, attribute.end)
134
+ const inner = value?.startsWith('{') && value.endsWith('}') ? value.slice(1, -1).trim() : undefined
135
+ const handler = inner !== undefined && HANDLER_NAME.test(inner) && !EVENT_WORD.test(inner) ? inner : undefined
136
+ const written = `event => ${handler}(${taken.map(field => `event.${field}`).join(', ')})`
137
+ const report = {
138
+ message: `\`${name}\` on \`${component}\` takes one event object since 1.105, \`{ ${fields.join(', ')} }\`, where it took ${fields.map(field => `\`${field}\``).join(', ')} as ${fields.length === 1 ? 'its argument' : 'arguments'}`,
139
+ help: handler === undefined ? 'take the event object, `({ value }) => ...`, and read the fields from it' : `write \`${name}={${written}}\``,
140
+ span,
141
+ }
142
+
143
+ if (handler === undefined || attribute === undefined)
144
+ return report
145
+
146
+ const start = attribute.start + name.length + 1 + value!.indexOf(handler)
147
+
148
+ return { ...report, fixes: [{ title: `Write \`${name}={${written}}\``, safe: !object, edits: [{ start, end: start + handler.length, text: written }] }] }
149
+ }
@@ -14,6 +14,7 @@ import { lintLevels } from '../compiler/lints'
14
14
  import { offsetAt, positionAt } from '../compiler/mapping'
15
15
  import { nativeExe } from '../compiler/native-typescript'
16
16
  import { pickConfig } from '../config'
17
+ import { moduleCallResult } from './call-result'
17
18
  import { diagnoseShadow, reportsTypeErrors, servedByTheApp, shownOutsideKay, unusedCodesOf } from './diagnose'
18
19
  import { unknownNameHelp } from './export-homes'
19
20
  import { generatedProblem } from './generated'
@@ -88,6 +89,8 @@ export interface CheckOptions extends Omit<Pick<KayConfig, (typeof CHECK_CONFIG)
88
89
  launch?: boolean | undefined
89
90
  // Set by `kay build --static`: a static host reads no `SITE_URL` once built, so a missing site is reported.
90
91
  exported?: boolean | undefined
92
+ // The header `proxy.key` names, which the fix of `testSite({ proxyKey })` writes beside the secret.
93
+ proxyHeader?: string | undefined
91
94
  }
92
95
 
93
96
  export interface CheckDiagnostic extends Pick<Diagnostic, 'label' | 'related' | 'note' | 'help' | 'severity' | 'fixes'> {
@@ -113,8 +116,9 @@ function helped({ message, help }: CheckDiagnostic): Pick<CheckDiagnostic, 'help
113
116
  export function configCheckOptions(config: LoadedConfig): CheckOptions {
114
117
  const { ops, ...picked } = pickConfig(config, CHECK_CONFIG)
115
118
  const { observe } = ops ?? {}
119
+ const proxyHeader = typeof config.proxy === 'object' ? config.proxy.key?.header : undefined
116
120
 
117
- return { ...picked, ...config.store?.database !== undefined && { storeDatabase: config.store.database }, ...ops !== undefined && { ops: { health: ops.health, ...observe !== undefined && { observe: { requestIdHeader: observe.requestIdHeader, loadBudget: observe.loadBudget } } } }, ...config.publicEnv !== undefined && { publicEnv: config.publicEnv } }
121
+ return { ...picked, ...proxyHeader !== undefined && { proxyHeader }, ...config.store?.database !== undefined && { storeDatabase: config.store.database }, ...ops !== undefined && { ops: { health: ops.health, ...observe !== undefined && { observe: { requestIdHeader: observe.requestIdHeader, loadBudget: observe.loadBudget } } } }, ...config.publicEnv !== undefined && { publicEnv: config.publicEnv } }
118
122
  }
119
123
 
120
124
  // Type-checks a project, .kay components included, and reports every error at the line and column the user wrote.
@@ -207,7 +211,7 @@ async function runCheck(root: string, given: CheckOptions, probes?: ProbeMemory)
207
211
 
208
212
  const mapped: CheckDiagnostic = shadow && diagnosed
209
213
  ? { ...diagnostic, file: shadow.file, ...positionAt(shadow.source, diagnosed.span?.start ?? 0), code: diagnosed.code ?? diagnostic.code, severity: diagnosed.severity, message: diagnosed.message, note: diagnosed.note, help: diagnosed.help ?? (shadow.route === true ? helped(diagnostic).help : undefined), ...diagnosed.fixes && { fixes: diagnosed.fixes } }
210
- : { ...diagnostic, ...helped(diagnostic) }
214
+ : { ...diagnostic, ...helped(diagnostic), ...await moduleCallResult(diagnostic, options.lints) }
211
215
  const generated = generatedProblem(root, mapped, types, content)
212
216
 
213
217
  // A guard file imported for two lines of the exports check is reported once.