@kayjs/kay 1.109.0 → 1.111.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 (199) hide show
  1. package/dist/eslint.js +488 -75
  2. package/editors/zed/extension.toml +2 -2
  3. package/llms/actions-from-islands.md +1 -1
  4. package/llms/build-and-start.md +1 -1
  5. package/llms/checks.md +1 -0
  6. package/llms/component-libraries.md +1 -1
  7. package/llms/components.md +1 -1
  8. package/llms/deprecated-lints.md +1 -1
  9. package/llms/dev-tool.md +1 -1
  10. package/llms/effects.md +1 -0
  11. package/llms/head.md +1 -1
  12. package/llms/images.md +2 -0
  13. package/llms/island-and-form-lints.md +2 -1
  14. package/llms/islands-lazy-components.md +23 -0
  15. package/llms/islands.md +4 -14
  16. package/llms/lints.md +1 -1
  17. package/llms/live-values.md +1 -1
  18. package/llms/navigation-from-code.md +1 -1
  19. package/llms/navigation.md +5 -3
  20. package/llms/performance-lints.md +1 -0
  21. package/llms/prerendering.md +1 -1
  22. package/llms/project-new-and-add.md +1 -1
  23. package/llms/project.md +1 -1
  24. package/llms/templates-elements-slots-snippets.md +4 -4
  25. package/llms/upgrading-archive.md +121 -42
  26. package/llms/upgrading.md +17 -133
  27. package/llms/whats-new-archive.md +31 -31
  28. package/llms/whats-new.md +45 -30
  29. package/llms.txt +3 -2
  30. package/package.json +11 -11
  31. package/src/build/client.ts +10 -8
  32. package/src/build/island-images.ts +277 -0
  33. package/src/build/pipeline.ts +10 -4
  34. package/src/build/static.ts +99 -24
  35. package/src/build/variants.ts +132 -18
  36. package/src/check/env-types.ts +1 -1
  37. package/src/check/project.ts +4 -0
  38. package/src/check/schema-builders.ts +230 -26
  39. package/src/check/shadow-types.ts +3 -3
  40. package/src/commands/upgrade.ts +2 -1
  41. package/src/compiler/allow-comments.ts +38 -2
  42. package/src/compiler/ast.ts +4 -4
  43. package/src/compiler/codegen.ts +4 -4
  44. package/src/compiler/deprecated-lints-1-106.ts +2 -2
  45. package/src/compiler/dom.ts +4 -3
  46. package/src/compiler/hand-parts.ts +36 -8
  47. package/src/compiler/handed-data.ts +15 -0
  48. package/src/compiler/helper-imports.ts +2 -2
  49. package/src/compiler/html.ts +3 -7
  50. package/src/compiler/index.ts +7 -4
  51. package/src/compiler/island-arguments.ts +9 -0
  52. package/src/compiler/island-lints.ts +7 -0
  53. package/src/compiler/items.ts +174 -0
  54. package/src/compiler/jsx.ts +10 -11
  55. package/src/compiler/kay-exports.ts +1 -0
  56. package/src/compiler/lints.ts +6 -7
  57. package/src/compiler/markup.ts +26 -24
  58. package/src/compiler/names.ts +1 -1
  59. package/src/compiler/removed-lints.ts +90 -0
  60. package/src/compiler/rewrite-types.ts +2 -0
  61. package/src/compiler/rewrite.ts +4 -2
  62. package/src/compiler/route-lints.ts +8 -0
  63. package/src/compiler/signal-from-prop.ts +141 -0
  64. package/src/compiler/template-reads.ts +16 -0
  65. package/src/compiler/template-walk.ts +2 -1
  66. package/src/config-shape.ts +4 -1
  67. package/src/config.ts +2 -2
  68. package/src/new.ts +16 -4
  69. package/src/project.ts +3 -3
  70. package/src/runtime/await.server.ts +4 -2
  71. package/src/runtime/checks.ts +14 -2
  72. package/src/runtime/client.ts +5 -9
  73. package/src/runtime/dev-tab-env.ts +28 -3
  74. package/src/runtime/dom-loop.ts +2 -4
  75. package/src/runtime/dom.ts +2 -2
  76. package/src/runtime/html.ts +53 -7
  77. package/src/runtime/image.ts +24 -23
  78. package/src/runtime/index.ts +2 -2
  79. package/src/runtime/island.server.ts +41 -11
  80. package/src/runtime/navigate.ts +14 -0
  81. package/src/runtime/navigation.ts +9 -1
  82. package/src/runtime/page-swap.ts +6 -3
  83. package/src/runtime/reactive.ts +72 -0
  84. package/src/runtime/row-key.ts +4 -0
  85. package/src/runtime/swap-flight.ts +10 -10
  86. package/src/runtime/swap-focus.ts +56 -9
  87. package/src/runtime/swap-kept.ts +97 -29
  88. package/src/runtime/swap-morph.ts +49 -9
  89. package/src/runtime/text-hash.ts +17 -0
  90. package/src/runtime/uid.server.ts +6 -4
  91. package/src/runtime/values.ts +12 -0
  92. package/src/server/client.ts +3 -0
  93. package/src/server/dev.ts +2 -0
  94. package/src/server/image.ts +1 -1
  95. package/src/server/kept-exports.ts +1 -0
  96. package/src/server/render-document.ts +11 -8
  97. package/src/server/render.ts +3 -3
  98. package/types/build/client.d.ts +6 -0
  99. package/types/build/client.d.ts.map +1 -1
  100. package/types/build/island-images.d.ts +45 -0
  101. package/types/build/island-images.d.ts.map +1 -0
  102. package/types/build/pipeline.d.ts.map +1 -1
  103. package/types/build/static.d.ts.map +1 -1
  104. package/types/build/variants.d.ts +9 -1
  105. package/types/build/variants.d.ts.map +1 -1
  106. package/types/check/project.d.ts.map +1 -1
  107. package/types/check/schema-builders.d.ts.map +1 -1
  108. package/types/commands/upgrade.d.ts.map +1 -1
  109. package/types/compiler/allow-comments.d.ts +2 -0
  110. package/types/compiler/allow-comments.d.ts.map +1 -1
  111. package/types/compiler/ast.d.ts +1 -1
  112. package/types/compiler/ast.d.ts.map +1 -1
  113. package/types/compiler/deprecated-lints-1-106.d.ts +2 -2
  114. package/types/compiler/deprecated-lints-1-106.d.ts.map +1 -1
  115. package/types/compiler/deprecated-lints.d.ts +2 -2
  116. package/types/compiler/dom.d.ts.map +1 -1
  117. package/types/compiler/hand-parts.d.ts +6 -3
  118. package/types/compiler/hand-parts.d.ts.map +1 -1
  119. package/types/compiler/handed-data.d.ts +5 -0
  120. package/types/compiler/handed-data.d.ts.map +1 -0
  121. package/types/compiler/html.d.ts.map +1 -1
  122. package/types/compiler/index.d.ts.map +1 -1
  123. package/types/compiler/island-arguments.d.ts +5 -0
  124. package/types/compiler/island-arguments.d.ts.map +1 -1
  125. package/types/compiler/island-lints.d.ts +7 -0
  126. package/types/compiler/island-lints.d.ts.map +1 -1
  127. package/types/compiler/items.d.ts +14 -0
  128. package/types/compiler/items.d.ts.map +1 -1
  129. package/types/compiler/jsx.d.ts.map +1 -1
  130. package/types/compiler/kay-exports.d.ts.map +1 -1
  131. package/types/compiler/lints.d.ts +20 -5
  132. package/types/compiler/lints.d.ts.map +1 -1
  133. package/types/compiler/markup.d.ts +3 -1
  134. package/types/compiler/markup.d.ts.map +1 -1
  135. package/types/compiler/names.d.ts.map +1 -1
  136. package/types/compiler/removed-lints.d.ts +3 -0
  137. package/types/compiler/removed-lints.d.ts.map +1 -0
  138. package/types/compiler/rewrite-types.d.ts +1 -0
  139. package/types/compiler/rewrite-types.d.ts.map +1 -1
  140. package/types/compiler/route-lints.d.ts +8 -0
  141. package/types/compiler/route-lints.d.ts.map +1 -1
  142. package/types/compiler/signal-from-prop.d.ts +4 -0
  143. package/types/compiler/signal-from-prop.d.ts.map +1 -0
  144. package/types/compiler/template-reads.d.ts +1 -0
  145. package/types/compiler/template-reads.d.ts.map +1 -1
  146. package/types/compiler/template-walk.d.ts.map +1 -1
  147. package/types/config-shape.d.ts.map +1 -1
  148. package/types/config.d.ts +3 -1
  149. package/types/config.d.ts.map +1 -1
  150. package/types/new.d.ts.map +1 -1
  151. package/types/project.d.ts +2 -2
  152. package/types/project.d.ts.map +1 -1
  153. package/types/runtime/await.server.d.ts.map +1 -1
  154. package/types/runtime/checks.d.ts +8 -2
  155. package/types/runtime/checks.d.ts.map +1 -1
  156. package/types/runtime/client.d.ts.map +1 -1
  157. package/types/runtime/dev-tab-env.d.ts.map +1 -1
  158. package/types/runtime/dom-loop.d.ts +2 -1
  159. package/types/runtime/dom-loop.d.ts.map +1 -1
  160. package/types/runtime/dom.d.ts +2 -2
  161. package/types/runtime/dom.d.ts.map +1 -1
  162. package/types/runtime/html.d.ts +6 -3
  163. package/types/runtime/html.d.ts.map +1 -1
  164. package/types/runtime/image.d.ts.map +1 -1
  165. package/types/runtime/index.d.ts +2 -2
  166. package/types/runtime/index.d.ts.map +1 -1
  167. package/types/runtime/island.server.d.ts +1 -0
  168. package/types/runtime/island.server.d.ts.map +1 -1
  169. package/types/runtime/navigate.d.ts.map +1 -1
  170. package/types/runtime/navigation.d.ts +4 -0
  171. package/types/runtime/navigation.d.ts.map +1 -1
  172. package/types/runtime/reactive.d.ts +5 -0
  173. package/types/runtime/reactive.d.ts.map +1 -1
  174. package/types/runtime/row-key.d.ts +2 -0
  175. package/types/runtime/row-key.d.ts.map +1 -0
  176. package/types/runtime/swap-flight.d.ts +1 -1
  177. package/types/runtime/swap-flight.d.ts.map +1 -1
  178. package/types/runtime/swap-focus.d.ts +2 -0
  179. package/types/runtime/swap-focus.d.ts.map +1 -1
  180. package/types/runtime/swap-kept.d.ts.map +1 -1
  181. package/types/runtime/swap-morph.d.ts.map +1 -1
  182. package/types/runtime/text-hash.d.ts +2 -0
  183. package/types/runtime/text-hash.d.ts.map +1 -0
  184. package/types/runtime/uid.server.d.ts.map +1 -1
  185. package/types/runtime/values.d.ts +4 -0
  186. package/types/runtime/values.d.ts.map +1 -1
  187. package/types/server/app-stages.d.ts +3 -1
  188. package/types/server/app-stages.d.ts.map +1 -1
  189. package/types/server/app.d.ts +3 -1
  190. package/types/server/app.d.ts.map +1 -1
  191. package/types/server/client.d.ts +2 -0
  192. package/types/server/client.d.ts.map +1 -1
  193. package/types/server/dev.d.ts +1 -0
  194. package/types/server/dev.d.ts.map +1 -1
  195. package/types/server/kept-exports.d.ts.map +1 -1
  196. package/types/server/render-document.d.ts +1 -1
  197. package/types/server/render-document.d.ts.map +1 -1
  198. package/types/server/render.d.ts +2 -2
  199. package/types/server/render.d.ts.map +1 -1
