@kayjs/kay 1.108.0 → 1.110.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 (595) hide show
  1. package/dist/eslint.js +2093 -3774
  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-library-conventions.md +1 -1
  12. package/llms/components.md +5 -5
  13. package/llms/deprecated-lints.md +2 -7
  14. package/llms/effects.md +1 -1
  15. package/llms/errors.md +2 -2
  16. package/llms/events.md +1 -1
  17. package/llms/guards.md +1 -1
  18. package/llms/head.md +1 -1
  19. package/llms/hooks.md +2 -2
  20. package/llms/images.md +1 -1
  21. package/llms/island-and-form-lints.md +4 -2
  22. package/llms/island-sources.md +1 -1
  23. package/llms/islands-state-to-ids.md +2 -2
  24. package/llms/islands.md +8 -4
  25. package/llms/lints.md +1 -1
  26. package/llms/live-values.md +4 -4
  27. package/llms/local-collections.md +1 -1
  28. package/llms/locales.md +1 -1
  29. package/llms/mcp.md +2 -2
  30. package/llms/metrics.md +1 -1
  31. package/llms/navigation-from-code.md +7 -7
  32. package/llms/navigation.md +4 -2
  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/templates-elements-slots-snippets.md +2 -2
  46. package/llms/testing-mount.md +49 -0
  47. package/llms/testing.md +4 -45
  48. package/llms/upgrading-1-105-config.md +13 -13
  49. package/llms/upgrading-archive.md +64 -74
  50. package/llms/upgrading.md +92 -70
  51. package/llms/whats-new.md +24 -0
  52. package/llms.txt +5 -6
  53. package/package.json +6 -10
  54. package/src/build/route-sizes.ts +2 -3
  55. package/src/build/variants.ts +132 -18
  56. package/src/check/browser-global-reads.ts +2 -2
  57. package/src/check/config-objects.ts +1 -1
  58. package/src/check/diagnose.ts +0 -22
  59. package/src/check/env-types.ts +1 -1
  60. package/src/check/export-homes.ts +1 -1
  61. package/src/check/guards.ts +3 -3
  62. package/src/check/index.ts +2 -7
  63. package/src/check/moved-keys.ts +1 -1
  64. package/src/check/project.ts +6 -7
  65. package/src/check/schema-builders.ts +125 -26
  66. package/src/check/shadow-types.ts +0 -86
  67. package/src/commands/check.ts +2 -2
  68. package/src/commands/env.ts +25 -3
  69. package/src/commands/upgrade.ts +2 -1
  70. package/src/compiler/allow-comments.ts +38 -2
  71. package/src/compiler/ast.ts +21 -19
  72. package/src/compiler/browser.ts +2 -14
  73. package/src/compiler/class-items.ts +16 -0
  74. package/src/compiler/codegen.ts +10 -10
  75. package/src/compiler/deprecated-library.ts +0 -12
  76. package/src/compiler/deprecated-lints-1-106.ts +2 -2
  77. package/src/compiler/deprecated-lints.ts +3 -495
  78. package/src/compiler/deprecated-ui-props.ts +5 -5
  79. package/src/compiler/errors.ts +2 -2
  80. package/src/compiler/fence-checks.ts +2 -121
  81. package/src/compiler/hand-parts.ts +83 -0
  82. package/src/compiler/helper-imports.ts +2 -2
  83. package/src/compiler/image-attributes.ts +1 -3
  84. package/src/compiler/index.ts +23 -23
  85. package/src/compiler/island-arguments.ts +17 -95
  86. package/src/compiler/island-cause.ts +7 -7
  87. package/src/compiler/island-declaration.ts +2 -8
  88. package/src/compiler/island-lints.ts +19 -0
  89. package/src/compiler/island-marker.ts +3 -3
  90. package/src/compiler/island-problems.ts +25 -0
  91. package/src/compiler/items.ts +12 -0
  92. package/src/compiler/jsx-class.ts +1 -25
  93. package/src/compiler/jsx.ts +7 -6
  94. package/src/compiler/kay-exports.ts +0 -2
  95. package/src/compiler/link-flags.ts +9 -38
  96. package/src/compiler/lints.ts +10 -18
  97. package/src/compiler/markup.ts +33 -41
  98. package/src/compiler/module-signals.ts +2 -2
  99. package/src/compiler/names.ts +1 -1
  100. package/src/compiler/page-settings.ts +11 -0
  101. package/src/compiler/parser.ts +6 -8
  102. package/src/compiler/plan.ts +1 -3
  103. package/src/compiler/removed-lints.ts +90 -0
  104. package/src/compiler/rewrite.ts +3 -18
  105. package/src/compiler/script-server.ts +8 -3
  106. package/src/compiler/signal-from-prop.ts +141 -0
  107. package/src/compiler/template-reads.ts +16 -0
  108. package/src/compiler/validate.ts +3 -8
  109. package/src/config-loader.ts +14 -4
  110. package/src/config-resolve.ts +18 -142
  111. package/src/config-shape.ts +44 -34
  112. package/src/config.ts +10 -114
  113. package/src/dev/preload.ts +4 -1
  114. package/src/lsp/server.ts +4 -0
  115. package/src/migrate/markup.ts +4 -1
  116. package/src/runtime/action-call.ts +0 -8
  117. package/src/runtime/action-encode.ts +26 -0
  118. package/src/runtime/action-error.ts +3 -11
  119. package/src/runtime/action-protection.ts +2 -2
  120. package/src/runtime/action-run.ts +2 -27
  121. package/src/runtime/action-shared.ts +14 -37
  122. package/src/runtime/action-stream.ts +0 -1
  123. package/src/runtime/action.ts +1 -1
  124. package/src/runtime/call-result.ts +2 -10
  125. package/src/runtime/checks.ts +25 -13
  126. package/src/runtime/client.ts +7 -11
  127. package/src/runtime/core.ts +5 -23
  128. package/src/runtime/dom.ts +1 -1
  129. package/src/runtime/html.ts +1 -1
  130. package/src/runtime/i18n.client.ts +1 -4
  131. package/src/runtime/i18n.server.ts +1 -4
  132. package/src/runtime/i18n.ts +3 -3
  133. package/src/runtime/image.ts +2 -19
  134. package/src/runtime/index.ts +3 -3
  135. package/src/runtime/island.server.ts +56 -13
  136. package/src/runtime/live-resource.server.ts +0 -1
  137. package/src/runtime/live-value.server.ts +2 -2
  138. package/src/runtime/live-value.shared.ts +7 -20
  139. package/src/runtime/live.ts +1 -12
  140. package/src/runtime/local-types.ts +1 -11
  141. package/src/runtime/local.ts +4 -14
  142. package/src/runtime/navigate-api.ts +2 -5
  143. package/src/runtime/navigate.ts +9 -0
  144. package/src/runtime/navigation-state.ts +0 -12
  145. package/src/runtime/navigation.ts +5 -1
  146. package/src/runtime/page-swap.ts +8 -8
  147. package/src/runtime/persist.ts +11 -3
  148. package/src/runtime/persisted.ts +4 -30
  149. package/src/runtime/presence.ts +6 -7
  150. package/src/runtime/query-param.ts +20 -12
  151. package/src/runtime/reactive.ts +3 -1
  152. package/src/runtime/refuse.ts +3 -17
  153. package/src/runtime/store-base.ts +4 -6
  154. package/src/runtime/swap-fetch.ts +1 -1
  155. package/src/runtime/swap-flight.ts +10 -10
  156. package/src/runtime/swap-kept.ts +69 -29
  157. package/src/runtime/swap-morph.ts +49 -9
  158. package/src/runtime/text-hash.ts +17 -0
  159. package/src/runtime/uid.server.ts +6 -4
  160. package/src/runtime/values.ts +52 -23
  161. package/src/runtime/with-query.ts +9 -0
  162. package/src/server/action-hooks.ts +8 -8
  163. package/src/server/actions.ts +13 -14
  164. package/src/server/api-modules.ts +2 -3
  165. package/src/server/app-stages.ts +15 -33
  166. package/src/server/app.ts +10 -5
  167. package/src/server/auth-mails.ts +0 -2
  168. package/src/server/env-state.ts +40 -10
  169. package/src/server/flash.ts +1 -1
  170. package/src/server/guard-requirement.ts +4 -4
  171. package/src/server/image.ts +2 -2
  172. package/src/server/index.ts +0 -2
  173. package/src/server/job-context.ts +3 -3
  174. package/src/server/jobs-page.ts +1 -1
  175. package/src/server/jobs.ts +5 -9
  176. package/src/server/kept-exports.ts +0 -2
  177. package/src/server/kv.ts +11 -14
  178. package/src/server/library.ts +1 -3
  179. package/src/server/live.ts +2 -2
  180. package/src/server/mcp.ts +3 -9
  181. package/src/server/metrics.ts +2 -4
  182. package/src/server/page-settings.ts +10 -19
  183. package/src/server/prerender.ts +19 -2
  184. package/src/server/protection.ts +15 -18
  185. package/src/server/queue.ts +3 -6
  186. package/src/server/rate-limit.ts +0 -3
  187. package/src/server/render-document.ts +9 -7
  188. package/src/server/render.ts +1 -1
  189. package/src/server/routes.ts +7 -3
  190. package/src/server/scope.ts +3 -2
  191. package/src/server/session.ts +5 -6
  192. package/src/server/setup.ts +1 -1
  193. package/src/server/signals.ts +17 -7
  194. package/src/server/signed.ts +1 -3
  195. package/src/server/source.ts +20 -4
  196. package/src/server/speculation.ts +1 -1
  197. package/src/server/storage.ts +3 -8
  198. package/src/server/validate.ts +1 -1
  199. package/src/server/vitals.ts +1 -3
  200. package/src/server/work-scope.ts +2 -4
  201. package/src/server/work.ts +1 -1
  202. package/src/server/workflow.ts +1 -1
  203. package/src/test/index.ts +2 -1
  204. package/src/test/site-actions.ts +16 -6
  205. package/src/test/site-keys.ts +10 -15
  206. package/src/test/site-socket.ts +1 -2
  207. package/src/test/site-types.ts +0 -8
  208. package/types/build/route-sizes.d.ts.map +1 -1
  209. package/types/build/variants.d.ts +9 -1
  210. package/types/build/variants.d.ts.map +1 -1
  211. package/types/check/diagnose.d.ts.map +1 -1
  212. package/types/check/index.d.ts +1 -2
  213. package/types/check/index.d.ts.map +1 -1
  214. package/types/check/project.d.ts.map +1 -1
  215. package/types/check/schema-builders.d.ts.map +1 -1
  216. package/types/check/shadow-types.d.ts.map +1 -1
  217. package/types/commands/env.d.ts.map +1 -1
  218. package/types/commands/upgrade.d.ts.map +1 -1
  219. package/types/compiler/allow-comments.d.ts +2 -0
  220. package/types/compiler/allow-comments.d.ts.map +1 -1
  221. package/types/compiler/ast.d.ts +1 -2
  222. package/types/compiler/ast.d.ts.map +1 -1
  223. package/types/compiler/browser.d.ts.map +1 -1
  224. package/types/compiler/class-items.d.ts +7 -0
  225. package/types/compiler/class-items.d.ts.map +1 -0
  226. package/types/compiler/deprecated-library.d.ts.map +1 -1
  227. package/types/compiler/deprecated-lints-1-106.d.ts +2 -2
  228. package/types/compiler/deprecated-lints-1-106.d.ts.map +1 -1
  229. package/types/compiler/deprecated-lints.d.ts +2 -553
  230. package/types/compiler/deprecated-lints.d.ts.map +1 -1
  231. package/types/compiler/deprecated-ui-props.d.ts +1 -8
  232. package/types/compiler/deprecated-ui-props.d.ts.map +1 -1
  233. package/types/compiler/errors.d.ts +2 -2
  234. package/types/compiler/errors.d.ts.map +1 -1
  235. package/types/compiler/fence-checks.d.ts +0 -1
  236. package/types/compiler/fence-checks.d.ts.map +1 -1
  237. package/types/compiler/hand-parts.d.ts +10 -0
  238. package/types/compiler/hand-parts.d.ts.map +1 -0
  239. package/types/compiler/image-attributes.d.ts +0 -1
  240. package/types/compiler/image-attributes.d.ts.map +1 -1
  241. package/types/compiler/index.d.ts.map +1 -1
  242. package/types/compiler/island-arguments.d.ts +7 -11
  243. package/types/compiler/island-arguments.d.ts.map +1 -1
  244. package/types/compiler/island-cause.d.ts +1 -1
  245. package/types/compiler/island-cause.d.ts.map +1 -1
  246. package/types/compiler/island-declaration.d.ts +1 -3
  247. package/types/compiler/island-declaration.d.ts.map +1 -1
  248. package/types/compiler/island-lints.d.ts +17 -0
  249. package/types/compiler/island-lints.d.ts.map +1 -0
  250. package/types/compiler/island-problems.d.ts +7 -0
  251. package/types/compiler/island-problems.d.ts.map +1 -0
  252. package/types/compiler/items.d.ts +1 -0
  253. package/types/compiler/items.d.ts.map +1 -1
  254. package/types/compiler/jsx-class.d.ts +1 -2
  255. package/types/compiler/jsx-class.d.ts.map +1 -1
  256. package/types/compiler/jsx.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 +21 -566
  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/removed-lints.d.ts +3 -0
  271. package/types/compiler/removed-lints.d.ts.map +1 -0
  272. package/types/compiler/script-server.d.ts.map +1 -1
  273. package/types/compiler/signal-from-prop.d.ts +4 -0
  274. package/types/compiler/signal-from-prop.d.ts.map +1 -0
  275. package/types/compiler/template-reads.d.ts +1 -0
  276. package/types/compiler/template-reads.d.ts.map +1 -1
  277. package/types/compiler/validate.d.ts.map +1 -1
  278. package/types/config-loader.d.ts.map +1 -1
  279. package/types/config-resolve.d.ts.map +1 -1
  280. package/types/config-shape.d.ts +1 -1
  281. package/types/config-shape.d.ts.map +1 -1
  282. package/types/config.d.ts +5 -105
  283. package/types/config.d.ts.map +1 -1
  284. package/types/dev/preload.d.ts.map +1 -1
  285. package/types/lsp/server.d.ts.map +1 -1
  286. package/types/migrate/markup.d.ts.map +1 -1
  287. package/types/runtime/action-call.d.ts.map +1 -1
  288. package/types/runtime/action-encode.d.ts +1 -0
  289. package/types/runtime/action-encode.d.ts.map +1 -1
  290. package/types/runtime/action-error.d.ts +1 -2
  291. package/types/runtime/action-error.d.ts.map +1 -1
  292. package/types/runtime/action-run.d.ts.map +1 -1
  293. package/types/runtime/action-shared.d.ts +1 -27
  294. package/types/runtime/action-shared.d.ts.map +1 -1
  295. package/types/runtime/action-stream.d.ts.map +1 -1
  296. package/types/runtime/action.d.ts +1 -1
  297. package/types/runtime/action.d.ts.map +1 -1
  298. package/types/runtime/call-result.d.ts +0 -10
  299. package/types/runtime/call-result.d.ts.map +1 -1
  300. package/types/runtime/checks.d.ts +14 -11
  301. package/types/runtime/checks.d.ts.map +1 -1
  302. package/types/runtime/client.d.ts.map +1 -1
  303. package/types/runtime/core.d.ts +2 -20
  304. package/types/runtime/core.d.ts.map +1 -1
  305. package/types/runtime/dom.d.ts +1 -1
  306. package/types/runtime/dom.d.ts.map +1 -1
  307. package/types/runtime/html.d.ts +1 -1
  308. package/types/runtime/html.d.ts.map +1 -1
  309. package/types/runtime/i18n.client.d.ts +0 -1
  310. package/types/runtime/i18n.client.d.ts.map +1 -1
  311. package/types/runtime/i18n.d.ts +1 -1
  312. package/types/runtime/i18n.d.ts.map +1 -1
  313. package/types/runtime/i18n.server.d.ts +0 -1
  314. package/types/runtime/i18n.server.d.ts.map +1 -1
  315. package/types/runtime/image.d.ts.map +1 -1
  316. package/types/runtime/index.d.ts +3 -3
  317. package/types/runtime/index.d.ts.map +1 -1
  318. package/types/runtime/island.server.d.ts +2 -0
  319. package/types/runtime/island.server.d.ts.map +1 -1
  320. package/types/runtime/live-resource.server.d.ts.map +1 -1
  321. package/types/runtime/live-value.shared.d.ts +7 -15
  322. package/types/runtime/live-value.shared.d.ts.map +1 -1
  323. package/types/runtime/live.d.ts +0 -11
  324. package/types/runtime/live.d.ts.map +1 -1
  325. package/types/runtime/local-types.d.ts +0 -14
  326. package/types/runtime/local-types.d.ts.map +1 -1
  327. package/types/runtime/navigate-api.d.ts +0 -4
  328. package/types/runtime/navigate-api.d.ts.map +1 -1
  329. package/types/runtime/navigate.d.ts.map +1 -1
  330. package/types/runtime/navigation-state.d.ts +0 -4
  331. package/types/runtime/navigation-state.d.ts.map +1 -1
  332. package/types/runtime/navigation.d.ts +2 -0
  333. package/types/runtime/navigation.d.ts.map +1 -1
  334. package/types/runtime/page-swap.d.ts.map +1 -1
  335. package/types/runtime/persist.d.ts +1 -0
  336. package/types/runtime/persist.d.ts.map +1 -1
  337. package/types/runtime/persisted.d.ts +0 -15
  338. package/types/runtime/persisted.d.ts.map +1 -1
  339. package/types/runtime/presence.d.ts +0 -2
  340. package/types/runtime/presence.d.ts.map +1 -1
  341. package/types/runtime/query-param.d.ts.map +1 -1
  342. package/types/runtime/reactive.d.ts +2 -1
  343. package/types/runtime/reactive.d.ts.map +1 -1
  344. package/types/runtime/refuse.d.ts +0 -7
  345. package/types/runtime/refuse.d.ts.map +1 -1
  346. package/types/runtime/store-base.d.ts +1 -2
  347. package/types/runtime/store-base.d.ts.map +1 -1
  348. package/types/runtime/swap-flight.d.ts +1 -1
  349. package/types/runtime/swap-flight.d.ts.map +1 -1
  350. package/types/runtime/swap-kept.d.ts.map +1 -1
  351. package/types/runtime/swap-morph.d.ts.map +1 -1
  352. package/types/runtime/text-hash.d.ts +2 -0
  353. package/types/runtime/text-hash.d.ts.map +1 -0
  354. package/types/runtime/uid.server.d.ts.map +1 -1
  355. package/types/runtime/values.d.ts +6 -1
  356. package/types/runtime/values.d.ts.map +1 -1
  357. package/types/runtime/with-query.d.ts +2 -0
  358. package/types/runtime/with-query.d.ts.map +1 -1
  359. package/types/server/action-hooks.d.ts +4 -4
  360. package/types/server/action-hooks.d.ts.map +1 -1
  361. package/types/server/actions.d.ts.map +1 -1
  362. package/types/server/api-modules.d.ts +0 -1
  363. package/types/server/api-modules.d.ts.map +1 -1
  364. package/types/server/app-stages.d.ts +5 -13
  365. package/types/server/app-stages.d.ts.map +1 -1
  366. package/types/server/app.d.ts +3 -8
  367. package/types/server/app.d.ts.map +1 -1
  368. package/types/server/auth-mails.d.ts +0 -5
  369. package/types/server/auth-mails.d.ts.map +1 -1
  370. package/types/server/env-state.d.ts +1 -0
  371. package/types/server/env-state.d.ts.map +1 -1
  372. package/types/server/guard-requirement.d.ts +0 -1
  373. package/types/server/guard-requirement.d.ts.map +1 -1
  374. package/types/server/image.d.ts +0 -1
  375. package/types/server/image.d.ts.map +1 -1
  376. package/types/server/index.d.ts +0 -2
  377. package/types/server/index.d.ts.map +1 -1
  378. package/types/server/job-context.d.ts +1 -1
  379. package/types/server/job-context.d.ts.map +1 -1
  380. package/types/server/jobs.d.ts +0 -4
  381. package/types/server/jobs.d.ts.map +1 -1
  382. package/types/server/kept-exports.d.ts.map +1 -1
  383. package/types/server/kv.d.ts +4 -4
  384. package/types/server/kv.d.ts.map +1 -1
  385. package/types/server/library.d.ts +1 -3
  386. package/types/server/library.d.ts.map +1 -1
  387. package/types/server/mcp.d.ts +0 -1
  388. package/types/server/mcp.d.ts.map +1 -1
  389. package/types/server/metrics.d.ts +0 -5
  390. package/types/server/metrics.d.ts.map +1 -1
  391. package/types/server/page-settings.d.ts +3 -3
  392. package/types/server/page-settings.d.ts.map +1 -1
  393. package/types/server/prerender.d.ts.map +1 -1
  394. package/types/server/protection.d.ts +6 -6
  395. package/types/server/protection.d.ts.map +1 -1
  396. package/types/server/queue.d.ts +1 -3
  397. package/types/server/queue.d.ts.map +1 -1
  398. package/types/server/rate-limit.d.ts +0 -2
  399. package/types/server/rate-limit.d.ts.map +1 -1
  400. package/types/server/render-document.d.ts +1 -1
  401. package/types/server/render-document.d.ts.map +1 -1
  402. package/types/server/routes.d.ts +1 -1
  403. package/types/server/routes.d.ts.map +1 -1
  404. package/types/server/scope.d.ts.map +1 -1
  405. package/types/server/session.d.ts +1 -1
  406. package/types/server/session.d.ts.map +1 -1
  407. package/types/server/signals.d.ts.map +1 -1
  408. package/types/server/signed.d.ts +0 -2
  409. package/types/server/signed.d.ts.map +1 -1
  410. package/types/server/source.d.ts +1 -1
  411. package/types/server/source.d.ts.map +1 -1
  412. package/types/server/storage.d.ts +0 -4
  413. package/types/server/storage.d.ts.map +1 -1
  414. package/types/server/vitals.d.ts +0 -1
  415. package/types/server/vitals.d.ts.map +1 -1
  416. package/types/server/work-scope.d.ts +0 -2
  417. package/types/server/work-scope.d.ts.map +1 -1
  418. package/types/server/workflow.d.ts +1 -1
  419. package/types/server/workflow.d.ts.map +1 -1
  420. package/types/test/index.d.ts.map +1 -1
  421. package/types/test/site-actions.d.ts +1 -1
  422. package/types/test/site-actions.d.ts.map +1 -1
  423. package/types/test/site-keys.d.ts +1 -1
  424. package/types/test/site-keys.d.ts.map +1 -1
  425. package/types/test/site-socket.d.ts +1 -1
  426. package/types/test/site-socket.d.ts.map +1 -1
  427. package/types/test/site-types.d.ts +0 -8
  428. package/types/test/site-types.d.ts.map +1 -1
  429. package/llms/deprecated-lints-1-105-libraries.md +0 -32
  430. package/llms/deprecated-lints-1-105.md +0 -58
  431. package/src/check/action-readers.ts +0 -115
  432. package/src/check/action-type.ts +0 -44
  433. package/src/check/ai-language.ts +0 -56
  434. package/src/check/app-hooks.ts +0 -90
  435. package/src/check/auth-methods.ts +0 -85
  436. package/src/check/auth-rate-limits.ts +0 -99
  437. package/src/check/call-result.ts +0 -242
  438. package/src/check/client-keys.ts +0 -10
  439. package/src/check/cms-options.ts +0 -81
  440. package/src/check/config-groups.ts +0 -22
  441. package/src/check/config-switches.ts +0 -38
  442. package/src/check/context-import.ts +0 -51
  443. package/src/check/env-files.ts +0 -31
  444. package/src/check/format-duration.ts +0 -75
  445. package/src/check/guard-options.ts +0 -58
  446. package/src/check/handler-events.ts +0 -149
  447. package/src/check/hook-context.ts +0 -94
  448. package/src/check/hook-names.ts +0 -104
  449. package/src/check/i18n-keys.ts +0 -50
  450. package/src/check/images-keys.ts +0 -54
  451. package/src/check/job-shapes.ts +0 -273
  452. package/src/check/link-flag-tests.ts +0 -130
  453. package/src/check/live-api.ts +0 -137
  454. package/src/check/mail-api.ts +0 -67
  455. package/src/check/one-state-api.ts +0 -357
  456. package/src/check/pages-options.ts +0 -35
  457. package/src/check/rate-enforce.ts +0 -53
  458. package/src/check/refusal-calls.ts +0 -185
  459. package/src/check/retired-lints.ts +0 -49
  460. package/src/check/route-keys.ts +0 -166
  461. package/src/check/secret-keys.ts +0 -83
  462. package/src/check/socket-frames.ts +0 -102
  463. package/src/check/source-readers.ts +0 -257
  464. package/src/check/store-ms.ts +0 -72
  465. package/src/check/store-names.ts +0 -88
  466. package/src/check/test-helpers.ts +0 -98
  467. package/src/check/ttl-names.ts +0 -142
  468. package/src/compiler/deprecated-ai-labels.ts +0 -97
  469. package/src/compiler/deprecated-ai-links.ts +0 -63
  470. package/src/compiler/deprecated-allow.ts +0 -50
  471. package/src/compiler/deprecated-auth-lints.ts +0 -14
  472. package/src/compiler/deprecated-auth-signed.ts +0 -29
  473. package/src/compiler/deprecated-children.ts +0 -66
  474. package/src/compiler/deprecated-image.ts +0 -116
  475. package/src/compiler/deprecated-island.ts +0 -155
  476. package/src/compiler/deprecated-lints-1-105.ts +0 -41
  477. package/src/compiler/deprecated-page.ts +0 -125
  478. package/src/compiler/deprecated-parts.ts +0 -22
  479. package/src/compiler/deprecated-typed-lints.ts +0 -23
  480. package/src/compiler/deprecated-ui-callbacks.ts +0 -66
  481. package/src/compiler/deprecated-ui-input.ts +0 -97
  482. package/src/compiler/deprecated-ui-items.ts +0 -47
  483. package/src/compiler/old-parts.ts +0 -84
  484. package/src/runtime/mount.compat.ts +0 -8
  485. package/src/server/moved-exports.ts +0 -17
  486. package/types/check/action-readers.d.ts +0 -3
  487. package/types/check/action-readers.d.ts.map +0 -1
  488. package/types/check/action-type.d.ts +0 -3
  489. package/types/check/action-type.d.ts.map +0 -1
  490. package/types/check/ai-language.d.ts +0 -3
  491. package/types/check/ai-language.d.ts.map +0 -1
  492. package/types/check/app-hooks.d.ts +0 -3
  493. package/types/check/app-hooks.d.ts.map +0 -1
  494. package/types/check/auth-methods.d.ts +0 -3
  495. package/types/check/auth-methods.d.ts.map +0 -1
  496. package/types/check/auth-rate-limits.d.ts +0 -3
  497. package/types/check/auth-rate-limits.d.ts.map +0 -1
  498. package/types/check/call-result.d.ts +0 -7
  499. package/types/check/call-result.d.ts.map +0 -1
  500. package/types/check/client-keys.d.ts +0 -3
  501. package/types/check/client-keys.d.ts.map +0 -1
  502. package/types/check/cms-options.d.ts +0 -3
  503. package/types/check/cms-options.d.ts.map +0 -1
  504. package/types/check/config-groups.d.ts +0 -3
  505. package/types/check/config-groups.d.ts.map +0 -1
  506. package/types/check/config-switches.d.ts +0 -3
  507. package/types/check/config-switches.d.ts.map +0 -1
  508. package/types/check/context-import.d.ts +0 -3
  509. package/types/check/context-import.d.ts.map +0 -1
  510. package/types/check/env-files.d.ts +0 -3
  511. package/types/check/env-files.d.ts.map +0 -1
  512. package/types/check/format-duration.d.ts +0 -5
  513. package/types/check/format-duration.d.ts.map +0 -1
  514. package/types/check/guard-options.d.ts +0 -3
  515. package/types/check/guard-options.d.ts.map +0 -1
  516. package/types/check/handler-events.d.ts +0 -9
  517. package/types/check/handler-events.d.ts.map +0 -1
  518. package/types/check/hook-context.d.ts +0 -3
  519. package/types/check/hook-context.d.ts.map +0 -1
  520. package/types/check/hook-names.d.ts +0 -3
  521. package/types/check/hook-names.d.ts.map +0 -1
  522. package/types/check/i18n-keys.d.ts +0 -3
  523. package/types/check/i18n-keys.d.ts.map +0 -1
  524. package/types/check/images-keys.d.ts +0 -3
  525. package/types/check/images-keys.d.ts.map +0 -1
  526. package/types/check/job-shapes.d.ts +0 -6
  527. package/types/check/job-shapes.d.ts.map +0 -1
  528. package/types/check/link-flag-tests.d.ts +0 -4
  529. package/types/check/link-flag-tests.d.ts.map +0 -1
  530. package/types/check/live-api.d.ts +0 -3
  531. package/types/check/live-api.d.ts.map +0 -1
  532. package/types/check/mail-api.d.ts +0 -3
  533. package/types/check/mail-api.d.ts.map +0 -1
  534. package/types/check/one-state-api.d.ts +0 -9
  535. package/types/check/one-state-api.d.ts.map +0 -1
  536. package/types/check/pages-options.d.ts +0 -3
  537. package/types/check/pages-options.d.ts.map +0 -1
  538. package/types/check/rate-enforce.d.ts +0 -3
  539. package/types/check/rate-enforce.d.ts.map +0 -1
  540. package/types/check/refusal-calls.d.ts +0 -3
  541. package/types/check/refusal-calls.d.ts.map +0 -1
  542. package/types/check/retired-lints.d.ts +0 -3
  543. package/types/check/retired-lints.d.ts.map +0 -1
  544. package/types/check/route-keys.d.ts +0 -3
  545. package/types/check/route-keys.d.ts.map +0 -1
  546. package/types/check/secret-keys.d.ts +0 -3
  547. package/types/check/secret-keys.d.ts.map +0 -1
  548. package/types/check/socket-frames.d.ts +0 -3
  549. package/types/check/socket-frames.d.ts.map +0 -1
  550. package/types/check/source-readers.d.ts +0 -3
  551. package/types/check/source-readers.d.ts.map +0 -1
  552. package/types/check/store-ms.d.ts +0 -3
  553. package/types/check/store-ms.d.ts.map +0 -1
  554. package/types/check/store-names.d.ts +0 -3
  555. package/types/check/store-names.d.ts.map +0 -1
  556. package/types/check/test-helpers.d.ts +0 -3
  557. package/types/check/test-helpers.d.ts.map +0 -1
  558. package/types/check/ttl-names.d.ts +0 -3
  559. package/types/check/ttl-names.d.ts.map +0 -1
  560. package/types/compiler/deprecated-ai-labels.d.ts +0 -5
  561. package/types/compiler/deprecated-ai-labels.d.ts.map +0 -1
  562. package/types/compiler/deprecated-ai-links.d.ts +0 -5
  563. package/types/compiler/deprecated-ai-links.d.ts.map +0 -1
  564. package/types/compiler/deprecated-allow.d.ts +0 -5
  565. package/types/compiler/deprecated-allow.d.ts.map +0 -1
  566. package/types/compiler/deprecated-auth-lints.d.ts +0 -12
  567. package/types/compiler/deprecated-auth-lints.d.ts.map +0 -1
  568. package/types/compiler/deprecated-auth-signed.d.ts +0 -5
  569. package/types/compiler/deprecated-auth-signed.d.ts.map +0 -1
  570. package/types/compiler/deprecated-children.d.ts +0 -4
  571. package/types/compiler/deprecated-children.d.ts.map +0 -1
  572. package/types/compiler/deprecated-image.d.ts +0 -5
  573. package/types/compiler/deprecated-image.d.ts.map +0 -1
  574. package/types/compiler/deprecated-island.d.ts +0 -9
  575. package/types/compiler/deprecated-island.d.ts.map +0 -1
  576. package/types/compiler/deprecated-lints-1-105.d.ts +0 -39
  577. package/types/compiler/deprecated-lints-1-105.d.ts.map +0 -1
  578. package/types/compiler/deprecated-page.d.ts +0 -4
  579. package/types/compiler/deprecated-page.d.ts.map +0 -1
  580. package/types/compiler/deprecated-parts.d.ts +0 -3
  581. package/types/compiler/deprecated-parts.d.ts.map +0 -1
  582. package/types/compiler/deprecated-typed-lints.d.ts +0 -21
  583. package/types/compiler/deprecated-typed-lints.d.ts.map +0 -1
  584. package/types/compiler/deprecated-ui-callbacks.d.ts +0 -5
  585. package/types/compiler/deprecated-ui-callbacks.d.ts.map +0 -1
  586. package/types/compiler/deprecated-ui-input.d.ts +0 -5
  587. package/types/compiler/deprecated-ui-input.d.ts.map +0 -1
  588. package/types/compiler/deprecated-ui-items.d.ts +0 -5
  589. package/types/compiler/deprecated-ui-items.d.ts.map +0 -1
  590. package/types/compiler/old-parts.d.ts +0 -9
  591. package/types/compiler/old-parts.d.ts.map +0 -1
  592. package/types/runtime/mount.compat.d.ts +0 -7
  593. package/types/runtime/mount.compat.d.ts.map +0 -1
  594. package/types/server/moved-exports.d.ts +0 -12
  595. package/types/server/moved-exports.d.ts.map +0 -1
