@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
@@ -98,14 +98,14 @@ function lineEnd(source: string, end: number): number {
98
98
  const SUGGESTED_MAX_LENGTH = 200
99
99
 
100
100
  // Where and what to insert to bound a string field: a new options object, the first property of an empty one, or a property before the others.
101
- function maxLengthEdit(call: NodeOfType<'CallExpression'>, options: NodeOfType<'CallExpression'>['arguments'][number] | undefined): { at: number, text: string } {
101
+ function maxLengthEdit(call: NodeOfType<'CallExpression'>, options: NodeOfType<'CallExpression'>['arguments'][number] | undefined, key: string): { at: number, text: string } {
102
102
  if (options === undefined)
103
- return { at: call.end - 1, text: `{ maxLength: ${SUGGESTED_MAX_LENGTH} }` }
103
+ return { at: call.end - 1, text: `{ ${key}: ${SUGGESTED_MAX_LENGTH} }` }
104
104
 
105
105
  if (options.type === 'ObjectExpression' && options.properties.length === 0)
106
- return { at: options.start + 1, text: ` maxLength: ${SUGGESTED_MAX_LENGTH} ` }
106
+ return { at: options.start + 1, text: ` ${key}: ${SUGGESTED_MAX_LENGTH} ` }
107
107
 
108
- return { at: (options as NodeOfType<'ObjectExpression'>).properties[0]!.start, text: `maxLength: ${SUGGESTED_MAX_LENGTH}, ` }
108
+ return { at: (options as NodeOfType<'ObjectExpression'>).properties[0]!.start, text: `${key}: ${SUGGESTED_MAX_LENGTH}, ` }
109
109
  }
110
110
 
111
111
  const UNBOUNDED_QUANTIFIER = /^\{\d+,\}/
@@ -169,7 +169,7 @@ function isShortField(field: string): boolean {
169
169
  export function unboundedFields(server: ServerAnalysis | undefined): Diagnostic[] {
170
170
  const fence = server?.fence
171
171
 
172
- if (!fence?.code.includes('String'))
172
+ if (!fence?.code.includes('String') && !fence?.code.includes('string'))
173
173
  return []
174
174
 
175
175
  const diagnostics: Diagnostic[] = []
@@ -184,19 +184,20 @@ export function unboundedFields(server: ServerAnalysis | undefined): Diagnostic[
184
184
  const options = call.arguments[0]
185
185
  const known = options === undefined || (options.type === 'ObjectExpression' && options.properties.every(property => property.type !== 'SpreadElement'))
186
186
 
187
- if (!known || (options?.type === 'ObjectExpression' && options.properties.some(property => property.type !== 'SpreadElement' && (propertyKey(property) === 'maxLength' || isBoundedByValue(property)))) || field === undefined || isSecret(field) || !isShortField(field))
187
+ if (!known || (options?.type === 'ObjectExpression' && options.properties.some(property => property.type !== 'SpreadElement' && (propertyKey(property) === 'maxLength' || propertyKey(property) === 'max' || isBoundedByValue(property)))) || field === undefined || isSecret(field) || !isShortField(field))
188
188
  return
189
189
 
190
- const edit = maxLengthEdit(call, options)
190
+ const lowercase = call.callee.type === 'MemberExpression' && call.callee.property.type === 'Identifier' && call.callee.property.name === 'string'
191
+ const edit = maxLengthEdit(call, options, lowercase ? 'max' : 'maxLength')
191
192
  const at = fence.offset + edit.at
192
193
 
193
194
  diagnostics.push({
194
195
  ...fence.shift(call.callee),
195
196
  code: 'unbounded-string',
196
- message: `The string field ${field} has no maxLength of its own`,
197
+ message: `The string field ${field} has no ${lowercase ? 'max' : 'maxLength'} of its own`,
197
198
  note: 'it takes the default bound of 10,000 characters, which is a lot for a value of its kind',
198
199
  help: 'give it a tighter one',
199
- fixes: [{ title: `Give it a maxLength of ${SUGGESTED_MAX_LENGTH}`, edits: [{ start: at, end: at, text: edit.text }] }],
200
+ fixes: [{ title: `Give it a ${lowercase ? 'max' : 'maxLength'} of ${SUGGESTED_MAX_LENGTH}`, edits: [{ start: at, end: at, text: edit.text }] }],
200
201
  checkOnly: true,
201
202
  })
202
203
  })
@@ -336,14 +337,14 @@ export function cssImportsWithoutText(fence: ParsedFence): Diagnostic[] {
336
337
  })
337
338
  }
338
339
 
339
- // Every `s.String(...)` call in a schema, with the name of the field it types, the nearest property holding it.
340
+ // Every `s.string(...)` (or old `s.String(...)`) call in a schema, with the name of the field it types, the nearest property holding it.
340
341
  function schemaStrings(node: Node | null | undefined, field: string | undefined, found: (call: NodeOfType<'CallExpression'>, field: string | undefined) => void): void {
341
342
  const optional = optionalParts()
342
343
 
343
344
  eachNode(node, (inner, parent) => {
344
345
  if (isPlainProperty(inner))
345
346
  schemaStrings(inner.value, propertyKey(inner) ?? field, found)
346
- else if (!optional(inner, parent) && inner.type === 'CallExpression' && inner.callee.type === 'MemberExpression' && inner.callee.property.type === 'Identifier' && inner.callee.property.name === 'String')
347
+ else if (!optional(inner, parent) && inner.type === 'CallExpression' && inner.callee.type === 'MemberExpression' && inner.callee.property.type === 'Identifier' && (inner.callee.property.name === 'String' || inner.callee.property.name === 'string'))
347
348
  found(inner, field)
348
349
 
349
350
  // A property's value is walked above, under the property's own name.
@@ -5,9 +5,9 @@ import { helperName } from './markup'
5
5
 
6
6
  // The call giving a field the ids and requirement a component around it hands it, beside its own `own` ids.
7
7
  // A field written with its own `aria-required` or `required`, or of a type whose role takes none, is left as it is whatever a component around it asks; an expression for either is read a second time, as the type's is, and counts once it gives a value.
8
- export function addFieldDescribed(b: CodeBuilder, own: (() => void) | undefined, type: PlannedAttribute | undefined, aria: FieldAria | undefined, refusing?: () => void): void {
8
+ export function addFieldDescribed(b: CodeBuilder, own: (() => void) | undefined, type: PlannedAttribute | undefined, aria: FieldAria | undefined, refusing?: () => void, schemaType?: () => void): void {
9
9
  const expression = (attribute: PlannedAttribute | undefined) => attribute?.kind === 'value' ? () => b.add('(').addSource(attribute.expression).add(')') : undefined
10
- const typed = type?.kind === 'text' ? () => b.add(JSON.stringify(type.text)) : expression(type)
10
+ const typed = type?.kind === 'text' ? () => b.add(JSON.stringify(type.text)) : expression(type) ?? schemaType
11
11
  const written = expression(aria?.required) ?? (aria?.required || aria?.unrequirable ? () => b.add('true') : undefined)
12
12
  const native = expression(aria?.native) ?? (aria?.native ? () => b.add('true') : undefined)
13
13
  // A field the template marks itself while its form refuses it, `refusing` writing the arguments of that check, counts as written then.
@@ -2,7 +2,7 @@ import type { AwaitAlert } from './names'
2
2
  import { helperName } from './markup'
3
3
 
4
4
  // The `kay/html` helpers static server output calls, each imported under a `Kay` name.
5
- const HTML_HELPERS = ['attempt', 'attribute', 'checkedMarkup', 'child', 'className', 'component', 'componentClass', 'currentPage', 'dynamic', 'element', 'errorParagraph', 'fieldDescribed', 'formConstraints', 'formKey', 'head', 'html', 'imageAttributes', 'innerMarkup', 'leadingNewline', 'linkHref', 'localHref', 'loop', 'memo', 'merge', 'nonEmptyAttribute', 'omit', 'outsideLink', 'partClass', 'partHanded', 'partsClass', 'raw', 'rawData', 'rawTyped', 'refillOptions', 'selectOptions', 'serverIsland', 'show', 'spreadAttributes', 'spreadWith', 'style', 'untrack']
5
+ const HTML_HELPERS = ['attempt', 'attribute', 'checkedMarkup', 'child', 'className', 'component', 'componentClass', 'currentPage', 'dynamic', 'element', 'errorParagraph', 'fieldDescribed', 'formConstraints', 'formKey', 'formOptions', 'formType', 'head', 'html', 'imageAttributes', 'innerMarkup', 'leadingNewline', 'linkHref', 'localHref', 'loop', 'memo', 'merge', 'nonEmptyAttribute', 'omit', 'outsideLink', 'partClass', 'partHanded', 'partsClass', 'raw', 'rawData', 'rawTyped', 'refillOptions', 'schemaFill', 'selectOptions', 'serverIsland', 'show', 'spreadAttributes', 'spreadWith', 'style', 'untrack']
6
6
 
7
7
  // The `kay/dom` helpers browser output calls, each imported under a `Kay` name.
8
8
  const DOM_HELPERS = ['append', 'attribute', 'branches', 'checkedMarkup', 'choose', 'close', 'component', 'componentClass', 'effect', 'errorParagraph', 'fragment', 'holdSubmits', 'insert', 'listen', 'listenSubmit', 'listenSubmitWith', 'listenWith', 'markers', 'memo', 'merge', 'omit', 'outside', 'part', 'partClass', 'partHanded', 'partsClass', 'property', 'ref', 'setClass', 'setStyle', 'spreadAttributes', 'spreadWith', 'template', 'text', 'transition', 'untrack']
@@ -0,0 +1,92 @@
1
+ import type { ElementNode, FormField, Node, Span } from './ast'
2
+ import type { Markup } from './html-parts'
3
+ import type { CodeBuilder } from './mapping'
4
+ import type { ElementPlan } from './markup'
5
+ import { addFilled } from './html-initial'
6
+ import { escapeStaticAttribute, helperName } from './markup'
7
+
8
+ // The `class` of an element: written as it is when static, else built as it renders.
9
+ export function addClassAttribute(b: CodeBuilder, markup: Markup, classes: ElementPlan['classes'], classList: (classes: NonNullable<ElementPlan['classes']>) => void): void {
10
+ if (classes?.parts) {
11
+ const parts = classes
12
+
13
+ markup.dynamic(() => {
14
+ b.add(`${helperName('nonEmptyAttribute')}("class", ${helperName('className')}(`)
15
+ classList(parts)
16
+ b.add('))')
17
+ })
18
+ }
19
+ else if (classes?.expression) {
20
+ const { text, expression } = classes
21
+
22
+ markup.text(' class="')
23
+ markup.dynamic(() => b.add(`${helperName('className')}([${JSON.stringify(text)}, (`).addSource(expression).add(')])'))
24
+ markup.text('"')
25
+ }
26
+ else if (classes?.pieces) {
27
+ const { pieces } = classes
28
+
29
+ markup.text(' class="')
30
+ markup.dynamic(() => b.add(`${helperName('className')}(${JSON.stringify(pieces)})`))
31
+ markup.text('"')
32
+ }
33
+ else if (classes) {
34
+ markup.text(` class="${escapeStaticAttribute(classes.text)}"`)
35
+ }
36
+ }
37
+
38
+ interface Fill {
39
+ filled: 'value' | 'checked'
40
+ fieldArguments: () => void
41
+ own: (() => void) | undefined
42
+ box: (() => void) | undefined
43
+ values: Span | undefined
44
+ name: string
45
+ }
46
+
47
+ // A field's `value`, or `checked` for a boolean. An input that writes no `type` takes the one its schema gives it, so which of the two it is is only known as it renders.
48
+ export function addFieldFill(b: CodeBuilder, src: string, element: ElementNode, markup: Markup, fill: Fill, field: FormField, typed: boolean): void {
49
+ const one = (filled: 'value' | 'checked', box = fill.box, schemaType = true) => addFilled(b, src, element, { ...fill, filled, box, own: filled === fill.filled ? fill.own : undefined, schemaType })
50
+
51
+ if (!(typed && field.marked && fill.filled === 'value')) {
52
+ markup.dynamic(() => one(fill.filled, fill.box, false))
53
+
54
+ return
55
+ }
56
+
57
+ markup.dynamic(() => {
58
+ b.add(helperName('schemaFill'))
59
+ fill.fieldArguments()
60
+ b.add(', (KaySchemaType) => ')
61
+ one('value')
62
+ b.add(', () => ')
63
+ one('checked', fill.own)
64
+
65
+ // The `value` a box posts when ticked, which the template wrote.
66
+ if (fill.own) {
67
+ b.add(` + ${helperName('attribute')}("value", `)
68
+ fill.own()
69
+ b.add(')')
70
+ }
71
+
72
+ b.add(')')
73
+ })
74
+ }
75
+
76
+ // The call reading the `type` the schema gives an input that writes none, for a component requiring the field to know what it is.
77
+ export function schemaTypeCall(b: CodeBuilder, element: string, type: unknown, field: FormField | undefined, target: Span | undefined): (() => void) | undefined {
78
+ if (element !== 'input' || type !== undefined || !field?.marked || !target)
79
+ return undefined
80
+
81
+ return () => void b.add(`${helperName('formType')}((`).addSource(target).add(`), ${JSON.stringify(field.name)})`)
82
+ }
83
+
84
+ // Whether a `select(field=...)` writes no options, which its schema's enum gives it.
85
+ export function listsFromSchema(element: string, children: Node[], field: FormField | undefined): boolean {
86
+ return element === 'select' && children.length === 0 && field?.marked === true
87
+ }
88
+
89
+ // The options of such a `select`, written as the helper that reads them off the schema of the action.
90
+ export function addSchemaOptions(b: CodeBuilder, target: Span, name: string): void {
91
+ b.add(`${helperName('formOptions')}((`).addSource(target).add(`), ${JSON.stringify(name)})`)
92
+ }
@@ -18,7 +18,7 @@ export function dateTypeOf(element: ElementNode, src: string): string | undefine
18
18
  }
19
19
 
20
20
  // What the record a form fills its fields from holds for a field, after the `separator` that makes it the last fallback: its text, or whether the box a `value` stands for is ticked. Writes nothing for a form with no record.
21
- export function addInitial(b: CodeBuilder, src: string, element: ElementNode, values: Span | undefined, name: string, box?: InitialBox, separator = ' ?? '): void {
21
+ export function addInitial(b: CodeBuilder, src: string, element: ElementNode, values: Span | undefined, name: string, box?: InitialBox, separator = ' ?? ', typeVariable?: string): void {
22
22
  if (!values)
23
23
  return
24
24
 
@@ -33,13 +33,15 @@ export function addInitial(b: CodeBuilder, src: string, element: ElementNode, va
33
33
 
34
34
  if (type !== undefined)
35
35
  b.add(`, ${JSON.stringify(type)}`)
36
+ else if (typeVariable !== undefined)
37
+ b.add(`, ${typeVariable}`)
36
38
  }
37
39
 
38
40
  b.add(')')
39
41
  }
40
42
 
41
43
  // What a field with a `value` or a `checked` is written as on the server: a refused post's, else the template's own, else the record's.
42
- export function addFilled(b: CodeBuilder, src: string, element: ElementNode, { filled, fieldArguments, own, box, values, name }: { filled: 'value' | 'checked', fieldArguments: () => void, own: (() => void) | undefined, box: (() => void) | undefined, values: Span | undefined, name: string }): void {
44
+ export function addFilled(b: CodeBuilder, src: string, element: ElementNode, { filled, fieldArguments, own, box, values, name, schemaType }: { filled: 'value' | 'checked', fieldArguments: () => void, own: (() => void) | undefined, box: (() => void) | undefined, values: Span | undefined, name: string, schemaType?: boolean }): void {
43
45
  b.add(`${helperName('attribute')}(${JSON.stringify(filled)}, ${filled === 'value' ? 'KayFormValue' : 'KayFormChecked'}`)
44
46
  fieldArguments()
45
47
 
@@ -56,7 +58,7 @@ export function addFilled(b: CodeBuilder, src: string, element: ElementNode, { f
56
58
  own()
57
59
  }
58
60
 
59
- addInitial(b, src, element, values, name, filled === 'checked' ? { value: box } : undefined)
61
+ addInitial(b, src, element, values, name, filled === 'checked' ? { value: box } : undefined, ' ?? ', schemaType ? 'KaySchemaType' : undefined)
60
62
  b.add(')')
61
63
  }
62
64
 
@@ -9,7 +9,8 @@ import { actionOf, failedBlockOf, marksServerIsland, sectionOf, serverIslandOf }
9
9
  import { decodeEntities } from './expression'
10
10
  import { addFieldDescribed, addInvalidAttribute } from './field-described'
11
11
  import { valuesOf } from './form-info'
12
- import { addFilled, addInitial } from './html-initial'
12
+ import { addClassAttribute, addFieldFill, addSchemaOptions, listsFromSchema, schemaTypeCall } from './html-fields'
13
+ import { addInitial } from './html-initial'
13
14
  import { Markup } from './html-parts'
14
15
  import { addRowItem, childItems, constDeclaration, contentOf, errorParagraphArguments, fixedSource, isDeclaration, rowKeying, slotValue, soleDynamic } from './items'
15
16
  import { END_MARKER, escapeStaticAttribute, escapeText, fromRoot, helperName, RAW_ELEMENTS, START_MARKER, TemplateWriter, VOID_ELEMENTS } from './markup'
@@ -480,7 +481,8 @@ export class HtmlTemplate extends TemplateWriter {
480
481
  const describable = fieldAria !== undefined
481
482
  let ownDescribed: (() => void) | undefined
482
483
  let refusing: (() => void) | undefined
483
- const fieldDescribed = (own: (() => void) | undefined, refusing?: () => void) => addFieldDescribed(b, own, type, fieldAria, refusing)
484
+ const schemaType = schemaTypeCall(b, name, type, field, target)
485
+ const fieldDescribed = (own: (() => void) | undefined, refusing?: () => void) => addFieldDescribed(b, own, type, fieldAria, refusing, schemaType)
484
486
 
485
487
  markup.text(`<${name}${element.fixed ?? ''}`)
486
488
 
@@ -492,32 +494,7 @@ export class HtmlTemplate extends TemplateWriter {
492
494
  if (unit !== undefined)
493
495
  markup.text(` data-kay-u="${unit.id}"`)
494
496
 
495
- if (plan.classes?.parts) {
496
- const classes = plan.classes
497
-
498
- markup.dynamic(() => {
499
- b.add(`${helperName('nonEmptyAttribute')}("class", ${helperName('className')}(`)
500
- this.classList(classes)
501
- b.add('))')
502
- })
503
- }
504
- else if (plan.classes?.expression) {
505
- const { text, expression } = plan.classes
506
-
507
- markup.text(' class="')
508
- markup.dynamic(() => b.add(`${helperName('className')}([${JSON.stringify(text)}, (`).addSource(expression).add(')])'))
509
- markup.text('"')
510
- }
511
- else if (plan.classes?.pieces) {
512
- const { pieces } = plan.classes
513
-
514
- markup.text(' class="')
515
- markup.dynamic(() => b.add(`${helperName('className')}(${JSON.stringify(pieces)})`))
516
- markup.text('"')
517
- }
518
- else if (plan.classes) {
519
- markup.text(` class="${escapeStaticAttribute(plan.classes.text)}"`)
520
- }
497
+ addClassAttribute(b, markup, plan.classes, classes => this.classList(classes))
521
498
 
522
499
  for (const attribute of plan.attributes) {
523
500
  if (attribute.kind === 'binding') {
@@ -667,7 +644,7 @@ export class HtmlTemplate extends TemplateWriter {
667
644
  }
668
645
 
669
646
  if (filled)
670
- markup.dynamic(() => addFilled(b, this.src, element, { filled, fieldArguments, own: ownFill, box: checkboxValue, values, name: field.name }))
647
+ addFieldFill(b, this.src, element, markup, { filled, fieldArguments, own: ownFill, box: checkboxValue, values, name: field.name }, field, name === 'input' && !this.named(element, 'type'))
671
648
 
672
649
  if (field.invalid) {
673
650
  refusing = fieldArguments
@@ -751,12 +728,18 @@ export class HtmlTemplate extends TemplateWriter {
751
728
  // A refused post's text takes the place of the textarea's static value.
752
729
  const staticContent = field?.fill === 'content' && plan.valueText !== undefined ? undefined : plan.staticContent
753
730
 
754
- if (children.length > 0 && field?.fill === 'selected' && target) {
731
+ const fromSchema = listsFromSchema(name, children, field)
732
+
733
+ if (field && (fromSchema || (children.length > 0 && field.fill === 'selected')) && target) {
755
734
  const own = selected
756
735
 
757
736
  markup.dynamic(() => {
758
737
  b.add(`${helperName('refillOptions')}(KayFormValue((`).addSource(target).add(`), ${JSON.stringify(field.name)}), `)
759
- this.markup(children, true)
738
+
739
+ if (fromSchema)
740
+ addSchemaOptions(b, target, field.name)
741
+ else
742
+ this.markup(children, true)
760
743
 
761
744
  if (own) {
762
745
  b.add(', () => ')
@@ -45,3 +45,18 @@ export function importEdits(file: KayFile, fence: Span | undefined, imports: rea
45
45
 
46
46
  return edits
47
47
  }
48
+
49
+ const COMMA_AFTER = /^\s*,\s*/
50
+ const COMMA_BEFORE = /,\s*$/
51
+
52
+ // An import specifier with the comma that separates it from its neighbour.
53
+ export function withoutComma(src: string, specifier: Span, declaration: Span): Span {
54
+ const after = COMMA_AFTER.exec(src.slice(specifier.end, declaration.end))
55
+
56
+ if (after)
57
+ return { start: specifier.start, end: specifier.end + after[0].length }
58
+
59
+ const before = COMMA_BEFORE.exec(src.slice(declaration.start, specifier.start))
60
+
61
+ return { start: specifier.start - (before?.[0].length ?? 0), end: specifier.end }
62
+ }
@@ -3,6 +3,7 @@ import type { UiEntry } from '../runtime/ui'
3
3
  import type { Attribute, Diagnostic, KayFile, Node, Span } from './ast'
4
4
  import type { ErrorName } from './errors'
5
5
  import type { IslandCause } from './island-cause'
6
+ import type { ImportedComponents } from './lazy-imports'
6
7
  import type { LintLevels } from './lints'
7
8
  import type { Expansion } from './markdown-block'
8
9
  import type { ImportedSignals, SignalKind } from './module-signals'
@@ -19,13 +20,13 @@ import { deprecatedChildrenProp } from './deprecated-children'
19
20
  import { deprecatedIslandAttributes, deprecatedIslandForms, islandProblems } from './deprecated-island'
20
21
  import { deprecatedPageSettings } from './deprecated-page'
21
22
  import { deprecatedPartsClass } from './deprecated-parts'
22
- import { spelledOutScriptFence } from './deprecated-script-fence'
23
23
  import { asyncReplies, cssImportsWithoutText, missingCaptchas, onceReadProps, separatePageSettings, serverOnlyImports, unboundedFields, unreturnedFails } from './fence-checks'
24
24
  import { openRedirects } from './fence-redirects'
25
25
  import { cwd, scopeStorage } from './host'
26
26
  import { ignoredIslandExport, interactiveProps, islandMessages, malformedInteractive, withAlertKeys } from './island-arguments'
27
27
  import { describeCause } from './island-cause'
28
28
  import { markerMismatch } from './island-marker'
29
+ import { lazyImportsOf } from './lazy-imports'
29
30
  import { linkFlags } from './link-flags'
30
31
  import { applyLints, templateLints } from './lints'
31
32
  import { SourceMap } from './mapping'
@@ -80,6 +81,8 @@ export interface CompileOptions {
80
81
  namedRefresh?: boolean | undefined
81
82
  // Server output of a static component's `?island` twin, which carries markers like an island.
82
83
  twinBuild?: boolean | undefined
84
+ // The props the component's call sites write, when all are known: the `...rest` of its props leaves out only these of the ones it declares.
85
+ writtenProps?: ReadonlySet<string> | undefined
83
86
  // Whether the file is a page of a routes directory (`isPageFile`), which nothing renders inside an island, so a page without a server fence reads its loops as static as the build does, is refused `--- client` and `--- island`, and is no island by its pin; `false` says it is a component, where a root `@block` is refused.
84
87
  page?: boolean | undefined
85
88
  // Whether the file is known to be a component, which has no `--- server` fence: a library checked on its own has pages no routes directory names, so only a caller knowing its routes says so.
@@ -94,6 +97,8 @@ export interface CompileOptions {
94
97
  insideIsland?: boolean | undefined
95
98
  // The signals and memos of the modules the component imports, which it writes by assigning and the check reports read uncalled: `importedSignals` from kay's build finds them.
96
99
  importedSignals?: ImportedSignals | undefined
100
+ // The `.kay` modules the component imports that a template draws only where a branch may not render, which then load on their own the first time they draw: found by kay's build, which names the chunk of each.
101
+ components?: ImportedComponents | undefined
97
102
  // The browser's build only: the classes a later Tailwind class overrides, with which literal classes written together resolve while compiling.
98
103
  classTable?: ClassTable | undefined
99
104
  // The server's build of an app with Tailwind: a shorthand beside a static `class` merges while rendering.
@@ -323,9 +328,11 @@ export function compileKay(original: string, filename: string, options: CompileO
323
328
  const hydratableServer = options.output === 'html' && options.hydratable === true
324
329
  const twin = hydratableServer && !options.twinBuild && island === undefined && !routeFile ? `./${basename(filename)}${ISLAND_TWIN}` : undefined
325
330
  const pin = file.pin
331
+ const hydrated = hydratableServer && (island !== undefined || options.twinBuild === true)
332
+ const lazy = lazyImportsOf(file, script.imports, options, hydrated, routeFile, client)
326
333
  const rawCause = island === undefined ? undefined : islandCause(file, script) ?? browserCause(file, script, live)
327
334
  const cause = withInteractive(realCause(rawCause, expansion, original), script)
328
- const generateOptions = { cause: options.inspect === true && cause !== undefined ? describeCause(cause) : undefined, classTable: options.classTable, classMerge: options.classMerge, awaitAlert: options.awaitAlert, island, client, lives: island === undefined ? undefined : liveBindings(script, options.importedSignals).map(binding => binding.local), twin, output: options.output, failedCode, hydratable: hydratableServer && (island !== undefined || options.twinBuild === true), moduleId: islandId(filename, options.root), includeServer: options.includeServer, params: options.params, paramTypes: options.paramTypes, outerQueries: options.outerQueries, outerGuards: options.outerGuards, outerSlots: options.outerSlots, layoutFile: basename(filename) === LAYOUT, component: options.page === false && !routeFile, check: options.check, route: options.check === true && pageFile, pageFile, namedRefresh: options.namedRefresh, insideIsland: options.insideIsland, inspect: options.inspect, inspectSource: expansion ? { text: original, real: (offset: number) => expansion.real(offset) } : undefined, relocateImport: options.relocateImport, contextModule: options.check === true ? options.contextModule : undefined, ui: options.output === undefined ? undefined : options.ui, uiAdded: options.output === undefined ? options.ui : undefined, errorPage: isErrorPage(basename(filename)), cardPage: basename(filename) === CARD_PAGE, special: basename(filename).startsWith('_') && basename(filename) !== LAYOUT }
335
+ const generateOptions = { cause: options.inspect === true && cause !== undefined ? describeCause(cause) : undefined, classTable: options.classTable, classMerge: options.classMerge, awaitAlert: options.awaitAlert, island, client, lives: island === undefined ? undefined : liveBindings(script, options.importedSignals).map(binding => binding.local), twin, writtenProps: options.writtenProps, output: options.output, failedCode, hydratable: hydrated, moduleId: islandId(filename, options.root), includeServer: options.includeServer, params: options.params, paramTypes: options.paramTypes, outerQueries: options.outerQueries, outerGuards: options.outerGuards, outerSlots: options.outerSlots, layoutFile: basename(filename) === LAYOUT, component: options.page === false && !routeFile, check: options.check, route: options.check === true && pageFile, pageFile, namedRefresh: options.namedRefresh, insideIsland: options.insideIsland, inspect: options.inspect, inspectSource: expansion ? { text: original, real: (offset: number) => expansion.real(offset) } : undefined, relocateImport: options.relocateImport, lazy, contextModule: options.check === true ? options.contextModule : undefined, ui: options.output === undefined ? undefined : options.ui, uiAdded: options.output === undefined ? options.ui : undefined, errorPage: isErrorPage(basename(filename)), cardPage: basename(filename) === CARD_PAGE, special: basename(filename).startsWith('_') && basename(filename) !== LAYOUT }
329
336
  // The analysis pass names the component so no read resolves to it, then the name is chosen free of what the code reads.
330
337
  const analysis = generate(file, script, server, { ...generateOptions, name: SELF })
331
338
  const imported = new Map<string, SignalKind>([...script.imports, ...server?.imports ?? []].flatMap((binding) => {
@@ -377,7 +384,7 @@ export function compileKay(original: string, filename: string, options: CompileO
377
384
  const browserScript = (island !== undefined || options.insideIsland === true) && !routeFile ? scriptFences(script) : []
378
385
  const unusedLints = broken ? [] : [...unreadNames(source, file.template, script, server, found.findings), ...constantSignals(source, [file.script, file.module], found.findings)]
379
386
 
380
- diagnostics.push(...unboundedFields(server), ...fenceLints, ...serialAwaits(server), ...browserScript.flatMap(fence => serverOnlyImports(fence)), ...browserScript.includes(script.fence!) ? onceReadProps(script.fence!, script.props, templateWords(file)) : [], ...unusedLints, ...templateLints(file), ...spelledOutScriptFence(file), ...retiredAllowComments(source), ...deprecatedIslandForms(file, script), ...deprecatedIslandAttributes(file), ...deprecatedChildrenProp(file, script), ...linkFlags(file), ...deprecatedPartsClass(file), ...deprecatedPageSettings(source, server), ...ignoredIslandExport(script, island !== undefined), ...malformedInteractive(script))
387
+ diagnostics.push(...unboundedFields(server), ...fenceLints, ...serialAwaits(server), ...browserScript.flatMap(fence => serverOnlyImports(fence)), ...browserScript.includes(script.fence!) ? onceReadProps(script.fence!, script.props, templateWords(file)) : [], ...unusedLints, ...templateLints(file), ...retiredAllowComments(source), ...deprecatedIslandForms(file, script), ...deprecatedIslandAttributes(file), ...deprecatedChildrenProp(file, script), ...linkFlags(file), ...deprecatedPartsClass(file), ...deprecatedPageSettings(source, server), ...ignoredIslandExport(script, island !== undefined), ...malformedInteractive(script))
381
388
  }
382
389
 
383
390
  if (checked && pin !== undefined)
@@ -179,3 +179,18 @@ export function rolesOf(source: string, script: Span | undefined, fence: Span &
179
179
 
180
180
  return island.render === 'client' ? { island, client: island.span, pin: undefined } : { island, client: undefined, pin: { kind: island.render, ...island.span } }
181
181
  }
182
+
183
+ // `--- script` opening a file: the bare `---` is the same fence, and only a script that follows a named fence needs the word, as there a bare line would close that one.
184
+ export function spelledOutFirstFence(source: string, line: Span | undefined, word: { start: number, end: number, word: string } | undefined): Diagnostic[] {
185
+ if (!line || word?.word !== 'script' || source.slice(0, line.start).trim() !== '')
186
+ return []
187
+
188
+ return [{
189
+ start: line.start,
190
+ end: word.end,
191
+ code: 'fence-invalid',
192
+ message: '`--- script` cannot open a file: the script is written `---`',
193
+ help: '`--- script` is only for a script that follows a `--- server`, `--- module` or `--- style` fence',
194
+ fixes: [{ title: 'Write `---`', safe: true, edits: [{ start: line.start + 3, end: word.end, text: '' }] }],
195
+ }]
196
+ }
@@ -9,7 +9,7 @@ import { parsedBindingNames } from './pattern-names'
9
9
  export type Item
10
10
  = | { kind: 'text', text: string }
11
11
  | { kind: 'element', node: ElementNode }
12
- | { kind: 'expression', node: TextExpression }
12
+ | { kind: 'expression', node: TextExpression, line: Node }
13
13
  | { kind: 'component', node: ElementNode }
14
14
  | { kind: 'slot', node: ElementNode }
15
15
  | { kind: 'if', node: IfNode }
@@ -91,7 +91,7 @@ export function childItems(nodes: Node[]): Item[] {
91
91
  if (part.kind === 'element')
92
92
  element(part)
93
93
  else if (part.kind === 'expression')
94
- items.push({ kind: 'expression', node: part })
94
+ items.push({ kind: 'expression', node: part, line: node })
95
95
  else if (part.text !== '')
96
96
  text(part.text)
97
97
  }
@@ -244,7 +244,7 @@ export function fixedSource(element: ElementNode): string {
244
244
  return names.length === 0 ? '' : `, { ${names.map(name => `${JSON.stringify(name)}: ""`).join(', ')} }`
245
245
  }
246
246
 
247
- // What an `error` or `pending` line outside every form of its file reads: the form it renders in, and the message the action gave a field; the import drops a repeat.
248
- export function ambientHelpers(facts: { ambientForm: boolean }): ('formHere' | 'formError')[] {
249
- return facts.ambientForm ? ['formHere', 'formError'] : []
247
+ // What an `error` or `pending` line outside every form of its file reads: the form it renders in, and the message the action gave a field; in the browser a snippet called in a form is built in that form's scope; the import drops a repeat.
248
+ export function ambientHelpers(facts: { ambientForm: boolean, snippet: boolean, forms: ReadonlyMap<unknown, unknown> }, mode: string): ('formHere' | 'formError' | 'issueScope')[] {
249
+ return [...facts.ambientForm ? ['formHere' as const, 'formError' as const] : [], ...mode === 'dom' && facts.snippet && facts.forms.size > 0 ? ['issueScope' as const] : []]
250
250
  }
@@ -91,6 +91,7 @@ export const KAY_ROLES: Readonly<Record<string, KayRole>> = {
91
91
  trustHtml: 'shared',
92
92
  uid: 'shared',
93
93
  untrack: 'browser',
94
+ validate: 'shared',
94
95
  watch: 'browser',
95
96
  webPush: 'browser',
96
97
  withBase: 'shared',