@kayjs/kay 1.107.0 → 1.109.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (576) hide show
  1. package/dist/eslint.js +1875 -3815
  2. package/editors/zed/extension.toml +2 -2
  3. package/llms/action-protection.md +1 -1
  4. package/llms/actions-from-islands.md +5 -5
  5. package/llms/actions-refused-fields.md +4 -4
  6. package/llms/api-from-islands.md +6 -6
  7. package/llms/browser-only.md +2 -2
  8. package/llms/cdn-caching.md +1 -1
  9. package/llms/checks.md +1 -1
  10. package/llms/code-lints.md +1 -2
  11. package/llms/component-libraries.md +1 -1
  12. package/llms/component-library-conventions.md +1 -1
  13. package/llms/components.md +4 -4
  14. package/llms/deprecated-lints.md +1 -7
  15. package/llms/effects.md +1 -1
  16. package/llms/errors.md +2 -2
  17. package/llms/events.md +1 -1
  18. package/llms/guards.md +1 -1
  19. package/llms/head.md +1 -1
  20. package/llms/hooks.md +2 -2
  21. package/llms/images.md +1 -1
  22. package/llms/island-and-form-lints.md +2 -1
  23. package/llms/island-sources.md +1 -1
  24. package/llms/islands-state-to-ids.md +2 -2
  25. package/llms/islands.md +5 -3
  26. package/llms/lints.md +1 -1
  27. package/llms/live-values.md +3 -3
  28. package/llms/local-collections.md +1 -1
  29. package/llms/locales.md +1 -1
  30. package/llms/mcp.md +2 -2
  31. package/llms/metrics.md +1 -1
  32. package/llms/navigation-from-code.md +6 -6
  33. package/llms/prerendering.md +1 -0
  34. package/llms/production.md +2 -2
  35. package/llms/project-new-and-add.md +1 -1
  36. package/llms/project.md +4 -4
  37. package/llms/proxy-and-security.md +1 -1
  38. package/llms/queues.md +1 -1
  39. package/llms/rate-limits.md +4 -4
  40. package/llms/rendering.md +1 -1
  41. package/llms/server-islands.md +2 -2
  42. package/llms/server.md +1 -1
  43. package/llms/stores.md +1 -1
  44. package/llms/styles-and-assets.md +1 -1
  45. package/llms/testing-mount.md +49 -0
  46. package/llms/testing.md +4 -45
  47. package/llms/upgrading-1-105-config.md +13 -13
  48. package/llms/upgrading-archive.md +42 -82
  49. package/llms/upgrading.md +92 -58
  50. package/llms/whats-new-archive.md +36 -1
  51. package/llms/whats-new.md +18 -39
  52. package/llms.txt +6 -7
  53. package/package.json +6 -10
  54. package/src/build/client.ts +7 -6
  55. package/src/build/icon-slots.ts +140 -0
  56. package/src/build/libraries.ts +24 -2
  57. package/src/build/plugin.ts +10 -0
  58. package/src/build/route-sizes.ts +2 -3
  59. package/src/build/runtime-chunk.ts +2 -2
  60. package/src/build/source-files.ts +8 -3
  61. package/src/build/variants.ts +90 -1
  62. package/src/check/browser-global-reads.ts +2 -2
  63. package/src/check/config-objects.ts +1 -1
  64. package/src/check/diagnose.ts +0 -22
  65. package/src/check/export-homes.ts +1 -1
  66. package/src/check/guards.ts +3 -3
  67. package/src/check/index.ts +2 -7
  68. package/src/check/moved-keys.ts +1 -1
  69. package/src/check/project.ts +4 -9
  70. package/src/check/renamed-packages.ts +3 -63
  71. package/src/check/shadow-types.ts +4 -104
  72. package/src/commands/check.ts +2 -2
  73. package/src/commands/env.ts +25 -3
  74. package/src/compiler/ast.ts +18 -16
  75. package/src/compiler/browser.ts +2 -14
  76. package/src/compiler/class-items.ts +16 -0
  77. package/src/compiler/codegen.ts +8 -8
  78. package/src/compiler/dead-code.ts +22 -0
  79. package/src/compiler/deprecated-library.ts +0 -12
  80. package/src/compiler/deprecated-lints.ts +4 -505
  81. package/src/compiler/deprecated-ui-props.ts +5 -5
  82. package/src/compiler/dom-property.ts +23 -0
  83. package/src/compiler/dom.ts +15 -15
  84. package/src/compiler/errors.ts +2 -2
  85. package/src/compiler/fence-checks.ts +2 -121
  86. package/src/compiler/hand-parts.ts +55 -0
  87. package/src/compiler/helper-imports.ts +2 -2
  88. package/src/compiler/image-attributes.ts +1 -3
  89. package/src/compiler/index.ts +20 -21
  90. package/src/compiler/island-arguments.ts +8 -95
  91. package/src/compiler/island-cause.ts +7 -7
  92. package/src/compiler/island-declaration.ts +2 -8
  93. package/src/compiler/island-lints.ts +12 -0
  94. package/src/compiler/island-marker.ts +3 -3
  95. package/src/compiler/island-problems.ts +25 -0
  96. package/src/compiler/jsx-class.ts +1 -25
  97. package/src/compiler/jsx.ts +2 -2
  98. package/src/compiler/kay-exports.ts +0 -2
  99. package/src/compiler/link-flags.ts +9 -38
  100. package/src/compiler/lints.ts +7 -14
  101. package/src/compiler/markup.ts +23 -26
  102. package/src/compiler/module-signals.ts +2 -2
  103. package/src/compiler/names.ts +1 -1
  104. package/src/compiler/page-settings.ts +11 -0
  105. package/src/compiler/parser.ts +6 -8
  106. package/src/compiler/plan.ts +1 -3
  107. package/src/compiler/rewrite.ts +3 -18
  108. package/src/compiler/script-server.ts +8 -3
  109. package/src/compiler/validate.ts +3 -8
  110. package/src/config-loader.ts +14 -4
  111. package/src/config-resolve.ts +18 -142
  112. package/src/config-shape.ts +44 -34
  113. package/src/config.ts +10 -114
  114. package/src/dev/preload.ts +4 -1
  115. package/src/lsp/server.ts +4 -0
  116. package/src/migrate/markup.ts +4 -1
  117. package/src/package-names.ts +1 -1
  118. package/src/runtime/action-call.ts +39 -335
  119. package/src/runtime/action-encode.ts +26 -0
  120. package/src/runtime/action-error.ts +3 -11
  121. package/src/runtime/action-protection.ts +2 -2
  122. package/src/runtime/action-run.ts +332 -0
  123. package/src/runtime/action-shared.ts +14 -37
  124. package/src/runtime/action-stream.ts +0 -1
  125. package/src/runtime/action.ts +1 -1
  126. package/src/runtime/call-result.ts +2 -10
  127. package/src/runtime/checks.ts +11 -11
  128. package/src/runtime/client.ts +2 -2
  129. package/src/runtime/core.ts +5 -23
  130. package/src/runtime/dom.ts +1 -1
  131. package/src/runtime/html.ts +1 -1
  132. package/src/runtime/i18n.client.ts +1 -4
  133. package/src/runtime/i18n.server.ts +1 -4
  134. package/src/runtime/i18n.ts +3 -3
  135. package/src/runtime/index.ts +2 -2
  136. package/src/runtime/island.server.ts +18 -5
  137. package/src/runtime/live-resource.server.ts +0 -1
  138. package/src/runtime/live-value.server.ts +2 -2
  139. package/src/runtime/live-value.shared.ts +7 -20
  140. package/src/runtime/live.ts +1 -12
  141. package/src/runtime/local-types.ts +1 -11
  142. package/src/runtime/local.ts +4 -14
  143. package/src/runtime/navigate-api.ts +2 -5
  144. package/src/runtime/navigation-state.ts +0 -12
  145. package/src/runtime/page-swap.ts +6 -6
  146. package/src/runtime/persist.ts +11 -3
  147. package/src/runtime/persisted.ts +4 -30
  148. package/src/runtime/presence.ts +6 -7
  149. package/src/runtime/query-param.ts +20 -12
  150. package/src/runtime/reactive.ts +3 -1
  151. package/src/runtime/refuse.ts +3 -17
  152. package/src/runtime/store-base.ts +4 -6
  153. package/src/runtime/swap-fetch.ts +1 -1
  154. package/src/runtime/values.ts +40 -23
  155. package/src/runtime/with-query.ts +9 -0
  156. package/src/server/action-hooks.ts +8 -8
  157. package/src/server/actions.ts +13 -14
  158. package/src/server/api-modules.ts +2 -3
  159. package/src/server/app-stages.ts +15 -33
  160. package/src/server/app.ts +10 -5
  161. package/src/server/auth-mails.ts +0 -2
  162. package/src/server/env-state.ts +40 -10
  163. package/src/server/flash.ts +1 -1
  164. package/src/server/guard-requirement.ts +4 -4
  165. package/src/server/image.ts +2 -2
  166. package/src/server/index.ts +0 -2
  167. package/src/server/job-context.ts +3 -3
  168. package/src/server/jobs-page.ts +1 -1
  169. package/src/server/jobs.ts +5 -9
  170. package/src/server/kept-exports.ts +0 -2
  171. package/src/server/kv.ts +11 -14
  172. package/src/server/library.ts +1 -3
  173. package/src/server/live.ts +2 -2
  174. package/src/server/mcp.ts +3 -9
  175. package/src/server/metrics.ts +2 -4
  176. package/src/server/page-settings.ts +10 -19
  177. package/src/server/prerender.ts +19 -2
  178. package/src/server/protection.ts +15 -18
  179. package/src/server/queue.ts +3 -6
  180. package/src/server/rate-limit.ts +0 -3
  181. package/src/server/render-document.ts +1 -1
  182. package/src/server/routes.ts +7 -3
  183. package/src/server/scope.ts +3 -2
  184. package/src/server/session.ts +5 -6
  185. package/src/server/setup.ts +1 -1
  186. package/src/server/signals.ts +17 -7
  187. package/src/server/signed.ts +1 -3
  188. package/src/server/source.ts +20 -4
  189. package/src/server/speculation.ts +1 -1
  190. package/src/server/storage.ts +3 -8
  191. package/src/server/validate.ts +1 -1
  192. package/src/server/vitals.ts +1 -3
  193. package/src/server/work-scope.ts +2 -4
  194. package/src/server/work.ts +1 -1
  195. package/src/server/workflow.ts +1 -1
  196. package/src/test/index.ts +2 -1
  197. package/src/test/site-actions.ts +16 -6
  198. package/src/test/site-keys.ts +10 -15
  199. package/src/test/site-socket.ts +1 -2
  200. package/src/test/site-types.ts +0 -8
  201. package/types/build/client.d.ts +1 -1
  202. package/types/build/client.d.ts.map +1 -1
  203. package/types/build/icon-slots.d.ts +7 -0
  204. package/types/build/icon-slots.d.ts.map +1 -0
  205. package/types/build/libraries.d.ts +2 -0
  206. package/types/build/libraries.d.ts.map +1 -1
  207. package/types/build/plugin.d.ts +1 -0
  208. package/types/build/plugin.d.ts.map +1 -1
  209. package/types/build/route-sizes.d.ts.map +1 -1
  210. package/types/build/source-files.d.ts.map +1 -1
  211. package/types/build/variants.d.ts.map +1 -1
  212. package/types/check/diagnose.d.ts.map +1 -1
  213. package/types/check/index.d.ts +1 -2
  214. package/types/check/index.d.ts.map +1 -1
  215. package/types/check/project.d.ts.map +1 -1
  216. package/types/check/renamed-packages.d.ts +0 -3
  217. package/types/check/renamed-packages.d.ts.map +1 -1
  218. package/types/check/shadow-types.d.ts.map +1 -1
  219. package/types/commands/env.d.ts.map +1 -1
  220. package/types/compiler/ast.d.ts +1 -2
  221. package/types/compiler/ast.d.ts.map +1 -1
  222. package/types/compiler/browser.d.ts.map +1 -1
  223. package/types/compiler/class-items.d.ts +7 -0
  224. package/types/compiler/class-items.d.ts.map +1 -0
  225. package/types/compiler/dead-code.d.ts +9 -0
  226. package/types/compiler/dead-code.d.ts.map +1 -0
  227. package/types/compiler/deprecated-library.d.ts.map +1 -1
  228. package/types/compiler/deprecated-lints.d.ts +0 -560
  229. package/types/compiler/deprecated-lints.d.ts.map +1 -1
  230. package/types/compiler/deprecated-ui-props.d.ts +1 -8
  231. package/types/compiler/deprecated-ui-props.d.ts.map +1 -1
  232. package/types/compiler/dom-property.d.ts +9 -0
  233. package/types/compiler/dom-property.d.ts.map +1 -0
  234. package/types/compiler/dom.d.ts +1 -0
  235. package/types/compiler/dom.d.ts.map +1 -1
  236. package/types/compiler/errors.d.ts +2 -2
  237. package/types/compiler/errors.d.ts.map +1 -1
  238. package/types/compiler/fence-checks.d.ts +0 -1
  239. package/types/compiler/fence-checks.d.ts.map +1 -1
  240. package/types/compiler/hand-parts.d.ts +7 -0
  241. package/types/compiler/hand-parts.d.ts.map +1 -0
  242. package/types/compiler/image-attributes.d.ts +0 -1
  243. package/types/compiler/image-attributes.d.ts.map +1 -1
  244. package/types/compiler/index.d.ts.map +1 -1
  245. package/types/compiler/island-arguments.d.ts +2 -11
  246. package/types/compiler/island-arguments.d.ts.map +1 -1
  247. package/types/compiler/island-cause.d.ts +1 -1
  248. package/types/compiler/island-cause.d.ts.map +1 -1
  249. package/types/compiler/island-declaration.d.ts +1 -3
  250. package/types/compiler/island-declaration.d.ts.map +1 -1
  251. package/types/compiler/island-lints.d.ts +10 -0
  252. package/types/compiler/island-lints.d.ts.map +1 -0
  253. package/types/compiler/island-problems.d.ts +7 -0
  254. package/types/compiler/island-problems.d.ts.map +1 -0
  255. package/types/compiler/jsx-class.d.ts +1 -2
  256. package/types/compiler/jsx-class.d.ts.map +1 -1
  257. package/types/compiler/kay-exports.d.ts.map +1 -1
  258. package/types/compiler/link-flags.d.ts +0 -6
  259. package/types/compiler/link-flags.d.ts.map +1 -1
  260. package/types/compiler/lints.d.ts +11 -572
  261. package/types/compiler/lints.d.ts.map +1 -1
  262. package/types/compiler/markup.d.ts +1 -1
  263. package/types/compiler/markup.d.ts.map +1 -1
  264. package/types/compiler/module-signals.d.ts.map +1 -1
  265. package/types/compiler/names.d.ts.map +1 -1
  266. package/types/compiler/page-settings.d.ts +4 -0
  267. package/types/compiler/page-settings.d.ts.map +1 -1
  268. package/types/compiler/parser.d.ts.map +1 -1
  269. package/types/compiler/plan.d.ts.map +1 -1
  270. package/types/compiler/script-server.d.ts.map +1 -1
  271. package/types/compiler/validate.d.ts.map +1 -1
  272. package/types/config-loader.d.ts.map +1 -1
  273. package/types/config-resolve.d.ts.map +1 -1
  274. package/types/config-shape.d.ts +1 -1
  275. package/types/config-shape.d.ts.map +1 -1
  276. package/types/config.d.ts +5 -105
  277. package/types/config.d.ts.map +1 -1
  278. package/types/dev/preload.d.ts.map +1 -1
  279. package/types/lsp/server.d.ts.map +1 -1
  280. package/types/migrate/markup.d.ts.map +1 -1
  281. package/types/runtime/action-call.d.ts.map +1 -1
  282. package/types/runtime/action-encode.d.ts +1 -0
  283. package/types/runtime/action-encode.d.ts.map +1 -1
  284. package/types/runtime/action-error.d.ts +1 -2
  285. package/types/runtime/action-error.d.ts.map +1 -1
  286. package/types/runtime/action-run.d.ts +23 -0
  287. package/types/runtime/action-run.d.ts.map +1 -0
  288. package/types/runtime/action-shared.d.ts +1 -27
  289. package/types/runtime/action-shared.d.ts.map +1 -1
  290. package/types/runtime/action-stream.d.ts.map +1 -1
  291. package/types/runtime/action.d.ts +1 -1
  292. package/types/runtime/action.d.ts.map +1 -1
  293. package/types/runtime/call-result.d.ts +0 -10
  294. package/types/runtime/call-result.d.ts.map +1 -1
  295. package/types/runtime/checks.d.ts +6 -9
  296. package/types/runtime/checks.d.ts.map +1 -1
  297. package/types/runtime/core.d.ts +2 -20
  298. package/types/runtime/core.d.ts.map +1 -1
  299. package/types/runtime/dom.d.ts +1 -1
  300. package/types/runtime/dom.d.ts.map +1 -1
  301. package/types/runtime/html.d.ts +1 -1
  302. package/types/runtime/html.d.ts.map +1 -1
  303. package/types/runtime/i18n.client.d.ts +0 -1
  304. package/types/runtime/i18n.client.d.ts.map +1 -1
  305. package/types/runtime/i18n.d.ts +1 -1
  306. package/types/runtime/i18n.d.ts.map +1 -1
  307. package/types/runtime/i18n.server.d.ts +0 -1
  308. package/types/runtime/i18n.server.d.ts.map +1 -1
  309. package/types/runtime/index.d.ts +2 -2
  310. package/types/runtime/index.d.ts.map +1 -1
  311. package/types/runtime/island.server.d.ts +1 -0
  312. package/types/runtime/island.server.d.ts.map +1 -1
  313. package/types/runtime/live-resource.server.d.ts.map +1 -1
  314. package/types/runtime/live-value.shared.d.ts +7 -15
  315. package/types/runtime/live-value.shared.d.ts.map +1 -1
  316. package/types/runtime/live.d.ts +0 -11
  317. package/types/runtime/live.d.ts.map +1 -1
  318. package/types/runtime/local-types.d.ts +0 -14
  319. package/types/runtime/local-types.d.ts.map +1 -1
  320. package/types/runtime/navigate-api.d.ts +0 -4
  321. package/types/runtime/navigate-api.d.ts.map +1 -1
  322. package/types/runtime/navigation-state.d.ts +0 -4
  323. package/types/runtime/navigation-state.d.ts.map +1 -1
  324. package/types/runtime/page-swap.d.ts.map +1 -1
  325. package/types/runtime/persist.d.ts +1 -0
  326. package/types/runtime/persist.d.ts.map +1 -1
  327. package/types/runtime/persisted.d.ts +0 -15
  328. package/types/runtime/persisted.d.ts.map +1 -1
  329. package/types/runtime/presence.d.ts +0 -2
  330. package/types/runtime/presence.d.ts.map +1 -1
  331. package/types/runtime/query-param.d.ts.map +1 -1
  332. package/types/runtime/reactive.d.ts +2 -1
  333. package/types/runtime/reactive.d.ts.map +1 -1
  334. package/types/runtime/refuse.d.ts +0 -7
  335. package/types/runtime/refuse.d.ts.map +1 -1
  336. package/types/runtime/store-base.d.ts +1 -2
  337. package/types/runtime/store-base.d.ts.map +1 -1
  338. package/types/runtime/values.d.ts +2 -1
  339. package/types/runtime/values.d.ts.map +1 -1
  340. package/types/runtime/with-query.d.ts +2 -0
  341. package/types/runtime/with-query.d.ts.map +1 -1
  342. package/types/server/action-hooks.d.ts +4 -4
  343. package/types/server/action-hooks.d.ts.map +1 -1
  344. package/types/server/actions.d.ts.map +1 -1
  345. package/types/server/api-modules.d.ts +0 -1
  346. package/types/server/api-modules.d.ts.map +1 -1
  347. package/types/server/app-stages.d.ts +5 -13
  348. package/types/server/app-stages.d.ts.map +1 -1
  349. package/types/server/app.d.ts +3 -8
  350. package/types/server/app.d.ts.map +1 -1
  351. package/types/server/auth-mails.d.ts +0 -5
  352. package/types/server/auth-mails.d.ts.map +1 -1
  353. package/types/server/env-state.d.ts +1 -0
  354. package/types/server/env-state.d.ts.map +1 -1
  355. package/types/server/guard-requirement.d.ts +0 -1
  356. package/types/server/guard-requirement.d.ts.map +1 -1
  357. package/types/server/image.d.ts +0 -1
  358. package/types/server/image.d.ts.map +1 -1
  359. package/types/server/index.d.ts +0 -2
  360. package/types/server/index.d.ts.map +1 -1
  361. package/types/server/job-context.d.ts +1 -1
  362. package/types/server/job-context.d.ts.map +1 -1
  363. package/types/server/jobs.d.ts +0 -4
  364. package/types/server/jobs.d.ts.map +1 -1
  365. package/types/server/kept-exports.d.ts.map +1 -1
  366. package/types/server/kv.d.ts +4 -4
  367. package/types/server/kv.d.ts.map +1 -1
  368. package/types/server/library.d.ts +1 -3
  369. package/types/server/library.d.ts.map +1 -1
  370. package/types/server/mcp.d.ts +0 -1
  371. package/types/server/mcp.d.ts.map +1 -1
  372. package/types/server/metrics.d.ts +0 -5
  373. package/types/server/metrics.d.ts.map +1 -1
  374. package/types/server/page-settings.d.ts +3 -3
  375. package/types/server/page-settings.d.ts.map +1 -1
  376. package/types/server/prerender.d.ts.map +1 -1
  377. package/types/server/protection.d.ts +6 -6
  378. package/types/server/protection.d.ts.map +1 -1
  379. package/types/server/queue.d.ts +1 -3
  380. package/types/server/queue.d.ts.map +1 -1
  381. package/types/server/rate-limit.d.ts +0 -2
  382. package/types/server/rate-limit.d.ts.map +1 -1
  383. package/types/server/routes.d.ts +1 -1
  384. package/types/server/routes.d.ts.map +1 -1
  385. package/types/server/scope.d.ts.map +1 -1
  386. package/types/server/session.d.ts +1 -1
  387. package/types/server/session.d.ts.map +1 -1
  388. package/types/server/signals.d.ts.map +1 -1
  389. package/types/server/signed.d.ts +0 -2
  390. package/types/server/signed.d.ts.map +1 -1
  391. package/types/server/source.d.ts +1 -1
  392. package/types/server/source.d.ts.map +1 -1
  393. package/types/server/storage.d.ts +0 -4
  394. package/types/server/storage.d.ts.map +1 -1
  395. package/types/server/vitals.d.ts +0 -1
  396. package/types/server/vitals.d.ts.map +1 -1
  397. package/types/server/work-scope.d.ts +0 -2
  398. package/types/server/work-scope.d.ts.map +1 -1
  399. package/types/server/workflow.d.ts +1 -1
  400. package/types/server/workflow.d.ts.map +1 -1
  401. package/types/test/index.d.ts.map +1 -1
  402. package/types/test/site-actions.d.ts +1 -1
  403. package/types/test/site-actions.d.ts.map +1 -1
  404. package/types/test/site-keys.d.ts +1 -1
  405. package/types/test/site-keys.d.ts.map +1 -1
  406. package/types/test/site-socket.d.ts +1 -1
  407. package/types/test/site-socket.d.ts.map +1 -1
  408. package/types/test/site-types.d.ts +0 -8
  409. package/types/test/site-types.d.ts.map +1 -1
  410. package/llms/deprecated-lints-1-105-libraries.md +0 -32
  411. package/llms/deprecated-lints-1-105.md +0 -58
  412. package/src/check/action-readers.ts +0 -115
  413. package/src/check/action-type.ts +0 -44
  414. package/src/check/ai-language.ts +0 -56
  415. package/src/check/app-hooks.ts +0 -90
  416. package/src/check/auth-methods.ts +0 -85
  417. package/src/check/auth-rate-limits.ts +0 -99
  418. package/src/check/call-result.ts +0 -242
  419. package/src/check/client-keys.ts +0 -10
  420. package/src/check/cms-options.ts +0 -81
  421. package/src/check/config-groups.ts +0 -22
  422. package/src/check/config-switches.ts +0 -38
  423. package/src/check/context-import.ts +0 -51
  424. package/src/check/env-files.ts +0 -31
  425. package/src/check/format-duration.ts +0 -75
  426. package/src/check/guard-options.ts +0 -58
  427. package/src/check/handler-events.ts +0 -149
  428. package/src/check/hook-context.ts +0 -94
  429. package/src/check/hook-names.ts +0 -104
  430. package/src/check/i18n-keys.ts +0 -50
  431. package/src/check/images-keys.ts +0 -54
  432. package/src/check/job-shapes.ts +0 -273
  433. package/src/check/link-flag-tests.ts +0 -130
  434. package/src/check/live-api.ts +0 -137
  435. package/src/check/mail-api.ts +0 -67
  436. package/src/check/one-state-api.ts +0 -357
  437. package/src/check/pages-options.ts +0 -35
  438. package/src/check/rate-enforce.ts +0 -53
  439. package/src/check/refusal-calls.ts +0 -185
  440. package/src/check/retired-lints.ts +0 -49
  441. package/src/check/route-keys.ts +0 -166
  442. package/src/check/secret-keys.ts +0 -83
  443. package/src/check/socket-frames.ts +0 -102
  444. package/src/check/source-readers.ts +0 -257
  445. package/src/check/store-ms.ts +0 -72
  446. package/src/check/store-names.ts +0 -88
  447. package/src/check/test-helpers.ts +0 -98
  448. package/src/check/ttl-names.ts +0 -142
  449. package/src/compiler/deprecated-ai-labels.ts +0 -97
  450. package/src/compiler/deprecated-ai-links.ts +0 -63
  451. package/src/compiler/deprecated-allow.ts +0 -50
  452. package/src/compiler/deprecated-auth-lints.ts +0 -14
  453. package/src/compiler/deprecated-auth-signed.ts +0 -29
  454. package/src/compiler/deprecated-children.ts +0 -66
  455. package/src/compiler/deprecated-image.ts +0 -116
  456. package/src/compiler/deprecated-island.ts +0 -155
  457. package/src/compiler/deprecated-lints-1-105.ts +0 -41
  458. package/src/compiler/deprecated-page.ts +0 -125
  459. package/src/compiler/deprecated-parts.ts +0 -22
  460. package/src/compiler/deprecated-typed-lints.ts +0 -23
  461. package/src/compiler/deprecated-ui-callbacks.ts +0 -66
  462. package/src/compiler/deprecated-ui-input.ts +0 -97
  463. package/src/compiler/deprecated-ui-items.ts +0 -47
  464. package/src/compiler/old-parts.ts +0 -84
  465. package/src/runtime/mount.compat.ts +0 -8
  466. package/src/server/moved-exports.ts +0 -17
  467. package/types/check/action-readers.d.ts +0 -3
  468. package/types/check/action-readers.d.ts.map +0 -1
  469. package/types/check/action-type.d.ts +0 -3
  470. package/types/check/action-type.d.ts.map +0 -1
  471. package/types/check/ai-language.d.ts +0 -3
  472. package/types/check/ai-language.d.ts.map +0 -1
  473. package/types/check/app-hooks.d.ts +0 -3
  474. package/types/check/app-hooks.d.ts.map +0 -1
  475. package/types/check/auth-methods.d.ts +0 -3
  476. package/types/check/auth-methods.d.ts.map +0 -1
  477. package/types/check/auth-rate-limits.d.ts +0 -3
  478. package/types/check/auth-rate-limits.d.ts.map +0 -1
  479. package/types/check/call-result.d.ts +0 -7
  480. package/types/check/call-result.d.ts.map +0 -1
  481. package/types/check/client-keys.d.ts +0 -3
  482. package/types/check/client-keys.d.ts.map +0 -1
  483. package/types/check/cms-options.d.ts +0 -3
  484. package/types/check/cms-options.d.ts.map +0 -1
  485. package/types/check/config-groups.d.ts +0 -3
  486. package/types/check/config-groups.d.ts.map +0 -1
  487. package/types/check/config-switches.d.ts +0 -3
  488. package/types/check/config-switches.d.ts.map +0 -1
  489. package/types/check/context-import.d.ts +0 -3
  490. package/types/check/context-import.d.ts.map +0 -1
  491. package/types/check/env-files.d.ts +0 -3
  492. package/types/check/env-files.d.ts.map +0 -1
  493. package/types/check/format-duration.d.ts +0 -5
  494. package/types/check/format-duration.d.ts.map +0 -1
  495. package/types/check/guard-options.d.ts +0 -3
  496. package/types/check/guard-options.d.ts.map +0 -1
  497. package/types/check/handler-events.d.ts +0 -9
  498. package/types/check/handler-events.d.ts.map +0 -1
  499. package/types/check/hook-context.d.ts +0 -3
  500. package/types/check/hook-context.d.ts.map +0 -1
  501. package/types/check/hook-names.d.ts +0 -3
  502. package/types/check/hook-names.d.ts.map +0 -1
  503. package/types/check/i18n-keys.d.ts +0 -3
  504. package/types/check/i18n-keys.d.ts.map +0 -1
  505. package/types/check/images-keys.d.ts +0 -3
  506. package/types/check/images-keys.d.ts.map +0 -1
  507. package/types/check/job-shapes.d.ts +0 -6
  508. package/types/check/job-shapes.d.ts.map +0 -1
  509. package/types/check/link-flag-tests.d.ts +0 -4
  510. package/types/check/link-flag-tests.d.ts.map +0 -1
  511. package/types/check/live-api.d.ts +0 -3
  512. package/types/check/live-api.d.ts.map +0 -1
  513. package/types/check/mail-api.d.ts +0 -3
  514. package/types/check/mail-api.d.ts.map +0 -1
  515. package/types/check/one-state-api.d.ts +0 -9
  516. package/types/check/one-state-api.d.ts.map +0 -1
  517. package/types/check/pages-options.d.ts +0 -3
  518. package/types/check/pages-options.d.ts.map +0 -1
  519. package/types/check/rate-enforce.d.ts +0 -3
  520. package/types/check/rate-enforce.d.ts.map +0 -1
  521. package/types/check/refusal-calls.d.ts +0 -3
  522. package/types/check/refusal-calls.d.ts.map +0 -1
  523. package/types/check/retired-lints.d.ts +0 -3
  524. package/types/check/retired-lints.d.ts.map +0 -1
  525. package/types/check/route-keys.d.ts +0 -3
  526. package/types/check/route-keys.d.ts.map +0 -1
  527. package/types/check/secret-keys.d.ts +0 -3
  528. package/types/check/secret-keys.d.ts.map +0 -1
  529. package/types/check/socket-frames.d.ts +0 -3
  530. package/types/check/socket-frames.d.ts.map +0 -1
  531. package/types/check/source-readers.d.ts +0 -3
  532. package/types/check/source-readers.d.ts.map +0 -1
  533. package/types/check/store-ms.d.ts +0 -3
  534. package/types/check/store-ms.d.ts.map +0 -1
  535. package/types/check/store-names.d.ts +0 -3
  536. package/types/check/store-names.d.ts.map +0 -1
  537. package/types/check/test-helpers.d.ts +0 -3
  538. package/types/check/test-helpers.d.ts.map +0 -1
  539. package/types/check/ttl-names.d.ts +0 -3
  540. package/types/check/ttl-names.d.ts.map +0 -1
  541. package/types/compiler/deprecated-ai-labels.d.ts +0 -5
  542. package/types/compiler/deprecated-ai-labels.d.ts.map +0 -1
  543. package/types/compiler/deprecated-ai-links.d.ts +0 -5
  544. package/types/compiler/deprecated-ai-links.d.ts.map +0 -1
  545. package/types/compiler/deprecated-allow.d.ts +0 -5
  546. package/types/compiler/deprecated-allow.d.ts.map +0 -1
  547. package/types/compiler/deprecated-auth-lints.d.ts +0 -12
  548. package/types/compiler/deprecated-auth-lints.d.ts.map +0 -1
  549. package/types/compiler/deprecated-auth-signed.d.ts +0 -5
  550. package/types/compiler/deprecated-auth-signed.d.ts.map +0 -1
  551. package/types/compiler/deprecated-children.d.ts +0 -4
  552. package/types/compiler/deprecated-children.d.ts.map +0 -1
  553. package/types/compiler/deprecated-image.d.ts +0 -5
  554. package/types/compiler/deprecated-image.d.ts.map +0 -1
  555. package/types/compiler/deprecated-island.d.ts +0 -9
  556. package/types/compiler/deprecated-island.d.ts.map +0 -1
  557. package/types/compiler/deprecated-lints-1-105.d.ts +0 -39
  558. package/types/compiler/deprecated-lints-1-105.d.ts.map +0 -1
  559. package/types/compiler/deprecated-page.d.ts +0 -4
  560. package/types/compiler/deprecated-page.d.ts.map +0 -1
  561. package/types/compiler/deprecated-parts.d.ts +0 -3
  562. package/types/compiler/deprecated-parts.d.ts.map +0 -1
  563. package/types/compiler/deprecated-typed-lints.d.ts +0 -21
  564. package/types/compiler/deprecated-typed-lints.d.ts.map +0 -1
  565. package/types/compiler/deprecated-ui-callbacks.d.ts +0 -5
  566. package/types/compiler/deprecated-ui-callbacks.d.ts.map +0 -1
  567. package/types/compiler/deprecated-ui-input.d.ts +0 -5
  568. package/types/compiler/deprecated-ui-input.d.ts.map +0 -1
  569. package/types/compiler/deprecated-ui-items.d.ts +0 -5
  570. package/types/compiler/deprecated-ui-items.d.ts.map +0 -1
  571. package/types/compiler/old-parts.d.ts +0 -9
  572. package/types/compiler/old-parts.d.ts.map +0 -1
  573. package/types/runtime/mount.compat.d.ts +0 -7
  574. package/types/runtime/mount.compat.d.ts.map +0 -1
  575. package/types/server/moved-exports.d.ts +0 -12
  576. package/types/server/moved-exports.d.ts.map +0 -1
