@kayjs/kay 1.107.0 → 1.109.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (576) hide show
  1. package/dist/eslint.js +1875 -3815
  2. package/editors/zed/extension.toml +2 -2
  3. package/llms/action-protection.md +1 -1
  4. package/llms/actions-from-islands.md +5 -5
  5. package/llms/actions-refused-fields.md +4 -4
  6. package/llms/api-from-islands.md +6 -6
  7. package/llms/browser-only.md +2 -2
  8. package/llms/cdn-caching.md +1 -1
  9. package/llms/checks.md +1 -1
  10. package/llms/code-lints.md +1 -2
  11. package/llms/component-libraries.md +1 -1
  12. package/llms/component-library-conventions.md +1 -1
  13. package/llms/components.md +4 -4
  14. package/llms/deprecated-lints.md +1 -7
  15. package/llms/effects.md +1 -1
  16. package/llms/errors.md +2 -2
  17. package/llms/events.md +1 -1
  18. package/llms/guards.md +1 -1
  19. package/llms/head.md +1 -1
  20. package/llms/hooks.md +2 -2
  21. package/llms/images.md +1 -1
  22. package/llms/island-and-form-lints.md +2 -1
  23. package/llms/island-sources.md +1 -1
  24. package/llms/islands-state-to-ids.md +2 -2
  25. package/llms/islands.md +5 -3
  26. package/llms/lints.md +1 -1
  27. package/llms/live-values.md +3 -3
  28. package/llms/local-collections.md +1 -1
  29. package/llms/locales.md +1 -1
  30. package/llms/mcp.md +2 -2
  31. package/llms/metrics.md +1 -1
  32. package/llms/navigation-from-code.md +6 -6
  33. package/llms/prerendering.md +1 -0
  34. package/llms/production.md +2 -2
  35. package/llms/project-new-and-add.md +1 -1
  36. package/llms/project.md +4 -4
  37. package/llms/proxy-and-security.md +1 -1
  38. package/llms/queues.md +1 -1
  39. package/llms/rate-limits.md +4 -4
  40. package/llms/rendering.md +1 -1
  41. package/llms/server-islands.md +2 -2
  42. package/llms/server.md +1 -1
  43. package/llms/stores.md +1 -1
  44. package/llms/styles-and-assets.md +1 -1
  45. package/llms/testing-mount.md +49 -0
  46. package/llms/testing.md +4 -45
  47. package/llms/upgrading-1-105-config.md +13 -13
  48. package/llms/upgrading-archive.md +42 -82
  49. package/llms/upgrading.md +92 -58
  50. package/llms/whats-new-archive.md +36 -1
  51. package/llms/whats-new.md +18 -39
  52. package/llms.txt +6 -7
  53. package/package.json +6 -10
  54. package/src/build/client.ts +7 -6
  55. package/src/build/icon-slots.ts +140 -0
  56. package/src/build/libraries.ts +24 -2
  57. package/src/build/plugin.ts +10 -0
  58. package/src/build/route-sizes.ts +2 -3
  59. package/src/build/runtime-chunk.ts +2 -2
  60. package/src/build/source-files.ts +8 -3
  61. package/src/build/variants.ts +90 -1
  62. package/src/check/browser-global-reads.ts +2 -2
  63. package/src/check/config-objects.ts +1 -1
  64. package/src/check/diagnose.ts +0 -22
  65. package/src/check/export-homes.ts +1 -1
  66. package/src/check/guards.ts +3 -3
  67. package/src/check/index.ts +2 -7
  68. package/src/check/moved-keys.ts +1 -1
  69. package/src/check/project.ts +4 -9
  70. package/src/check/renamed-packages.ts +3 -63
  71. package/src/check/shadow-types.ts +4 -104
  72. package/src/commands/check.ts +2 -2
  73. package/src/commands/env.ts +25 -3
  74. package/src/compiler/ast.ts +18 -16
  75. package/src/compiler/browser.ts +2 -14
  76. package/src/compiler/class-items.ts +16 -0
  77. package/src/compiler/codegen.ts +8 -8
  78. package/src/compiler/dead-code.ts +22 -0
  79. package/src/compiler/deprecated-library.ts +0 -12
  80. package/src/compiler/deprecated-lints.ts +4 -505
  81. package/src/compiler/deprecated-ui-props.ts +5 -5
  82. package/src/compiler/dom-property.ts +23 -0
  83. package/src/compiler/dom.ts +15 -15
  84. package/src/compiler/errors.ts +2 -2
  85. package/src/compiler/fence-checks.ts +2 -121
  86. package/src/compiler/hand-parts.ts +55 -0
  87. package/src/compiler/helper-imports.ts +2 -2
  88. package/src/compiler/image-attributes.ts +1 -3
  89. package/src/compiler/index.ts +20 -21
  90. package/src/compiler/island-arguments.ts +8 -95
  91. package/src/compiler/island-cause.ts +7 -7
  92. package/src/compiler/island-declaration.ts +2 -8
  93. package/src/compiler/island-lints.ts +12 -0
  94. package/src/compiler/island-marker.ts +3 -3
  95. package/src/compiler/island-problems.ts +25 -0
  96. package/src/compiler/jsx-class.ts +1 -25
  97. package/src/compiler/jsx.ts +2 -2
  98. package/src/compiler/kay-exports.ts +0 -2
  99. package/src/compiler/link-flags.ts +9 -38
  100. package/src/compiler/lints.ts +7 -14
  101. package/src/compiler/markup.ts +23 -26
  102. package/src/compiler/module-signals.ts +2 -2
  103. package/src/compiler/names.ts +1 -1
  104. package/src/compiler/page-settings.ts +11 -0
  105. package/src/compiler/parser.ts +6 -8
  106. package/src/compiler/plan.ts +1 -3
  107. package/src/compiler/rewrite.ts +3 -18
  108. package/src/compiler/script-server.ts +8 -3
  109. package/src/compiler/validate.ts +3 -8
  110. package/src/config-loader.ts +14 -4
  111. package/src/config-resolve.ts +18 -142
  112. package/src/config-shape.ts +44 -34
  113. package/src/config.ts +10 -114
  114. package/src/dev/preload.ts +4 -1
  115. package/src/lsp/server.ts +4 -0
  116. package/src/migrate/markup.ts +4 -1
  117. package/src/package-names.ts +1 -1
  118. package/src/runtime/action-call.ts +39 -335
  119. package/src/runtime/action-encode.ts +26 -0
  120. package/src/runtime/action-error.ts +3 -11
  121. package/src/runtime/action-protection.ts +2 -2
  122. package/src/runtime/action-run.ts +332 -0
  123. package/src/runtime/action-shared.ts +14 -37
  124. package/src/runtime/action-stream.ts +0 -1
  125. package/src/runtime/action.ts +1 -1
  126. package/src/runtime/call-result.ts +2 -10
  127. package/src/runtime/checks.ts +11 -11
  128. package/src/runtime/client.ts +2 -2
  129. package/src/runtime/core.ts +5 -23
  130. package/src/runtime/dom.ts +1 -1
  131. package/src/runtime/html.ts +1 -1
  132. package/src/runtime/i18n.client.ts +1 -4
  133. package/src/runtime/i18n.server.ts +1 -4
  134. package/src/runtime/i18n.ts +3 -3
  135. package/src/runtime/index.ts +2 -2
  136. package/src/runtime/island.server.ts +18 -5
  137. package/src/runtime/live-resource.server.ts +0 -1
  138. package/src/runtime/live-value.server.ts +2 -2
  139. package/src/runtime/live-value.shared.ts +7 -20
  140. package/src/runtime/live.ts +1 -12
  141. package/src/runtime/local-types.ts +1 -11
  142. package/src/runtime/local.ts +4 -14
  143. package/src/runtime/navigate-api.ts +2 -5
  144. package/src/runtime/navigation-state.ts +0 -12
  145. package/src/runtime/page-swap.ts +6 -6
  146. package/src/runtime/persist.ts +11 -3
  147. package/src/runtime/persisted.ts +4 -30
  148. package/src/runtime/presence.ts +6 -7
  149. package/src/runtime/query-param.ts +20 -12
  150. package/src/runtime/reactive.ts +3 -1
  151. package/src/runtime/refuse.ts +3 -17
  152. package/src/runtime/store-base.ts +4 -6
  153. package/src/runtime/swap-fetch.ts +1 -1
  154. package/src/runtime/values.ts +40 -23
  155. package/src/runtime/with-query.ts +9 -0
  156. package/src/server/action-hooks.ts +8 -8
  157. package/src/server/actions.ts +13 -14
  158. package/src/server/api-modules.ts +2 -3
  159. package/src/server/app-stages.ts +15 -33
  160. package/src/server/app.ts +10 -5
  161. package/src/server/auth-mails.ts +0 -2
  162. package/src/server/env-state.ts +40 -10
  163. package/src/server/flash.ts +1 -1
  164. package/src/server/guard-requirement.ts +4 -4
  165. package/src/server/image.ts +2 -2
  166. package/src/server/index.ts +0 -2
  167. package/src/server/job-context.ts +3 -3
  168. package/src/server/jobs-page.ts +1 -1
  169. package/src/server/jobs.ts +5 -9
  170. package/src/server/kept-exports.ts +0 -2
  171. package/src/server/kv.ts +11 -14
  172. package/src/server/library.ts +1 -3
  173. package/src/server/live.ts +2 -2
  174. package/src/server/mcp.ts +3 -9
  175. package/src/server/metrics.ts +2 -4
  176. package/src/server/page-settings.ts +10 -19
  177. package/src/server/prerender.ts +19 -2
  178. package/src/server/protection.ts +15 -18
  179. package/src/server/queue.ts +3 -6
  180. package/src/server/rate-limit.ts +0 -3
  181. package/src/server/render-document.ts +1 -1
  182. package/src/server/routes.ts +7 -3
  183. package/src/server/scope.ts +3 -2
  184. package/src/server/session.ts +5 -6
  185. package/src/server/setup.ts +1 -1
  186. package/src/server/signals.ts +17 -7
  187. package/src/server/signed.ts +1 -3
  188. package/src/server/source.ts +20 -4
  189. package/src/server/speculation.ts +1 -1
  190. package/src/server/storage.ts +3 -8
  191. package/src/server/validate.ts +1 -1
  192. package/src/server/vitals.ts +1 -3
  193. package/src/server/work-scope.ts +2 -4
  194. package/src/server/work.ts +1 -1
  195. package/src/server/workflow.ts +1 -1
  196. package/src/test/index.ts +2 -1
  197. package/src/test/site-actions.ts +16 -6
  198. package/src/test/site-keys.ts +10 -15
  199. package/src/test/site-socket.ts +1 -2
  200. package/src/test/site-types.ts +0 -8
  201. package/types/build/client.d.ts +1 -1
  202. package/types/build/client.d.ts.map +1 -1
  203. package/types/build/icon-slots.d.ts +7 -0
  204. package/types/build/icon-slots.d.ts.map +1 -0
  205. package/types/build/libraries.d.ts +2 -0
  206. package/types/build/libraries.d.ts.map +1 -1
  207. package/types/build/plugin.d.ts +1 -0
  208. package/types/build/plugin.d.ts.map +1 -1
  209. package/types/build/route-sizes.d.ts.map +1 -1
  210. package/types/build/source-files.d.ts.map +1 -1
  211. package/types/build/variants.d.ts.map +1 -1
  212. package/types/check/diagnose.d.ts.map +1 -1
  213. package/types/check/index.d.ts +1 -2
  214. package/types/check/index.d.ts.map +1 -1
  215. package/types/check/project.d.ts.map +1 -1
  216. package/types/check/renamed-packages.d.ts +0 -3
  217. package/types/check/renamed-packages.d.ts.map +1 -1
  218. package/types/check/shadow-types.d.ts.map +1 -1
  219. package/types/commands/env.d.ts.map +1 -1
  220. package/types/compiler/ast.d.ts +1 -2
  221. package/types/compiler/ast.d.ts.map +1 -1
  222. package/types/compiler/browser.d.ts.map +1 -1
  223. package/types/compiler/class-items.d.ts +7 -0
  224. package/types/compiler/class-items.d.ts.map +1 -0
  225. package/types/compiler/dead-code.d.ts +9 -0
  226. package/types/compiler/dead-code.d.ts.map +1 -0
  227. package/types/compiler/deprecated-library.d.ts.map +1 -1
  228. package/types/compiler/deprecated-lints.d.ts +0 -560
  229. package/types/compiler/deprecated-lints.d.ts.map +1 -1
  230. package/types/compiler/deprecated-ui-props.d.ts +1 -8
  231. package/types/compiler/deprecated-ui-props.d.ts.map +1 -1
  232. package/types/compiler/dom-property.d.ts +9 -0
  233. package/types/compiler/dom-property.d.ts.map +1 -0
  234. package/types/compiler/dom.d.ts +1 -0
  235. package/types/compiler/dom.d.ts.map +1 -1
  236. package/types/compiler/errors.d.ts +2 -2
  237. package/types/compiler/errors.d.ts.map +1 -1
  238. package/types/compiler/fence-checks.d.ts +0 -1
  239. package/types/compiler/fence-checks.d.ts.map +1 -1
  240. package/types/compiler/hand-parts.d.ts +7 -0
  241. package/types/compiler/hand-parts.d.ts.map +1 -0
  242. package/types/compiler/image-attributes.d.ts +0 -1
  243. package/types/compiler/image-attributes.d.ts.map +1 -1
  244. package/types/compiler/index.d.ts.map +1 -1
  245. package/types/compiler/island-arguments.d.ts +2 -11
  246. package/types/compiler/island-arguments.d.ts.map +1 -1
  247. package/types/compiler/island-cause.d.ts +1 -1
  248. package/types/compiler/island-cause.d.ts.map +1 -1
  249. package/types/compiler/island-declaration.d.ts +1 -3
  250. package/types/compiler/island-declaration.d.ts.map +1 -1
  251. package/types/compiler/island-lints.d.ts +10 -0
  252. package/types/compiler/island-lints.d.ts.map +1 -0
  253. package/types/compiler/island-problems.d.ts +7 -0
  254. package/types/compiler/island-problems.d.ts.map +1 -0
  255. package/types/compiler/jsx-class.d.ts +1 -2
  256. package/types/compiler/jsx-class.d.ts.map +1 -1
  257. package/types/compiler/kay-exports.d.ts.map +1 -1
  258. package/types/compiler/link-flags.d.ts +0 -6
  259. package/types/compiler/link-flags.d.ts.map +1 -1
  260. package/types/compiler/lints.d.ts +11 -572
  261. package/types/compiler/lints.d.ts.map +1 -1
  262. package/types/compiler/markup.d.ts +1 -1
  263. package/types/compiler/markup.d.ts.map +1 -1
  264. package/types/compiler/module-signals.d.ts.map +1 -1
  265. package/types/compiler/names.d.ts.map +1 -1
  266. package/types/compiler/page-settings.d.ts +4 -0
  267. package/types/compiler/page-settings.d.ts.map +1 -1
  268. package/types/compiler/parser.d.ts.map +1 -1
  269. package/types/compiler/plan.d.ts.map +1 -1
  270. package/types/compiler/script-server.d.ts.map +1 -1
  271. package/types/compiler/validate.d.ts.map +1 -1
  272. package/types/config-loader.d.ts.map +1 -1
  273. package/types/config-resolve.d.ts.map +1 -1
  274. package/types/config-shape.d.ts +1 -1
  275. package/types/config-shape.d.ts.map +1 -1
  276. package/types/config.d.ts +5 -105
  277. package/types/config.d.ts.map +1 -1
  278. package/types/dev/preload.d.ts.map +1 -1
  279. package/types/lsp/server.d.ts.map +1 -1
  280. package/types/migrate/markup.d.ts.map +1 -1
  281. package/types/runtime/action-call.d.ts.map +1 -1
  282. package/types/runtime/action-encode.d.ts +1 -0
  283. package/types/runtime/action-encode.d.ts.map +1 -1
  284. package/types/runtime/action-error.d.ts +1 -2
  285. package/types/runtime/action-error.d.ts.map +1 -1
  286. package/types/runtime/action-run.d.ts +23 -0
  287. package/types/runtime/action-run.d.ts.map +1 -0
  288. package/types/runtime/action-shared.d.ts +1 -27
  289. package/types/runtime/action-shared.d.ts.map +1 -1
  290. package/types/runtime/action-stream.d.ts.map +1 -1
  291. package/types/runtime/action.d.ts +1 -1
  292. package/types/runtime/action.d.ts.map +1 -1
  293. package/types/runtime/call-result.d.ts +0 -10
  294. package/types/runtime/call-result.d.ts.map +1 -1
  295. package/types/runtime/checks.d.ts +6 -9
  296. package/types/runtime/checks.d.ts.map +1 -1
  297. package/types/runtime/core.d.ts +2 -20
  298. package/types/runtime/core.d.ts.map +1 -1
  299. package/types/runtime/dom.d.ts +1 -1
  300. package/types/runtime/dom.d.ts.map +1 -1
  301. package/types/runtime/html.d.ts +1 -1
  302. package/types/runtime/html.d.ts.map +1 -1
  303. package/types/runtime/i18n.client.d.ts +0 -1
  304. package/types/runtime/i18n.client.d.ts.map +1 -1
  305. package/types/runtime/i18n.d.ts +1 -1
  306. package/types/runtime/i18n.d.ts.map +1 -1
  307. package/types/runtime/i18n.server.d.ts +0 -1
  308. package/types/runtime/i18n.server.d.ts.map +1 -1
  309. package/types/runtime/index.d.ts +2 -2
  310. package/types/runtime/index.d.ts.map +1 -1
  311. package/types/runtime/island.server.d.ts +1 -0
  312. package/types/runtime/island.server.d.ts.map +1 -1
  313. package/types/runtime/live-resource.server.d.ts.map +1 -1
  314. package/types/runtime/live-value.shared.d.ts +7 -15
  315. package/types/runtime/live-value.shared.d.ts.map +1 -1
  316. package/types/runtime/live.d.ts +0 -11
  317. package/types/runtime/live.d.ts.map +1 -1
  318. package/types/runtime/local-types.d.ts +0 -14
  319. package/types/runtime/local-types.d.ts.map +1 -1
  320. package/types/runtime/navigate-api.d.ts +0 -4
  321. package/types/runtime/navigate-api.d.ts.map +1 -1
  322. package/types/runtime/navigation-state.d.ts +0 -4
  323. package/types/runtime/navigation-state.d.ts.map +1 -1
  324. package/types/runtime/page-swap.d.ts.map +1 -1
  325. package/types/runtime/persist.d.ts +1 -0
  326. package/types/runtime/persist.d.ts.map +1 -1
  327. package/types/runtime/persisted.d.ts +0 -15
  328. package/types/runtime/persisted.d.ts.map +1 -1
  329. package/types/runtime/presence.d.ts +0 -2
  330. package/types/runtime/presence.d.ts.map +1 -1
  331. package/types/runtime/query-param.d.ts.map +1 -1
  332. package/types/runtime/reactive.d.ts +2 -1
  333. package/types/runtime/reactive.d.ts.map +1 -1
  334. package/types/runtime/refuse.d.ts +0 -7
  335. package/types/runtime/refuse.d.ts.map +1 -1
  336. package/types/runtime/store-base.d.ts +1 -2
  337. package/types/runtime/store-base.d.ts.map +1 -1
  338. package/types/runtime/values.d.ts +2 -1
  339. package/types/runtime/values.d.ts.map +1 -1
  340. package/types/runtime/with-query.d.ts +2 -0
  341. package/types/runtime/with-query.d.ts.map +1 -1
  342. package/types/server/action-hooks.d.ts +4 -4
  343. package/types/server/action-hooks.d.ts.map +1 -1
  344. package/types/server/actions.d.ts.map +1 -1
  345. package/types/server/api-modules.d.ts +0 -1
  346. package/types/server/api-modules.d.ts.map +1 -1
  347. package/types/server/app-stages.d.ts +5 -13
  348. package/types/server/app-stages.d.ts.map +1 -1
  349. package/types/server/app.d.ts +3 -8
  350. package/types/server/app.d.ts.map +1 -1
  351. package/types/server/auth-mails.d.ts +0 -5
  352. package/types/server/auth-mails.d.ts.map +1 -1
  353. package/types/server/env-state.d.ts +1 -0
  354. package/types/server/env-state.d.ts.map +1 -1
  355. package/types/server/guard-requirement.d.ts +0 -1
  356. package/types/server/guard-requirement.d.ts.map +1 -1
  357. package/types/server/image.d.ts +0 -1
  358. package/types/server/image.d.ts.map +1 -1
  359. package/types/server/index.d.ts +0 -2
  360. package/types/server/index.d.ts.map +1 -1
  361. package/types/server/job-context.d.ts +1 -1
  362. package/types/server/job-context.d.ts.map +1 -1
  363. package/types/server/jobs.d.ts +0 -4
  364. package/types/server/jobs.d.ts.map +1 -1
  365. package/types/server/kept-exports.d.ts.map +1 -1
  366. package/types/server/kv.d.ts +4 -4
  367. package/types/server/kv.d.ts.map +1 -1
  368. package/types/server/library.d.ts +1 -3
  369. package/types/server/library.d.ts.map +1 -1
  370. package/types/server/mcp.d.ts +0 -1
  371. package/types/server/mcp.d.ts.map +1 -1
  372. package/types/server/metrics.d.ts +0 -5
  373. package/types/server/metrics.d.ts.map +1 -1
  374. package/types/server/page-settings.d.ts +3 -3
  375. package/types/server/page-settings.d.ts.map +1 -1
  376. package/types/server/prerender.d.ts.map +1 -1
  377. package/types/server/protection.d.ts +6 -6
  378. package/types/server/protection.d.ts.map +1 -1
  379. package/types/server/queue.d.ts +1 -3
  380. package/types/server/queue.d.ts.map +1 -1
  381. package/types/server/rate-limit.d.ts +0 -2
  382. package/types/server/rate-limit.d.ts.map +1 -1
  383. package/types/server/routes.d.ts +1 -1
  384. package/types/server/routes.d.ts.map +1 -1
  385. package/types/server/scope.d.ts.map +1 -1
  386. package/types/server/session.d.ts +1 -1
  387. package/types/server/session.d.ts.map +1 -1
  388. package/types/server/signals.d.ts.map +1 -1
  389. package/types/server/signed.d.ts +0 -2
  390. package/types/server/signed.d.ts.map +1 -1
  391. package/types/server/source.d.ts +1 -1
  392. package/types/server/source.d.ts.map +1 -1
  393. package/types/server/storage.d.ts +0 -4
  394. package/types/server/storage.d.ts.map +1 -1
  395. package/types/server/vitals.d.ts +0 -1
  396. package/types/server/vitals.d.ts.map +1 -1
  397. package/types/server/work-scope.d.ts +0 -2
  398. package/types/server/work-scope.d.ts.map +1 -1
  399. package/types/server/workflow.d.ts +1 -1
  400. package/types/server/workflow.d.ts.map +1 -1
  401. package/types/test/index.d.ts.map +1 -1
  402. package/types/test/site-actions.d.ts +1 -1
  403. package/types/test/site-actions.d.ts.map +1 -1
  404. package/types/test/site-keys.d.ts +1 -1
  405. package/types/test/site-keys.d.ts.map +1 -1
  406. package/types/test/site-socket.d.ts +1 -1
  407. package/types/test/site-socket.d.ts.map +1 -1
  408. package/types/test/site-types.d.ts +0 -8
  409. package/types/test/site-types.d.ts.map +1 -1
  410. package/llms/deprecated-lints-1-105-libraries.md +0 -32
  411. package/llms/deprecated-lints-1-105.md +0 -58
  412. package/src/check/action-readers.ts +0 -115
  413. package/src/check/action-type.ts +0 -44
  414. package/src/check/ai-language.ts +0 -56
  415. package/src/check/app-hooks.ts +0 -90
  416. package/src/check/auth-methods.ts +0 -85
  417. package/src/check/auth-rate-limits.ts +0 -99
  418. package/src/check/call-result.ts +0 -242
  419. package/src/check/client-keys.ts +0 -10
  420. package/src/check/cms-options.ts +0 -81
  421. package/src/check/config-groups.ts +0 -22
  422. package/src/check/config-switches.ts +0 -38
  423. package/src/check/context-import.ts +0 -51
  424. package/src/check/env-files.ts +0 -31
  425. package/src/check/format-duration.ts +0 -75
  426. package/src/check/guard-options.ts +0 -58
  427. package/src/check/handler-events.ts +0 -149
  428. package/src/check/hook-context.ts +0 -94
  429. package/src/check/hook-names.ts +0 -104
  430. package/src/check/i18n-keys.ts +0 -50
  431. package/src/check/images-keys.ts +0 -54
  432. package/src/check/job-shapes.ts +0 -273
  433. package/src/check/link-flag-tests.ts +0 -130
  434. package/src/check/live-api.ts +0 -137
  435. package/src/check/mail-api.ts +0 -67
  436. package/src/check/one-state-api.ts +0 -357
  437. package/src/check/pages-options.ts +0 -35
  438. package/src/check/rate-enforce.ts +0 -53
  439. package/src/check/refusal-calls.ts +0 -185
  440. package/src/check/retired-lints.ts +0 -49
  441. package/src/check/route-keys.ts +0 -166
  442. package/src/check/secret-keys.ts +0 -83
  443. package/src/check/socket-frames.ts +0 -102
  444. package/src/check/source-readers.ts +0 -257
  445. package/src/check/store-ms.ts +0 -72
  446. package/src/check/store-names.ts +0 -88
  447. package/src/check/test-helpers.ts +0 -98
  448. package/src/check/ttl-names.ts +0 -142
  449. package/src/compiler/deprecated-ai-labels.ts +0 -97
  450. package/src/compiler/deprecated-ai-links.ts +0 -63
  451. package/src/compiler/deprecated-allow.ts +0 -50
  452. package/src/compiler/deprecated-auth-lints.ts +0 -14
  453. package/src/compiler/deprecated-auth-signed.ts +0 -29
  454. package/src/compiler/deprecated-children.ts +0 -66
  455. package/src/compiler/deprecated-image.ts +0 -116
  456. package/src/compiler/deprecated-island.ts +0 -155
  457. package/src/compiler/deprecated-lints-1-105.ts +0 -41
  458. package/src/compiler/deprecated-page.ts +0 -125
  459. package/src/compiler/deprecated-parts.ts +0 -22
  460. package/src/compiler/deprecated-typed-lints.ts +0 -23
  461. package/src/compiler/deprecated-ui-callbacks.ts +0 -66
  462. package/src/compiler/deprecated-ui-input.ts +0 -97
  463. package/src/compiler/deprecated-ui-items.ts +0 -47
  464. package/src/compiler/old-parts.ts +0 -84
  465. package/src/runtime/mount.compat.ts +0 -8
  466. package/src/server/moved-exports.ts +0 -17
  467. package/types/check/action-readers.d.ts +0 -3
  468. package/types/check/action-readers.d.ts.map +0 -1
  469. package/types/check/action-type.d.ts +0 -3
  470. package/types/check/action-type.d.ts.map +0 -1
  471. package/types/check/ai-language.d.ts +0 -3
  472. package/types/check/ai-language.d.ts.map +0 -1
  473. package/types/check/app-hooks.d.ts +0 -3
  474. package/types/check/app-hooks.d.ts.map +0 -1
  475. package/types/check/auth-methods.d.ts +0 -3
  476. package/types/check/auth-methods.d.ts.map +0 -1
  477. package/types/check/auth-rate-limits.d.ts +0 -3
  478. package/types/check/auth-rate-limits.d.ts.map +0 -1
  479. package/types/check/call-result.d.ts +0 -7
  480. package/types/check/call-result.d.ts.map +0 -1
  481. package/types/check/client-keys.d.ts +0 -3
  482. package/types/check/client-keys.d.ts.map +0 -1
  483. package/types/check/cms-options.d.ts +0 -3
  484. package/types/check/cms-options.d.ts.map +0 -1
  485. package/types/check/config-groups.d.ts +0 -3
  486. package/types/check/config-groups.d.ts.map +0 -1
  487. package/types/check/config-switches.d.ts +0 -3
  488. package/types/check/config-switches.d.ts.map +0 -1
  489. package/types/check/context-import.d.ts +0 -3
  490. package/types/check/context-import.d.ts.map +0 -1
  491. package/types/check/env-files.d.ts +0 -3
  492. package/types/check/env-files.d.ts.map +0 -1
  493. package/types/check/format-duration.d.ts +0 -5
  494. package/types/check/format-duration.d.ts.map +0 -1
  495. package/types/check/guard-options.d.ts +0 -3
  496. package/types/check/guard-options.d.ts.map +0 -1
  497. package/types/check/handler-events.d.ts +0 -9
  498. package/types/check/handler-events.d.ts.map +0 -1
  499. package/types/check/hook-context.d.ts +0 -3
  500. package/types/check/hook-context.d.ts.map +0 -1
  501. package/types/check/hook-names.d.ts +0 -3
  502. package/types/check/hook-names.d.ts.map +0 -1
  503. package/types/check/i18n-keys.d.ts +0 -3
  504. package/types/check/i18n-keys.d.ts.map +0 -1
  505. package/types/check/images-keys.d.ts +0 -3
  506. package/types/check/images-keys.d.ts.map +0 -1
  507. package/types/check/job-shapes.d.ts +0 -6
  508. package/types/check/job-shapes.d.ts.map +0 -1
  509. package/types/check/link-flag-tests.d.ts +0 -4
  510. package/types/check/link-flag-tests.d.ts.map +0 -1
  511. package/types/check/live-api.d.ts +0 -3
  512. package/types/check/live-api.d.ts.map +0 -1
  513. package/types/check/mail-api.d.ts +0 -3
  514. package/types/check/mail-api.d.ts.map +0 -1
  515. package/types/check/one-state-api.d.ts +0 -9
  516. package/types/check/one-state-api.d.ts.map +0 -1
  517. package/types/check/pages-options.d.ts +0 -3
  518. package/types/check/pages-options.d.ts.map +0 -1
  519. package/types/check/rate-enforce.d.ts +0 -3
  520. package/types/check/rate-enforce.d.ts.map +0 -1
  521. package/types/check/refusal-calls.d.ts +0 -3
  522. package/types/check/refusal-calls.d.ts.map +0 -1
  523. package/types/check/retired-lints.d.ts +0 -3
  524. package/types/check/retired-lints.d.ts.map +0 -1
  525. package/types/check/route-keys.d.ts +0 -3
  526. package/types/check/route-keys.d.ts.map +0 -1
  527. package/types/check/secret-keys.d.ts +0 -3
  528. package/types/check/secret-keys.d.ts.map +0 -1
  529. package/types/check/socket-frames.d.ts +0 -3
  530. package/types/check/socket-frames.d.ts.map +0 -1
  531. package/types/check/source-readers.d.ts +0 -3
  532. package/types/check/source-readers.d.ts.map +0 -1
  533. package/types/check/store-ms.d.ts +0 -3
  534. package/types/check/store-ms.d.ts.map +0 -1
  535. package/types/check/store-names.d.ts +0 -3
  536. package/types/check/store-names.d.ts.map +0 -1
  537. package/types/check/test-helpers.d.ts +0 -3
  538. package/types/check/test-helpers.d.ts.map +0 -1
  539. package/types/check/ttl-names.d.ts +0 -3
  540. package/types/check/ttl-names.d.ts.map +0 -1
  541. package/types/compiler/deprecated-ai-labels.d.ts +0 -5
  542. package/types/compiler/deprecated-ai-labels.d.ts.map +0 -1
  543. package/types/compiler/deprecated-ai-links.d.ts +0 -5
  544. package/types/compiler/deprecated-ai-links.d.ts.map +0 -1
  545. package/types/compiler/deprecated-allow.d.ts +0 -5
  546. package/types/compiler/deprecated-allow.d.ts.map +0 -1
  547. package/types/compiler/deprecated-auth-lints.d.ts +0 -12
  548. package/types/compiler/deprecated-auth-lints.d.ts.map +0 -1
  549. package/types/compiler/deprecated-auth-signed.d.ts +0 -5
  550. package/types/compiler/deprecated-auth-signed.d.ts.map +0 -1
  551. package/types/compiler/deprecated-children.d.ts +0 -4
  552. package/types/compiler/deprecated-children.d.ts.map +0 -1
  553. package/types/compiler/deprecated-image.d.ts +0 -5
  554. package/types/compiler/deprecated-image.d.ts.map +0 -1
  555. package/types/compiler/deprecated-island.d.ts +0 -9
  556. package/types/compiler/deprecated-island.d.ts.map +0 -1
  557. package/types/compiler/deprecated-lints-1-105.d.ts +0 -39
  558. package/types/compiler/deprecated-lints-1-105.d.ts.map +0 -1
  559. package/types/compiler/deprecated-page.d.ts +0 -4
  560. package/types/compiler/deprecated-page.d.ts.map +0 -1
  561. package/types/compiler/deprecated-parts.d.ts +0 -3
  562. package/types/compiler/deprecated-parts.d.ts.map +0 -1
  563. package/types/compiler/deprecated-typed-lints.d.ts +0 -21
  564. package/types/compiler/deprecated-typed-lints.d.ts.map +0 -1
  565. package/types/compiler/deprecated-ui-callbacks.d.ts +0 -5
  566. package/types/compiler/deprecated-ui-callbacks.d.ts.map +0 -1
  567. package/types/compiler/deprecated-ui-input.d.ts +0 -5
  568. package/types/compiler/deprecated-ui-input.d.ts.map +0 -1
  569. package/types/compiler/deprecated-ui-items.d.ts +0 -5
  570. package/types/compiler/deprecated-ui-items.d.ts.map +0 -1
  571. package/types/compiler/old-parts.d.ts +0 -9
  572. package/types/compiler/old-parts.d.ts.map +0 -1
  573. package/types/runtime/mount.compat.d.ts +0 -7
  574. package/types/runtime/mount.compat.d.ts.map +0 -1
  575. package/types/server/moved-exports.d.ts +0 -12
  576. package/types/server/moved-exports.d.ts.map +0 -1