@@ -1,14 +1,14 @@
1
1
  id = "kay"
2
2
  name = "Kay"
3
3
  description = "Highlighting and the kay language server for .kay components"
4
- version = "1.109.0"
4
+ version = "1.111.0"
5
5
  schema_version = 1
6
6
  authors = [ "Kaynooo" ]
7
7
  repository = "https://github.com/Kayno0o/kayjs"
8
8
 
9
9
  [grammars.kay]
10
10
  repository = "https://github.com/Kayno0o/kayjs"
11
- rev = "v1.109.0"
11
+ rev = "v1.111.0"
12
12
  path = "editors/tree-sitter-kay"
13
13
 
14
14
  [language_servers.kay]
@@ -119,7 +119,7 @@ p {column()}
119
119
 
120
120
  - An island imports the action from the page and calls it, as in [Call an action from an island](#call-an-action-from-an-island): `const { ok, data, error } = await add({ title })`, or `const id = await add({ title }).orThrow()` to throw the failure.
121
121
  - An optional field (`optional: true`) takes `undefined` as the field left out, `exactOptionalPropertyTypes` or not: `resize({ file, width: max ?? undefined })`. A wrong field is reported at that field, not against the `FormData` form of the call.
122
- - Once a call went through, the page shows what it changed, its loads run again as `refresh()` runs them, where the page swap runs: islands whose props did not change keep their state. A page with `liveRefresh: true` in its [settings](routing.md#page-settings) is left alone when every cached key the handler invalidated (`cached(..., { live: true })`) is one the page or a `resource()` follows: its live connection, once open, shows them a moment after the answer (`x-kay-invalidated` names the keys on the answer; a streaming action's end event names them, as it goes on invalidating until the stream ends). One key not followed, more than 20 keys or a connection that is down load the page as before, and `refresh: true` always does.
122
+ - Once a call went through, the page shows what it changed, its loads run again as `refresh()` runs them, where the page swap runs: every island stays with its state and takes its new props in place, and what the visitor typed in a static field or opened in a `details` stays unless the server changed it ([navigation](navigation.md#islands-kept-across-pages)). A page with `liveRefresh: true` in its [settings](routing.md#page-settings) is left alone when every cached key the handler invalidated (`cached(..., { live: true })`) is one the page or a `resource()` follows: its live connection, once open, shows them a moment after the answer (`x-kay-invalidated` names the keys on the answer; a streaming action's end event names them, as it goes on invalidating until the stream ends). One key not followed, more than 20 keys or a connection that is down load the page as before, and `refresh: true` always does.
123
123
  - `add({ title }, { refresh: false })` leaves the page as it is, so a frequent write from an island (a vote, an undo) needs no API route to avoid the refresh; `add` answers a refusal as a result, as `await add(input, { refresh: false })` does.
124
124
  - `await add.settled()` resolves once no call to `add` is in flight, whichever way they went (a stream counts until it ends; it never rejects), so an island that fired writes without awaiting them waits for them there; `save.settled()` does the same for the calls made through a `track()` handle.
125
125
  - `add.pending()` reads, reactively, whether a call the page made is still in flight, and `add.progress()` how much of a call carrying files the browser sent, from 0 to 1: `button(disabled={add.pending()})`.
@@ -58,7 +58,7 @@ kay build --static --outdir dist
58
58
  - It carries the maps of its code and of the browser build too, compressed (about 1.5 MB for a small app), so a stack in its logs and an island's report to `onError` point at your `.kay` lines as under `kay start`.
59
59
  - It reads nothing of the project from disk but a `.env` and `bunfig.toml` where it runs, as `bun` would, so a file a page reads at runtime by path, rather than importing it, is not in it; the root, routes and public directory it was built with win over the options given to `pages()`.
60
60
  - `--compile` and `--entry` are relative to the current directory.
61
- - A build removes the executable the last `--compile` wrote, and the folder the last `--static` wrote (only one holding its `.kay-static` marker), before it starts: Tailwind scans every file of the project, so a leftover output would give its stylesheets the classes it names, at the cost of reading it.
61
+ - A build removes the executable the last `--compile` wrote, and the folder the last `--static` wrote (only one holding its `.kay-static` marker) unless git ignores it, before it starts: Tailwind scans every file of the project git does not ignore, so a leftover output would give its stylesheets the classes it names, at the cost of reading it. An ignored folder such as `dist` stays in place, served whole, until the new export replaces it.
62
62
  - The public directory cannot be named `client`.
63
63
  - The executable carries `kay.config.ts` without its `plugins`, nor the imports and top-level declarations only they used, side effects included, so a build plugin such as Tailwind's, whose native addon loads from node_modules, never runs there;
64
64
  - Plugins set other than as a property of the object the file exports by default, or beside a spread, stay in, with a warning.
package/llms/checks.md CHANGED
@@ -120,6 +120,7 @@ kay lint --cache
120
120
 
121
121
  - `typescript7`, which `kay check` and the type checks of `kay dev`, `kay build` and the editor server run on, and `axe-core`, which `kay a11y`, `page.a11y()` and the dev tool's a11y warnings run on, are optional peers of kay: the app lists both in `devDependencies`, as `kay new` writes them, so a production install carries neither.
122
122
  - Without `typescript7` those commands stop at once with `bun add -d typescript7@npm:typescript@^7.0.2`, without `axe-core` the a11y ones with `bun add -d axe-core@^4.14.0`; `kay dev` says so once at start and goes on without type checks, and `kay build --no-check` needs neither. `kay doctor`'s `peers` fails for the first and warns for the second.
123
+ - An optional peer of a kay library is reported by `kay check` when the app's configuration needs it: `auth()` with no `store` function or `AuthStore`, a SQLite file included, needs `@kaynooo/pg-orm`, and the check fails with `bun add @kaynooo/pg-orm`.
123
124
  - `kay upgrade` adds both to an app coming from a kay before 1.97, in the first `kay check` it runs (`bun add --dev`).
124
125
 
125
126
  ### Linting
@@ -54,7 +54,7 @@ A package can ship `.kay` components, which the app installing it compiles as it
54
54
  - One project renders with one set of settings: `bun test`, the server and `kay build` all read them from `kay.config.ts`.
55
55
  - kay's own libraries, `@kayjs/auth`, `@kayjs/ui`, `@kayjs/mail`, `@kayjs/cms` and `@kayjs/ai`, are released with kay at its version, each peering on kay's minor and on the libraries of that same version: install the ones matching the app's kay, and move them together.
56
56
  - An app on a `^0.x` range of one of kay's libraries moves it to kay's version by hand, as a caret on 0.x never reaches it.
57
- - A library linked rather than installed, `"@kayjs/ui": "link:../kayjs-ui"`, works the same, and so does one installed in a `node_modules` above the project, as a workspace hoists it, or kept under `node_modules/.bun/` by Bun's isolated linker, a workspace's default, whose stylesheets the app's Tailwind plugin processes all the same, a bare `@import` of the library's own dependencies included: the app's own `package.json` names it either way. A linked library's own `kay`, a dev dependency in its folder, loads as the app's, so its `api()` and its signals are the app's own; its other peers resolve from its folder, as any linked package's do.
57
+ - A library linked rather than installed, `"@kayjs/ui": "link:../kayjs-ui"`, works the same, and so does one installed in a `node_modules` above the project, as a workspace hoists it, or kept under `node_modules/.bun/` by Bun's isolated linker, a workspace's default, whose stylesheets the app's Tailwind plugin processes all the same, a bare `@import` of the library's own dependencies included: the app's own `package.json` names it either way. `kay check` resolves a library's own imports from where Bun linked its dependencies, so the app lists only the library. A linked library's own `kay`, a dev dependency in its folder, loads as the app's, so its `api()` and its signals are the app's own; its other peers resolve from its folder, as any linked package's do.
58
58
 
59
59
  ### Extensions
60
60
 
@@ -221,7 +221,7 @@ p {game.miners[0].ore}
221
221
  - `linked(() => board.tiers)` from `kay` is a writable signal that follows its source: an island edits it locally, and it takes its source's value again whenever that changes: `tiers = moved` shows the edit, and once a refresh or the next page gives a new `board`, `tiers()` reads its tiers.
222
222
  - A `linked` signal drops its edit when its source changes, even when the source comes back to the value it was edited over.
223
223
  - `linked` reads a prop of a component inside an island, or of an island marked `persist`, the ones whose props change in place, a prop given unchanged keeping its edit.
224
- - A top-level island whose props changed on a refresh renders afresh from them, its dialogs and focus lost: one whose state should outlive a refresh, such as an editor, is marked `persist`, so it stays and takes the new props.
224
+ - An island stays on a refresh and takes the new props in place, its dialogs, focus and signals kept: what it reads from `props` in its template or an effect follows them, a `signal(light)` seeded from a prop keeps the first value, and `linked(() => light)` is the form that follows. A list whose items move is kept by `persist={id}`.
225
225
  - `selection<Key>(initial?)` from `kay` holds one selected string or number key among many rows, or none. It is a signal: it reads as `selected()` and writes as `selected = id`.
226
226
  - `selected.is(row.id)` re-runs only for the rows a change selects or unselects, not every row: `tr(class={{ danger: selected.is(row.id) }})`.
227
227
 
@@ -13,5 +13,5 @@ The lints of the `deprecated` group, each the old form a minor replaced, reporte
13
13
  | Lint | Default | Group | Reports |
14
14
  | --- | --- | --- | --- |
15
15
  | `deprecated-action-options` | warn | deprecated | The arguments of `action` before 1.107, `action(schema, handler, options)` and `action(handler, options)`: the options come first, with the input in them, as an API route's do, `action({ input: schema, ...options }, handler)` and `action(options, handler)`. `input` is a plain record of fields or any schema. The old forms work until 2.0. Found on the `action` a file imports from `kay`, in the TypeScript files and the fences of `.kay` files; the fix moves the arguments and keeps their text. |
16
- | `deprecated-schema-builders` | warn | deprecated | The PascalCase builders of `s` before 1.106, which kay's own lowercase builders replace, each taking the same field options (`optional`, `default`, `error`, `label`, `description`, `example`) and short names for the rest: `s.String` is `s.string` (`min`, `max`), `s.Integer` `s.int`, `s.Number` and `s.Numeric` `s.number`, `s.Boolean` and `s.BooleanString` `s.boolean`, `s.Array` `s.list`, `s.UnionEnum` and `s.UnionKeys` `s.enum`, and `s.Date`, `s.Literal`, `s.Union`, `s.Object`, `s.File`, `s.Files`, `s.Secret` and `s.Public` their lowercase names; `s.Optional(field)` is `optional: true` in the options of the field; an `s.Object({ ... })` that is the schema of an `action` or a `defineEnv` is the record of fields alone; and a file size written `'2m'` is `'2mb'`. The old names work until 2.0. Found on the `s` a file imports from `kay`, in the TypeScript files and the fences of `.kay` files. The fix renames the builder and the options that changed; an `s.Optional` around anything but one of these builders, such as a helper of `kay/content`, is left as it is. A lowercase `s.object` refuses a key its shape lacks where kay reads the schema itself (an action's input, an API route's body, `defineEnv`, collection frontmatter), where `s.Object` let it by: write `{ extra: 'strip' }` where the old way is wanted. A query, the headers and the cookies of a request carry keys no schema names, so their unknown keys are dropped whatever the schema says. |
16
+ | `deprecated-schema-builders` | warn | deprecated | The PascalCase builders of `s` before 1.106, which kay's own lowercase builders replace, each taking the same field options (`optional`, `default`, `error`, `label`, `description`, `example`) and short names for the rest: `s.String` is `s.string` (`min`, `max`), `s.Integer` `s.int`, `s.Number` and `s.Numeric` `s.number`, `s.Boolean` and `s.BooleanString` `s.boolean`, `s.Array` `s.list`, `s.UnionEnum` and `s.UnionKeys` `s.enum`, and `s.Date`, `s.Literal`, `s.Union`, `s.Object`, `s.File`, `s.Files`, `s.Secret` and `s.Public` their lowercase names; `s.Optional(field)` is `optional: true` in the options of the field; an `s.Object({ ... })` that is the schema of a `defineEnv` is the record of fields alone, as an env reads only the names it declares; and a file size written `'2m'` is `'2mb'`. The old names work until 2.0. Found on the `s` a file imports from `kay`, in the TypeScript files and the fences of `.kay` files. The fix renames the builder and the options that changed, and keeps what each did: an `s.Array` takes `max: Number.MAX_SAFE_INTEGER` (the lowercase list stops at 1,000 items), an `s.String` with no `maxLength` takes it too (the lowercase string stops at 10,000 characters), except in an action's input and an API route's `body`, which cap a string at 10,000 already, and an `s.Object` `extra: 'strip'`, a rewrite whose options are not an object literal being reported without a fix; an `s.Union` of `Object.keys(R).map(key => s.Literal(key))` is `s.enum(R)`, and any other `s.Union` of a mapped array is reported without a fix; an `s.Optional` around anything but one of these builders, such as a helper of `kay/content`, is left as it is. A lowercase `s.object` refuses a key its shape lacks where kay reads the schema itself (an action's input, an API route's body, `defineEnv`, collection frontmatter), where `s.Object` let it by, so the fix writes `{ extra: 'strip' }`. A query, the headers and the cookies of a request carry keys no schema names, so their unknown keys are dropped whatever the schema says. |
17
17
  | `deprecated-ui-props` | warn | deprecated | A kayjs-ui or kayjs-ai prop under its name before 1.98. `heading` on a Dialog, SidePanel or FormDialog is `title`, which takes a string or a `@title` block as a Card's does, and the string that named the dialog for screen readers is `label`. `variant` on a Stat, Chat or ChatLauncher is `layout`, `variant` naming only the frame of a control. The old names work until 2.0. The fix renames the prop or the block, and the `title` string beside a `heading` to `label`; it offers none where the new name is already written. |
package/llms/dev-tool.md CHANGED
@@ -27,7 +27,7 @@ The Request tab shows the route matched, the layouts, the params, the locale, th
27
27
  - Its Network tab lists what the page fetched, read off Resource Timing, by navigation, newest first: the load, then each page swap, the last 5 kept, each request with its kind (document, page for a swap or prefetch, action, server island, fetch, script, stylesheet, image, font), status, size or `from the cache`, time and start after the navigation, an error status counted on the tab for the page shown; the tool's own requests, the live reload's and `/_kay/dev/` are left out, a hover prefetch is listed under its page, and another site's answer shows no status or size without `Timing-Allow-Origin`;
28
28
  - Its Head tab shows the page's head as it is now: the search result it makes, its title and description with their length and the description's limit of 160 characters, the canonical link, hreflang alternates, the robots tag, whether the sitemap lists the page, the og and twitter tags with a preview of the social card image, and each JSON-LD block parsed or with its parse error; what `kay check` would flag in a built page's head shows as a problem, and with `seo` set but no origin it says there is no canonical link or sitemap; it reads again after each page swap;
29
29
  - Its Routes tab lists every page, endpoint and API route the server serves, each locale's copy of a page on its own line, filtered by path or file, a path no request fills in linking to itself, fetched again after each restart; a section of what kay serves itself lists the sitemap, robots.txt, feeds, manifest, favicons, service worker, health check and a library's dev pages such as kayjs-mail's `/_kay/mail`, only those the running server serves, so a path an app file took over shows as the app's, and with `seo` set but no origin it says why there is no sitemap or robots.txt; under it a "kay's plumbing" group lists kay's own endpoints the app serves, one line each with its purpose and a `docs` link (the build files, `/_kay/assets/*` and `/_kay/images/*` once the build has some, `/_kay/images`, `/_kay/card`, `/_kay/files/*`, `POST /_kay/action/<file>/<name>` and `GET /_kay/fields/<file>/<name>` once an action exists, `/_kay/live`, `/_kay/error`, `/_kay/csp` with `security.reports`, `/_kay/preview` and `/_kay/draft` with `preview`, `/_kay/env.js` with an `s.public` field, `/_kay/search.json` and `/_kay/search/*` with a search index, the `analytics()` and `vitals()` routes, `/_kay/THIRD-PARTY-LICENSES.txt`), the filter box matching their path and purpose, a GET path with nothing to fill in linking to itself under `base`;
30
- - Its Env tab lists each public variable (`s.public`) sent to the browser, read from `/_kay/env.js` with its value, flags one whose value looks like a secret (a URL with a password, a well-known token prefix, a hexadecimal or random string), only noting a name ending in `_KEY`, and says when the app sends no public env; the server's own env is never shown;
30
+ - Its Env tab lists each public variable (`s.public`) sent to the browser, read from `/_kay/env.js` with its value, flags one whose value looks like a secret (a URL with a password, a well-known token prefix, a hexadecimal or random string), only noting a name ending in `_KEY`, and says when the app sends no public env, without asking for `/_kay/env.js` then, as the page's request block tells it (no 404 in the browser console); the server's own env is never shown;
31
31
  - Its Images tab lists each image of the page with the variant it got (a ladder width, a crop, the share card, or not resized by kay), the format and bytes the server answers with (a HEAD request, only for a loaded image of kay's image route or built variants, with a timeout; any other image is not asked), the size served against the size drawn (flagged past 4 times the pixels shown, never for an SVG, whose address ends in `.svg` or whose fetch answered `image/svg+xml`, as Resource Timing keeps it), the largest contentful paint, and an image without `width` and `height` or lazy-loaded while in view; copies of one image drawn alike share a row with their count, and hovering or focusing a row outlines each, and the list follows the page as images change;
32
32
  - Its Performance tab shows the page load's LCP (with its element), CLS and INP as the browser reports them while the page is used, each rated against its good limit (2.5 s, 0.1, 200 ms) and naming the page they were measured on once a swap moved away from it, and the page's footprint measured in the browser (the DOM elements without the tool's own, the requests of the load, the EcoIndex grade and score and the grams of CO2e per view, worked out by the server with the models `kay build` uses, [Build](build-and-start.md#build-and-start-commands)), then the HTML (the document the browser holds), CSS and JS gzipped and the images, fonts and other files as the browser says they came, measured again after a swap, with the entry, the islands' chunks and the other chunks apart (a page a swap fetched and an action are not counted, another site's file counts as a request of unknown weight); the sizes are dev sizes, not minified, larger than `kay build` makes them, and a "Last kay build" block gives the route's scripts and stylesheets from the report `.kay` keeps (its age, `~` for an estimate, nothing before a first build);
33
33
  - Its Not found tab lists the paths a production run recorded visitors found nothing at (the database of the app's `store`, SQLite or Postgres, else `data/not-found.sqlite`: the log `kay not-found` reads), most hit first, with the hosts they came from and the suggested target, those a `redirects` entry answers left out; a field holds the target (the suggestion, or one typed) and Add redirect writes it into `kay.config.ts` as `kay not-found --redirect` does, then `kay dev` restarts; `kay dev` records nothing itself, so the tab leaves the list while the file, or the Postgres table `kay_missing`, is absent (it creates none).
package/llms/effects.md CHANGED
@@ -71,6 +71,7 @@ p {seconds()}s on the page, last key {key()}
71
71
 
72
72
  - `effect(fn)` runs once the render is done and again whenever what it read changes; `effect(fn, { signal })` stops it when the signal aborts, as `every`, `watch` and `listen` stop.
73
73
  - `onMount(fn)` is the sugar for `effect(() => untrack(fn))`: it runs once, after the markup is in place, and never runs again. It takes `{ signal }` too. `onCleanup`, `untrack`, `batch`, `root` and `flush` come from `kay` as well.
74
+ - `followed(read, draw)` draws what a block shows for the item `read` returns once, however often the item is replaced by a copy under the same key: `draw` gets the item, and a block it calls reads its parameter as the current item where it is used, so `{followed(() => row, row => cell(row, column))}` under `for row of rows key={row.id}` keeps the cell's nodes and focus while `rows.indexOf(row)` and `row === selected` hold in it. A value that is not an object is drawn as a call is, again when it changes. More reads after `draw`, `followed(() => entry.row, (row, index) => item(row, index), () => entry.index)`, are other arguments the block reads in place. `slot name(item, index)` called with names or paths does it for the first argument already, reading every other argument in place too, so a reorder keeps the block's nodes, and in a `form` as anywhere else. A block that does not read a parameter through its name, one taken as a pattern, a default or a rest, is drawn again when that argument changes, as is a plain function handed the item.
74
75
  - Which one: `effect` to keep something in step with the signals it reads, `watch(source, run)` to react when `source` changes (the callback reads what it likes, gets the value before, and `{ immediate: true }` runs it once at the start too), `onMount` for what happens once, `every` for a timer and `listen` for an event.
75
76
  - A function an `effect` or `onMount` callback returns runs as its cleanup, as one passed to `onCleanup` does: `effect(() => { const t = setInterval(tick, 1000); return () => clearInterval(t) })`.
76
77
  - `effect`, `watch`, `every`, `listen` and `onCleanup` run with no owner at a module's top level, after an `await`, or in a timer: nothing stops the first four, which live until the page goes, and `onCleanup` drops its function. In development each logs a `[kay]` warning naming it, once, and `kay check` reports a call in an inline handler (one more per event), a timer, a promise callback or after an `await` as the `unowned-effect` lint; `root(fn)` is the owner to give them.
package/llms/head.md CHANGED
@@ -203,7 +203,7 @@ export default defineConfig({
203
203
  ```
204
204
 
205
205
  - With `i18n`, `name`, `titleTemplate`, `description`, `image`, `imageAlt` and `locale` each take a string or a record of one string per locale, `description: { en: 'What the site is', fr: 'Ce qu\'est le site' }`, so no page sets a tag for its language's; a locale the record lacks reads the default locale's. The head lints check every text. Each surface reads the locale it is served for: the page's tags and share card name follow the page's locale, and the web manifest does too (see below), but the one OpenAPI document is titled with the default locale's `name`.
206
- - `head` adds tags to every page's head, written as a `head` block compiles them, a tag's text as `children`: `head: [{ tag: 'script', props: { src: '/stats.js', defer: true } }, { tag: 'meta', props: { name: 'color-scheme', content: 'light dark' } }]`. An analytics script that needs the visitor's consent loads from an island once they agreed (see [Privacy](privacy.md)).
206
+ - `head` adds tags to every page's head, written as a `head` block compiles them, a tag's text as `props.children`, never a `children` beside `props`, which `kay check` refuses: `head: [{ tag: 'script', props: { src: '/stats.js', defer: true } }, { tag: 'script', props: { children: 'window.dataLayer = []' } }, { tag: 'meta', props: { name: 'color-scheme', content: 'light dark' } }]`. An analytics script that needs the visitor's consent loads from an island once they agreed (see [Privacy](privacy.md)).
207
207
  - A layout or the page setting a tag of the same identity replaces one of those.
208
208
  - An inline script or style among them is let through by the content security policy, its hash added.
209
209
  - `site` is an origin, nothing after the host.
package/llms/images.md CHANGED
@@ -131,6 +131,8 @@ img(src={hero} sizes="(min-width: 60rem) 50vw, 100vw" alt="The workshop")
131
131
  - The URL is signed with a key the build keeps beside the client build and never serves, so nobody can have the site draw a title of their own; whitespace runs read as one space and a title is cut at 200 characters before it is signed.
132
132
  - Each distinct title is one more card file, so a page titled by what visitors type, such as a search, draws one card per query.
133
133
  - `kay build` writes the cards its prerendered pages ask for as files, which a static export links, refusing one on an image from `assets.images.dirs`; one on an image from `assets.images.remote` is drawn from a download.
134
+ - On a static export an island that draws an imported image in the browser links the same files as the server HTML, under the base. The build writes the ladder of every imported image and reads the `img` and `image()` calls of the islands' components, so a crop, a quality or a width below the ladder drawn only by a `render: 'client'` island has its file too; a `sizes`, `aspect` or `quality` that is no literal is not read, and its variant needs the same call in a server-rendered place.
135
+ - On a static export an island's `image('https://cms.example/a.jpg', { width, height })` with a literal URL on a host `assets.images.remote` lists is downloaded at build time (`remote.timeout` applies; a failure fails the build naming the URL) and linked as files; any other remote image or upload keeps its own URL in the browser, and an island image the build cannot read (a source, a size, a crop, a quality or `sizes` that is no literal, or a URL on a host `images.remote` does not list) warns with `static-remote-image`, a best-effort read of the island's source.
134
136
  - Variants are served by `/_kay/images?src=...&w=...`, which answers only those widths, `&crop=16x9` for a cut one and `?src=...&card` for the share card.
135
137
  - `kay build` writes every variant of every imported image, and the cut ones, share cards and widths under 320 its prerendered pages ask for, served as files with a year of immutable caching; development makes them on request, kept in `.kay/cache/images`.
136
138
  Images stored at runtime, images looked up by `assets.images.resolve` and `assets.images.guards`, and images on another host (`assets.images.remote`) are in [Images uploaded at runtime and from other hosts](images-runtime-and-remote.md#runtime-and-remote-images).
@@ -20,10 +20,11 @@
20
20
  | `uncalled-signal` | deny | islands | A signal or memo the template names without calling it where its value goes, `{count}` or `if count > 1`: a signal is read by calling it, in the template as in the script, `{count()}`. Handed on whole, as a component prop or a function argument, it passes the signal itself, which a parameter typed `Signal<T>`, `Memo<T>`, a function type or a generic `T` takes; one typed `unknown` or `any` is reported too, `String(count)`. `--fix` calls the signal named where its value goes. |
21
21
  | `constant-signal` | deny | islands | A signal the component script declares and only ever reads: it never changes, so a plain `const` renders the same without the reactivity. |
22
22
  | `signal-set-call` | deny | islands | A signal written `count.set(value)`, as a statement or an arrow's body, where assigning it, `count = value`, compiles to the same call; an updater written inline, `count.set(c => c * 2)`, and a `.set` whose value an expression uses are left. `--fix` assigns it. |
23
+ | `signal-from-prop` | warn | islands | A `signal` seeded from a destructured prop at the top of an island's script, `signal(light)` or `signal(todo.title)` that the island never writes: the island stays when the page gives it new props, as after an action or a refresh, so the signal keeps the first value. `linked(() => light)` follows the prop; `--fix` writes it, adding `linked` to the `kay` import. A signal the island writes (a counter starting from a prop) is its own state and is left alone, as is a prop named `initial...` or `default...`. |
23
24
  | `server-only-import` | deny | islands | `invalidatePage` or `sqliteCache` imported from `kay/cache` by an island's script, a browser-only component, a component only islands render, or a `.ts` module they import: the browser's `kay/cache` has `cached` and `invalidate` alone, so the build fails on the import. |
24
25
  | `missing-captcha` | warn | forms | A call of `password.register`, `password.requestReset`, `magicLink.request` or `password.signIn` on a receiver named `*auth` with no `captcha` option, where neither the file nor a module's `authCore` sets `captcha: false`: kayjs-auth's default proof of work refuses it as `{ ok: false, error: 'captcha' }`. Pass `{ captcha: input.captcha }` from a form carrying `input(type="hidden" name="captcha" data-kay-work={await auth.captcha.challenge('register')})`. In `.kay` fences and `.ts` modules alike. |
25
26
  | `island-marker` | deny | islands | An `island()` declaration on a page, layout or special page, which are never islands. |
26
27
  | `page-island` | deny | islands | A page without a `--- server` fence that needs the browser (an `on*`, `bind:` or `ref`, a browser value of `kay`, a live or persisted import), which a page never does: move it into a component the page renders. |
27
- | `island-prop` | deny | islands | A component that is not an island passing one a value its type says cannot be sent: a function, a block with parameters, a symbol, an object holding one. `island()` is the fix, offered, never applied by `--fix`. Found by the type check. |
28
+ | `island-prop` | deny | islands | A component that is not an island passing one a value its type says cannot be sent: a function, a block with parameters, a symbol, an object holding one. A function or a block with parameters is no error for an island that lists `interactive` props when the use writes none of them. `island()` is the fix, offered, never applied by `--fix`. Found by the type check. |
28
29
  | `hydration-mismatch` | deny | islands | An island reading the clock, `Math.random()` or a `toLocale*String` or `Intl` format with no locale (or, for dates, no `timeZone`) while it renders, which the server and the browser compute apart; `// kay-allow hydration-mismatch` allows a deliberate read. |
29
30
  | `unowned-effect` | warn | islands | `effect`, `watch`, `every`, `listen`, `debounced`, `throttled`, `onMount` or `onCleanup` called in a timer, a promise callback or after an `await`, where no owner stops them and each call lives until the page goes, or in an inline event handler or `listen` handler, where each event adds one stopped only when the component goes. Call them in the component script, or inside `root()`. Only inline handlers are seen: a named handler, a conditional handler and an `await` inside a loop are not. |
@@ -0,0 +1,23 @@
1
+ # Islands: components that load when they first draw
2
+
3
+ The rest of [Islands](islands.md).
4
+
5
+ ## Common tasks
6
+
7
+ - Keep a large component out of the page's first load: draw it in a branch (`if`, `else`, a `match` case, a closed `Dialog`), and it loads when it first draws, with no declaration.
8
+ - Keep a component eager: draw it once outside a branch, or read it as a `snippet` value.
9
+
10
+ ## Reference
11
+
12
+ ### Components that load when they first draw
13
+
14
+ - A component an island imports loads on its own, with no declaration, when every tag using it sits where the island may not draw it at first paint: inside an `if`, `else`, `match` case or `@failed`, or in the lines or `@block` of a component that draws them only in such a branch (a closed `Dialog` and a `FormDialog` draw their body only when open). A tag also drawn outside a branch, a `snippet` read as a value, a dynamic tag or a server island keeps the import eager. A `for` body or a `pending` block inherits the position of the loop or `await` around it.
15
+ - What the server drew is loaded before the island hydrates (the page preloads its chunks, and the island names them in `data-lazy`), so its markup is claimed as it stands. What it did not draw loads when it first draws: a visitor reaching for the island (pointer over it, focus or touch inside it) loads every such component ahead, so the click finds the code in, except with `Save-Data`, which loads one when it opens.
16
+ - Until the code arrives the branch draws nothing, then the component in its place. A chunk that fails to load is tried again after 1 s and 3 s, a deploy that dropped it reloads the page as other chunks do, and a failure for good goes to `reportError` and `console.error`, not to `@failed`, which a render error of the branch reaches as ever; the branch tries again the next time it opens. A server-drawn chunk that fails to load leaves its island to draw that branch afresh.
17
+ - Only a component of 2,000 bytes of source or more loads this way, a chunk that only repeats code the islands load anyway is folded back into them after the bundle, so is every lazy chunk of a build when together they hold under 6,000 minified bytes (the lazy runtime would cost more), and an island that renders in the browser only (`clientOnly`) keeps its imports eager. A module with lazy imports awaits what the server drew at its top level, so a page without one carries none of this.
18
+ - A name inside a string or a whole-line comment of the file is no use of the component: only a tag or other code naming it keeps its import eager (a Table's `'Select all'` once kept its Select in every island). kayjs-ui's `Form`, `FormDialog` and `SaveForm` load the code that sends and reports a form (`forms-send`, with the toast it reports through) with the first send or blur check, tried once more when the chunk fails, so a page with a closed form-dialog does not carry it.
19
+ - `kay/dom-lazy` is the compiler's output contract for it, not API. `kay build --analyze` lists the modules of every island, a lazy component's apart from the eager ones.
20
+
21
+ A refresh, or a visit keeping its layout, keeps an island and gives it the new props in place; seed from a prop with `linked(() => prop)` ([Navigation](navigation.md#islands-kept-across-pages)).
22
+
23
+ Shared and persisted state, transitions, error fallbacks, element size, context and unique ids are in [Islands: state to unique ids](islands-state-to-ids.md).
package/llms/islands.md CHANGED
@@ -92,7 +92,7 @@ button {label}
92
92
 
93
93
  `island()` alone says the component is an island though nothing in it needs the browser, and `render` says how it renders: `'island'` (the default), `'client'` for one that renders in the browser only (`island({ render: 'client' })`, see [Browser-only code](browser-only.md)), `'static'` to hold it to staying no island, so anything in it that needs the browser is the compile error `static-pin`. A `--- island`, `--- client` or `--- static` fence line is an unknown fence, and a `--- module` fence exports no `island`.
94
94
 
95
- A component can also list the props that make a use of it an island: `island({ interactive: { selectable: false, pageSize: false } })`, each prop with whether it is on when a use leaves it out. A page or a server component whose use turns none of them on, passes no function, no promise and nothing `island` could not send, and writes no `hydrate` or `persist`, gets the component as plain markup: no island, and no script for the page when nothing else on it needs one. Its children and blocks render in the page as an island's do, and an island inside it stays an island of its own. A use inside another island is part of that island as before, and the props the use is given decide, so a spread counts. A route that is not prerendered still counts the island in `kay build`'s size estimate, an upper bound. `kay explain island` lists the props.
95
+ A component can also list the props that make a use of it an island: `island({ interactive: { selectable: false, pageSize: false } })`, each prop with whether it is on when a use leaves it out. A page or a server component whose use turns none of them on, passes no promise and nothing `island` could not send, and writes no `hydrate` or `persist`, gets the component as plain markup: no island, and no script for the page when nothing else on it needs one. A function it is handed, a block taking parameters among them, is called by the server and is no `island-prop` while the use writes none of the listed props, `hydrate`, `persist` or `render` (a spread, or a function inside an object or array, still is). Its children and blocks render in the page as an island's do, and an island inside it stays an island of its own. A use inside another island is part of that island as before, and the props the use is given decide, so a spread counts. A route that is not prerendered still counts the island in `kay build`'s size estimate, an upper bound. `kay explain island` lists the props.
96
96
 
97
97
  ### Animate an element in and out
98
98
 
@@ -239,7 +239,7 @@ if !connected()
239
239
  ### Islands
240
240
 
241
241
  - A component is interactive when any element in it has an `on*` handler, a `bind:` (on an element or a component) or a `ref`, or when its script uses a value from `kay`, such as `signal`; the rule is at the top.
242
- - `ActionError`, `ActionRedirectError`, `ApiError`, `apiUrl`, `byteCount`, `composing`, `ctx`, `defer`, `defineUi`, `describeField`, `durationMs`, `escapeHtml`, `formErrors`, `isEmail`, `lengthMs`, `localPath`, `postedChecked`, `postedValue`, `postedValues`, `publicEnv`, `recipe`, `route`, `s`, `sanitizeHtml`, `trustHtml`, `uid`, `validate`, `withBase` and `withQuery` from `kay` compute the same on both sides and keep a component static; every other value of `kay` needs the browser (state, effects, lifecycle, browser readings, navigation: `navigate`, `refresh`, `call` and `logFrom` among them), and so does `relativeTime` of `kay/i18n`.
242
+ - `ActionError`, `ActionRedirectError`, `ApiError`, `apiUrl`, `byteCount`, `composing`, `ctx`, `defer`, `defineUi`, `describeField`, `durationMs`, `escapeHtml`, `followed`, `formErrors`, `isEmail`, `lengthMs`, `localPath`, `postedChecked`, `postedValue`, `postedValues`, `publicEnv`, `recipe`, `route`, `s`, `sanitizeHtml`, `trustHtml`, `uid`, `validate`, `withBase` and `withQuery` from `kay` compute the same on both sides and keep a component static; every other value of `kay` needs the browser (state, effects, lifecycle, browser readings, navigation: `navigate`, `refresh`, `call` and `logFrom` among them), and so does `relativeTime` of `kay/i18n`.
243
243
  - A namespace or default import of `kay` or `kay/i18n` (`import * as i18n from 'kay/i18n'`) always makes an island, as the compiler cannot tell which names the component reads through it: import the names (`import { formatDate } from 'kay/i18n'`) to keep a component static that only formats.
244
244
  - An interactive component renders on the server and hydrates in the browser as an island.
245
245
  - Everything else ships no JavaScript, except the small script swapping pages in on a page posting a form to an action, and elsewhere one line keeping Back right after a reload (see [Navigation](navigation.md#navigation)).
@@ -247,7 +247,7 @@ if !connected()
247
247
  - A button opens a popover or a dialog with no handler, so the component stays static: `button(popovertarget="menu")` toggles `ul#menu(popover)`, and `button(commandfor="settings" command="show-modal")` opens `dialog#settings`. `command` is `show-modal`, `close`, `request-close`, `show-popover`, `hide-popover`, `toggle-popover` or a `--custom` name the target hears as a `command` event, and `kay check` types it. `popovertarget` needs Chrome and Edge 114, Firefox 125, Safari 17; `commandfor` and `command` Chrome and Edge 135, Firefox 144, Safari 26.2, past the floor below, so an app keeping older browsers uses `popovertarget` or an `onClick`.
248
248
  - kay's browser code runs on Chrome and Edge 98, Firefox 104 and Safari 16.4 or later; kayjs-ui's popovers, tooltips, toasts and site nav menu need the Popover API, Chrome and Edge 114, Firefox 125, Safari 17, and its popovers, tooltips and site nav lists sit beside their trigger through CSS anchor positioning, Chrome and Edge 129, Firefox 147, Safari 26, so an older browser opens them away from their trigger; its colours use `light-dark()` and its carousel `inert`, which every browser with anchor positioning has. Bun bundles an island's code as written, newer syntax and APIs included, so an app keeping those browsers stays off what they lack, such as `Map.groupBy` or `Promise.withResolvers`.
249
249
  - `kay build` lists each island under its JavaScript with what makes it one, the first `on*`, `bind:`, `ref`, value from `kay` or `island()` declaration as `onClick, line 4`; `--format json` gives them as `why` and `cause` (`kind`, `name`, `line`) on each island of `built.sizes.islands` (a route's `islands` under `built.routes` only lists their files); `why` stays for tools reading it and `cause` is the data. `kay explain island <file>` says a component's role and cause and the rule, and `kay explain island` lists every island of the project (`--format json` for both).
250
- - `kay check` reads from the types what a static component hands an island, not from how the call looks: a value typed as a function, a symbol, a class instance or an object holding one (a `Column` with a `sortValue` function), or a block with parameters, is the error `island-prop` at the prop, and a value that is data says nothing, an action, a Date, a list a `map` built, a call returning a string, nor does one typed `any` or `unknown`. `island()` first in the component's script is the fix: `kay check --fix` writes it where the value is always a function, and only offers it where the type is a union holding one, as the component may be static on some pages. A page, layout or special page is never an island, so it passes the island data or goes through a component of its own. Rendering throws an `IslandPropsError` naming the prop and the same fix, as no component is made an island for what it passes. `island({ render: 'static' })` pins the other way: anything that makes the component an island is the compile error `static-pin`, standing at the `on*`, import or call that does it, and a function it hands an island is `island-prop`. A pin on a page, layout or special page is `island-marker`, as they are never islands, and a static pin on one says nothing. A `// kay-island` or `// kay-static` comment pins nothing: the declaration does. The editor shows a lens on a component's first line saying whether it is an island and why, and a click on it reveals the `on*`, import or declaration that decides it; under `kay dev` the Islands tab of the dev tool shows the same cause on each island, from a `data-why` attribute on its slot that a production build never writes.
250
+ - `kay check` reads from the types what a static component hands an island, not from how the call looks: a value typed as a function, a symbol, a class instance or an object holding one (a `Column` with a `sortValue` function), or a block with parameters, is the error `island-prop` at the prop (a function or a block with parameters is no error for an island listing `interactive` props, when the use writes none of them), and a value that is data says nothing, an action, a Date, a list a `map` built, a call returning a string, nor does one typed `any` or `unknown`. `island()` first in the component's script is the fix: `kay check --fix` writes it where the value is always a function, and only offers it where the type is a union holding one, as the component may be static on some pages. A page, layout or special page is never an island, so it passes the island data or goes through a component of its own. Rendering throws an `IslandPropsError` naming the prop and the same fix, as no component is made an island for what it passes. `island({ render: 'static' })` pins the other way: anything that makes the component an island is the compile error `static-pin`, standing at the `on*`, import or call that does it, and a function it hands an island is `island-prop`. A pin on a page, layout or special page is `island-marker`, as they are never islands, and a static pin on one says nothing. A `// kay-island` or `// kay-static` comment pins nothing: the declaration does. The editor shows a lens on a component's first line saying whether it is an island and why, and a click on it reveals the `on*`, import or declaration that decides it; under `kay dev` the Islands tab of the dev tool shows the same cause on each island, from a `data-why` attribute on its slot that a production build never writes.
251
251
  - A component the server renders per request inside an otherwise prerendered page, such as a form carrying a fresh token, is a server island instead: see [Server islands](server-islands.md#server-islands).
252
252
 
253
253
  ### Props to an island
@@ -255,6 +255,7 @@ if !connected()
255
255
  - Props a static component passes to an island are serialized for the browser: plain objects and arrays, strings, numbers, booleans, `null` and `undefined`.
256
256
  - Dates, Maps, Sets, bigints, URLs and RegExps arrive as themselves, and a value referenced twice arrives once.
257
257
  - They go into the page as JSON in an attribute, quoted with whichever quote it holds fewer of; every page carries them, so pass what the island reads rather than a whole object it picks from.
258
+ - A page that is an island itself (a closure passed to an interactive component) sends only the `--- server` consts its script or template read, so a list only the fence reduces stays on the server; one the template reads goes whole, so slice it in the fence.
258
259
  - A `Snippet` prop (children and `@name` blocks without parameters) crosses; a `Snippet<[...]>` is a function and does not (below). Children and `@name` blocks without parameters pass from any static parent, a page or a layout included: the server renders them with the parent, as static markup the island shows where its template puts `slot` or the prop, and their code never reaches the browser.
259
260
  - An island among those children is one of its own, hydrating by itself, and keeps its state when the island hides the block and shows it again, or moves it, since the island shows the same nodes each time.
260
261
  - A block the island did not show on the server, or a client-only island's, travels in its props as markup and is built once shown.
@@ -281,14 +282,3 @@ if !connected()
281
282
  ### The action caller
282
283
 
283
284
  - The code that runs an action call (its queue, timeout and retries, the post and its answer) loads with the first call, so an island that only declares or passes an action does not carry it; the action's own state (`pending()`, `data()`, `status()`, `error()`) is there from the first paint, and a call counts as pending at once, before that code is in, its `onStart` hook running when it is. A call whose code never loads rejects without running its hooks. An island holding an action caller loads it at idle, so a call made as the page goes away finds it in; a chunk a deploy dropped reloads the page as other chunks do.
284
-
285
- ### Components that load when they first draw
286
-
287
- - A component an island imports loads on its own, with no declaration, when every tag using it sits where the island may not draw it at first paint: inside an `if`, `else`, `match` case or `@failed`, or in the lines or `@block` of a component that draws them only in such a branch (a closed `Dialog` and a `FormDialog` draw their body only when open). A tag also drawn outside a branch, a `snippet` read as a value, a dynamic tag or a server island keeps the import eager. A `for` body or a `pending` block inherits the position of the loop or `await` around it.
288
- - What the server drew is loaded before the island hydrates (the page preloads its chunks, and the island names them in `data-lazy`), so its markup is claimed as it stands. What it did not draw loads when it first draws: a visitor reaching for the island (pointer over it, focus or touch inside it) loads every such component ahead, so the click finds the code in, except with `Save-Data`, which loads one when it opens.
289
- - Until the code arrives the branch draws nothing, then the component in its place. A chunk that fails to load is tried again after 1 s and 3 s, a deploy that dropped it reloads the page as other chunks do, and a failure for good goes to `reportError` and `console.error`, not to `@failed`, which a render error of the branch reaches as ever; the branch tries again the next time it opens. A server-drawn chunk that fails to load leaves its island to draw that branch afresh.
290
- - Only a component of 2,000 bytes of source or more loads this way, a chunk that only repeats code the islands load anyway is folded back into them after the bundle, so is every lazy chunk of a build when together they hold under 6,000 minified bytes (the lazy runtime would cost more), and an island that renders in the browser only (`clientOnly`) keeps its imports eager. A module with lazy imports awaits what the server drew at its top level, so a page without one carries none of this.
291
- - A name inside a string or a whole-line comment of the file is no use of the component: only a tag or other code naming it keeps its import eager (a Table's `'Select all'` once kept its Select in every island). kayjs-ui's `Form`, `FormDialog` and `SaveForm` load the code that sends and reports a form (`forms-send`, with the toast it reports through) with the first send or blur check, tried once more when the chunk fails, so a page with a closed form-dialog does not carry it.
292
- - `kay/dom-lazy` is the compiler's output contract for it, not API. `kay build --analyze` lists the modules of every island, a lazy component's apart from the eager ones.
293
-
294
- Shared and persisted state, transitions, error fallbacks, element size, context and unique ids are in [Islands: state to unique ids](islands-state-to-ids.md).
package/llms/lints.md CHANGED
@@ -91,7 +91,7 @@ The table of lints is split by group, each page holding its rows (the `deprecate
91
91
 
92
92
  ### Performance lints
93
93
 
94
- The `performance` group (`unsized-image`, `large-public-image`, `serial-awaits`) has its own page, which holds its rows: [Performance lints](performance-lints.md).
94
+ The `performance` group (`unsized-image`, `large-public-image`, `static-remote-image`, `serial-awaits`) has its own page, which holds its rows: [Performance lints](performance-lints.md).
95
95
 
96
96
  ### SEO lints
97
97
 
@@ -105,7 +105,7 @@ On an `api()` chain only, a message failing `body` is answered `{ error: { key,
105
105
  ### Following cached values
106
106
 
107
107
  - `cached(key, ttl, load, { live: true })` makes every page that read the key in its render follow it: once `invalidate` drops the key, a key its `load` read (a collection, another `cached`) or a `cache()` tag it names (also when the process no longer holds the value), each open tab shows the page as its loads give it now, with no island, route or socket written. Read it in the page's or a layout's server fence; a read after the document went out (an `await` block's) or in an API route is not followed.
108
- - The server pushes no value, only that the key changed: the tab runs `refresh()`, so the page is rendered again for that visitor, and a guard, a per-visitor branch, the locale and `base` apply as for any visit. A `persist` island is given the new props and keeps its state; any other island whose props changed hydrates afresh, as after an action.
108
+ - The server pushes no value, only that the key changed: the tab runs `refresh()`, so the page is rendered again for that visitor, and a guard, a per-visitor branch, the locale and `base` apply as for any visit. An island is given the new props and keeps its state, as after an action.
109
109
  - The page carries its `data-kay-live` script with `[kay:cache, key, readAt]` per followed key, covered by the same signed proof, and the entry script loads the `live-cache` chunk only then. `POST /_kay/live` first sends the time each key was last invalidated (0 when never), then one event per invalidation, as often as it happens; a tab refreshes when that time is at or after its page's read, both from the server's clock, so an invalidation between render and connect, or during a dropped connection, is not missed. A page reading no such key opens no connection and loads no code for it.
110
110
  - A refresh waits a random 0 to 750 ms so tabs do not render together, waits while the tab is hidden and runs once it is shown, and one in flight absorbs the events meanwhile. A dropped connection reconnects with a growing delay, from half a second, not while the tab is hidden or the browser offline; a 403 (a proof an hour old, a restart without `KAY_SECRET`, or any followed key whose proof is out of date) refreshes the page and every followed route for new ones. With `navigation: false` the page reloads instead, unless a `guardLeave` holds changes.
111
111
  - Several processes sharing a `sqliteCache`, the one `store: sqliteData(path)` gives included, or the Postgres one of `pgData(db)` ([Jobs](queues.md)), follow each other's `invalidate` (heard within about half a second, up to 5 seconds on a server idle for a few seconds with no tab watching a value: the poll slows while it hears nothing and returns to full pace on a write, a use of the store or while a tab watches; a live store while no `live()` value is declared, and a Postgres cache nothing has used, are not polled); with no shared store a process hears its own only. A key expiring by `ttl` refreshes in the background without telling tabs: only `invalidate` pushes.
@@ -47,7 +47,7 @@ const dispose = mount(Panel, document.querySelector('#panel')!, { title: 'Ticket
47
47
  - `navigate('/todos/1')`, imported from `kay`, goes to a page as a link would (the mount point and the current locale's prefix put on as on any `href`, `/todos/1` on a French page going to `/fr/todos/1`, a path already prefixed or another site's URL left as written; a module that gets `navigate` through a dynamic `import('kay')` is not covered, so import it statically), `{ replace: true }` taking the current history entry's place, `{ scroll: 'keep' }` leaving the window scrolled where it is instead of going to the top, `{ transition: false }` swapping without a view transition; another site's page loads, so a `?next=` param goes through `localPath()` as a redirect's does, and a `javascript:` URL throws, as it would run in the page; `mailto:`, `tel:` and other schemes go to the browser as a link would. A link or `navigate()` that a redirect takes to another site loads that page fully rather than swapping it in.
48
48
  - `navigate.query({ sort: 'name', page: null })` goes to the current page with those params set (a list sets one param once per item, `{ tag: ['a', 'b'] }` giving `?tag=a&tag=b`) and a null, undefined or empty one dropped, the others and the path kept and the hash left out, keeping the scroll and the focus as `refresh()` does: a filter or a sort picked in place. It takes the options of `navigate()` and resolves as it does. A query that is state of the page, not a one-off change, is a `queryParam` signal ([state](islands-state-to-ids.md#shared-and-persisted-state)).
49
49
  - `withQuery({ page: 2, sort: null })` from `kay`, in a server fence, a template or an island (where it follows the address, so the link is built again after each `navigate.query()`, swap, Back and `queryParam` write), returns the path of the current page with those params set by the rule of `navigate.query()`, the other params kept and the hash left out, to link to it with one filter changed: `a(href={withQuery({ page: 2 })}) Next`. The path is the site's own, so `base`, `trailingSlash` and the locale prefix are put on by the link as on any `href`; in a fence it reads the request, so it throws in a page rendered once at build time.
50
- - `refresh()` from `kay` runs the current page's loads again and shows what they return, keeping the scroll, the focus and every island whose props did not change, as a call to an action does by itself once it went through.
50
+ - `refresh()` from `kay` runs the current page's loads again and shows what they return, keeping the scroll, the focus, every island (kept with its state and given its new props, [navigation](navigation.md#islands-kept-across-pages)), a field the visitor typed in and a `details` the visitor toggled, as a call to an action does by itself once it went through.
51
51
  - `refresh('cart')` or `refresh(['cart', 'user'])` sends and swaps only the elements of the page reading the loads of its fence that bind those names, and leaves the rest of the page as it is: [rendering](rendering.md#refreshing-some-loads).
52
52
  - An island calls `refresh()` once something else changed what the page shows, or polls with it, `every('3s', refresh, { while: () => issuing })`.
53
53
  - A `refresh()`, including the one an action's call or a live value ends in, never cancels a link, `navigate()` or Back in flight: it waits for the swap, then runs again only when the swap left the URL it was asked for, since the new page is as recent as its answer. An island polling an action needs no `{ refresh: false }` to keep links working.
@@ -63,7 +63,8 @@ A handler of your own on Enter in a text field starts with `if (composing(event)
63
63
  - The body is morphed rather than replaced: an element the next page renders again, in the same place with the same tag, `id` and `class`, stays the same element and takes the next page's attributes and children, so a layout's sidebar keeps where it was scrolled to and its links' `aria-current` moves, with nothing to mark.
64
64
  - A form field shows the value the next page renders, as on a page loaded afresh, and a popover or a dialog left open closes.
65
65
  - The element holding the new page's `h1`, such as a main column scrolling on its own, goes back to the top as the window does.
66
- - Islands are never morphed: one is kept only when marked `persist` or, on a refresh, unchanged; every other one is ended and the next page's hydrates afresh.
66
+ - Islands are never morphed: one is kept when it has its match in the next page, and takes that page's props in place (below); every other one is ended and the next page's hydrates afresh.
67
+ - The rule of every swap is to apply what the server changed and keep what the visitor changed. On a refresh (an action's, `refresh()`, a live value's) a field whose value the server's render left as it was keeps what was typed in it, in production as in `kay dev`, and a `details` the visitor toggled keeps its state, whatever the server renders for it again; a value the server changed takes the new one. A visit or a redirect to another page, and a form refused, show the next page's own.
67
68
  - Outside the body's content, one rule holds for the head's elements, the attributes of `<html>` and those of `<body>`: what the server served changes as the next page serves it, and what a script changed or added since stays as the script left it. A theme toggle's `meta[name="theme-color"]`, a tag a loader added to the head and a class a script put on `<body>` live on through every swap, a meta a script changed or added standing in for the next page's meta of that name and media, while a head tag the page left served alone goes with it. The server writes `<body>` bare, so its attributes are always a script's. A change an inline head script makes before kay's script runs counts as served. A served head tag a script removed comes back with the next page serving it, and a `<style>` an island injects itself outlives the island.
68
69
  - An element a script put in `<body>` goes with the next swap, as the next page never renders it; marked `data-kay-keep`, a direct child of `<body>` lives on through every swap, the same element left where it is, never moved, such as a live region an announcer fills: kayjs-ui's `announce()` marks its own. A server-rendered element takes no `data-kay-keep`, as the next page renders it again.
69
70
  - A swap fires `kay:navigate` on `document` once the new page is in place and its islands are hydrating, with `event.detail.url` the page's address, so a plain script (an analytics tag, a lightbox) can set itself up again; a full load fires none. `kay:navigate-start` and `kay:navigate-error` come before it, and `navigation` and `onBeforeNavigate` follow it from an island: [navigation state and hooks](navigation-from-code.md#navigation-state-and-hooks).
@@ -81,12 +82,13 @@ A handler of your own on Enter in a text field starts with `if (composing(event)
81
82
  ### Islands kept across pages
82
83
 
83
84
  - An island marked `persist` lives on from page to page, its state and its element kept, when the next page renders it too: `Player(persist)` in a layout keeps a song playing.
85
+ - An island without `persist` is kept too when the next page renders the same component in the same place, its state staying and its props given in place: on a refresh any island is paired so, by component and its `key` or `id` prop when it has a string or number one, else the key of the keyed `for` it is drawn in, else by order among the islands of that component, so a list of islands needs an `id` or a `persist` only when its loop is by position or the keys of two loops drawing the same component overlap, and an island drawn in a deferred `await` block of a row takes none (an island marked `persist` by its key first); on a visit, a query change, Back or a redirect only the islands a layout renders are, by layout, component and order, so a sidebar's folded group or a menu stays as it was while a page's own islands are ended. An island whose static slots changed, or with no match, is ended, and a list whose items move is kept by `persist={id}`, which also changes the island by changing it. A call or a `refresh()` has `refresh: false` to leave the page alone.
84
86
  - A browser with `Element.moveBefore` (Chrome 133, Firefox 144) moves it in place, so an iframe in it stays loaded, a video keeps playing and the focus stays in it; elsewhere it is taken out and put back, and the swap gives the focus and the selection back; a popover open in it closes either way. The scroll of every element inside it, nested ones and horizontal scroll too, is kept either way.
85
87
  - `persist` takes a static or a dynamic value, a string computed from props or state (`Graph(persist={`${repo}:${scope}`})`): another value is another island, ended and hydrated afresh, while the same value keeps it.
86
88
  - A bare `persist` matches the same component on the next page; `persist="left"` names one use, for two uses of a component to be told apart.
87
89
  - Only an island takes `persist`, and only from a static parent.
88
90
  - The props the next page gives a kept island reach it as a component inside an island gets new props: what reads them in the template or an effect shows the new values, while a value the script computed from them once keeps the old one.
89
- - The element focused inside an island a swap keeps, marked `persist` or unchanged on a refresh, stays focused, a text field, `textarea` or `contenteditable` with its caret and selection, so a field whose every key shows a draft or refreshes the page keeps taking the keys.
91
+ - The element focused inside an island a swap keeps, stays focused, a text field, `textarea` or `contenteditable` with its caret and selection, so a field whose every key shows a draft or refreshes the page keeps taking the keys.
90
92
  - A text field or `textarea` the swap replaces on a query `navigate()`, a refresh or a redirect, such as a field of an island hydrated afresh for its new `value` prop, gets the focus back with the caret and selection of the old one (kept within the new text, at its end when the caret was at the end), so a search as you type keeps taking the keys; on a query `navigate()` or a refresh, keys typed in it while the page was fetched are kept, and its `input` event fires again so the island asks for them.
91
93
  - The focused element a swap keeps holds on to the `tabindex` a script gave it when the next page's markup has none, until the focus leaves it, as the browser would otherwise move the focus to the body: a heading the swap focused, or a kayjs-cms title whose inline edit just ended, stays focused through a refresh or a draft's render.
92
94
  - A swap to a new page still moves the focus to its heading.
@@ -94,7 +96,7 @@ A handler of your own on Enter in a text field starts with `if (composing(event)
94
96
  ### Forms posting in place
95
97
 
96
98
  - A form posting to an action posts without a reload, then shows the page the post leads to, as the browser would: `form.failed()` and `data()` of an action read as after a full post.
97
- - A post going back to the same page, or refused and rendering it again, keeps the scroll position and the focused field.
99
+ - A post going back to the same page, or refused and rendering it again, keeps the scroll position and the focused field: the swap turns off Chrome's scroll anchoring while it morphs, so a list whose rows move or drop around the one in view leaves the window where it was. A focused field the swap removed (the posting row's) gives the focus to the field of that name now at its place in the document, else the last, never the first of the page.
98
100
  - A refused post moves focus to the form's first field marked `aria-invalid`, which a screen reader reads with the message describing it (see [Actions](actions.md)).
99
101
  - With no field marked, the message describing the form itself is announced and the control that posted it, such as a submit button, is focused again.
100
102
  - A refused post focusing its field reveals it as `focusInvalid` does.
@@ -15,3 +15,4 @@
15
15
  | `unsized-image` | warn | performance | An `img` or `input(type="image")` with neither `width` and `height` nor a spread that may carry them, so the page shifts as it loads; an imported PNG, JPEG, WebP, GIF or AVIF as `src={name}` and a stored file's `files.url(key)` alone are sized by kay; an SVG, a path, a value from data, an image with its own `srcset` or one size still warns; static `aspect-*` with a width or height, `w-*` with `h-*`, `size-*` or a `style` `aspect-ratio` reserve the box, a variant or a bound class does not. No fix: write the image's size. |
16
16
  | `serial-awaits` | warn | performance | Two or more consecutive top-level `const x = await ...` statements of a `--- server` fence where no awaited expression reads a name an earlier one of the run declares, so the page takes the sum of their times. A pattern, a type annotation, `let`, a `try`, a statement or comment between two awaits and an expression reading an earlier binding end the run and are left alone. The fix, `const [a, b] = await Promise.all([...])`, is offered in the editor but is not safe, so `kay check --fix` leaves it: it starts the awaits together, so a guard (`await requireUser()`, anything that redirects or throws) stays in its own statement before them. |
17
17
  | `large-public-image` | warn | performance | A static `img` `src`, a CSS `url()` or `image-set()` string, an `og:image` or `twitter:image` `meta`, `seo.image`, or a Markdown image, reference image, HTML `img` or frontmatter `image:` (CSS comments and Markdown code left out; an address under `site` counts) that names a PNG, JPEG, GIF, WebP, AVIF or BMP in `public/` over 256 KiB, sent whole as public files are. No fix: import it from `src/` so kay serves it resized as WebP; an `img` with its own `srcset` or a `src` written as an expression is left alone. Reported by `kay check` and `kay build`, set with `lints` only. |
18
+ | `static-remote-image` | warn | performance | On `kay build --static`, an island image the build cannot write files for: an `image(source, { width, height })` whose source is neither an imported image nor a literal URL, a literal URL on a host `assets.images.remote` does not list, a width or height that is no number literal, or an `aspect`, `quality` or `sizes` that is no literal. The export has no image route, so the browser links the original or asks for a missing file. No fix: write the URL, size and options as literals, on a listed host. Reported by `kay build --static`. |
@@ -157,5 +157,5 @@ export const pageWeight: KayExtension = {
157
157
  - A redirect without params becomes a page sending the browser on with `<meta http-equiv="refresh">`; every redirect also goes to `_redirects`, read by hosts such as Netlify and Cloudflare Pages.
158
158
  - With `i18n.mode: 'always'`, each unprefixed path sends the browser to the default locale's copy.
159
159
  - Locales by domain need a server.
160
- - The directory is cleared first, only when the last export wrote it: kay refuses one holding other files, and the project itself.
160
+ - The site is written to a folder beside the output (`dist.kay-staging`) and renamed over it once complete, the last export moved aside (`dist.kay-old`) and removed, so a host serving the directory never finds it empty or half written, and an export that fails leaves the last one untouched. kay replaces only a directory the last export wrote: it refuses one holding other files, and the project itself.
161
161
  - A page is rendered once, at the default query, and served at every query (`/page?tab=b` is `page.html`). An island reading a `queryParam` is marked `data-query` by that render: the browser draws it again from the address when the page is opened with a query, rather than claiming markup made for the default one, so it shows `?tab=b` with no mismatch. The page's own markup outside islands stays the default's, as does the island's before its JavaScript runs, so read the query in an island, never in the page, and the build warns naming each page holding such an island. The same holds for any `prerender: true` page.
@@ -33,7 +33,7 @@ kay generate resource post title:string body:text published:boolean
33
33
  ## Reference
34
34
 
35
35
  - `kay new <dir> [--kay <dependency>] [--template blank|server|site|app] [--with <features>] [--without <features>] [--forge forgejo|github] [--agents none] [--runner <label>] [--editor helix,zed|none] [-y] [--dry-run] [--format text|json] [--quiet]`:
36
- - Scaffold a project in an empty directory.
36
+ - Scaffold a project in an empty directory, or in a fresh clone holding only `.git` and what a new forge repo carries (`README.md`, a `LICENSE` file, `.gitignore`, `.gitattributes`): the `.git` folder and its `origin` stay (the origin picks the CI host), the README, licence and `.gitattributes` are kept, and the template's `.gitignore` replaces the forge's. Any other entry stops it with `kay: <dir> is not empty: <first five entries> in the way`.
37
37
  - A project is a set of features: `server` (an Elysia server; off, a static site), `starter` (a header, a skip link, a `_404.kay`, a home page greeting from the server with a counter island), `tailwind` (Tailwind through `bun-plugin-tailwind` over orbit's near-black palette (kayjs-ui's token names: `background`, `foreground`, `border`, `muted`, `accent`) with a hairline on every box, no shadows and, with `ui`, a starfield behind the page, with the `.vscode/settings.json` every project gets also pointing Tailwind IntelliSense at the shorthand and `class="..."`; off, the markup carries no classes), `ui` (kayjs-ui: its space skin imported in `app.css`, Space Grotesk and JetBrains Mono served through `fonts`, `ui()` in `kay.config.ts` and the header drawn with `AppHeader`; in every preset, and it needs `tailwind`), `accents` (an accent picker in the header, twelve accents kept in a cookie, `starlight` by default, in no preset: `--with accents` or `kay add accents`, and it needs `starter` and `tailwind`), `eslint`, `tests`, `ci` (the workflow below, Forgejo's or GitHub's), `docker` (the container below; a static site's brings a `_404.kay` when `starter` is off, for its nginx 404), `auth` (kayjs-auth: what `kay add auth` writes, its users in a SQLite file, which needs `server` and `tailwind`), `postgres` (kayjs-auth's users in Postgres instead, with its compose stack and roles, which needs `auth`) and `ws` (the app's API module and websocket island, shown on the home page, which needs `server`).
38
38
  - A preset names a set: `blank` none, one layout and one bare page built as a static site; `server`, `site` and `app` as described below.
39
39
  - Run in a terminal with none of `--template`, `--with`, `--without` or `-y`, it asks for a preset, then shows its features as a checklist. Checking a feature checks what it needs, and unchecking one unchecks what needs it.
package/llms/project.md CHANGED
@@ -54,7 +54,7 @@ kay migrate astro ../my-astro-site --outdir ../my-kay-site
54
54
  - kay is published as `@kayjs/kay` to npm, and as a mirror to the Forgejo registry at `https://git.kaynooo.fr/api/packages/kaynooo/npm/`, its libraries as `@kayjs/ui`, `@kayjs/auth`, `@kayjs/mail`, `@kayjs/cms` and `@kayjs/ai` (`@kaynooo/kayjs*` up to 1.103, which `kay upgrade` moves an app off), and installed under the name its imports use: `"kay": "npm:@kayjs/kay@~<version>"` in `package.json`. From 2.0.0 kay follows semver (a breaking change is a major, and `kay new` writes `^<version>`); through 1.x a minor may break what the one before it took, so `kay new` writes `~<version>`, each break listed in [Upgrading](upgrading.md) and every one `kay check` can recognise a `deprecated` lint with a fix, which `kay upgrade` applies as it moves the app. Every package a project installs, pg-orm and eslint included, is on npm, so a project carries no `.npmrc` and Bun needs no registry setup.
55
55
  - `bunx -p @kayjs/kay kay new my-app` writes a project that, after `cd my-app && bun install`, checks, builds and runs (`bun run dev`), both of those included: this setup, a layout, a page, a `_404.kay` and islands, or only what is picked of them (see [Commands](commands.md#commands) for the presets and features).
56
56
 
57
- - kay runs on Bun 1.4.4 or later, as its `engines` says: the CLI and `pages()` refuse an older one, naming its version, its path and the fix, `bun update bun` when it is the project's npm `bun` package, which a plugin's peer dependency installs and package scripts run ahead of the system Bun.
57
+ - kay runs on Bun 1.4.5 or later, as its `engines` says: the CLI and `pages()` refuse an older one, naming its version, its path and the fix, `bun update bun` when it is the project's npm `bun` package, which a plugin's peer dependency installs and package scripts run ahead of the system Bun.
58
58
 
59
59
  - A folder of the project holding its own `package.json` or `kay.config.ts`, such as a workspace package or a second kay app, is a project of its own: `kay check` and `kay build` leave its files out of the app's, and the app reaches a package there through `node_modules`, as it would one installed.
60
60
 
@@ -98,9 +98,9 @@ Card(title="Todos")
98
98
  p Body text
99
99
  ```
100
100
 
101
- A prop taking markup is typed `Snippet` from `kay`: `Snippet` for the children and a block with no parameters, `Snippet<[Item, number]>` for markup the component calls with values, once per row for instance. `@name(a, b)`, a local `snippet` passed as `name={feature}` and `slot name(a, b)` all use it, a fill with other parameters, or a `@name` written without the parameters the prop is called with, is a `kay check` error (the second names the parameters to write), and `slot name` on a prop that is no `Snippet` is reported at the name.
101
+ A prop taking markup is typed `Snippet` from `kay`: `Snippet` for the children and a block with no parameters, `Snippet<[Item, number]>` for markup the component calls with values, once per row for instance. `@name(a, b)`, a local `snippet` passed as `name={feature}` and `slot name(a, b)` all use it. A block or a snippet reads each plain parameter where the parameter is used, so a caller that draws it once for an item (`slot row(item)` under a keyed `for`, or `followed`) hands it the real item, and the block's markup follows a copy of the item replacing it under the same key, in the same nodes with their focus; a fill with other parameters, or a `@name` written without the parameters the prop is called with, is a `kay check` error (the second names the parameters to write), and `slot name` on a prop that is no `Snippet` is reported at the name.
102
102
 
103
- No function reaches the browser, so a static component passing one to an island is the `island-prop` error, fixed with `island()`, and a layout or a page with a `--- server` fence cannot pass one.
103
+ No function reaches the browser, so a static component passing one to an island is the `island-prop` error (unless the island lists `interactive` props and the use writes none, which renders as markup), fixed with `island()`, and a layout or a page with a `--- server` fence cannot pass one.
104
104
 
105
105
  A static component that only islands render is part of them, so it can.
106
106
 
@@ -136,10 +136,10 @@ List(items={todos})
136
136
  - `{name(args)}` renders it anywhere below, as a text line or in the text of an element, and `kay check` types the call as any call.
137
137
  - It reads the signals, script consts, template `const`s and loop variables around it, so it needs no parameter for them.
138
138
  - A signal read in the snippet updates there in place; one read in an argument, `{feature(title())}`, draws that call again.
139
- - A loop row passed as the argument, `{show(row)}` under `for row of rows()`, is such a read when a new copy of the row replaces the old one, as a game snapshot each tick does: the call is drawn again and its nodes are new. A component, `Show(row={row})`, writes only the attributes that changed to the same nodes, so make per-row markup a component when it should keep its nodes, a CSS transition included.
139
+ - A loop row passed as the argument, `{show(row)}` under `for row of rows()`, is such a read when a new copy of the row replaces the old one, as a game snapshot each tick does: the call is drawn again and its nodes are new. `{followed(() => row, row => show(row))}` (`followed` from `kay`) draws it once for the row under its key instead, and the parameter reads the row as it stands where it is used (a plain script function handed the row, not a block or a snippet, gets the row as it was handed, and is drawn again when the row is replaced). A component, `Show(row={row})`, writes only the attributes that changed to the same nodes, so make per-row markup a component when it should keep its nodes, a CSS transition included.
140
140
  - It is scoped as a template `const` is: the lines after it at its indentation and their children see it, its own lines included, so it can call itself for a tree, and a later snippet can call an earlier one; an `@name` block after it among a component's children does not see it. Above its declaration or outside its block the name is unknown, and `kay check` reports it.
141
141
  - A name another snippet, an import, a script const, a prop or a loop variable already holds is reported at the snippet, and assigning one is refused.
142
142
  - It can hold components, a bare `slot` of the component declaring it, `if`, `for`, `await`, `match` and other snippets, and is a plain function, so `List(row={feature})` passes it where a prop takes a function, which the component renders with `slot row(item, i)`.
143
143
  - An `error` or `pending` line in a snippet follows the form the snippet is rendered in while it renders, as one in a component does, unless the form it is declared in is around it, which it keeps reading. In an island the snippet, like the children a component is given, takes the form it is called in once, as it is called, so a line inside an `await` block or an `if` shown later reads the same form, and a snippet declared outside the form works as one declared inside; call it in the form's own markup, `{note()}` or inside a larger expression. A component an `await` or an `if` of the snippet shows later reads no form: put the line in the snippet itself. `add.form.error('title')` and `add.pending()` take the action from anywhere.
144
- - A static component passing one to an island is the `island-prop` error, as it is for a `@row(item)` block.
144
+ - A static component passing one to an island is the `island-prop` error, as it is for a `@row(item)` block, unless the island lists `interactive` props and the use writes none.
145
145
  - Markup used by several files is a component; a snippet is for one file.