@@ -0,0 +1,23 @@
1
+ import type { Span } from './ast'
2
+ import type { CodeBuilder } from './mapping'
3
+ import type { LinkPlan } from './plan'
4
+ import { neverSet } from './dead-code'
5
+
6
+ // The effect setting the property an attribute written `name={value}` stands for, as the server writes it: none for one a build leaves `{undefined}`.
7
+ export function propertyBindings<Node>(b: CodeBuilder, src: string, attribute: { name: string, expression: Span, action: boolean }, link: LinkPlan, node: Node): ((variable: (node: Node) => string) => void)[] {
8
+ if (neverSet(src, attribute))
9
+ return []
10
+
11
+ return [(variable) => {
12
+ b.add(`KayEffect(() => KayProperty(${variable(node)}, ${JSON.stringify(attribute.name)}, `)
13
+
14
+ if (attribute.action)
15
+ b.add('KayFormAction((').addSource(attribute.expression).add('))')
16
+ else if (attribute.name === 'href' && link.leaving)
17
+ b.add(`KayOutside(${variable(node)}, (`).addSource(attribute.expression).add(`)${link.rel ? ', true' : ''})`)
18
+ else
19
+ b.add('(').addSource(attribute.expression).add(')')
20
+
21
+ b.add(`${link.written && attribute.name === 'href' ? ', true' : ''}));`)
22
+ }]
23
+ }
@@ -5,8 +5,10 @@ import type { CodeBuilder } from './mapping'
5
5
  import type { BindingPlan, LinkPlan } from './plan'