@@ -1,273 +0,0 @@
1
- import type { CheckDiagnostic, CheckOptions } from '.'
2
- import type { Node, NodeOfType } from '../compiler/estree'
3
- import type { Edit, Found } from './renamed-exports'
4
- import { lintLevel } from '../compiler/lints'
5
- import { keyName } from '../compiler/object-literal'
6
- import { DURATION_TEXT } from '../runtime/duration'
7
- import { importsOf, walk } from './ast'
8
- import { renamedCallOptions } from './renamed-call-options'
9
- import { scan } from './renamed-exports'
10
-
11
- const FROM_SERVER = (source: string) => source === 'kay/server' || source === '@kayjs/kay/server'
12
- const JOBS = /\b(?:queue|workflow|schedule|background)\b/
13
- const UNDERSCORE = /(?<![\w$])_(?:input)?(?![\w$])/
14
- const SCHEDULE = /\bschedule\b/
15
- const LOST_AFTER = /\blostAfter\b/
16
- const DISK_FILES = /\bdiskFiles\b/
17
- const COMMENT = /\/[*/]/
18
- const SIGNAL_NAME = /signal|abort/i
19
- const JOB_CALLS = ['queue', 'workflow', 'schedule', 'background'] as const
20
-
21
- type CallNode = NodeOfType<'CallExpression'>
22
- type FunctionNode = NodeOfType<'ArrowFunctionExpression'> | NodeOfType<'FunctionExpression'>
23
- type Param = FunctionNode['params'][number]
24
-
25
- const isFunction = (node: Node | undefined): node is FunctionNode => node?.type === 'ArrowFunctionExpression' || node?.type === 'FunctionExpression'
26
-
27
- // The job function a call of `queue`, `workflow`, `schedule` or `background` from `kay/server` is: its name, as it was imported or read off `import * as`.
28
- function jobCall(ast: Parameters<typeof importsOf>[0]): (callee: Node) => (typeof JOB_CALLS)[number] | undefined {
29
- const bound = JOB_CALLS.map(name => ({ name, ...importsOf(ast, FROM_SERVER, name) })).filter(call => call.locals.size > 0 || call.namespaces.size > 0)
30
-
31
- return callee => bound.find(call => callee.type === 'Identifier'
32
- ? call.locals.has(callee.name)
33
- : callee.type === 'MemberExpression' && !callee.computed && callee.object.type === 'Identifier' && call.namespaces.has(callee.object.name) && callee.property.type === 'Identifier' && callee.property.name === call.name)?.name
34
- }
35
-
36
- // Whether a parameter is a plain name, with no default, no `?` and no annotation but `AbortSignal` when `signal` allows it.
37
- function plainName(param: Param | undefined, signal = false): param is NodeOfType<'Identifier'> {
38
- if (param?.type !== 'Identifier' || param.optional)
39
- return false
40
-
41
- const annotation = param.typeAnnotation?.typeAnnotation
42
-
43
- if (annotation === undefined)
44
- return true
45
-
46
- return signal && annotation.type === 'TSTypeReference' && annotation.typeName.type === 'Identifier' && annotation.typeName.name === 'AbortSignal' && annotation.typeArguments == null
47
- }
48
-
49
- // Whether a parameter reads as the signal of the old shape: named like one, or annotated `AbortSignal`, and not a context.
50
- function signalLike(param: NodeOfType<'Identifier'>): boolean {
51
- const annotation = param.typeAnnotation?.typeAnnotation
52
-
53
- if (annotation == null)
54
- return SIGNAL_NAME.test(param.name)
55
-
56
- return annotation.type === 'TSTypeReference' && annotation.typeName.type === 'Identifier' && annotation.typeName.name === 'AbortSignal'
57
- }
58
-
59
- const binding = (name: string, key: string) => name === key ? key : `${key}: ${name}`
60
-
61
- // The handlers a call of one of the four hands over, where the handler is: a queue's or workflow's second argument, a background job's first, a schedule's jobs, the second argument, a list of them or the values of a table.
62
- function handlersOf(call: CallNode, name: (typeof JOB_CALLS)[number]): FunctionNode[] {
63
- const args = call.arguments
64
-
65
- if (name === 'queue' || name === 'workflow')
66
- return isFunction(args[1]) ? [args[1]] : []
67
-
68
- if (name === 'background')
69
- return isFunction(args[0]) ? [args[0]] : []
70
-
71
- const listed = (node: Node | undefined): FunctionNode[] => {
72
- if (isFunction(node))
73
- return [node]
74
-
75
- return node?.type === 'ArrayExpression' ? node.elements.filter((element): element is FunctionNode => isFunction(element ?? undefined)) : []
76
- }
77
-
78
- const [first] = args
79
-
80
- if (first?.type === 'ObjectExpression' && !first.properties.some(property => property.type === 'Property' && ['every', 'cron'].includes(keyName(property) ?? '')))
81
- return first.properties.flatMap(property => property.type === 'Property' ? listed(property.value) : [])
82
-
83
- return listed(args[1])
84
- }
85
-
86
- // The edits giving a queue handler `(payload, { signal, job })` for `(payload, signal, job)`, null where the parameters are not plain names.
87
- function queueEdits(fn: FunctionNode, base: number): Edit[] | null | undefined {
88
- const [, signal, job] = fn.params
89
-
90
- if (signal === undefined || signal.type !== 'Identifier' || (fn.params.length < 3 && !signalLike(signal)))
91
- return undefined
92
-
93
- if (fn.params.length > 3 || !plainName(signal, true) || (job !== undefined && !plainName(job)))
94
- return null
95
-
96
- const text = `{ ${[binding(signal.name, 'signal'), ...job === undefined ? [] : [binding((job as NodeOfType<'Identifier'>).name, 'job')]].join(', ')} }`
97
-
98
- return [{ start: base + signal.start, end: base + (job ?? signal).end, text }]
99
- }
100
-
101
- // The edits giving a workflow `(input, { step, job: { id } })` for `({ id, input, step })`.
102
- function workflowEdits(fn: FunctionNode, base: number): Edit[] | null | undefined {
103
- const [run] = fn.params
104
-
105
- if (run?.type !== 'ObjectPattern' || fn.params.length > 1)
106
- return undefined
107
-
108
- const keys = run.properties.map(property => property.type === 'Property' ? keyName(property) : undefined)
109
-
110
- if (!keys.some(key => key === 'step' || key === 'input'))
111
- return undefined
112
-
113
- if (run.typeAnnotation != null || run.properties.some((property, at) => property.type !== 'Property' || property.computed || !['id', 'input', 'step'].includes(keys[at]!) || property.value.type !== 'Identifier'))
114
- return null
115
-
116
- const names = new Map(run.properties.map(property => [keyName(property as NodeOfType<'Property'>)!, (property as NodeOfType<'Property'> & { value: NodeOfType<'Identifier'> }).value.name]))
117
- const context = [...names.has('step') ? [binding(names.get('step')!, 'step')] : [], ...names.has('id') ? [`job: { ${binding(names.get('id')!, 'id')} }`] : []]
118
-
119
- return [{ start: base + run.start, end: base + run.end, text: `${names.get('input') ?? '_input'}${context.length === 0 ? '' : `, { ${context.join(', ')} }`}` }]
120
- }
121
-
122
- // The edits giving a scheduled or background job `(_, { signal })` for `(signal)`.
123
- function signalEdits(fn: FunctionNode, base: number, source: string): Edit[] | null | undefined {
124
- const [signal] = fn.params
125
-
126
- if (fn.params.length !== 1 || signal?.type !== 'Identifier' || !signalLike(signal))
127
- return undefined
128
-
129
- if (!plainName(signal, true))
130
- return null
131
-
132
- // An arrow function written `signal => ...` needs the parentheses two parameters take.
133
- const text = `_, { ${binding(signal.name, 'signal')} }`
134
- const bare = source.slice(0, base + signal.start).trimEnd().at(-1) !== '('
135
-
136
- return [{ start: base + signal.start, end: base + signal.end, text: bare ? `(${text})` : text }]
137
- }
138
-
139
- function editsOf(fn: FunctionNode, name: (typeof JOB_CALLS)[number], base: number, source: string): Edit[] | null | undefined {
140
- if (name === 'queue')
141
- return queueEdits(fn, base)
142
-
143
- const edits = name === 'workflow' ? workflowEdits(fn, base) : signalEdits(fn, base, source)
144
-
145
- // The fix adds an unused parameter named `_` or `_input`, which would shadow one the body reads.
146
- return edits && UNDERSCORE.test(source.slice(base + fn.body!.start, base + fn.body!.end)) ? null : edits
147
- }
148
-
149
- // The options written after a first argument, as the properties of the new object or, for any other expression, spread into it.
150
- function spreadOf(source: string, base: number, options: Node | undefined): string[] {
151
- if (options === undefined)
152
- return []
153
-
154
- if (options.type === 'ObjectExpression')
155
- return options.properties.map(property => source.slice(base + property.start, base + property.end))
156
-
157
- return [`...${source.slice(base + options.start, base + options.end)}`]
158
- }
159
-
160
- // A handler written before 1.105, which gets its signal and its job as arguments of their own: `queue(name, (payload, signal, job) => ...)`, `workflow(name, ({ id, input, step }) => ...)`, `schedule(when, (signal) => ...)` and `background((signal) => ...)`.
161
- // Every job handler is `(input, ctx)` since 1.105, with `ctx.signal`, `ctx.job`, `ctx.log`, `ctx.locale` and a workflow's `ctx.step`. Found on a handler written inline in the call, where its parameters are plain names; the fix destructures them off the context, so the body reads them under the names it used. A queue handler written in the old shape still runs, as its second argument is the signal; a workflow's, a schedule's and a background job's does not.
162
- export async function jobHandlers(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
163
- if (lintLevel('deprecated-job-handler', options.lints) === 'allow')
164
- return []
165
-
166
- return scan(root, options, 'deprecated-job-handler', JOBS, ({ source, parsed, report }) => {
167
- for (const { ast, base } of parsed) {
168
- const named = jobCall(ast)
169
-
170
- walk(ast, (node) => {
171
- if (node.type !== 'CallExpression')
172
- return
173
-
174
- const name = named(node.callee)
175
-
176
- if (name === undefined)
177
- return
178
-
179
- for (const fn of handlersOf(node, name)) {
180
- const edits = editsOf(fn, name, base, source)
181
-
182
- if (edits === undefined)
183
- continue
184
-
185
- // A comment in a range the fix replaces would be lost with it.
186
- const lost = edits?.some(edit => COMMENT.test(source.slice(edit.start, edit.end)))
187
-
188
- report(base + fn.params[0]!.start, base + fn.params.at(-1)!.end, `the handler of \`${name}()\` is \`(input, ctx)\` since 1.105: its signal and job are read off \`ctx\``, 'take `ctx` and read `signal`, `job`, `log` and `locale` off it', lost ? null : edits)
189
- }
190
- })
191
- }
192
- })
193
- }
194
-
195
- // `schedule(when, job, options)`, `schedule({ cron | every, ...options }, job)` since 1.105: one shape, the schedule and its options in one object, as `queue` and `workflow` keep theirs in one.
196
- // Found on a call of `schedule` from `kay/server` whose first argument is a string or number literal; the fix writes `every` for a length and `cron` for the rest, and spreads the options after it.
197
- export async function scheduleCalls(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
198
- if (lintLevel('deprecated-schedule-call', options.lints) === 'allow')
199
- return []
200
-
201
- return scan(root, options, 'deprecated-schedule-call', SCHEDULE, ({ source, parsed, report }) => {
202
- for (const { ast, base } of parsed) {
203
- const named = jobCall(ast)
204
-
205
- walk(ast, (node) => {
206
- if (node.type !== 'CallExpression' || named(node.callee) !== 'schedule')
207
- return
208
-
209
- const [when, job, rest] = node.arguments
210
-
211
- if (when?.type !== 'Literal' || (typeof when.value !== 'string' && typeof when.value !== 'number') || job === undefined || node.arguments.length > 3 || node.arguments.some(argument => argument.type === 'SpreadElement'))
212
- return
213
-
214
- const key = typeof when.value === 'number' || DURATION_TEXT.test(when.value) ? 'every' : 'cron'
215
- const spread = spreadOf(source, base, rest)
216
-
217
- const edits: Edit[] = [{ start: base + when.start, end: base + when.end, text: `{ ${[`${key}: ${source.slice(base + when.start, base + when.end)}`, ...spread].join(', ')} }` }]
218
-
219
- if (rest !== undefined)
220
- edits.push({ start: base + job.end, end: base + rest.end, text: '' })
221
-
222
- const lost = rest !== undefined && COMMENT.test(source.slice(base + job.end, base + rest.end))
223
-
224
- report(base + when.start, base + when.end, '`schedule(when, job, options)` is deprecated since 1.105: the schedule and its options are one object', `write \`schedule({ ${key}: ... }, job)\``, lost ? null : edits)
225
- })
226
- }
227
- })
228
- }
229
-
230
- // `lostAfter` in the options of `queue()` or `workflow()`, `timeout` since 1.105: the one name of a job's time limit, as a schedule's.
231
- export async function jobOptions(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
232
- return renamedCallOptions(root, options, { lint: 'deprecated-job-options', needle: LOST_AFTER, from: FROM_SERVER, calls: { queue: 2, workflow: 2 }, renames: [['lostAfter', 'timeout']], since: '1.105', of: '`queue()` and `workflow()`' })
233
- }
234
-
235
- // `diskFiles(dir, hooks)`, `diskFiles({ dir, ...hooks })` since 1.105: the options of every file store are one object, as `s3Files({ ...settings, ...hooks })` and `memoryFiles({ ...hooks })` take them.
236
- export async function diskFilesCalls(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
237
- if (lintLevel('deprecated-disk-files', options.lints) === 'allow')
238
- return []
239
-
240
- return scan(root, options, 'deprecated-disk-files', DISK_FILES, ({ source, parsed, report }: Found) => {
241
- for (const { ast, base } of parsed) {
242
- const { locals, namespaces } = importsOf(ast, FROM_SERVER, 'diskFiles')
243
-
244
- if (locals.size === 0 && namespaces.size === 0)
245
- continue
246
-
247
- walk(ast, (node) => {
248
- if (node.type !== 'CallExpression' || node.arguments.length === 0 || node.arguments.length > 2 || node.arguments.some(argument => argument.type === 'SpreadElement'))
249
- return
250
-
251
- const { callee } = node
252
- const isDisk = callee.type === 'Identifier'
253
- ? locals.has(callee.name)
254
- : callee.type === 'MemberExpression' && !callee.computed && callee.object.type === 'Identifier' && namespaces.has(callee.object.name) && callee.property.type === 'Identifier' && callee.property.name === 'diskFiles'
255
- const [dir, hooks] = node.arguments
256
-
257
- // A string is the old form; an object, or any other expression that may hold one, is the new.
258
- const oldForm = node.arguments.length === 2 || dir!.type === 'TemplateLiteral' || (dir!.type === 'Literal' && typeof dir!.value === 'string')
259
-
260
- if (!isDisk || !oldForm)
261
- return
262
-
263
- const spread = spreadOf(source, base, hooks)
264
-
265
- const last = hooks ?? dir!
266
- const text = `{ ${[`dir: ${source.slice(base + dir!.start, base + dir!.end)}`, ...spread].join(', ')} }`
267
- const lost = COMMENT.test(source.slice(base + dir!.start, base + last.end))
268
-
269
- report(base + dir!.start, base + last.end, '`diskFiles(dir, hooks)` is deprecated since 1.105: the options of a file store are one object', 'write `diskFiles({ dir, ...hooks })`', lost ? null : [{ start: base + dir!.start, end: base + last.end, text }])
270
- })
271
- }
272
- })
273
- }
@@ -1,130 +0,0 @@
1
- import type { CheckDiagnostic } from '.'
2
- import type { Fix } from '../compiler/ast'
3
- import type { Node } from '../compiler/estree'
4
- import type { LintLevels } from '../compiler/lints'
5
- import { findProjectFiles } from '../build/files'
6
- import { parseProgram } from '../compiler/estree'
7
- import { OLD_LINK_FLAGS } from '../compiler/link-flags'
8
- import { lintLevel } from '../compiler/lints'
9
- import { childrenOf } from './ast'
10
-
11
- const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$/
12
- const OLD_FLAG = new RegExp(`(?<![\\w-])(${Object.keys(OLD_LINK_FLAGS).join('|')})(?![\\w-])`, 'g')
13
- const DATASET_END = /dataset$/
14
- const ATTRIBUTE_CALL = /\.(?:get|has|set|remove|toggle)Attribute\(\s*$/
15
-
16
- // The `dataset` property of each old flag: `data-keep-scroll` is `keepScroll`.
17
- const DATASET_NAMES = new Map(Object.keys(OLD_LINK_FLAGS).map(name => [name.slice(5).replace(/-(\w)/g, (_, letter: string) => letter.toUpperCase()), name]))
18
-
19
- interface Scanned {
20
- // The content of each string literal and template chunk, as `[start, end]` offsets.
21
- strings: [number, number][]
22
- // The `x.dataset.<flag>` member expressions, and whether each is assigned, updated or deleted.
23
- datasets: { node: Node, written: boolean, direct: boolean }[]
24
- }
25
-
26
- const WRAPPERS = new Set(['ChainExpression', 'TSNonNullExpression', 'ParenthesizedExpression'])
27
-
28
- // The expression under any wrappers.
29
- function unwrapped(node: Node): Node {
30
- let inner = node
31
-
32
- while (inner.type === 'ChainExpression' || inner.type === 'TSNonNullExpression' || inner.type === 'ParenthesizedExpression')
33
- inner = inner.expression
34
-
35
- return inner
36
- }
37
-
38
- function isDataset(node: Node): boolean {
39
- const inner = unwrapped(node)
40
-
41
- return inner.type === 'MemberExpression' && !inner.computed && inner.property.type === 'Identifier' && inner.property.name === 'dataset'
42
- }
43
-
44
- // What the parsed program holds that names a flag, so a regex literal or a comment cannot shift what is a string.
45
- function scan(source: string): Scanned {
46
- const found: Scanned = { strings: [], datasets: [] }
47
- const visit = (node: Node, ancestors: Node[]) => {
48
- if (node.type === 'Literal' && typeof node.value === 'string') {
49
- found.strings.push([node.start + 1, node.end - 1])
50
- }
51
- else if (node.type === 'TemplateElement') {
52
- // The span holds its delimiters: a backtick or `}` before, a backtick or `${` after.
53
- found.strings.push([node.start + 1, node.end - (source[node.end - 1] === '`' ? 1 : 2)])
54
- }
55
- else if (node.type === 'MemberExpression' && !node.computed && node.property.type === 'Identifier' && DATASET_NAMES.has(node.property.name) && isDataset(node.object)) {
56
- // Through `?.`, `!` and parentheses: `delete el?.dataset.keepScroll` and `el.dataset!.keepScroll = 1` write it.
57
- let at = ancestors.length - 1
58
- let target: Node = node
59
-
60
- while (at >= 0 && WRAPPERS.has(ancestors[at]!.type))
61
- target = ancestors[at--]!
62
-
63
- const parent = ancestors[at]
64
- const assigned = parent?.type === 'AssignmentExpression' && parent.left === target
65
-
66
- found.datasets.push({ node, written: assigned || parent?.type === 'UpdateExpression' || (parent?.type === 'UnaryExpression' && parent.operator === 'delete'), direct: unwrapped(node.object) === node.object })
67
- }
68
-
69
- for (const child of childrenOf(node))
70
- visit(child, [...ancestors, node])
71
- }
72
-
73
- visit(parseProgram(source, { lang: 'ts', recover: true }).program, [])
74
-
75
- return found
76
- }
77
-
78
- // The selectors, attribute reads and `dataset` reads of an app's test files that name a link flag by its name before 1.105, which `deprecated-link-flags` rewrites in the templates: `[data-keep-scroll]` is written `[data-scroll=keep]`, as the template's attribute was.
79
- // An attribute read by name (`getAttribute('data-keep-scroll')`) and a read of `dataset.keepScroll` get a fix that is not safe, as the new name holds a word where the old one was there or not; any other string naming the flag (a selector with a value, one built in a template) and a write of `dataset` are reported with no fix.
80
- export async function linkFlagTests(root: string, levels: LintLevels | undefined): Promise<CheckDiagnostic[]> {
81
- const level = lintLevel('deprecated-link-flags', levels)
82
-
83
- if (level === 'allow')
84
- return []
85
-
86
- const found: CheckDiagnostic[] = []
87
-
88
- for (const file of (await findProjectFiles(root, TEST_FILE, { project: true, ownKayOnly: true })).sort()) {
89
- const source = await Bun.file(file).text()
90
- const { strings, datasets } = scan(source)
91
- const report = (start: number, end: number, message: string, help: string, fixes: Fix[] | undefined) => {
92
- const before = source.slice(0, start).split('\n')
93
-
94
- found.push({ file, line: before.length, column: before.at(-1)!.length + 1, end, severity: level === 'warn' ? 'warning' : 'error', code: 'deprecated-link-flags', message, help, ...fixes === undefined ? {} : { fixes } })
95
- }
96
-
97
- for (const match of source.matchAll(OLD_FLAG)) {
98
- const name = match[1]!
99
- const end = match.index + name.length
100
- const string = strings.find(([from, to]) => match.index >= from && end <= to)
101
-
102
- if (string === undefined)
103
- continue
104
-
105
- const next = OLD_LINK_FLAGS[name]!
106
- const written = `${next.name}=${next.value}`
107
- const selector = source[match.index - 1] === '[' && source[end] === ']'
108
- const read = !selector && string[1] - string[0] === name.length && ATTRIBUTE_CALL.test(source.slice(Math.max(0, string[0] - 201), string[0] - 1))
109
- let fixes: Fix[] | undefined
110
-
111
- if (selector)
112
- fixes = [{ title: `write [${written}]`, safe: true, edits: [{ start: match.index - 1, end: end + 1, text: `[${written}]` }] }]
113
- else if (read)
114
- fixes = [{ title: `write ${next.name}`, safe: false, edits: [{ start: match.index, end, text: next.name }] }]
115
-
116
- report(match.index, end, `\`${name}\` is \`${written}\`, deprecated since 1.105: a template written with the new attribute no longer matches this`, `select \`[${written}]\`; an attribute read follows the new name, whose value is \`${next.value}\` where the old one was present`, fixes)
117
- }
118
-
119
- for (const { node, written, direct } of datasets) {
120
- const member = node as Node & { object: Node, property: Node & { name: string } }
121
- const old = OLD_LINK_FLAGS[DATASET_NAMES.get(member.property.name)!]!
122
- const to = `dataset.${old.name.slice(5)} === '${old.value}'`
123
- const fixes: Fix[] | undefined = written || !direct ? undefined : [{ title: `write ${to}`, safe: false, edits: [{ start: node.start, end: node.end, text: `(${source.slice(member.object.start, member.object.end).replace(DATASET_END, '')}${to})` }] }]
124
-
125
- report(node.start, node.end, `\`dataset.${member.property.name}\` is \`${to}\`, deprecated since 1.105: the template's attribute is \`${old.name}\``, `read \`${to}\`; a write is set on \`${old.name}\` by hand`, fixes)
126
- }
127
- }
128
-
129
- return found.sort((a, b) => a.file.localeCompare(b.file) || a.line - b.line || a.column - b.column)
130
- }
@@ -1,137 +0,0 @@
1
- import type { CheckDiagnostic, CheckOptions } from '.'
2
- import type { Node, Program } from '../compiler/estree'
3
- import type { Edit } from './renamed-exports'
4
- import { lintLevel } from '../compiler/lints'
5
- import { unwrapped } from '../compiler/object-literal'
6
- import { importedName, importsOf, walk } from './ast'
7
- import { bindings, boundOnce } from './bindings'
8
- import { scan } from './renamed-exports'
9
-
10
- type Kind = 'plain' | 'key' | 'user' | 'unknown'
11
-
12
- const LIVE_CALL = /\blive\s*[(<]/
13
- const PROJECT_SOURCE = /^(?:[./#~]|@\/)/
14
- const SPECIAL = /[$.*+?^{}()|[\]\\]/g
15
-
16
- // What a declaration `live(initial, options)` is: a value per key given a function of it or `key: true`, per user given `user: true`, and unknown when the options are no object written there.
17
- function kindOf(call: Node): Kind {
18
- if (call.type !== 'CallExpression')
19
- return 'unknown'
20
-
21
- const [initial, options] = call.arguments
22
-
23
- if (options !== undefined && options.type !== 'ObjectExpression')
24
- return 'unknown'
25
-
26
- const flag = (name: string) => options?.type === 'ObjectExpression' && options.properties.some(property => property.type === 'Property' && !property.computed && property.key.type === 'Identifier' && property.key.name === name && property.value.type === 'Literal' && property.value.value === true)
27
-
28
- if (flag('user'))
29
- return 'user'
30
-
31
- return flag('key') || initial?.type === 'ArrowFunctionExpression' || initial?.type === 'FunctionExpression' ? 'key' : 'plain'
32
- }
33
-
34
- // The live values a program declares, by the name they are bound to once.
35
- function declared(ast: Program): Map<string, Kind> {
36
- const names = bindings(ast)
37
- const known = boundOnce(ast, names, 'live')
38
- const kinds = new Map<string, Kind>()
39
-
40
- walk(ast, (node) => {
41
- if (node.type === 'VariableDeclarator' && node.id.type === 'Identifier' && node.init && known.has(node.id.name))
42
- kinds.set(node.id.name, kindOf(unwrapped(node.init)))
43
- })
44
-
45
- return kinds
46
- }
47
-
48
- // The text of an argument as the property of an options object: `{ key }` for an identifier of that name.
49
- function property(name: string, argument: Node, text: string): string {
50
- return argument.type === 'Identifier' && argument.name === name ? name : `${name}: ${text.slice(argument.start, argument.end)}`
51
- }
52
-
53
- // Whether the second argument of a `set` is the options of the new form, an object holding only `field`.
54
- function isOptions(argument: Node, field: string): boolean {
55
- return argument.type === 'ObjectExpression' && argument.properties.length === 1 && argument.properties[0]!.type === 'Property' && !argument.properties[0]!.computed && argument.properties[0]!.key.type === 'Identifier' && argument.properties[0]!.key.name === field
56
- }
57
-
58
- // What live values and `presence` take since 1.105: `set(next, { key })` and `set(next, { user })` in place of `set(key, next)`, and `presence({ room, member })` in place of `presence(room, member)`.
59
- // A value is known by a name the file binds once to a `live()` call from `kay`, or imports under the name of a declaration of the project that every file agrees on, as `kay check` reads no types; `presence` is the one imported from `kay`.
60
- export async function liveApi(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
61
- if (lintLevel('deprecated-live-api', options.lints) === 'allow')
62
- return []
63
-
64
- // The kinds each declared name is given across the project, so an import of it is known.
65
- const everywhere = new Map<string, Set<Kind>>()
66
-
67
- await scan(root, options, 'deprecated-live-api', LIVE_CALL, ({ parsed }) => {
68
- for (const { ast } of parsed) {
69
- for (const [name, kind] of declared(ast))
70
- (everywhere.get(name) ?? everywhere.set(name, new Set()).get(name)!).add(kind)
71
- }
72
- })
73
-
74
- // A file is read when it names a live value declared in the project, whatever else it holds, as `live` is written where it is declared.
75
- const named = [...everywhere.keys()].map(name => name.replace(SPECIAL, String.raw`\$&`))
76
- const needle = new RegExp(`\\b(?:live|presence${named.map(name => `|${name}`).join('')})\\b`)
77
-
78
- return scan(root, options, 'deprecated-live-api', needle, ({ parsed, report }) => {
79
- for (const { ast, base, text } of parsed) {
80
- const receivers = declared(ast)
81
- const names = bindings(ast)
82
-
83
- for (const statement of ast.body) {
84
- if (statement.type !== 'ImportDeclaration' || statement.importKind === 'type' || !PROJECT_SOURCE.test(statement.source.value))
85
- continue
86
-
87
- for (const specifier of statement.specifiers) {
88
- const kinds = specifier.type === 'ImportSpecifier' && specifier.importKind !== 'type' ? everywhere.get(importedName(specifier)) : undefined
89
-
90
- if (kinds?.size === 1 && names.get(specifier.local.name) === 1)
91
- receivers.set(specifier.local.name, [...kinds][0]!)
92
- }
93
- }
94
-
95
- const presences = importsOf(ast, from => from === 'kay', 'presence').locals
96
-
97
- walk(ast, (node) => {
98
- if (node.type !== 'CallExpression' || node.arguments.some(argument => argument.type === 'SpreadElement'))
99
- return
100
-
101
- const { callee, arguments: args } = node
102
-
103
- if (callee.type === 'MemberExpression' && !callee.computed && callee.object.type === 'Identifier' && callee.property.type === 'Identifier' && callee.property.name === 'set' && args.length === 2) {
104
- const kind = receivers.get(callee.object.name)
105
-
106
- if ((kind !== 'key' && kind !== 'user') || isOptions(args[1]!, kind))
107
- return
108
-
109
- const [first, second] = args as [Node, Node]
110
-
111
- report(base + callee.property.start, base + callee.property.end, `\`${callee.object.name}.set(${kind}, next)\` of a live value per ${kind} is \`set(next, { ${kind} })\` since 1.105, as one \`set\` writes every live value; the old order works until 1.108`, `write \`set(next, { ${kind} })\``, first.type === 'SequenceExpression' || second.type === 'SequenceExpression' ? null : [{ start: base + first.start, end: base + second.end, text: `${text.slice(second.start, second.end)}, { ${property(kind, first, text)} }` }])
112
-
113
- return
114
- }
115
-
116
- if (callee.type !== 'Identifier' || !presences.has(callee.name) || args.length === 0 || args[0]!.type === 'ObjectExpression')
117
- return
118
-
119
- const [room, member, extra] = args as [Node, Node | undefined, Node | undefined]
120
- const parts = [property('room', room, text), ...member ? [property('member', member, text)] : []]
121
- let fix: Edit[] | null = null
122
-
123
- // A lone argument that is no string was the options of the old form, as `presence(options)`.
124
- const written = args.length > 1 || room.type === 'Literal' || room.type === 'TemplateLiteral'
125
-
126
- if (written && !args.some(argument => argument.type === 'SequenceExpression') && (extra === undefined || extra.type === 'ObjectExpression')) {
127
- if (extra !== undefined && extra.properties.length > 0)
128
- parts.push(text.slice(extra.properties[0]!.start, extra.properties.at(-1)!.end))
129
-
130
- fix = [{ start: base + room.start, end: base + (extra ?? member ?? room).end, text: `{ ${parts.join(', ')} }` }]
131
- }
132
-
133
- report(base + callee.start, base + callee.end, '`presence(room, member)` is `presence({ room, member })` since 1.105, as every kay call with options takes one object; the old form works until 1.108', 'write `presence({ room, member })`', fix)
134
- })
135
- }
136
- })
137
- }
@@ -1,67 +0,0 @@
1
- import type { CheckDiagnostic, CheckOptions } from '.'
2
- import { existsSync, readFileSync } from 'node:fs'
3
- import { join } from 'node:path'
4
- import { lintLevel } from '../compiler/lints'
5
- import { importedName } from './ast'
6
- import { scan } from './renamed-exports'
7
-
8
- const MAIL_FORM = '@kayjs/mail/subscribe-form.kay'
9
- const UI_FORM = '@kayjs/ui/subscribe-form.kay'
10
- const SEND_NAMES = new Set(['send', 'enqueue', 'registeredMailer'])
11
- const NEEDLE = /@kayjs\/mail/
12
-
13
- // Whether the project's manifest lists kayjs-ui, which the moved form comes from.
14
- function hasUi(root: string): boolean {
15
- const manifest = join(root, 'package.json')
16
-
17
- return existsSync(manifest) && readFileSync(manifest, 'utf8').includes('"@kayjs/ui"')
18
- }
19
-
20
- // The old forms of kayjs-mail's API: its own `SubscribeForm`, which kayjs-ui's replaces since 1.105 (the same props, themed), and the `send`, `enqueue` and `registeredMailer` that reach the latest started site's mailer, `ctx.locals.mail` being the request's own.
21
- export async function mailApi(root: string, options: CheckOptions): Promise<CheckDiagnostic[]> {
22
- const formLevel = lintLevel('deprecated-mail-form', options.lints)
23
- const sendLevel = lintLevel('deprecated-mail-send', options.lints)
24
-
25
- if (formLevel === 'allow' && sendLevel === 'allow')
26
- return []
27
-
28
- const ui = hasUi(root)
29
- const found: CheckDiagnostic[] = []
30
-
31
- if (formLevel !== 'allow') {
32
- found.push(...await scan(root, options, 'deprecated-mail-form', NEEDLE, ({ parsed, report }) => {
33
- for (const { ast, base } of parsed) {
34
- for (const statement of ast.body) {
35
- if (statement.type !== 'ImportDeclaration' || statement.source.value !== MAIL_FORM)
36
- continue
37
-
38
- const { start, end } = statement.source
39
-
40
- report(base + start, base + end, `kayjs-mail's \`SubscribeForm\` is kayjs-ui's since 1.105, which takes the same props and reads the list's \`privacy\` from its action`, `import it from \`${UI_FORM}\``, [{ start: base + start, end: base + end, text: `'${UI_FORM}'` }], ui)
41
- }
42
- }
43
- }))
44
- }
45
-
46
- if (sendLevel !== 'allow') {
47
- found.push(...await scan(root, options, 'deprecated-mail-send', NEEDLE, ({ parsed, report }) => {
48
- for (const { ast, base } of parsed) {
49
- for (const statement of ast.body) {
50
- if (statement.type !== 'ImportDeclaration' || statement.importKind === 'type' || statement.source.value !== '@kayjs/mail')
51
- continue
52
-
53
- for (const specifier of statement.specifiers) {
54
- if (specifier.type !== 'ImportSpecifier' || specifier.importKind === 'type' || !SEND_NAMES.has(importedName(specifier)))
55
- continue
56
-
57
- const name = importedName(specifier)
58
-
59
- report(base + specifier.start, base + specifier.end, name === 'registeredMailer' ? '`registeredMailer()` is gone since 1.105: it answered the latest site started, which is none of a request\'s' : `\`${name}()\` of kayjs-mail sends through the latest site started, which is none of a request's, since 1.105: \`ctx.locals.mail\` is the request's own`, 'write `ctx.locals.mail.send(...)` or `.enqueue(...)` in a page, an action or a guard, and the mailer of `src/mail.ts` in a job or a script', null)
60
- }
61
- }
62
- }
63
- }))
64
- }
65
-
66
- return found
67
- }