@@ -2,12 +2,15 @@ import type { Policy } from './swap-flight'
2
2
  import { ISLAND } from './markers'
3
3
  import { moves, place } from './move'
4
4
  import { navigation } from './navigation'
5
+ import { inFlight } from './swap-flight'
5
6
  import { runnable, scriptMarkup } from './swap-head'
6
7
  import { KEPT, MISSING, morphChildren, scoped, UNIT } from './swap-morph'
7
8
  import { decodeServerValue } from './wire'
8
9
 
9
10
  const PERSISTENT = 'slot[data-persist]'
10
11
  const SERVER_ISLAND = 'slot[data-kay-server]'
12
+ // The islands a layout rendered, which a navigation keeping the layout keeps.
13
+ const LAYOUT_ISLAND = `${ISLAND}[data-layout]`
11
14
  // What a script put in the body to outlive every page, a live region an announcer fills for one: the next body never holds it, so the morph leaves it where it is, never moved, as a live region taken out and put back may go unread.
12
15
  const LASTING = ':scope > [data-kay-keep]'
13
16
 
@@ -92,7 +95,8 @@ export function swapBody(next: Document, policy: Policy, held: Held | undefined,
92
95
  const scrolls = new Map<Element, readonly [left: number, top: number]>()
93
96
 
94
97
  // Read before the first move, and only when the next page has an island to keep, so every read shares one layout instead of forcing one after each move.
95
- const candidates = policy.islands === 'unchanged' ? `${PERSISTENT},${ISLAND}` : PERSISTENT
98
+ const matching = policy.islands === 'all' ? ISLAND : LAYOUT_ISLAND
99
+ const candidates = `${PERSISTENT},${matching}`
96
100
 
97
101
  for (const root of [...body.querySelector(candidates) ? old.querySelectorAll(candidates) : [], ...lives]) {
98
102
  for (const element of [root, ...root.querySelectorAll('*')]) {
@@ -132,37 +136,11 @@ export function swapBody(next: Document, policy: Policy, held: Held | undefined,
132
136
  markCurrent(live, placeholder)
133
137
  keep(placeholder, live)
134
138
 
135
- const props = placeholder.dataset.props
136
-
137
- // What the next page gives it, which it reads from now on, or once it hydrates.
138
- if (props !== live.dataset.props) {
139
- if (props === undefined)
140
- delete live.dataset.props
141
- else
142
- live.dataset.props = props
143
-
144
- live._$p?.(props === undefined ? {} : decodeServerValue(props) as object)
145
- }
139
+ givePropsOf(live, placeholder)
146
140
  }
147
141
  }
148
142
 
149
- if (policy.islands === 'unchanged') {
150
- const unchanged = [...old.querySelectorAll<KeptIsland>(ISLAND)]
151
-
152
- for (const placeholder of body.querySelectorAll<HTMLElement>(ISLAND)) {
153
- // One in the static slot of an island kept went along with it, or away with the copy it replaced.
154
- if (!body.contains(placeholder) || standIns.has(placeholder) || [...kept].some(island => island.contains(placeholder)))
155
- continue
156
-
157
- const index = unchanged.findIndex(live => old.contains(live) && live.dataset.component === placeholder.dataset.component && live.dataset.props === placeholder.dataset.props && live.dataset.slots === placeholder.dataset.slots && (live.dataset.slots === undefined || (live._$h ?? live.innerHTML) === placeholder.innerHTML))
158
-
159
- if (index !== -1) {
160
- const [live] = unchanged.splice(index, 1)
161
-
162
- keep(placeholder, live!)
163
- }
164
- }
165
- }
143
+ keepMatched(old, body, matching, standIns, keep)
166
144
 
167
145
  // Every island left is taken away, as the morph never keeps one.
168
146
  navigation.hooks!.dispose(old)
@@ -209,6 +187,12 @@ export function swapBody(next: Document, policy: Policy, held: Held | undefined,
209
187
  if (focused && document.activeElement !== focused.element && [...kept].some(island => island.contains(focused.element)))
210
188
  focused.restore()
211
189
 
190
+ // What each `details` shows now is what the server served: the visitor's toggle, which a refresh compares with it, comes after, and a toggle event the markup's own opening fires is not one.
191
+ for (const details of document.querySelectorAll('details')) {
192
+ if (!inFlight.typing || !navigation.opened.has(details))
193
+ navigation.opened.set(details, details.open)
194
+ }
195
+
212
196
  // A drawer or a menu left open closes as the page changes, as it would on a page loaded afresh.
213
197
  for (const popover of opened) {
214
198
  if (popover.isConnected && popover instanceof HTMLElement && popover.matches(':popover-open'))
@@ -222,6 +206,62 @@ export function swapBody(next: Document, policy: Policy, held: Held | undefined,
222
206
  }
223
207
  }
224
208
 
209
+ // An island of the next page that has its match among those of this one, the same component in the same place, stays and takes the new props: what the visitor did in it is its own.
210
+ function keepMatched(old: Element, body: Element, matching: string, standIns: ReadonlyMap<Element, Element>, keep: (placeholder: Element, live: Element) => void): void {
211
+ const live = new Map<string, KeptIsland[]>()
212
+
213
+ // Only the islands of the page itself take part: one in another's static slot goes where its parent goes.
214
+ for (const island of old.querySelectorAll<KeptIsland>(matching)) {
215
+ if (island.dataset.persist !== undefined || island.parentElement?.closest(ISLAND))
216
+ continue
217
+
218
+ const place = placeOf(island)
219
+ const list = live.get(place)
220
+
221
+ if (list)
222
+ list.push(island)
223
+ else
224
+ live.set(place, [island])
225
+ }
226
+
227
+ if (live.size === 0)
228
+ return
229
+
230
+ for (const placeholder of body.querySelectorAll<HTMLElement>(matching)) {
231
+ // One in the static slot of an island kept went along with it, or away with the copy it replaced.
232
+ if (placeholder.dataset.persist !== undefined || !body.contains(placeholder) || standIns.has(placeholder) || placeholder.parentElement?.closest(ISLAND))
233
+ continue
234
+
235
+ const match = live.get(placeOf(placeholder))?.shift()
236
+
237
+ if (match && old.contains(match) && match.dataset.slots === placeholder.dataset.slots && (match.dataset.slots === undefined || (match._$h ?? match.innerHTML) === placeholder.innerHTML)) {
238
+ markCurrent(match, placeholder)
239
+ keep(placeholder, match)
240
+ givePropsOf(match, placeholder)
241
+ }
242
+ }
243
+ }
244
+
245
+ // Where an island stands among the others, which the next page's copy of it is paired by: its layout, component and `key` or `id`, then in order.
246
+ function placeOf(island: HTMLElement): string {
247
+ return `${island.dataset.layout ?? ''}\0${island.dataset.component}\0${island.dataset.key ?? ''}`
248
+ }
249
+
250
+ // What the next page gives a kept island, which it reads from now on, or once it hydrates.
251
+ function givePropsOf(live: KeptIsland, next: HTMLElement): void {
252
+ const props = next.dataset.props
253
+
254
+ if (props === live.dataset.props)
255
+ return
256
+
257
+ if (props === undefined)
258
+ delete live.dataset.props
259
+ else
260
+ live.dataset.props = props
261
+
262
+ live._$p?.(props === undefined ? {} : decodeServerValue(props) as object)
263
+ }
264
+
225
265
  const KAY_MARKS = new Set<string | null>([null, 'page', 'true'])
226
266
 
227
267
  // The marks of the next page's copy of an island kept, a link to the page now shown, `aria-current`, carried over to the links of the one that lives on, found by their place and address: those that differ are left, as the island renders them itself, and so is a value kay never writes (`step`, `false`), which an island setting its own holds.
@@ -1,8 +1,9 @@
1
1
  import { ISLAND } from './markers'
2
+ import { navigation } from './navigation'
2
3
  import { inFlight } from './swap-flight'
3
4
 
4
5
  const NOTHING: ReadonlySet<Node> = new Set()
5
- // What the morph never keeps across pages: islands are kept by `persist` or a refresh alone, and a script or a template is put in afresh.
6
+ // What the morph never keeps across pages: islands are kept by `persist`, a match in the same place or a refresh, never morphed, and a script or a template is put in afresh.
6
7
  const OPAQUE = `${ISLAND},slot[data-kay-server],script,template`
7
8
  // The tags OPAQUE can match, so the selector is only matched for them.
8
9
  const OPAQUE_TAGS = new Set(['slot', 'script', 'template'])
@@ -37,9 +38,9 @@ function alike(live: Node, next: Node): boolean {
37
38
  return live.id === other.id && live.getAttribute('class') === other.getAttribute('class') && (!OPAQUE_TAGS.has(live.localName) || (!live.matches(OPAQUE) && !other.matches(OPAQUE)))
38
39
  }
39
40
 
40
- // Whether a field keeps what was typed into it: it is the same field and the edit left what the server renders in it as it was, so only a visitor changed it.
41
+ // Whether a field keeps what was typed into it: it is the same field and the render left what the server renders in it as it was, so only a visitor changed it.
41
42
  function typedKept(live: Element, other: Element): boolean {
42
- if (process.env.NODE_ENV === 'production' || !inFlight.typing)
43
+ if (!inFlight.typing)
43
44
  return false
44
45
 
45
46
  if (live instanceof HTMLInputElement && other instanceof HTMLInputElement)
@@ -72,6 +73,37 @@ function holdTabStop(element: Element): void {
72
73
  }, { once: true, signal: held.signal })
73
74
  }
74
75
 
76
+ // Whether a `details` the visitor toggled keeps its state: the render leaves what the server wrote as `open` when the visitor toggled it, so only the visitor changed it. One the server changed takes the server's, and is the visitor's again from its next toggle.
77
+ function keepsOpen(live: Element, other: Element): boolean {
78
+ if (!(live instanceof HTMLDetailsElement))
79
+ return false
80
+
81
+ // A swap that keeps nothing of the visitor's leaves what it served as the new baseline.
82
+ if (!inFlight.typing) {
83
+ navigation.opened.delete(live)
84
+
85
+ return false
86
+ }
87
+
88
+ const served = navigation.opened.get(live)
89
+
90
+ if (served === undefined)
91
+ return false
92
+
93
+ if (other.hasAttribute('open') === served)
94
+ return true
95
+
96
+ navigation.opened.delete(live)
97
+
98
+ return false
99
+ }
100
+
101
+ // A change the morph makes to `open`, whose `toggle` event is not the visitor's.
102
+ function wrote(live: Element, name: string): void {
103
+ if (name === 'open' && live instanceof HTMLDetailsElement)
104
+ navigation.written.add(live)
105
+ }
106
+
75
107
  // Makes the live node read as the next one, keeping it and each child of it the next page renders again.
76
108
  function morph(live: Node, next: Node): void {
77
109
  if (!(live instanceof Element)) {
@@ -89,29 +121,37 @@ function morph(live: Node, next: Node): void {
89
121
  // Read before the attributes and the children become the next page's, which the defaults come from.
90
122
  const typed = typedKept(live, other)
91
123
 
92
- if (process.env.NODE_ENV !== 'production' && inFlight.typing && live instanceof HTMLSelectElement && live.name !== (other as HTMLSelectElement).name)
124
+ if (inFlight.typing && live instanceof HTMLSelectElement && live.name !== (other as HTMLSelectElement).name)
93
125
  inFlight.renamed.add(live)
94
126
 
95
127
  // An element's open state is closed through it, as the attribute alone would leave a modal dialog blocking the page.
96
128
  if (live instanceof HTMLDialogElement && live.open && !other.hasAttribute('open'))
97
129
  live.close()
98
130
 
131
+ const opened = keepsOpen(live, other)
132
+
99
133
  for (const { name, value } of other.attributes) {
100
- if (live.getAttribute(name) !== value)
134
+ if (live.getAttribute(name) !== value && !(opened && name === 'open')) {
135
+ wrote(live, name)
101
136
  live.setAttribute(name, value)
137
+ }
102
138
  }
103
139
 
104
140
  if (other.hasAttribute('tabindex'))
105
141
  heldTabStops.get(live)?.abort()
106
142
 
107
143
  for (const name of live.getAttributeNames()) {
108
- if (other.hasAttribute(name))
144
+ if (other.hasAttribute(name) || (opened && name === 'open'))
109
145
  continue
110
146
 
111
- if (name === 'tabindex' && live === document.activeElement)
147
+ if (name === 'tabindex' && live === document.activeElement) {
112
148
  holdTabStop(live)
113
- else
114
- live.removeAttribute(name)
149
+
150
+ continue
151
+ }
152
+
153
+ wrote(live, name)
154
+ live.removeAttribute(name)
115
155
  }
116
156
 
117
157
  morphChildren(live, other)
@@ -0,0 +1,17 @@
1
+ // cyrb53, 53 bits of a string's hash in base 36, in plain script so the browser and the docs playground run it as the server does.
2
+ export function textHash(text: string): string {
3
+ let h1 = 0xDEADBEEF
4
+ let h2 = 0x41C6CE57
5
+
6
+ for (let index = 0; index < text.length; index++) {
7
+ const code = text.charCodeAt(index)
8
+
9
+ h1 = Math.imul(h1 ^ code, 2654435761)
10
+ h2 = Math.imul(h2 ^ code, 1597334677)
11
+ }
12
+
13
+ h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^ Math.imul(h2 ^ (h2 >>> 13), 3266489909)
14
+ h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^ Math.imul(h1 ^ (h1 >>> 13), 3266489909)
15
+
16
+ return (4294967296 * (2097151 & h2) + (h1 >>> 0)).toString(36)
17
+ }
@@ -1,4 +1,5 @@
1
1
  import { AsyncLocalStorage } from 'node:async_hooks'
2
+ import { textHash } from './text-hash'
2
3
  import { freshPrefix, withIds } from './uid'
3
4
 
4
5
  // The page the server is rendering: its token keeps ids apart from those of a page swapped out around a persistent island.
@@ -50,7 +51,7 @@ export function withSlotIslands<T>(prefix: string, run: () => T): T {
50
51
  }
51
52
 
52
53
  // The prefix of the next island the server renders, written on its slot.
53
- // A `persist` island takes it from its key instead of its place, so the page that replaces one at the same URL, with the same token, cannot give another island the ids the kept one still holds.
54
+ // An island takes it from its key (a `persist` one's own, else its component's with its layout's) and its index among those of that key, not from its place in the page, so the page that replaces one at the same URL, with the same token, cannot give another island the ids the kept one still holds.
54
55
  export function islandPrefix(persist?: string): string {
55
56
  if (!page)
56
57
  return freshPrefix()
@@ -61,9 +62,10 @@ export function islandPrefix(persist?: string): string {
61
62
  if (persist === undefined)
62
63
  return `${page.token}-${page.islands++}-`
63
64
 
64
- const seen = page.kept.get(persist) ?? 0
65
+ const hash = textHash(persist).slice(-6)
66
+ const seen = page.kept.get(hash) ?? 0
65
67
 
66
- page.kept.set(persist, seen + 1)
68
+ page.kept.set(hash, seen + 1)
67
69
 
68
- return `${page.token}-p${Bun.hash(persist).toString(36)}${seen === 0 ? '' : `_${seen}`}-`
70
+ return `${page.token}-p${hash}${seen === 0 ? '' : `_${seen}`}-`
69
71
  }
@@ -184,12 +184,12 @@ export function componentClass(list: readonly unknown[]): string | undefined {
184
184
  return classText(list) || undefined
185
185
  }
186
186
 
187
- // The class of a call that hands a part's entry on, which is the parts object of a component with parts of its own, or a string: the rest of the call's classes join that component's root.
188
- export function partsClass(list: readonly unknown[]): unknown {
187
+ // The parts a list holds as one object, the rest of its classes joining its root; none when it holds no parts.
188
+ function partsIn(list: readonly unknown[]): Parts | undefined {
189
189
  const found = list.filter(isParts)
190
190
 
191
191
  if (found.length === 0)
192
- return componentClass(list)
192
+ return undefined
193
193
 
194
194
  const parts = found.length === 1 ? found[0]! : mergeParts(found)
195
195
  const rest = list.filter(item => !isParts(item))
@@ -197,9 +197,40 @@ export function partsClass(list: readonly unknown[]): unknown {
197
197
  return rest.length === 0 ? parts : taggedParts({ ...parts, root: [...rest, parts.root] })
198
198
  }
199
199
 
200
+ // The `class` of a call that hands parts on: the classes of the list as a string, none once the list holds parts, which carry them as their `root` (see `handParts`).
201
+ export function partsClass(list: readonly unknown[]): string | undefined {
202
+ return list.some(isParts) ? undefined : componentClass(list)
203
+ }
204
+
205
+ // The `parts` of a call that hands parts on: the parts its list holds, with the rest of its classes at their root, laid over the `written` parts object of the call; none when there are neither.
206
+ export function handParts(list: readonly unknown[], written?: unknown): unknown {
207
+ const own = typeof written === 'object' && written !== null && !Array.isArray(written) ? [taggedParts(Object.fromEntries(Object.entries(written).map(([name, entry]) => [name, entryParts(entry)])))] : []
208
+ const handed = partsIn(list)
209
+ const all = handed === undefined ? own : [...own, handed]
210
+
211
+ return all.length < 2 ? all[0] : mergeParts(all)
212
+ }
213
+
214
+ // The `class` and `parts` of a call handing a part of this component on, both read from one list (and the `parts` the call writes): the one prop pair a call site writes, as `partsClass` and `handParts` give them.
215
+ export function partProps(read: () => readonly [list: readonly unknown[], written?: unknown]): { readonly class: string | undefined, readonly parts: unknown } {
216
+ return {
217
+ get class() {
218
+ return partsClass(read()[0])
219
+ },
220
+ get parts() {
221
+ return handParts(...read())
222
+ },
223
+ }
224
+ }
225
+
226
+ // The entry of a part that is a component is its own parts, as `partClass` reads it from a prop.
227
+ function entryParts(entry: unknown): unknown {
228
+ return typeof entry === 'object' && entry !== null && !Array.isArray(entry) ? taggedParts(entry as Record<string, unknown>) : entry
229
+ }
230
+
200
231
  // A part of this component handed to the called one under its name, `{ spinner: ... }`, which joins the entries the call hands it: its value is what the part's classes and the caller's entry make.
201
232
  export function partHanded(part: string, list: readonly unknown[]): unknown {
202
- return taggedParts({ [part]: partsClass(list) })
233
+ return taggedParts({ [part]: partsIn(list) ?? componentClass(list) })
203
234
  }
204
235
 
205
236
  // Whether a part's classes can be listed beside another's: a string, an array, or an object of conditions, which the class normalizer reads inside an array as well.
@@ -207,7 +238,14 @@ function joinable(value: unknown): boolean {
207
238
  return typeof value === 'string' || Array.isArray(value) || (typeof value === 'object' && value !== null && !isParts(value))
208
239
  }
209
240
 
210
- // Several objects of parts as one, a part two of them give joined in order when both are classes, the later one replacing it when either is the parts of a component.
241
+ function mergedEntry(earlier: unknown, entry: unknown): unknown {
242
+ if (joinable(earlier) && joinable(entry))
243
+ return [earlier, entry]
244
+
245
+ return isParts(earlier) && isParts(entry) ? mergeParts([earlier, entry]) : entry ?? earlier
246
+ }
247
+
248
+ // Several objects of parts as one, a part two of them give joined in order when both are classes, merged the same way when both are the parts of a component, the later one replacing it otherwise.
211
249
  function mergeParts(found: readonly Parts[]): Parts {
212
250
  const merged: Record<string, unknown> = {}
213
251
 
@@ -215,7 +253,7 @@ function mergeParts(found: readonly Parts[]): Parts {
215
253
  for (const [name, entry] of Object.entries(parts)) {
216
254
  const earlier = Object.hasOwn(merged, name) ? merged[name] : undefined
217
255
 
218
- merged[name] = joinable(earlier) && joinable(entry) ? [earlier, entry] : entry ?? earlier
256
+ merged[name] = mergedEntry(earlier, entry)
219
257
  }
220
258
  }
221
259
 
@@ -226,7 +264,7 @@ const PARTS = Symbol.for('kay.parts')
226
264
 
227
265
  type Parts = Record<string, unknown> & { readonly [PARTS]?: true }
228
266
 
229
- // An object of classes by part name, as a part that is a component hands it: told from a `{ class: condition }` object, which a plain `class` takes.
267
+ // An object of classes by part name, as a part that is a component hands it: told from a `{ class: condition }` object, which a plain `class` takes, inside the list of classes of a call.
230
268
  function isParts(value: unknown): value is Parts {
231
269
  return typeof value === 'object' && value !== null && (value as Parts)[PARTS] === true
232
270
  }
@@ -235,27 +273,18 @@ function taggedParts(parts: Record<string, unknown>): Parts {
235
273
  return Object.defineProperty({ ...parts }, PARTS, { value: true })
236
274
  }
237
275
 
238
- // What a component's `class` and `parts` props give a part, `class` winning: a `class` string, array or object of conditions is the root's, and `parts` holds one entry per part, its own object when that part is a component. The parts a component hands on come tagged through `class`.
276
+ // What a component's `class` and `parts` props give a part, `class` winning: a `class` string, array or object of conditions is the root's, and `parts` holds one entry per part, its own object when that part is a component.
239
277
  export function partClass(props: unknown, part: string): unknown {
240
- const { class: value, parts } = (props ?? {}) as { class?: unknown, parts?: unknown }
241
- const own = (from: unknown): unknown => {
242
- // A `class` that is no handed-on parts object is the root's.
243
- if (typeof from !== 'object' || from === null || Array.isArray(from) || (from === value && !isParts(from)))
244
- return part === 'root' && from === value ? from : undefined
245
-
246
- const entry = Object.hasOwn(from, part) ? (from as Record<string, unknown>)[part] : undefined
247
-
248
- return typeof entry === 'object' && entry !== null && !Array.isArray(entry) ? taggedParts(entry as Record<string, unknown>) : entry
249
- }
250
- const given = own(value)
251
- const added = typeof parts === 'object' && parts !== null ? own(parts) : undefined
278
+ const { parts } = (props ?? {}) as { parts?: unknown }
279
+ const entry = typeof parts === 'object' && parts !== null && !Array.isArray(parts) && Object.hasOwn(parts, part) ? (parts as Record<string, unknown>)[part] : undefined
280
+ const added = entryParts(entry)
281
+ const given = part === 'root' ? (props as { class?: unknown } | undefined)?.class : undefined
252
282
 
253
- // The `class` entry comes last: a component handing a part on gives its caller's entry as `class` beside the `parts` its own template writes, and the caller has the last word.
254
283
  if (given === undefined || added === undefined)
255
284
  return added ?? given
256
285
 
257
- if (isParts(given) && isParts(added))
258
- return mergeParts([added, given])
286
+ if (isParts(added) && joinable(given))
287
+ return taggedParts({ ...added, root: [added.root, given] })
259
288
 
260
289
  return joinable(given) && joinable(added) ? [added, given] : given
261
290
  }
@@ -21,6 +21,15 @@ export function setCurrentUrl(read: () => URL | undefined): void {
21
21
  serverUrl = read
22
22
  }
23
23
 
24
+ // The signals kept in the query, each reading its param again from the address when a swap or a traversal changed it under them: a signal made outside a component, which an app shares between its islands, outlives the page that read it first.
25
+ export const followers = new Set<() => void>()
26
+
27
+ // Reads every signal kept in the query again from the address the page was swapped or traversed to.
28
+ export function followAddress(): void {
29
+ for (const reread of followers)
30
+ reread()
31
+ }
32
+
24
33
  // Tells the links built by `withQuery` in the browser that the address changed, a swap or a query written in place.
25
34
  export function addressChanged(): void {
26
35
  if (built !== location.pathname + location.search)
@@ -1,6 +1,6 @@
1
1
  import type { TSchema } from 'elysia'
2
2
  import type { ActionsConfig } from '../config'
3
- import type { ActionDone, ActionFailed, ActionHookContext, ActionHooks, ActionRun, ServerAction } from '../runtime/action'
3
+ import type { ActionContext, ActionDone, ActionFailed, ActionHookContext, ActionHooks, ActionRun, ServerAction } from '../runtime/action'
4
4
  import type { ErrorShape } from '../runtime/api-error'
5
5
  import type { BeforeHook, Hook } from './hooks'
6
6
  import { resolveProtection } from '../runtime/action-protection'
@@ -31,30 +31,30 @@ export function hasHooks(lists: ActionHookLists): boolean {
31
31
  }
32
32
 
33
33
  // The `context` of an action's hooks: the action's own, read through it as it is lazy, with who asks.
34
- async function contextOf({ ctx }: ActionRun): Promise<ActionHookContext> {
34
+ async function contextOf(ctx: ActionContext): Promise<ActionHookContext> {
35
35
  const { ip, userAgent, userId } = await hookContext()
36
36
 
37
37
  return Object.create(ctx, { ip: { value: ip, enumerable: true }, userAgent: { value: userAgent, enumerable: true }, userId: { value: userId, enumerable: true } }) as ActionHookContext
38
38
  }
39
39
 
40
40
  // The `beforeRun` hooks of a run: the refusal when one stops it.
41
- export async function refusedBeforeRun(lists: ActionHookLists, event: ActionRun): Promise<(ErrorShape & { retryAfter?: number | undefined }) | undefined> {
41
+ export async function refusedBeforeRun(lists: ActionHookLists, event: ActionRun, ctx: ActionContext): Promise<(ErrorShape & { retryAfter?: number | undefined }) | undefined> {
42
42
  if (lists.before.length === 0)
43
43
  return undefined
44
44
 
45
- const answer = await decide('actions.beforeRun', lists.before, event, await contextOf(event))
45
+ const answer = await decide('actions.beforeRun', lists.before, event, await contextOf(ctx))
46
46
 
47
47
  return 'refused' in answer ? answer.refused : undefined
48
48
  }
49
49
 
50
- export async function tellSuccess(lists: ActionHookLists, event: ActionRun, result: unknown): Promise<void> {
50
+ export async function tellSuccess(lists: ActionHookLists, event: ActionRun, ctx: ActionContext, result: unknown): Promise<void> {
51
51
  if (lists.success.length > 0)
52
- await dispatch('actions.onSuccess', lists.success, { ...event, result }, { context: await contextOf(event) })
52
+ await dispatch('actions.onSuccess', lists.success, { ...event, result }, { context: await contextOf(ctx) })
53
53
  }
54
54
 
55
- export async function tellError(lists: ActionHookLists, event: ActionRun, failure: Pick<ActionFailed, 'status' | 'message' | 'errors' | 'data' | 'error'>): Promise<void> {
55
+ export async function tellError(lists: ActionHookLists, event: ActionRun, ctx: ActionContext, failure: Pick<ActionFailed, 'status' | 'message' | 'errors' | 'data' | 'error'>): Promise<void> {
56
56
  if (lists.error.length > 0)
57
- await dispatch('actions.onError', lists.error, { ...event, ...failure }, { context: await contextOf(event) })
57
+ await dispatch('actions.onError', lists.error, { ...event, ...failure }, { context: await contextOf(ctx) })
58
58
  }
59
59
 
60
60
  // The action as one app serves it, with the app's `actions` defaults laid under its own options key by key: a check the action names replaces the app's, `messages` merge one level, and `protect: false` keeps the app's checks out (its `maxSize` and `messages` still apply). The action itself is left as declared, so two apps in one process (a test site after another) each read their own defaults.
@@ -3,7 +3,7 @@ import type { Elysia, TSchema } from 'elysia'
3
3
  import type { Server } from 'elysia/universal'
4
4
  import type { ActionsConfig } from '../config'
5
5
  import type { GuardContext, Locals, RouteParams } from '../runtime'
6
- import type { ActionContext, ActionRun, FieldErrors, RateKeyContext, ServerAction } from '../runtime/action'
6
+ import type { ActionContext, ActionRun, RateKeyContext, ServerAction } from '../runtime/action'
7
7
  import type { Locale } from '../runtime/i18n'
8
8
  import type { LocaleState } from '../runtime/locale-state'
9
9
  import type { ActionHookLists } from './action-hooks'
@@ -21,7 +21,7 @@ import type { ToolOutputs } from './tool-outputs'
21
21
  import type { Source } from './validate'
22
22
  import { relative } from 'node:path'
23
23
  import { KayError } from '../compiler/errors'
24
- import { decodeCall, failure, FORM_CALL, FORM_FIELD, honeypotField, isAction, isFailure, protectionFields, STAMP_FIELD } from '../runtime/action'
24
+ import { decodeCall, FORM_CALL, FORM_FIELD, honeypotField, isAction, isFailure, protectionFields, STAMP_FIELD } from '../runtime/action'
25
25
  import { joinBase } from '../runtime/base'
26
26
  import { escapeAttribute } from '../runtime/escape'
27
27
  import { localeState, runInLocale } from '../runtime/locale-state'
@@ -602,14 +602,13 @@ async function runAction(action: ServerAction<TSchema, unknown>, context: { body
602
602
  status = code
603
603
  },
604
604
  ...actionStoppers(request),
605
- fail: <Data>(code: number, data?: Data, errors?: FieldErrors) => failure(code, data as Data, errors),
606
605
  }
607
606
 
608
607
  const { lists } = named
609
- const run: ActionRun = { action: named.name, file: named.file, input: context.body, ctx }
608
+ const run: ActionRun = { action: named.name, file: named.file, input: context.body }
610
609
 
611
610
  try {
612
- const stopping = await refusedBeforeRun(lists, run)
611
+ const stopping = await refusedBeforeRun(lists, run, ctx)
613
612
 
614
613
  if (stopping !== undefined) {
615
614
  if (stopping.retryAfter !== undefined)
@@ -630,9 +629,9 @@ async function runAction(action: ServerAction<TSchema, unknown>, context: { body
630
629
  // What `ctx.once` loaded before the handler changed things is stale for the page rendered again after a failure.
631
630
  forgetOnces(request)
632
631
 
633
- // A string passed to `ctx.fail` is the form's message, read where a rate limit's is.
632
+ // A library's failed result, such as kayjs-auth's, returned as it is: its status and `data` refuse the call, a string `data` being the form's message.
634
633
  if (isFailure(result)) {
635
- await tellError(lists, run, { status: result.status, message: typeof result.data === 'string' ? result.data : result.errors?.[''] ?? '', errors: result.errors ?? {}, data: result.data, error: undefined })
634
+ await tellError(lists, run, ctx, { status: result.status, message: typeof result.data === 'string' ? result.data : result.errors?.[''] ?? '', errors: result.errors ?? {}, data: result.data, error: undefined })
636
635
 
637
636
  return await failed(request, headers, jar.cookies, { action: action.url, status: result.status, values: submittedValues(context.body), errors: { ...typeof result.data === 'string' ? { '': result.data } : {}, ...result.errors }, data: result.data }, context.server, back)
638
637
  }
@@ -642,7 +641,7 @@ async function runAction(action: ServerAction<TSchema, unknown>, context: { body
642
641
  const answer = isAsyncIterable(result) ? await (streams ? started : lastOf)(gathering(result, invalidated, askedKeys(request)), requestSignal(request)) : result
643
642
 
644
643
  await countGoneThrough(action, request, context.server, options)
645
- await tellSuccess(lists, run, answer)
644
+ await tellSuccess(lists, run, ctx, answer)
646
645
 
647
646
  // A stream names its keys on its end event, as the handler goes on invalidating until then.
648
647
  invalidatedHeader(invalidated, headers, isCall(request) && !streams)
@@ -655,11 +654,11 @@ async function runAction(action: ServerAction<TSchema, unknown>, context: { body
655
654
  // Sent on after it went through, as to a thank-you page.
656
655
  if (error instanceof Redirect) {
657
656
  await countGoneThrough(action, request, context.server, options)
658
- await tellSuccess(lists, run, undefined)
657
+ await tellSuccess(lists, run, ctx, undefined)
659
658
  }
660
659
 
661
660
  if (error instanceof Denied || error instanceof NotFound)
662
- await tellError(lists, run, { status: error instanceof Denied ? error.status : 404, message: error instanceof Denied ? error.message : 'Not Found', errors: {}, data: undefined, error })
661
+ await tellError(lists, run, ctx, { status: error instanceof Denied ? error.status : 404, message: error instanceof Denied ? error.message : 'Not Found', errors: {}, data: undefined, error })
663
662
 
664
663
  if (error instanceof Redirect || error instanceof Denied || error instanceof NotFound)
665
664
  return stopped(error, request, state, options)
@@ -672,7 +671,7 @@ async function runAction(action: ServerAction<TSchema, unknown>, context: { body
672
671
 
673
672
  // A library's limit, such as kayjs-ai's, answers like the action's own rate limit.
674
673
  if (refused !== undefined) {
675
- await tellError(lists, run, { status: refused.status, message: refused.message, errors: refused.errors, data: refused.data, error })
674
+ await tellError(lists, run, ctx, { status: refused.status, message: refused.message, errors: refused.errors, data: refused.data, error })
676
675
 
677
676
  if (refused.retryAfter !== undefined)
678
677
  headers.set('retry-after', String(refused.retryAfter))
@@ -682,7 +681,7 @@ async function runAction(action: ServerAction<TSchema, unknown>, context: { body
682
681
 
683
682
  // A mistake, or a service the handler relies on gone down: logged as any server error, and told the visitor beside the form they keep, as a refusal is.
684
683
  reportServerError(error, request, options.onError)
685
- await tellError(lists, run, { status: 500, message: 'Internal server error', errors: {}, data: undefined, error })
684
+ await tellError(lists, run, ctx, { status: 500, message: 'Internal server error', errors: {}, data: undefined, error })
686
685
 
687
686
  return failed(request, headers, jar.cookies, { action: action.url, status: 500, values: submittedValues(context.body), errors: { '': await serverErrorMessage(action, error, ctx, request, options.onError) } }, context.server, back)
688
687
  }
@@ -719,7 +718,7 @@ async function countGoneThrough(action: ServerAction<TSchema, unknown>, request:
719
718
  }
720
719
  }
721
720
 
722
- // A call gets the result; a plain form post goes back to the page it came from, which reads the result through `succeeded()`.
721
+ // A call gets the result; a plain form post goes back to the page it came from, which reads the result through `data()`.
723
722
  function succeeded(action: ServerAction<TSchema, unknown>, request: Request, jar: CookieJar, headers: Headers, result: unknown, status: number, base = ''): Response {
724
723
  if (!isCall(request))
725
724
  writeSuccess(jar.cookies, { action: action.url, succeeded: true, data: result, page: new URL(backTo(request, base), 'http://kay').pathname }, overHttps(request), base)
@@ -791,7 +790,7 @@ async function failed(request: Request, headers: Headers, cookies: CookieMap, fl
791
790
  headers.set('content-type', 'application/json')
792
791
  headers.set(FAILURE_HEADER, '1')
793
792
 
794
- return new Response(encodeOrExplain({ errors: flash.errors, data: flash.data }, `what ${flash.action} passed to ctx.fail`), { status: flash.status, headers })
793
+ return new Response(encodeOrExplain({ errors: flash.errors, data: flash.data }, `what ${flash.action} passed to ctx.deny`), { status: flash.status, headers })
795
794
  }
796
795
 
797
796
  // The page renders as for a visit, through the app, its guards and hooks included, and the failure reaches `form.failed()` in memory, so all the visitor typed comes back whatever its length.
@@ -22,7 +22,7 @@ export interface ApiModule {
22
22
  mount: string
23
23
  // The `_guard.ts` files of its directory and above, outermost first.
24
24
  guards: ApiGuard[]
25
- // No guard is asked of it on a site with `requireGuards`: it sets `api({ guards: false })`, or a library serves it.
25
+ // No guard is asked of it on a site with `guards.default` closed: it sets `api({ guards: false })`, or a library serves it.
26
26
  open?: true | undefined
27
27
  // The extension whose `api` directory holds it, whose `ExtensionApp` a module exporting a function is called with.
28
28
  extension?: string | undefined
@@ -46,9 +46,8 @@ export const REFERENCE_PATH = `${API_PREFIX}/reference`
46
46
  export function apiPathOf(value: string | undefined): string {
47
47
  return value === undefined ? API_PREFIX : servedPath(value, 'endpoints.api')
48
48
  }
49
- // Where `mcp` serves the app's tools, and where it did before 1.105, which is answered in place until 2.0.
49
+ // Where `mcp` serves the app's tools.
50
50
  export const MCP_PATH = '/_kay/mcp'
51
- export const FORMER_MCP_PATH = '/mcp'
52
51
  // Where an MCP client finds how to sign in, which the endpoint's 401 points to.
53
52
  export const RESOURCE_METADATA = '/.well-known/oauth-protected-resource'
54
53
  const SERVED_PATH = /^\/[\w.~-]+(?:\/[\w.~-]+)*$/