6
6
  import { mayLeaveSite } from '../runtime/outside'
7
7
  import { marksServerIsland, modifiersOf } from './ast'
8
+ import { neverShown, neverTaken } from './dead-code'
8
9
  import { fieldBindings } from './dom-fields'
9
10
  import { FormHere } from './dom-here'
11
+ import { propertyBindings } from './dom-property'
10
12
  import { addHandler, listenerOptions } from './event-modifiers'
11
13
  import { decodeEntities, isFunctionAt } from './expression'
12
14
  import { addKeyParameters, addRowItem, childItems, constDeclaration, contentOf, errorParagraphArguments, isDeclaration, rowKeying, slotValue, soleDynamic } from './items'
@@ -105,6 +107,9 @@ export class DomTemplate extends TemplateWriter {
105
107
  this.element(item.node)
106
108
  b.add('); ')
107
109
  }
110
+ else if (item.kind === 'if' && neverShown(this.src, item.node)) {
111
+ b.add(`KayMarkers(${parent}); `)
112
+ }
108
113
  else {
109
114
  b.add(`{ const [KayS, KayE] = KayMarkers(${parent}); `)
110
115
  this.dynamic(item, 'null', 'KayS', 'KayE')
@@ -115,6 +120,12 @@ export class DomTemplate extends TemplateWriter {
115
120
  b.add(`${'} '.repeat(blocks)}})`)
116
121
  }
117
122
 
123
+ // A dynamic part, but for an `if` that draws nothing: its markers are in the markup and there is no block to run.
124
+ private slot(item: DynamicItem, element: string, start: string, end: string): void {
125
+ if (item.kind !== 'if' || !neverShown(this.src, item.node))
126
+ this.dynamic(item, element, start, end)
127
+ }
128
+
118
129
  // A dynamic part rendered into an element's content, or between two markers.
119
130
  private dynamic(item: DynamicItem, element: string, start: string, end: string): void {
120
131
  const { b } = this
@@ -218,7 +229,7 @@ export class DomTemplate extends TemplateWriter {
218
229
  // A chain naming no value needs no memo of it.
219
230
  b.add(`${node.branches.some(branch => branch.alias) ? 'KayBranches' : 'KayChoose'}(${at}, [`)
220
231
 
221
- for (const branch of node.branches) {
232
+ for (const branch of node.branches.filter(each => !neverTaken(this.src, each))) {
222
233
  b.wrap(branch, () => {
223
234
  b.add('[() => (').addSource(branch.test).add('), (')
224
235
 
@@ -540,18 +551,7 @@ export class DomTemplate extends TemplateWriter {
540
551
  break
541
552
  case 'value':
542
553
  this.notesLink(link, attribute.name)
543
- own.push((variable) => {
544
- b.add(`KayEffect(() => KayProperty(${variable(node)}, ${JSON.stringify(attribute.name)}, `)
545
-
546
- if (attribute.action)
547
- b.add('KayFormAction((').addSource(attribute.expression).add('))')
548
- else if (attribute.name === 'href' && link.leaving)
549
- b.add(`KayOutside(${variable(node)}, (`).addSource(attribute.expression).add(`)${link.rel ? ', true' : ''})`)
550
- else
551
- b.add('(').addSource(attribute.expression).add(')')
552
-
553
- b.add(`${link.written && attribute.name === 'href' ? ', true' : ''}));`)
554
- })
554
+ own.push(...propertyBindings(b, this.src, attribute, link, node))
555
555
 
556
556
  break
557
557
  }
@@ -620,14 +620,14 @@ export class DomTemplate extends TemplateWriter {
620
620
  html += this.templateOf(item.node, this.child(node, 'element'), bindings)
621
621
  }
622
622
  else if (sole) {
623
- bindings.push(variable => this.dynamic(item, variable(node), 'null', 'null'))
623
+ bindings.push(variable => this.slot(item, variable(node), 'null', 'null'))
624
624
  }
625
625
  else {
626
626
  const start = this.child(node, 'start')
627
627
  const end = this.child(node, 'end')
628
628
 
629
629
  html += START_MARKER + END_MARKER
630
- bindings.push(variable => this.dynamic(item, 'null', variable(start), variable(end)))
630
+ bindings.push(variable => this.slot(item, 'null', variable(start), variable(end)))
631
631
  }
632
632
  }
633
633
 
@@ -138,7 +138,7 @@ export const ERRORS = {
138
138
  },
139
139
  'client-route-fence': {
140
140
  group: 'compile',
141
- summary: 'A page, layout or special page declaring `island({ render: \'client\' })` or with a `--- client` fence: they render on the server.',
141
+ summary: 'A page, layout or special page declaring `island({ render: \'client\' })`: they render on the server.',
142
142
  fix: { file: 'llms/islands.md', heading: 'Islands' },
143
143
  },
144
144
  'server-import-in-island': {
@@ -228,7 +228,7 @@ export const ERRORS = {
228
228
  },
229
229
  'locales-invalid': {
230
230
  group: 'build',
231
- summary: 'An `i18n` config that does not hold together: no locales, a tag that is none, a default outside the locales, domains and `prefixDefault` together, `paths` naming a page that does not exist, a catalog that exports no messages or not as `defineMessages`, or `writeDraftMessages` given a locale the config does not translate.',
231
+ summary: 'An `i18n` config that does not hold together: no locales, a tag that is none, a default outside the locales, `paths` naming a page that does not exist, a catalog that exports no messages or not as `defineMessages`, or `writeDraftMessages` given a locale the config does not translate.',
232
232
  fix: { file: 'llms/locales.md', heading: 'Configuring locales' },
233
233
  },
234
234
  'font-invalid': {
@@ -508,125 +508,6 @@ export function asyncReplies(fence: ParsedFence): Diagnostic[] {
508
508
  return diagnostics
509
509
  }
510
510
 
511
- // The name an action handler reads `fail` by: `ctx.fail` for a `ctx` parameter, `fail` for a destructured one.
512
- function failReader(ctx: Node | undefined): ((call: NodeOfType<'CallExpression'>) => boolean) | undefined {
513
- if (ctx?.type === 'Identifier') {
514
- const name = ctx.name
515
-
516
- return call => call.callee.type === 'MemberExpression' && !call.callee.computed && call.callee.object.type === 'Identifier' && call.callee.object.name === name && call.callee.property.type === 'Identifier' && call.callee.property.name === 'fail'
517
- }
518
-
519
- if (ctx?.type !== 'ObjectPattern')
520
- return undefined
521
-
522
- for (const property of ctx.properties) {
523
- if (isPlainProperty(property) && !property.computed && property.key.type === 'Identifier' && property.key.name === 'fail' && property.value.type === 'Identifier') {
524
- const local = property.value.name
525
-
526
- return call => call.callee.type === 'Identifier' && call.callee.name === local
527
- }
528
- }
529
-
530
- return undefined
531
- }
532
-
533
- // The `fail` calls an expression statement drops: the call itself, awaited, or on either side of `&&`, `||`, `??` and a ternary.
534
- function droppedFails(node: Node, reads: (call: NodeOfType<'CallExpression'>) => boolean): NodeOfType<'CallExpression'>[] {
535
- if (node.type === 'CallExpression')
536
- return reads(node) ? [node] : []
537
-
538
- if (node.type === 'AwaitExpression')
539
- return droppedFails(node.argument, reads)
540
-
541
- if (node.type === 'LogicalExpression')
542
- return [...droppedFails(node.left, reads), ...droppedFails(node.right, reads)]
543
-
544
- if (node.type === 'ConditionalExpression')
545
- return [...droppedFails(node.consequent, reads), ...droppedFails(node.alternate, reads)]
546
-
547
- return node.type === 'ParenthesizedExpression' || node.type === 'TSNonNullExpression' ? droppedFails(node.expression, reads) : []
548
- }
549
-
550
- // The names `action` is called by: the one `kay` exports, as imported or not yet, and the aliases imported from it; none when another module's or a local one takes the name.
551
- function actionNames(fence: ParsedFence): Set<string> {
552
- const names = new Set(['action'])
553
-
554
- for (const node of fence.ast.body) {
555
- if (node.type === 'ImportDeclaration') {
556
- for (const specifier of node.specifiers) {
557
- const name = specifier.type === 'ImportSpecifier' ? specifier.imported : undefined
558
- const imported = name?.type === 'Identifier' ? name.name : name?.value
559
-
560
- if (node.source.value === 'kay' && imported === 'action')
561
- names.add(specifier.local.name)
562
- else if (specifier.local.name === 'action')
563
- names.delete('action')
564
- }
565
- }
566
- else if ((node.type === 'FunctionDeclaration' && node.id?.name === 'action') || (node.type === 'VariableDeclaration' && node.declarations.some(declaration => patternNames(declaration.id).includes('action')))) {
567
- names.delete('action')
568
- }
569
- }
570
-
571
- return names
572
- }
573
-
574
- // A `ctx.fail(...)` statement in an action's handler: `fail` returns the failure, where `deny`, `notFound` and `redirect` throw, so a statement not returned does nothing and the handler carries on.
575
- export function unreturnedFails(fence: ParsedFence): Diagnostic[] {
576
- if (!fence.code.includes('fail(') || !fence.code.includes('action'))
577
- return []
578
-
579
- const diagnostics: Diagnostic[] = []
580
- const names = actionNames(fence)
581
- const seen = new Set<number>()
582
-
583
- eachNode(fence.ast, (node) => {
584
- if (node.type !== 'CallExpression' || node.callee.type !== 'Identifier' || !names.has(node.callee.name))
585
- return
586
-
587
- const handler = node.arguments.findIndex(argument => argument.type === 'ArrowFunctionExpression' || argument.type === 'FunctionExpression')
588
- const fn = node.arguments[handler]
589
-
590
- if (!fn || !isFunction(fn) || !fn.body || fn.body.type !== 'BlockStatement')
591
- return
592
-
593
- const reads = failReader(fn.params[handler === 0 ? 0 : 1])
594
-
595
- if (!reads)
596
- return
597
-
598
- eachNode(fn.body, (inner) => {
599
- if (isFunction(inner))
600
- return false
601
-
602
- if (inner.type === 'ExpressionStatement') {
603
- const { expression } = inner
604
- const awaited = expression.type === 'AwaitExpression' ? expression.argument : expression
605
- const direct = awaited.type === 'CallExpression' ? awaited : undefined
606
-
607
- for (const call of droppedFails(inner.expression, reads)) {
608
- if (seen.has(call.start))
609
- continue
610
-
611
- seen.add(call.start)
612
- diagnostics.push({
613
- ...fence.shift(call),
614
- code: 'unreturned-fail',
615
- message: 'This `fail()` is not returned, so it does nothing and the handler carries on',
616
- note: '`fail` returns the failure the action answers with, where `deny`, `notFound` and `redirect` throw',
617
- help: 'write `return ctx.fail(...)`',
618
- fixes: call === direct ? [{ title: 'Return it', edits: [{ start: fence.offset + inner.start, end: fence.offset + inner.start, text: 'return ' }], safe: true }] : [],
619
- })
620
- }
621
- }
622
-
623
- return true
624
- })
625
- })
626
-
627
- return diagnostics
628
- }
629
-
630
511
  // A destructured prop read into a top-level `const` or `let` that a function or the template reads later: the declaration runs once, when the component is created, so the value keeps the prop's first value after the parent changes it.
631
512
  // A prop read as the test of a condition, as an argument of a call or `new`, as a write target or inside a class is left alone: those choose or build something once, and a name declared again anywhere in the script is left alone too.
632
513
  export function onceReadProps(fence: ParsedFence, props: PropsDeclaration | undefined, templateNames: readonly string[]): Diagnostic[] {
@@ -756,7 +637,7 @@ export function missingCaptchas(fence: ParsedFence): Diagnostic[] {
756
637
  // The checks a plain module takes, parsed only when one of them may find something.
757
638
  // A module the browser bundle reaches (`browser`) is checked for the names the browser's entries lack as well.
758
639
  export function moduleChecks(source: string, browser = false): Diagnostic[] {
759
- if (!CSS_BINDING.test(source) && !(browser && source.includes('kay/cache')) && !(source.includes(AI_PACKAGE) && source.includes('async')) && !source.includes('redirect(') && !source.includes('fail(') && !CAPTCHA_CALLS.keys().some(name => source.includes(name)))
640
+ if (!CSS_BINDING.test(source) && !(browser && source.includes('kay/cache')) && !(source.includes(AI_PACKAGE) && source.includes('async')) && !source.includes('redirect(') && !CAPTCHA_CALLS.keys().some(name => source.includes(name)))
760
641
  return []
761
642
 
762
643
  const whole = { start: 0, end: source.length }
@@ -775,5 +656,5 @@ export function moduleChecks(source: string, browser = false): Diagnostic[] {
775
656
  }
776
657
 
777
658
  function checksOf(module: ParsedFence, browser: boolean): Diagnostic[] {
778
- return [...cssImportsWithoutText(module), ...asyncReplies(module), ...openRedirects(module), ...missingCaptchas(module), ...unreturnedFails(module), ...browser ? serverOnlyImports(module) : []]
659
+ return [...cssImportsWithoutText(module), ...asyncReplies(module), ...openRedirects(module), ...missingCaptchas(module), ...browser ? serverOnlyImports(module) : []]
779
660
  }
@@ -0,0 +1,55 @@
1
+ import type { Attribute, ElementNode, NamedAttribute } from './ast'
2
+ import type { CodeBuilder } from './mapping'
3
+ import { helperName } from './markup'
4
+
5
+ type ExpressionAttribute = Extract<NamedAttribute, { kind: 'expression' }>
6
+
7
+ // The `parts` a component call writes and the spreads, whose `parts` a call handing parts on lays under its own, as the called component would otherwise lose them to the hand-off.
8
+ export function writtenParts(element: ElementNode, source: string): Attribute[] {
9
+ const hand = element.attributes.find((one): one is ExpressionAttribute => one.kind === 'expression' && source.slice(one.name.start, one.name.end) === 'parts')
10
+
11
+ return [...element.attributes.filter(one => one.kind === 'spread'), hand].filter(attribute => attribute !== undefined)
12
+ }
13
+
14
+ // What opens the list of classes of an element: an array, or on a component call the helper merging it, which is `handParts` for the `parts` of a call handing parts on.
15
+ export function openClassList(b: CodeBuilder, component: boolean, parts: boolean, handing: readonly Attribute[] | undefined): void {
16
+ const helper = handing ? 'handParts' : 'partsClass'
17
+
18
+ b.add(component ? `${helperName(parts ? helper : 'componentClass')}([` : '[')
19
+ }
20
+
21
+ // What closes the `handParts` of a call: the `parts` it writes, the spreads' under them.
22
+ export function closeHandParts(b: CodeBuilder, component: boolean, written: readonly Attribute[] | undefined): void {
23
+ b.add(component && !written ? '])' : ']')
24
+
25
+ const given = written?.filter(attribute => attribute.kind === 'expression' || attribute.kind === 'spread') ?? []
26
+ const emit = (attribute: (typeof given)[number]) => {
27
+ if (attribute.kind === 'spread')
28
+ b.add('((').addSource(attribute.expression).add(') as unknown as { parts?: unknown }).parts')
29
+ else if (attribute.kind === 'expression')
30
+ b.add('(').addSource(attribute.expression).add(')')
31
+ }
32
+
33
+ if (given.length === 1) {
34
+ b.add(', ')
35
+ emit(given[0]!)
36
+ }
37
+ else if (given.length > 1) {
38
+ b.add(', { ')
39
+
40
+ for (const [index, attribute] of given.entries()) {
41
+ b.add(index === 0 ? '...' : ', ...')
42
+ emit(attribute)
43
+ }
44
+
45
+ b.add(' }')
46
+ }
47
+
48
+ if (written)
49
+ b.add(')')
50
+ }
51
+
52
+ // Whether an attribute of a call handing parts on is one it writes itself, as `parts`: the `parts` and the spreads.
53
+ export function handsEntry(element: ElementNode, source: string, attribute: NamedAttribute, hands: boolean): boolean {
54
+ return hands && writtenParts(element, source).includes(attribute)
55
+ }
@@ -2,10 +2,10 @@ 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', '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']
5
+ const HTML_HELPERS = ['attempt', 'attribute', 'checkedMarkup', 'child', 'className', 'component', 'componentClass', 'currentPage', 'dynamic', 'element', 'errorParagraph', 'fieldDescribed', 'formConstraints', 'formKey', 'formOptions', 'formType', 'handParts', '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
- 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']
8
+ const DOM_HELPERS = ['append', 'attribute', 'branches', 'checkedMarkup', 'choose', 'close', 'component', 'componentClass', 'effect', 'errorParagraph', 'fragment', 'handParts', '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']
9
9
  // The helpers in modules of their own, as their runtimes weigh on a page whose islands use none of them: the module of each is only loaded by a page with an island that compiles to it.
10
10
  const APART = [['kay/dom-loop', ['loop', 'rowKey']], ['kay/dom-await', ['awaited']], ['kay/dom-try', ['attempt']], ['kay/dom-spread', ['dynamic', 'spread']], ['kay/dom-image', ['image']], ['kay/pending', ['pendingCall']]] as const
11
11
 
@@ -29,8 +29,6 @@ export interface ImageOptionAttributes {
29
29
 
30
30
  // What an `img` with an imported `src` takes beside `sizes`, `width` and `height`: the shape it is cut to, the quality of its variants, and whether it shows its color until it loads. Read by the source and never written.
31
31
  export const IMAGE_OPTIONS = new Set(['aspect', 'quality', 'placeholder'])
32
- // The attribute an `img` read before 1.105 for leaving out the color it shows until it loads, `placeholder={false}` since.
33
- export const NO_PLACEHOLDER = 'no-placeholder'
34
32
 
35
33
  // The attributes an `img` with an imported `src` takes besides `sizes`, and whether it shows its color until it loads.
36
34
  export function imageOptions(element: ElementNode, source: Source): { options: ImageOptionAttributes, colour: boolean } {
@@ -38,7 +36,7 @@ export function imageOptions(element: ElementNode, source: Source): { options: I
38
36
  const options = { aspect: find('aspect'), quality: find('quality'), placeholder: find('placeholder') }
39
37
  const written = (name: string) => element.attributes.some(attribute => attribute.kind !== 'spread' && source(attribute.name) === name)
40
38
 
41
- return { options, colour: !written('style') && !written(NO_PLACEHOLDER) && !placeholderOff(options.placeholder, source) }
39
+ return { options, colour: !written('style') && !placeholderOff(options.placeholder, source) }
42
40
  }
43
41
 
44
42
  // Whether the attribute is `placeholder={false}`, the one form kay reads while compiling, so the server leaves the color out.
@@ -15,17 +15,13 @@ import { actionOf, drawIcons, elementsIn, INTERACTIVE_ATTRIBUTE, SERVER_IN_ISLAN
15
15
  import { browserReads } from './browser'
16
16
  import { wrapActionButtons } from './button-forms'
17
17
  import { generate, isInteractive, islandCause, lineOf } from './codegen'
18
- import { retiredAllowComments } from './deprecated-allow'
19
- import { deprecatedChildrenProp } from './deprecated-children'
20
- import { deprecatedIslandAttributes, deprecatedIslandForms, islandProblems } from './deprecated-island'
21
- import { deprecatedPageSettings } from './deprecated-page'
22
- import { deprecatedPartsClass } from './deprecated-parts'
23
- import { asyncReplies, cssImportsWithoutText, missingCaptchas, onceReadProps, separatePageSettings, serverOnlyImports, unboundedFields, unreturnedFails } from './fence-checks'
18
+ import { asyncReplies, cssImportsWithoutText, missingCaptchas, onceReadProps, separatePageSettings, serverOnlyImports, unboundedFields } from './fence-checks'
24
19
  import { openRedirects } from './fence-redirects'
25
20
  import { cwd, scopeStorage } from './host'
26
- import { ignoredIslandExport, interactiveProps, islandMessages, malformedInteractive, withAlertKeys } from './island-arguments'
21
+ import { ignoredIslandExport, islandMessages, withAlertKeys } from './island-arguments'
27
22
  import { describeCause } from './island-cause'
28
23
  import { markerMismatch } from './island-marker'
24
+ import { islandProblems } from './island-problems'
29
25
  import { lazyImportsOf } from './lazy-imports'
30
26
  import { linkFlags } from './link-flags'
31
27
  import { applyLints, templateLints } from './lints'
@@ -83,7 +79,7 @@ export interface CompileOptions {
83
79
  twinBuild?: boolean | undefined
84
80
  // 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
81
  writtenProps?: ReadonlySet<string> | undefined
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.
82
+ // 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 `island()`, and is no island by its pin; `false` says it is a component, where a root `@block` is refused.
87
83
  page?: boolean | undefined
88
84
  // 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.
89
85
  component?: boolean | undefined
@@ -91,7 +87,7 @@ export interface CompileOptions {
91
87
  lints?: LintLevels | undefined
92
88
  // Type checking only: the types alone, for a file whose problems nothing reads, so the ones only `kay check` reports are not looked for.
93
89
  typesOnly?: boolean | undefined
94
- // Renders in the browser only, as `--- client` does: set when a package the component imports cannot load on the server.
90
+ // Renders in the browser only, as `island({ render: 'client' })` does: set when a package the component imports cannot load on the server.
95
91
  clientOnly?: boolean | undefined
96
92
  // Type-checking a static component only islands render: its children render inline with it, so the props it passes them are not serialized.
97
93
  insideIsland?: boolean | undefined
@@ -182,9 +178,9 @@ function browserCause(file: KayFile, script: ScriptAnalysis, value: ReturnType<t
182
178
  return value === undefined || binding === undefined ? undefined : { kind: value.kind, name: value.local, span: binding.span, line: lineOf(file.source, binding.span.start) }
183
179
  }
184
180
 
185
- // The cause with the props the component's `island` export lists as making a use interactive, when it lists some: a client-only component and one following a live or persisted value are islands in every use.
181
+ // The cause with the props the component's `island()` lists as making a use interactive, when it lists some: a client-only component and one following a live or persisted value are islands in every use.
186
182
  function withInteractive(cause: IslandCause | undefined, script: ScriptAnalysis): IslandCause | undefined {
187
- const interactive = interactiveProps(script)
183
+ const interactive = script.island?.interactive
188
184
 
189
185
  return cause !== undefined && interactive !== undefined && cause.kind !== 'client' && cause.kind !== 'live' && cause.kind !== 'persisted' ? { ...cause, interactive } : cause
190
186
  }
@@ -204,12 +200,12 @@ function staticPin(span: Span, cause: IslandCause): Diagnostic {
204
200
  return { ...span, code: 'static-pin', message: `This component is declared \`island({ render: 'static' })\`, and is an island: ${describeCause(cause)}`, note: 'it needs the browser, so it hydrates there', help: 'take that out of the component, or declare it `island()`' }
205
201
  }
206
202
 
207
- // A page without a server fence that is an island for a handler, a `kay` value or a live or persisted import: a page renders once, so a component should hold what needs the browser. It works until 1.108.
208
- function deprecatedPageIsland(page: boolean, route: boolean, client: boolean, check: boolean | undefined, raw: IslandCause | undefined, cause: IslandCause | undefined): Diagnostic[] {
203
+ // A page without a server fence that is an island for a handler, a `kay` value or a live or persisted import: a page renders once, so a component should hold what needs the browser.
204
+ function pageIsland(page: boolean, route: boolean, client: boolean, check: boolean | undefined, raw: IslandCause | undefined, cause: IslandCause | undefined): Diagnostic[] {
209
205
  if (!page || route || client || check !== true || raw === undefined || cause === undefined)
210
206
  return []
211
207
 
212
- return [{ ...raw.span, code: 'deprecated-page-island', checkOnly: true, message: `A page is never an island since 1.105, and this one is for ${describeCause(cause)}`, note: 'a page renders once on the server, so nothing in it should run in the browser', help: 'move what needs the browser into a component of its own and render it from the page' }]
208
+ return [{ ...raw.span, code: 'page-island', checkOnly: true, message: `A page is never an island, and this one is for ${describeCause(cause)}`, note: 'a page renders once on the server, so nothing in it should run in the browser', help: 'move what needs the browser into a component of its own and render it from the page' }]
213
209
  }
214
210
 
215
211
  // What the server fence declares for the template: its data and its exports, which the script reads as declared rather than as kay values to import.
@@ -219,9 +215,9 @@ function serverNames(server: ServerAnalysis | undefined): string[] | undefined {
219
215
 
220
216
  // What a component's script and template say of its role in the browser, from one analysis.
221
217
  interface Role {
222
- // A `--- client` component or an interactive one, an island whatever its file.
218
+ // A client-only component or an interactive one, an island whatever its file.
223
219
  always: boolean
224
- // A `--- island` fence: an island unless the file is a page, a layout or a special page, which is never one by its pin.
220
+ // An `island()` pin: an island unless the file is a page, a layout or a special page, which is never one by its pin.
225
221
  pinned: boolean
226
222
  // It imports a live or persisted value, which makes a file that is not a layout, a special page or one with a server fence an island.
227
223
  live: boolean
@@ -263,7 +259,7 @@ function roleOf(original: string, imported: ImportedSignals | undefined, page: b
263
259
  }
264
260
 
265
261
  // Whether a component renders as an island of its own, as compileKay decides it, without generating its code.
266
- // `page` says the file is a page of the routes directory (`isPageFile`), which its `--- island` fence does not make an island.
262
+ // `page` says the file is a page of the routes directory (`isPageFile`), which its `island()` declaration does not make an island.
267
263
  export function rendersAsIsland(original: string, imported?: ImportedSignals, page = false): boolean {
268
264
  const { always, live, pinned, server } = roleOf(original, imported, page)
269
265
 
@@ -356,7 +352,7 @@ export function compileKay(original: string, filename: string, options: CompileO
356
352
  ...coded(server ? separatePageSettings(source, server) : [], 'page-settings-invalid'),
357
353
  ...validate(file, script, server, generateOptions),
358
354
  ...coded(unparsed ? [] : found.diagnostics, 'signal-misuse'),
359
- ...deprecatedPageIsland(pageFile, routeFile, client, options.check, rawCause, cause),
355
+ ...pageIsland(pageFile, routeFile, client, options.check, rawCause, cause),
360
356
  ...coded(pin?.kind === 'static' && cause !== undefined && rawCause !== undefined && !routeFile && island !== undefined ? [staticPin(rawCause.span, { ...cause, interactive: undefined })] : [], 'static-pin'),
361
357
  ]
362
358
 
@@ -369,6 +365,9 @@ export function compileKay(original: string, filename: string, options: CompileO
369
365
  // Type checking only, so a page still runs while it is fixed, and fails there in development naming the same fixes.
370
366
  const serverData = server?.data.map(data => data.name) ?? []
371
367
 
368
+ // The `island` export of the `--- module` fence read before 1.109 is an error in every output, as it declares nothing now.
369
+ diagnostics.push(...ignoredIslandExport(script))
370
+
372
371
  if (checked && !client)
373
372
  diagnostics.push(...coded(browserReads(file, island !== undefined, serverData, routeFile), 'browser-only-read'), ...coded(serverImportReads(file, script, server, island !== undefined), 'server-import-in-island'))
374
373
 
@@ -379,12 +378,12 @@ export function compileKay(original: string, filename: string, options: CompileO
379
378
  const broken = diagnostics.some(diagnostic => !diagnostic.checkOnly)
380
379
 
381
380
  if (checked) {
382
- const fenceLints = [script.fence, script.moduleFence, server?.fence].flatMap(fence => fence ? [...cssImportsWithoutText(fence), ...asyncReplies(fence), ...openRedirects(fence), ...missingCaptchas(fence), ...unreturnedFails(fence)] : [])
381
+ const fenceLints = [script.fence, script.moduleFence, server?.fence].flatMap(fence => fence ? [...cssImportsWithoutText(fence), ...asyncReplies(fence), ...openRedirects(fence), ...missingCaptchas(fence)] : [])
383
382
  // The script runs in the browser as an island's and in a component only islands render.
384
383
  const browserScript = (island !== undefined || options.insideIsland === true) && !routeFile ? scriptFences(script) : []
385
384
  const unusedLints = broken ? [] : [...unreadNames(source, file.template, script, server, found.findings), ...constantSignals(source, [file.script, file.module], found.findings)]
386
385
 
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))
386
+ 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), ...linkFlags(file))
388
387
  }
389
388
 
390
389
  if (checked && pin !== undefined)
@@ -537,7 +536,7 @@ function takeBlock(file: KayFile, filename: string, options: CompileOptions, scr
537
536
  const at = file.source.slice(block.start, block.end).search(new RegExp(`(?<![\\w$])${name.replaceAll('$', '\\$')}(?![\\w$])`, 'g'))
538
537
  const start = at < 0 ? block.name.start : block.start + at
539
538
 
540
- file.diagnostics.push({ start, end: at < 0 ? block.name.end : start + name.length, code: 'fallback-invalid', message: `\`@${which}\` of ${which === 'failed' ? 'a' : 'a `--- client`'} component reads \`${name}\`, which the server does not have`, note: 'the server renders it without running the script', help: 'write static markup, or import what it needs' })
539
+ file.diagnostics.push({ start, end: at < 0 ? block.name.end : start + name.length, code: 'fallback-invalid', message: `\`@${which}\` of ${which === 'failed' ? 'a' : 'a client-only'} component reads \`${name}\`, which the server does not have`, note: 'the server renders it without running the script', help: 'write static markup, or import what it needs' })
541
540
  }
542
541
 
543
542
  return { code: compiled.tsx.replace(FALLBACK_COMPONENT, which === 'failed' ? 'function KayFailed(' : 'function KayFallback('), classes: compiled.classes }
@@ -1,4 +1,4 @@
1
- import type { Diagnostic, Span } from './ast'
1
+ import type { Diagnostic } from './ast'
2
2
  import type { AwaitAlert } from './names'
3
3
  import type { ScriptAnalysis } from './script'
4
4
  import { AWAIT_FAILED_KEY } from '../runtime/await-failed'
@@ -21,109 +21,22 @@ export function withAlertKeys(source: string, alert: AwaitAlert | undefined): st
21
21
  return alert === undefined || (!AWAIT_LINE.test(source) && !KAY_IMPORT.test(source)) ? source : `${source}\n${alert.keys.map(key => `t('${key}')`).join(' ')}`
22
22
  }
23
23
 
24
- // The `island` the `--- module` fence exports: `const` for `export const island = { hydrate, persist }`, the one form the compiler reads, `listed` for any other, `export { island }` included.
25
- export function islandExport(script: ScriptAnalysis): { form: 'const' | 'listed', span: Span } | undefined {
26
- const fence = script.moduleFence
27
-
28
- for (const statement of fence?.ast.body ?? []) {
29
- if (statement.type !== 'ExportNamedDeclaration')
30
- continue
31
-
32
- if (statement.declaration?.type === 'VariableDeclaration' && statement.declaration.declarations.some(declarator => declarator.id.type === 'Identifier' && declarator.id.name === 'island'))
33
- return { form: 'const', span: fence!.shift(statement) }
34
-
35
- if (statement.specifiers.some(specifier => specifier.exported.type === 'Identifier' ? specifier.exported.name === 'island' : specifier.exported.value === 'island'))
36
- return { form: 'listed', span: fence!.shift(statement) }
37
- }
38
-
39
- return undefined
40
- }
41
-
42
- // The problem with an `island` export nothing reads: one written any other way than `export const island`, or on a component that is no island.
43
- export function ignoredIslandExport(script: ScriptAnalysis, isIsland: boolean): Diagnostic[] {
44
- const asked = islandExport(script)
45
-
46
- if (asked !== undefined && script.island !== undefined)
47
- return [{ ...asked.span, code: 'fence-invalid', message: 'The component declares `island()` already, so its `island` export is not read', help: 'move what it says into the `island()` call and drop the export' }]
48
-
49
- if (asked?.form === 'listed')
50
- return [{ ...asked.span, code: 'fence-invalid', message: 'Only `export const island = { hydrate, persist, interactive }` is read as what the component asks of its parents', help: 'write it as that declaration' }]
51
-
52
- return asked && !isIsland ? [{ ...asked.span, code: 'fence-invalid', message: 'This component is no island, so nothing reads its `island` export', help: 'write `island()`, or drop the export' }] : []
53
- }
54
-
55
- // The `hydrate` the exported `island` asks for, when it is written as a string.
56
- export function exportedHydrate(script: ScriptAnalysis): string | undefined {
57
- if (script.island !== undefined)
58
- return script.island.hydrate
59
-
60
- for (const statement of script.moduleFence?.ast.body ?? []) {
61
- const declaration = statement.type === 'ExportNamedDeclaration' && statement.declaration?.type === 'VariableDeclaration' ? statement.declaration.declarations.find(each => each.id.type === 'Identifier' && each.id.name === 'island') : undefined
62
- const init = declaration?.init?.type === 'TSAsExpression' ? declaration.init.expression : declaration?.init
63
- const property = init?.type === 'ObjectExpression' ? init.properties.find(each => each.type === 'Property' && each.key.type === 'Identifier' && each.key.name === 'hydrate') : undefined
64
-
65
- if (property?.type === 'Property' && property.value.type === 'Literal' && typeof property.value.value === 'string')
66
- return property.value.value
67
- }
68
-
69
- return undefined
70
- }
71
-
72
- // The `interactive` of the exported `island`, `{ prop: whether it is on when a use leaves it out }`, read where it is written as an object of booleans.
73
- export function interactiveProps(script: ScriptAnalysis): Record<string, boolean> | undefined {
74
- if (script.island !== undefined)
75
- return script.island.interactive
76
-
24
+ // An `island` exported by the `--- module` fence, which nothing reads: a component says what it asks of its parents with `island({ hydrate, persist, interactive })` in its script.
25
+ export function ignoredIslandExport(script: ScriptAnalysis): Diagnostic[] {
77
26
  for (const statement of script.moduleFence?.ast.body ?? []) {
78
- const declaration = statement.type === 'ExportNamedDeclaration' && statement.declaration?.type === 'VariableDeclaration' ? statement.declaration.declarations.find(each => each.id.type === 'Identifier' && each.id.name === 'island') : undefined
79
- const init = declaration?.init?.type === 'TSAsExpression' ? declaration.init.expression : declaration?.init
80
- const property = init?.type === 'ObjectExpression' ? init.properties.find(each => each.type === 'Property' && each.key.type === 'Identifier' && each.key.name === 'interactive') : undefined
81
- const given = property?.type === 'Property' ? property.value : undefined
82
- const value = given?.type === 'TSAsExpression' ? given.expression : given
83
-
84
- if (value?.type !== 'ObjectExpression')
27
+ if (statement.type !== 'ExportNamedDeclaration')
85
28
  continue
86
29
 
87
- const props: Record<string, boolean> = {}
88
-
89
- for (const each of value.properties) {
90
- if (each.type === 'Property' && each.key.type === 'Identifier' && each.value.type === 'Literal' && typeof each.value.value === 'boolean')
91
- props[each.key.name] = each.value.value
92
- }
93
-
94
- return props
95
- }
96
-
97
- return undefined
98
- }
99
-
100
- // The problem with an `interactive` that is no object of booleans written in place, which the compiler could not read and the runtime would take as it is.
101
- export function malformedInteractive(script: ScriptAnalysis): Diagnostic[] {
102
- for (const statement of script.moduleFence?.ast.body ?? []) {
103
- const declaration = statement.type === 'ExportNamedDeclaration' && statement.declaration?.type === 'VariableDeclaration' ? statement.declaration.declarations.find(each => each.id.type === 'Identifier' && each.id.name === 'island') : undefined
104
- const init = declaration?.init?.type === 'TSAsExpression' ? declaration.init.expression : declaration?.init
105
- const property = init?.type === 'ObjectExpression' ? init.properties.find(each => each.type === 'Property' && each.key.type === 'Identifier' && each.key.name === 'interactive') : undefined
106
-
107
- if (property?.type === 'Property' && interactiveProps(script) === undefined)
108
- return [{ ...script.moduleFence!.shift(property), code: 'fence-invalid', message: '`interactive` is read only as an object of booleans written in place, each prop with whether it is on when a use leaves it out', help: 'write `interactive: { sortable: true, selectable: false }`' }]
30
+ const named = statement.declaration?.type === 'VariableDeclaration' && statement.declaration.declarations.some(declarator => declarator.id.type === 'Identifier' && declarator.id.name === 'island')
31
+ const listed = statement.specifiers.some(specifier => specifier.exported.type === 'Identifier' ? specifier.exported.name === 'island' : specifier.exported.value === 'island')
109
32
 
110
- if (property?.type === 'Property' && property.value.type === 'ObjectExpression' && property.value.properties.some(each => each.type !== 'Property' || each.key.type !== 'Identifier' || each.value.type !== 'Literal' || typeof each.value.value !== 'boolean'))
111
- return [{ ...script.moduleFence!.shift(property), code: 'fence-invalid', message: 'Every prop of `interactive` must be a name given `true` or `false`', help: 'write `interactive: { sortable: true, selectable: false }`' }]
33
+ if (named || listed)
34
+ return [{ ...script.moduleFence!.shift(statement), code: 'fence-invalid', message: 'A component declares `island({ hydrate, persist, interactive })` first in its script, and its `--- module` fence exports no `island`', help: 'write the call at the top of the script and drop the export' }]
112
35
  }
113
36
 
114
37
  return []
115
38
  }
116
39
 
117
- // Whether the `--- module` fence has `export const island = { hydrate, persist }`: what the component asks of every parent that uses it.
118
- export function exportsIslandOptions(script: ScriptAnalysis): boolean {
119
- return script.island === undefined ? islandExport(script)?.form === 'const' : script.island.asks !== undefined
120
- }
121
-
122
- // What the generated module hands `island()` of what the component asks of its parents: the `island` its `--- module` fence exports, or the object its `island()` call says.
123
- export function asksOf(script: ScriptAnalysis): string {
124
- return script.island?.asks ?? 'island'
125
- }
126
-
127
40
  // The message keys an island's source names, as the third argument to `island()`, with the flag of a lone button's form when it writes one, or nothing for an island naming none; the live values it imports go last.
128
41
  // Under `kay dev` the cause goes last, as the `data-why` the dev tool shows. A component exporting `island` passes it last of all.
129
42
  export function islandMessages(source: string, client = false, lives: string[] = [], cause?: string, fallback = false, options: string | false = false, wrapsButtons = false): string {