@kayjs/kay 1.105.0 → 1.106.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 (310) hide show
  1. package/dist/eslint.js +435 -120
  2. package/editors/zed/extension.toml +2 -2
  3. package/llms/action-protection.md +1 -1
  4. package/llms/actions-from-islands.md +2 -2
  5. package/llms/actions.md +22 -19
  6. package/llms/analytics.md +1 -1
  7. package/llms/api-from-islands.md +1 -1
  8. package/llms/api-routes.md +6 -6
  9. package/llms/check-and-tools.md +1 -1
  10. package/llms/code-lints.md +2 -2
  11. package/llms/compiler-api.md +1 -1
  12. package/llms/component-libraries.md +1 -0
  13. package/llms/content-cms.md +1 -1
  14. package/llms/content-markdown-to-caching.md +1 -1
  15. package/llms/content-preview.md +2 -2
  16. package/llms/content.md +21 -21
  17. package/llms/deprecated-lints-1-105-libraries.md +2 -0
  18. package/llms/deprecated-lints-1-105.md +3 -3
  19. package/llms/deprecated-lints.md +3 -2
  20. package/llms/dev-tool.md +2 -2
  21. package/llms/environment.md +22 -22
  22. package/llms/files.md +5 -5
  23. package/llms/islands-state-to-ids.md +2 -1
  24. package/llms/local-collections.md +2 -2
  25. package/llms/mcp.md +2 -1
  26. package/llms/navigation-from-code.md +1 -1
  27. package/llms/notifications.md +4 -2
  28. package/llms/project.md +1 -1
  29. package/llms/rate-limits.md +1 -1
  30. package/llms/recipes.md +16 -16
  31. package/llms/rooms.md +4 -4
  32. package/llms/routing-endpoints-and-base.md +1 -1
  33. package/llms/routing.md +5 -5
  34. package/llms/schemas.md +10 -5
  35. package/llms/server.md +7 -7
  36. package/llms/site.md +9 -9
  37. package/llms/sitemap-search-fonts.md +2 -0
  38. package/llms/styles-and-assets.md +2 -1
  39. package/llms/templates-elements-slots-snippets.md +2 -2
  40. package/llms/testing-browser.md +20 -0
  41. package/llms/testing.md +1 -1
  42. package/llms/upgrading-1-105-config.md +2 -2
  43. package/llms/upgrading.md +18 -3
  44. package/llms/whats-new-archive.md +35 -66
  45. package/llms/whats-new.md +34 -28
  46. package/llms.txt +1 -1
  47. package/package.json +15 -11
  48. package/src/add.ts +1 -1
  49. package/src/build/class-table.ts +2 -2
  50. package/src/build/client.ts +7 -6
  51. package/src/build/plugin.ts +14 -11
  52. package/src/build/styles.ts +3 -3
  53. package/src/build/transform.ts +3 -1
  54. package/src/build/ui-layers.ts +30 -0
  55. package/src/build/ui.ts +108 -11
  56. package/src/build/variants.ts +119 -43
  57. package/src/build/worker-bundle.ts +6 -0
  58. package/src/check/boot.ts +22 -1
  59. package/src/check/call-result.ts +242 -0
  60. package/src/check/config-objects.ts +17 -2
  61. package/src/check/diagnose.ts +22 -0
  62. package/src/check/handler-events.ts +149 -0
  63. package/src/check/index.ts +6 -2
  64. package/src/check/link-flag-tests.ts +130 -0
  65. package/src/check/project.ts +4 -3
  66. package/src/check/refusal-calls.ts +2 -2
  67. package/src/check/regroup.ts +5 -3
  68. package/src/check/renamed-packages.ts +58 -14
  69. package/src/check/schema-builders.ts +256 -0
  70. package/src/check/secret-keys.ts +15 -2
  71. package/src/check/shadow-types.ts +2 -0
  72. package/src/check/template-hints.ts +1 -1
  73. package/src/check/tool-labels.ts +11 -9
  74. package/src/check/ui-types.ts +4 -3
  75. package/src/check/ui.ts +14 -11
  76. package/src/commands/env-declare.ts +18 -6
  77. package/src/commands/routes.ts +1 -1
  78. package/src/compiler/a11y.ts +8 -1
  79. package/src/compiler/ast.ts +1 -1
  80. package/src/compiler/bound-props.ts +1 -1
  81. package/src/compiler/codegen.ts +6 -6
  82. package/src/compiler/deprecated-lints-1-106.ts +14 -0
  83. package/src/compiler/deprecated-lints.ts +10 -5
  84. package/src/compiler/deprecated-typed-lints.ts +23 -0
  85. package/src/compiler/dom-here.ts +72 -0
  86. package/src/compiler/dom.ts +23 -23
  87. package/src/compiler/fence-checks.ts +12 -11
  88. package/src/compiler/field-described.ts +2 -2
  89. package/src/compiler/helper-imports.ts +1 -1
  90. package/src/compiler/html-fields.ts +92 -0
  91. package/src/compiler/html-initial.ts +5 -3
  92. package/src/compiler/html.ts +14 -31
  93. package/src/compiler/index.ts +3 -1
  94. package/src/compiler/items.ts +5 -5
  95. package/src/compiler/link-flags.ts +6 -5
  96. package/src/compiler/lints.ts +12 -12
  97. package/src/compiler/rest-omits.ts +15 -0
  98. package/src/config-loader.ts +10 -2
  99. package/src/config-resolve.ts +3 -1
  100. package/src/config-shape.ts +2 -2
  101. package/src/config.ts +20 -4
  102. package/src/content/markdown.ts +2 -3
  103. package/src/generate-resource.ts +9 -9
  104. package/src/generate.ts +1 -1
  105. package/src/mcp/guards.ts +1 -1
  106. package/src/mcp/tools.ts +1 -1
  107. package/src/migrate/content.ts +61 -55
  108. package/src/runtime/action-shared.ts +2 -2
  109. package/src/runtime/action.ts +6 -2
  110. package/src/runtime/form-types.ts +99 -0
  111. package/src/runtime/form.ts +22 -7
  112. package/src/runtime/html.ts +36 -5
  113. package/src/runtime/markdown-autolink.ts +69 -0
  114. package/src/runtime/markdown-render.client.ts +39 -3
  115. package/src/runtime/markdown.client.ts +6 -3
  116. package/src/runtime/markdown.server.ts +6 -3
  117. package/src/runtime/markdown.ts +125 -1
  118. package/src/runtime/navigate-api.ts +10 -5
  119. package/src/runtime/persist.ts +7 -7
  120. package/src/runtime/query-param.ts +1 -1
  121. package/src/runtime/reactive.ts +14 -0
  122. package/src/runtime/sanitize.ts +3 -1
  123. package/src/runtime/schema-record.ts +31 -0
  124. package/src/runtime/schema.client.ts +1 -4
  125. package/src/runtime/schema.ts +321 -26
  126. package/src/runtime/swap-focus.ts +59 -11
  127. package/src/server/action-module.ts +16 -0
  128. package/src/server/actions.ts +6 -14
  129. package/src/server/api-modules.ts +1 -1
  130. package/src/server/api.ts +13 -1
  131. package/src/server/app-stages.ts +23 -18
  132. package/src/server/dev-ui.ts +2 -2
  133. package/src/server/env-state.ts +1 -1
  134. package/src/server/env.ts +11 -3
  135. package/src/server/favicon.ts +47 -1
  136. package/src/server/image-metadata-bmff.ts +1 -1
  137. package/src/server/kept-pages.ts +3 -3
  138. package/src/server/library.ts +2 -0
  139. package/src/server/mcp.ts +13 -12
  140. package/src/server/notifications.ts +4 -2
  141. package/src/server/offline.ts +24 -7
  142. package/src/server/push-settings.ts +16 -2
  143. package/src/server/push.ts +12 -4
  144. package/src/server/query.ts +13 -6
  145. package/src/server/render.ts +1 -1
  146. package/src/server/scope.ts +20 -13
  147. package/src/server/signals.ts +4 -4
  148. package/src/template-ws.ts +1 -1
  149. package/src/test/a11y-dom.ts +70 -0
  150. package/src/test/html-snapshot.ts +103 -0
  151. package/src/test/index.ts +2 -1
  152. package/src/test/mount.ts +8 -1
  153. package/src/test/page-checks.ts +12 -0
  154. package/src/test/screenshot-match.ts +2 -2
  155. package/src/test/shared-modules.ts +27 -5
  156. package/src/test/site-types.ts +5 -1
  157. package/types/build/class-table.d.ts +1 -1
  158. package/types/build/class-table.d.ts.map +1 -1
  159. package/types/build/client.d.ts.map +1 -1
  160. package/types/build/plugin.d.ts.map +1 -1
  161. package/types/build/transform.d.ts +1 -0
  162. package/types/build/transform.d.ts.map +1 -1
  163. package/types/build/ui-layers.d.ts +5 -0
  164. package/types/build/ui-layers.d.ts.map +1 -0
  165. package/types/build/ui.d.ts +7 -0
  166. package/types/build/ui.d.ts.map +1 -1
  167. package/types/build/variants.d.ts +1 -1
  168. package/types/build/variants.d.ts.map +1 -1
  169. package/types/build/worker-bundle.d.ts +1 -0
  170. package/types/build/worker-bundle.d.ts.map +1 -1
  171. package/types/check/boot.d.ts.map +1 -1
  172. package/types/check/call-result.d.ts +7 -0
  173. package/types/check/call-result.d.ts.map +1 -0
  174. package/types/check/config-objects.d.ts.map +1 -1
  175. package/types/check/diagnose.d.ts.map +1 -1
  176. package/types/check/handler-events.d.ts +9 -0
  177. package/types/check/handler-events.d.ts.map +1 -0
  178. package/types/check/index.d.ts +1 -0
  179. package/types/check/index.d.ts.map +1 -1
  180. package/types/check/link-flag-tests.d.ts +4 -0
  181. package/types/check/link-flag-tests.d.ts.map +1 -0
  182. package/types/check/project.d.ts.map +1 -1
  183. package/types/check/regroup.d.ts +1 -1
  184. package/types/check/regroup.d.ts.map +1 -1
  185. package/types/check/renamed-packages.d.ts +1 -0
  186. package/types/check/renamed-packages.d.ts.map +1 -1
  187. package/types/check/schema-builders.d.ts +3 -0
  188. package/types/check/schema-builders.d.ts.map +1 -0
  189. package/types/check/secret-keys.d.ts.map +1 -1
  190. package/types/check/shadow-types.d.ts.map +1 -1
  191. package/types/check/template-hints.d.ts +1 -0
  192. package/types/check/template-hints.d.ts.map +1 -1
  193. package/types/check/tool-labels.d.ts.map +1 -1
  194. package/types/check/ui-types.d.ts.map +1 -1
  195. package/types/check/ui.d.ts.map +1 -1
  196. package/types/commands/env-declare.d.ts.map +1 -1
  197. package/types/compiler/a11y.d.ts.map +1 -1
  198. package/types/compiler/bound-props.d.ts +1 -0
  199. package/types/compiler/bound-props.d.ts.map +1 -1
  200. package/types/compiler/codegen.d.ts +1 -0
  201. package/types/compiler/codegen.d.ts.map +1 -1
  202. package/types/compiler/deprecated-lints-1-106.d.ts +12 -0
  203. package/types/compiler/deprecated-lints-1-106.d.ts.map +1 -0
  204. package/types/compiler/deprecated-lints.d.ts +32 -5
  205. package/types/compiler/deprecated-lints.d.ts.map +1 -1
  206. package/types/compiler/deprecated-typed-lints.d.ts +21 -0
  207. package/types/compiler/deprecated-typed-lints.d.ts.map +1 -0
  208. package/types/compiler/dom-here.d.ts +14 -0
  209. package/types/compiler/dom-here.d.ts.map +1 -0
  210. package/types/compiler/dom.d.ts +1 -0
  211. package/types/compiler/dom.d.ts.map +1 -1
  212. package/types/compiler/fence-checks.d.ts.map +1 -1
  213. package/types/compiler/field-described.d.ts +1 -1
  214. package/types/compiler/field-described.d.ts.map +1 -1
  215. package/types/compiler/html-fields.d.ts +19 -0
  216. package/types/compiler/html-fields.d.ts.map +1 -0
  217. package/types/compiler/html-initial.d.ts +3 -2
  218. package/types/compiler/html-initial.d.ts.map +1 -1
  219. package/types/compiler/html.d.ts.map +1 -1
  220. package/types/compiler/index.d.ts +1 -0
  221. package/types/compiler/index.d.ts.map +1 -1
  222. package/types/compiler/items.d.ts +4 -1
  223. package/types/compiler/items.d.ts.map +1 -1
  224. package/types/compiler/link-flags.d.ts +6 -0
  225. package/types/compiler/link-flags.d.ts.map +1 -1
  226. package/types/compiler/lints.d.ts +44 -17
  227. package/types/compiler/lints.d.ts.map +1 -1
  228. package/types/compiler/rest-omits.d.ts +4 -0
  229. package/types/compiler/rest-omits.d.ts.map +1 -0
  230. package/types/config-loader.d.ts.map +1 -1
  231. package/types/config-resolve.d.ts.map +1 -1
  232. package/types/config.d.ts +15 -2
  233. package/types/config.d.ts.map +1 -1
  234. package/types/content/markdown.d.ts.map +1 -1
  235. package/types/migrate/content.d.ts.map +1 -1
  236. package/types/runtime/action-shared.d.ts +1 -1
  237. package/types/runtime/action-shared.d.ts.map +1 -1
  238. package/types/runtime/action.d.ts +3 -0
  239. package/types/runtime/action.d.ts.map +1 -1
  240. package/types/runtime/form-types.d.ts +6 -0
  241. package/types/runtime/form-types.d.ts.map +1 -0
  242. package/types/runtime/form.d.ts +3 -1
  243. package/types/runtime/form.d.ts.map +1 -1
  244. package/types/runtime/html.d.ts +3 -0
  245. package/types/runtime/html.d.ts.map +1 -1
  246. package/types/runtime/markdown-autolink.d.ts +11 -0
  247. package/types/runtime/markdown-autolink.d.ts.map +1 -0
  248. package/types/runtime/markdown-render.client.d.ts +2 -1
  249. package/types/runtime/markdown-render.client.d.ts.map +1 -1
  250. package/types/runtime/markdown.client.d.ts +3 -1
  251. package/types/runtime/markdown.client.d.ts.map +1 -1
  252. package/types/runtime/markdown.d.ts +11 -0
  253. package/types/runtime/markdown.d.ts.map +1 -1
  254. package/types/runtime/markdown.server.d.ts +3 -1
  255. package/types/runtime/markdown.server.d.ts.map +1 -1
  256. package/types/runtime/navigate-api.d.ts +1 -1
  257. package/types/runtime/navigate-api.d.ts.map +1 -1
  258. package/types/runtime/persist.d.ts +2 -2
  259. package/types/runtime/persist.d.ts.map +1 -1
  260. package/types/runtime/reactive.d.ts +3 -0
  261. package/types/runtime/reactive.d.ts.map +1 -1
  262. package/types/runtime/sanitize.d.ts.map +1 -1
  263. package/types/runtime/schema-record.d.ts +9 -0
  264. package/types/runtime/schema-record.d.ts.map +1 -0
  265. package/types/runtime/schema.client.d.ts.map +1 -1
  266. package/types/runtime/schema.d.ts +94 -10
  267. package/types/runtime/schema.d.ts.map +1 -1
  268. package/types/runtime/swap-focus.d.ts.map +1 -1
  269. package/types/server/action-module.d.ts +2 -0
  270. package/types/server/action-module.d.ts.map +1 -0
  271. package/types/server/actions.d.ts +1 -0
  272. package/types/server/actions.d.ts.map +1 -1
  273. package/types/server/api.d.ts.map +1 -1
  274. package/types/server/app-stages.d.ts +3 -2
  275. package/types/server/app-stages.d.ts.map +1 -1
  276. package/types/server/env-state.d.ts.map +1 -1
  277. package/types/server/env.d.ts +5 -1
  278. package/types/server/env.d.ts.map +1 -1
  279. package/types/server/favicon.d.ts +3 -1
  280. package/types/server/favicon.d.ts.map +1 -1
  281. package/types/server/kept-pages.d.ts +1 -1
  282. package/types/server/kept-pages.d.ts.map +1 -1
  283. package/types/server/library.d.ts +2 -0
  284. package/types/server/library.d.ts.map +1 -1
  285. package/types/server/mcp.d.ts +1 -1
  286. package/types/server/mcp.d.ts.map +1 -1
  287. package/types/server/notifications.d.ts +2 -1
  288. package/types/server/notifications.d.ts.map +1 -1
  289. package/types/server/offline.d.ts.map +1 -1
  290. package/types/server/push-settings.d.ts +1 -1
  291. package/types/server/push-settings.d.ts.map +1 -1
  292. package/types/server/push.d.ts +1 -0
  293. package/types/server/push.d.ts.map +1 -1
  294. package/types/server/query.d.ts.map +1 -1
  295. package/types/server/scope.d.ts +1 -1
  296. package/types/server/scope.d.ts.map +1 -1
  297. package/types/test/a11y-dom.d.ts +20 -0
  298. package/types/test/a11y-dom.d.ts.map +1 -0
  299. package/types/test/html-snapshot.d.ts +4 -0
  300. package/types/test/html-snapshot.d.ts.map +1 -0
  301. package/types/test/index.d.ts.map +1 -1
  302. package/types/test/mount.d.ts +3 -0
  303. package/types/test/mount.d.ts.map +1 -1
  304. package/types/test/page-checks.d.ts +6 -0
  305. package/types/test/page-checks.d.ts.map +1 -0
  306. package/types/test/screenshot-match.d.ts +1 -1
  307. package/types/test/screenshot-match.d.ts.map +1 -1
  308. package/types/test/shared-modules.d.ts.map +1 -1
  309. package/types/test/site-types.d.ts +3 -1
  310. package/types/test/site-types.d.ts.map +1 -1
@@ -9,7 +9,8 @@ import { actionOf, failedBlockOf, marksServerIsland, sectionOf, serverIslandOf }
9
9
  import { decodeEntities } from './expression'
10
10
  import { addFieldDescribed, addInvalidAttribute } from './field-described'
11
11
  import { valuesOf } from './form-info'
12
- import { addFilled, addInitial } from './html-initial'
12
+ import { addClassAttribute, addFieldFill, addSchemaOptions, listsFromSchema, schemaTypeCall } from './html-fields'
13
+ import { addInitial } from './html-initial'
13
14
  import { Markup } from './html-parts'
14
15
  import { addRowItem, childItems, constDeclaration, contentOf, errorParagraphArguments, fixedSource, isDeclaration, rowKeying, slotValue, soleDynamic } from './items'
15
16
  import { END_MARKER, escapeStaticAttribute, escapeText, fromRoot, helperName, RAW_ELEMENTS, START_MARKER, TemplateWriter, VOID_ELEMENTS } from './markup'
@@ -480,7 +481,8 @@ export class HtmlTemplate extends TemplateWriter {
480
481
  const describable = fieldAria !== undefined
481
482
  let ownDescribed: (() => void) | undefined
482
483
  let refusing: (() => void) | undefined
483
- const fieldDescribed = (own: (() => void) | undefined, refusing?: () => void) => addFieldDescribed(b, own, type, fieldAria, refusing)
484
+ const schemaType = schemaTypeCall(b, name, type, field, target)
485
+ const fieldDescribed = (own: (() => void) | undefined, refusing?: () => void) => addFieldDescribed(b, own, type, fieldAria, refusing, schemaType)
484
486
 
485
487
  markup.text(`<${name}${element.fixed ?? ''}`)
486
488
 
@@ -492,32 +494,7 @@ export class HtmlTemplate extends TemplateWriter {
492
494
  if (unit !== undefined)
493
495
  markup.text(` data-kay-u="${unit.id}"`)
494
496
 
495
- if (plan.classes?.parts) {
496
- const classes = plan.classes
497
-
498
- markup.dynamic(() => {
499
- b.add(`${helperName('nonEmptyAttribute')}("class", ${helperName('className')}(`)
500
- this.classList(classes)
501
- b.add('))')
502
- })
503
- }
504
- else if (plan.classes?.expression) {
505
- const { text, expression } = plan.classes
506
-
507
- markup.text(' class="')
508
- markup.dynamic(() => b.add(`${helperName('className')}([${JSON.stringify(text)}, (`).addSource(expression).add(')])'))
509
- markup.text('"')
510
- }
511
- else if (plan.classes?.pieces) {
512
- const { pieces } = plan.classes
513
-
514
- markup.text(' class="')
515
- markup.dynamic(() => b.add(`${helperName('className')}(${JSON.stringify(pieces)})`))
516
- markup.text('"')
517
- }
518
- else if (plan.classes) {
519
- markup.text(` class="${escapeStaticAttribute(plan.classes.text)}"`)
520
- }
497
+ addClassAttribute(b, markup, plan.classes, classes => this.classList(classes))
521
498
 
522
499
  for (const attribute of plan.attributes) {
523
500
  if (attribute.kind === 'binding') {
@@ -667,7 +644,7 @@ export class HtmlTemplate extends TemplateWriter {
667
644
  }
668
645
 
669
646
  if (filled)
670
- markup.dynamic(() => addFilled(b, this.src, element, { filled, fieldArguments, own: ownFill, box: checkboxValue, values, name: field.name }))
647
+ addFieldFill(b, this.src, element, markup, { filled, fieldArguments, own: ownFill, box: checkboxValue, values, name: field.name }, field, name === 'input' && !this.named(element, 'type'))
671
648
 
672
649
  if (field.invalid) {
673
650
  refusing = fieldArguments
@@ -751,12 +728,18 @@ export class HtmlTemplate extends TemplateWriter {
751
728
  // A refused post's text takes the place of the textarea's static value.
752
729
  const staticContent = field?.fill === 'content' && plan.valueText !== undefined ? undefined : plan.staticContent
753
730
 
754
- if (children.length > 0 && field?.fill === 'selected' && target) {
731
+ const fromSchema = listsFromSchema(name, children, field)
732
+
733
+ if (field && (fromSchema || (children.length > 0 && field.fill === 'selected')) && target) {
755
734
  const own = selected
756
735
 
757
736
  markup.dynamic(() => {
758
737
  b.add(`${helperName('refillOptions')}(KayFormValue((`).addSource(target).add(`), ${JSON.stringify(field.name)}), `)
759
- this.markup(children, true)
738
+
739
+ if (fromSchema)
740
+ addSchemaOptions(b, target, field.name)
741
+ else
742
+ this.markup(children, true)
760
743
 
761
744
  if (own) {
762
745
  b.add(', () => ')
@@ -80,6 +80,8 @@ export interface CompileOptions {
80
80
  namedRefresh?: boolean | undefined
81
81
  // Server output of a static component's `?island` twin, which carries markers like an island.
82
82
  twinBuild?: boolean | undefined
83
+ // The props the component's call sites write, when all are known: the `...rest` of its props leaves out only these of the ones it declares.
84
+ writtenProps?: ReadonlySet<string> | undefined
83
85
  // Whether the file is a page of a routes directory (`isPageFile`), which nothing renders inside an island, so a page without a server fence reads its loops as static as the build does, is refused `--- client` and `--- island`, and is no island by its pin; `false` says it is a component, where a root `@block` is refused.
84
86
  page?: boolean | undefined
85
87
  // Whether the file is known to be a component, which has no `--- server` fence: a library checked on its own has pages no routes directory names, so only a caller knowing its routes says so.
@@ -325,7 +327,7 @@ export function compileKay(original: string, filename: string, options: CompileO
325
327
  const pin = file.pin
326
328
  const rawCause = island === undefined ? undefined : islandCause(file, script) ?? browserCause(file, script, live)
327
329
  const cause = withInteractive(realCause(rawCause, expansion, original), script)
328
- const generateOptions = { cause: options.inspect === true && cause !== undefined ? describeCause(cause) : undefined, classTable: options.classTable, classMerge: options.classMerge, awaitAlert: options.awaitAlert, island, client, lives: island === undefined ? undefined : liveBindings(script, options.importedSignals).map(binding => binding.local), twin, output: options.output, failedCode, hydratable: hydratableServer && (island !== undefined || options.twinBuild === true), moduleId: islandId(filename, options.root), includeServer: options.includeServer, params: options.params, paramTypes: options.paramTypes, outerQueries: options.outerQueries, outerGuards: options.outerGuards, outerSlots: options.outerSlots, layoutFile: basename(filename) === LAYOUT, component: options.page === false && !routeFile, check: options.check, route: options.check === true && pageFile, pageFile, namedRefresh: options.namedRefresh, insideIsland: options.insideIsland, inspect: options.inspect, inspectSource: expansion ? { text: original, real: (offset: number) => expansion.real(offset) } : undefined, relocateImport: options.relocateImport, contextModule: options.check === true ? options.contextModule : undefined, ui: options.output === undefined ? undefined : options.ui, uiAdded: options.output === undefined ? options.ui : undefined, errorPage: isErrorPage(basename(filename)), cardPage: basename(filename) === CARD_PAGE, special: basename(filename).startsWith('_') && basename(filename) !== LAYOUT }
330
+ const generateOptions = { cause: options.inspect === true && cause !== undefined ? describeCause(cause) : undefined, classTable: options.classTable, classMerge: options.classMerge, awaitAlert: options.awaitAlert, island, client, lives: island === undefined ? undefined : liveBindings(script, options.importedSignals).map(binding => binding.local), twin, writtenProps: options.writtenProps, output: options.output, failedCode, hydratable: hydratableServer && (island !== undefined || options.twinBuild === true), moduleId: islandId(filename, options.root), includeServer: options.includeServer, params: options.params, paramTypes: options.paramTypes, outerQueries: options.outerQueries, outerGuards: options.outerGuards, outerSlots: options.outerSlots, layoutFile: basename(filename) === LAYOUT, component: options.page === false && !routeFile, check: options.check, route: options.check === true && pageFile, pageFile, namedRefresh: options.namedRefresh, insideIsland: options.insideIsland, inspect: options.inspect, inspectSource: expansion ? { text: original, real: (offset: number) => expansion.real(offset) } : undefined, relocateImport: options.relocateImport, contextModule: options.check === true ? options.contextModule : undefined, ui: options.output === undefined ? undefined : options.ui, uiAdded: options.output === undefined ? options.ui : undefined, errorPage: isErrorPage(basename(filename)), cardPage: basename(filename) === CARD_PAGE, special: basename(filename).startsWith('_') && basename(filename) !== LAYOUT }
329
331
  // The analysis pass names the component so no read resolves to it, then the name is chosen free of what the code reads.
330
332
  const analysis = generate(file, script, server, { ...generateOptions, name: SELF })
331
333
  const imported = new Map<string, SignalKind>([...script.imports, ...server?.imports ?? []].flatMap((binding) => {
@@ -9,7 +9,7 @@ import { parsedBindingNames } from './pattern-names'
9
9
  export type Item
10
10
  = | { kind: 'text', text: string }
11
11
  | { kind: 'element', node: ElementNode }
12
- | { kind: 'expression', node: TextExpression }
12
+ | { kind: 'expression', node: TextExpression, line: Node }
13
13
  | { kind: 'component', node: ElementNode }
14
14
  | { kind: 'slot', node: ElementNode }
15
15
  | { kind: 'if', node: IfNode }
@@ -91,7 +91,7 @@ export function childItems(nodes: Node[]): Item[] {
91
91
  if (part.kind === 'element')
92
92
  element(part)
93
93
  else if (part.kind === 'expression')
94
- items.push({ kind: 'expression', node: part })
94
+ items.push({ kind: 'expression', node: part, line: node })
95
95
  else if (part.text !== '')
96
96
  text(part.text)
97
97
  }
@@ -244,7 +244,7 @@ export function fixedSource(element: ElementNode): string {
244
244
  return names.length === 0 ? '' : `, { ${names.map(name => `${JSON.stringify(name)}: ""`).join(', ')} }`
245
245
  }
246
246
 
247
- // What an `error` or `pending` line outside every form of its file reads: the form it renders in, and the message the action gave a field; the import drops a repeat.
248
- export function ambientHelpers(facts: { ambientForm: boolean }): ('formHere' | 'formError')[] {
249
- return facts.ambientForm ? ['formHere', 'formError'] : []
247
+ // What an `error` or `pending` line outside every form of its file reads: the form it renders in, and the message the action gave a field; in the browser a snippet called in a form is built in that form's scope; the import drops a repeat.
248
+ export function ambientHelpers(facts: { ambientForm: boolean, snippet: boolean, forms: ReadonlyMap<unknown, unknown> }, mode: string): ('formHere' | 'formError' | 'issueScope')[] {
249
+ return [...facts.ambientForm ? ['formHere' as const, 'formError' as const] : [], ...mode === 'dom' && facts.snippet && facts.forms.size > 0 ? ['issueScope' as const] : []]
250
250
  }
@@ -3,7 +3,7 @@ import type { Lint } from './lints'
3
3
  import { editDistance } from './aria'
4
4
  import { elementsIn } from './ast'
5
5
 
6
- interface Renamed {
6
+ export interface Renamed {
7
7
  name: string
8
8
  value: string
9
9
  // What a `false` value of the old name becomes, for a flag that was off by that word.
@@ -23,13 +23,14 @@ export const LINK_LINTS = {
23
23
 
24
24
  // The attributes a link, or an element around links, takes to say how the swap follows it, named as the options of `navigate()` are: `scroll`, `transition`, `prefetch`, and `reload` for a full load.
25
25
  const FLAGS = new Set(['data-scroll', 'data-transition', 'data-prefetch', 'data-reload'])
26
+
26
27
  // The names before 1.105 and what each became: `data-keep-scroll` is `data-scroll="keep"`, `data-no-transition` is `data-transition="false"`, `data-no-prefetch` is `data-prefetch="false"`.
27
- const OLD: Record<string, Renamed> = {
28
+ export const OLD_LINK_FLAGS: Record<string, Renamed> = {
28
29
  'data-keep-scroll': { name: 'data-scroll', value: 'keep', off: 'top' },
29
30
  'data-no-transition': { name: 'data-transition', value: 'false' },
30
31
  'data-no-prefetch': { name: 'data-prefetch', value: 'false' },
31
32
  }
32
- const NEARBY = [...FLAGS, ...Object.keys(OLD)]
33
+ const NEARBY = [...FLAGS, ...Object.keys(OLD_LINK_FLAGS)]
33
34
 
34
35
  // The name an attribute is written with, none for a spread or a `{name}` shorthand.
35
36
  function nameOf(attribute: Attribute): Span | undefined {
@@ -66,7 +67,7 @@ export function linkFlags(file: KayFile): Diagnostic[] {
66
67
  continue
67
68
 
68
69
  const name = file.source.slice(at.start, at.end)
69
- const old = OLD[name]
70
+ const old = OLD_LINK_FLAGS[name]
70
71
 
71
72
  if (old !== undefined) {
72
73
  found.push(oldFlag(file.source, attribute, at, name, old))
@@ -79,7 +80,7 @@ export function linkFlags(file: KayFile): Diagnostic[] {
79
80
  if (meant === undefined)
80
81
  continue
81
82
 
82
- const renamed = OLD[meant]
83
+ const renamed = OLD_LINK_FLAGS[meant]
83
84
  const to = renamed === undefined ? meant : `${renamed.name}="${renamed.value}"`
84
85
  // An old name written with a value keeps that value after the name, so writing `name="value"` there would leave two: that case gets the help alone.
85
86
  const fixes = renamed !== undefined && attribute.kind !== 'boolean' ? [] : [{ title: `Write \`${to}\``, safe: false, edits: [{ ...at, text: to }] }]
@@ -295,8 +295,8 @@ export const LINTS = {
295
295
  level: 'warn',
296
296
  group: 'forms',
297
297
  summary: 'A string field of an action\'s schema named like a short value (`name`, `email`, `title`, `subject`, `slug`, `phone`, `code`...) with no `maxLength` of its own: every string field is refused past 10,000 characters by default, which is far too long for these. Any other field keeps the default, and a secret such as a password is left alone.',
298
- wrong: '--- server\nimport { action, s } from \'kay\'\n\nexport const add = action(s.Object({ title: s.String() }), async ({ title }) => create(title))\n---\nform(action={add})\n input(name="title")',
299
- right: '--- server\nimport { action, s } from \'kay\'\n\nexport const add = action(s.Object({ title: s.String({ maxLength: 200 }) }), async ({ title }) => create(title))\n---\nform(action={add})\n input(name="title")',
298
+ wrong: '--- server\nimport { action, s } from \'kay\'\n\nexport const add = action(s.object({ title: s.string() }), async ({ title }) => create(title))\n---\nform(action={add})\n input(name="title")',
299
+ right: '--- server\nimport { action, s } from \'kay\'\n\nexport const add = action(s.object({ title: s.string({ max: 200 }) }), async ({ title }) => create(title))\n---\nform(action={add})\n input(name="title")',
300
300
  },
301
301
  'css-import-without-text': {
302
302
  level: 'deny',
@@ -309,22 +309,22 @@ export const LINTS = {
309
309
  level: 'warn',
310
310
  group: 'code',
311
311
  summary: 'An `async` function returning `ask()` from kayjs-ai: the reply is a thenable, so the function awaits it and the action, API route or `await` block reading it gets the whole text at once, with no streaming. The fix removes `async` (not from a function with a return type); a function that awaits something first returns `ask(...).stream()` instead, and `return await ask(...)` says the whole text is meant, which this lint leaves alone. Found in `.kay` fences and `.ts` modules alike.',
312
- wrong: '--- server\nimport { ask } from \'@kayjs/ai\'\nimport { action, s } from \'kay\'\n\nexport const reply = action(s.Object({ messages: s.Array(s.Any()) }), async ({ messages }) => ask(messages))\n---\np x',
313
- right: '--- server\nimport { ask } from \'@kayjs/ai\'\nimport { action, s } from \'kay\'\n\nexport const reply = action(s.Object({ messages: s.Array(s.Any()) }), ({ messages }) => ask(messages))\n---\np x',
312
+ wrong: '--- server\nimport { ask } from \'@kayjs/ai\'\nimport { action, s } from \'kay\'\n\nexport const reply = action(s.object({ messages: s.list(s.string()) }), async ({ messages }) => ask(messages))\n---\np x',
313
+ right: '--- server\nimport { ask } from \'@kayjs/ai\'\nimport { action, s } from \'kay\'\n\nexport const reply = action(s.object({ messages: s.list(s.string()) }), ({ messages }) => ask(messages))\n---\np x',
314
314
  },
315
315
  'unreturned-fail': {
316
316
  level: 'deny',
317
317
  group: 'code',
318
318
  summary: 'A `ctx.fail(...)` statement in an action\'s handler (or `fail(...)` destructured from the context) that is not returned: `fail` returns the failure the action answers with, where `deny`, `notFound` and `redirect` throw, so the statement does nothing and the handler carries on. An arrow function with an expression body already returns, and a nested function is left alone. The fix prepends `return`. Found in `.kay` fences and `.ts` modules alike.',
319
- wrong: '--- server\nexport const rename = action(s.Object({ name: s.String() }), ({ name }, ctx) => {\n if (name === \'admin\')\n ctx.fail(409, \'That name is taken\')\n\n return name\n})\n---\np x',
320
- right: '--- server\nexport const rename = action(s.Object({ name: s.String() }), ({ name }, ctx) => {\n if (name === \'admin\')\n return ctx.fail(409, \'That name is taken\')\n\n return name\n})\n---\np x',
319
+ wrong: '--- server\nexport const rename = action(s.object({ name: s.string() }), ({ name }, ctx) => {\n if (name === \'admin\')\n ctx.fail(409, \'That name is taken\')\n\n return name\n})\n---\np x',
320
+ right: '--- server\nexport const rename = action(s.object({ name: s.string() }), ({ name }, ctx) => {\n if (name === \'admin\')\n return ctx.fail(409, \'That name is taken\')\n\n return name\n})\n---\np x',
321
321
  },
322
322
  'missing-captcha': {
323
323
  level: 'warn',
324
324
  group: 'forms',
325
325
  summary: 'A call to `password.register`, `password.requestReset`, `magicLink.request` or `password.signIn` on an auth (a receiver named `auth`, or ending in `auth`), with no `captcha` option, while no `captcha: false` is written in the same file or in an `authCore` (`createAuth` before 1.91) call of the project (`kay check` reads every module): kayjs-auth asks a proof of work by default, so such a call answers `{ ok: false, error: \'captcha\' }` until the form carries the challenge. Put `input(type="hidden" name="captcha" data-kay-work={await auth.captcha.challenge(\'register\')})` in the form (action `\'reset\'`, `\'magic-link\'` or `\'sign-in\'` for the others), read the field in the action and pass it as `{ captcha: input.captcha }`. Found in `.kay` fences and `.ts` modules alike.',
326
- wrong: '--- server\nexport const reset = action(s.Object({ email: s.String() }), ({ email }, ctx) => ctx.locals.auth.password.requestReset(email))\n---\np x',
327
- right: '--- server\nexport const reset = action(s.Object({ email: s.String(), captcha: s.String() }), ({ email, captcha }, ctx) => ctx.locals.auth.password.requestReset(email, { captcha }))\n---\np x',
326
+ wrong: '--- server\nexport const reset = action(s.object({ email: s.string() }), ({ email }, ctx) => ctx.locals.auth.password.requestReset(email))\n---\np x',
327
+ right: '--- server\nexport const reset = action(s.object({ email: s.string(), captcha: s.string() }), ({ email, captcha }, ctx) => ctx.locals.auth.password.requestReset(email, { captcha }))\n---\np x',
328
328
  },
329
329
  'positional-key': {
330
330
  level: 'deny',
@@ -411,8 +411,8 @@ export const LINTS = {
411
411
  group: 'security',
412
412
  site: true,
413
413
  summary: 'With `mcp`, an action that sets `tool` and a `honeypot`, `minTime` or `proofOfWork`, with no `_guard.ts` covering it: an agent calls it without the form those protections ask of a person, so anonymous callers can spam it. A guard, or a `rateLimit` with `tool` alone, keeps it in hand.',
414
- wrong: '// kay.config.ts sets mcp: true\nexport const subscribe = action(s.Object({ email: s.String() }), save, { tool: true, protect: { honeypot: \'website\' } })',
415
- right: '// src/routes/_guard.ts covers it, or the action keeps tool and drops the honeypot\nexport const subscribe = action(s.Object({ email: s.String() }), save, { tool: true, protect: { rateLimit: { max: 5, window: \'1m\' } } })',
414
+ wrong: '// kay.config.ts sets mcp: true\nexport const subscribe = action(s.object({ email: s.string() }), save, { tool: true, protect: { honeypot: \'website\' } })',
415
+ right: '// src/routes/_guard.ts covers it, or the action keeps tool and drops the honeypot\nexport const subscribe = action(s.object({ email: s.string() }), save, { tool: true, protect: { rateLimit: { max: 5, window: \'1m\' } } })',
416
416
  },
417
417
  'external-redirect': {
418
418
  level: 'warn',
@@ -489,8 +489,8 @@ export const LINTS = {
489
489
  group: 'code',
490
490
  site: true,
491
491
  summary: 'An API route `.ws()` with a `body` and no `response`, written with an object literal of options and no spread: an island\'s `socket()` receives its messages as `unknown`, so `last()` and `on()` need a cast. Add `response: chats.response` when it sends through `rooms()`, or a `response` schema; a route only other clients read can allow the lint.',
492
- wrong: 'export default api().ws(\'/\', { body: s.Object({ text: s.String() }), message(ws, { text }) { chats.publish(\'main\', { text }) } })',
493
- right: 'export default api().ws(\'/\', { body: s.Object({ text: s.String() }), response: chats.response, message(ws, { text }) { chats.publish(\'main\', { text }) } })',
492
+ wrong: 'export default api().ws(\'/\', { body: s.object({ text: s.string() }), message(ws, { text }) { chats.publish(\'main\', { text }) } })',
493
+ right: 'export default api().ws(\'/\', { body: s.object({ text: s.string() }), response: chats.response, message(ws, { text }) { chats.publish(\'main\', { text }) } })',
494
494
  },
495
495
  'unsized-image': {
496
496
  level: 'warn',
@@ -0,0 +1,15 @@
1
+ import type { TemplateFacts } from './ast'
2
+ import type { PropsDeclaration } from './script'
3
+
4
+ // The keys `omit` takes out of the props to make the rest object: the declared props that can arrive (all of them, or the ones `written` names), then what a component that merges parts owns (`class`, `parts`, its recipe's variants and the app's).
5
+ export function restOmits(props: PropsDeclaration, written: ReadonlySet<string> | undefined, facts: TemplateFacts): string[] {
6
+ const owned = facts.parts?.merges === true
7
+ const declared = props.bindings.filter(binding => written?.has(binding.key) ?? true)
8
+
9
+ return [
10
+ ...declared.map(binding => JSON.stringify(binding.key)),
11
+ ...owned ? ['"class"', '"parts"'] : [],
12
+ ...owned && facts.recipe !== undefined ? [`...${facts.recipe}.variants`] : [],
13
+ ...owned ? Object.keys(facts.ui?.variants ?? {}).map(name => JSON.stringify(name)) : [],
14
+ ]
15
+ }
@@ -4,6 +4,7 @@ import { existsSync, realpathSync } from 'node:fs'
4
4
  import { dirname, join, resolve } from 'node:path'
5
5
  import process from 'node:process'
6
6
  import { APP_DEPENDENCIES, dependencyNames, libraryMessageExtensions, readManifest } from './build/manifests'
7
+ import { setUiLayers } from './build/ui-layers'
7
8
  import { KayError } from './compiler/errors'
8
9
  import { APP_CONTEXT, CONFIG_FILE } from './config'
9
10
  import { resolveConfig } from './config-resolve'
@@ -14,7 +15,14 @@ import { publicEnvFiles } from './server/env-state'
14
15
 
15
16
  // `fresh` reads the file again as it is now, as `kay dev` does once it changed, rather than the module this process imported first.
16
17
  export async function loadConfig(root: string, fresh = false): Promise<LoadedConfig> {
17
- return withTailwind(root, withSiteUrl(withPublicFields(root, withExtensions(withAppContext(root, withLibraryMessages(root, await importConfig(root, fresh)))))))
18
+ return withUiLayers(root, await withTailwind(root, withSiteUrl(withPublicFields(root, withExtensions(withAppContext(root, withLibraryMessages(root, await importConfig(root, fresh))))))))
19
+ }
20
+
21
+ // The config, once the `ui` files of its extensions are known to the build of the project.
22
+ function withUiLayers<Config extends KayConfig>(root: string, config: Config): Config {
23
+ setUiLayers(root, config.extensions)
24
+
25
+ return config
18
26
  }
19
27
 
20
28
  const CONFIG_TIMEOUT = 30_000
@@ -332,7 +340,7 @@ export async function withConfig<Options extends ConfigInput>(root: string, opti
332
340
  // The options are resolved as the file is, so a code call may pass a list's function or an old key as `kay.config.ts` may.
333
341
  const given = await resolveConfig(options) as KayConfig & Omit<Options, keyof ConfigInput>
334
342
 
335
- return withTailwind(root, withPublicFields(root, withAppContext(root, mergeConfig(withLibraryMessages(root, await importConfig(root)), given))))
343
+ return withUiLayers(root, await withTailwind(root, withPublicFields(root, withAppContext(root, mergeConfig(withLibraryMessages(root, await importConfig(root)), given)))))
336
344
  }
337
345
 
338
346
  // `config` is as `kay.config.ts` writes it, so the extensions the options name lie under it rather than the file's.
@@ -173,13 +173,15 @@ export async function resolveConfig(config: ConfigInput): Promise<KayConfig> {
173
173
  ])
174
174
  const cors = config.cors === undefined ? undefined : await loadKeys(config.cors, ['origins'])
175
175
  const { onStart, ...kept } = config
176
+ // An extension's config is written as `kay.config.ts` is, so its keys of before 1.105 move as the app's do.
177
+ const extensions = config.extensions === undefined ? undefined : await Promise.all(config.extensions.map(async extension => extension.config === undefined ? extension : { ...extension, config: await resolveConfig(extension.config) }))
176
178
 
177
179
  for (const key of MOVED_KEYS)
178
180
  delete kept[key]
179
181
 
180
182
  const { ops, onError, paths } = resolveOps(config)
181
183
  const routes = resolveEndpoints(config, paths, resolveMcp(config.mcp))
182
- const resolved: Record<string, unknown> = { ...kept, security, proxy: resolveProxy(proxy), ...routes, robots, i18n, redirects, assets, ops, cors, client: resolveClient(config), onListen: config.onListen ?? onStart, onError: config.onError ?? onError }
184
+ const resolved: Record<string, unknown> = { ...kept, ...extensions !== undefined && { extensions }, security, proxy: resolveProxy(proxy), ...routes, robots, i18n, redirects, assets, ops, cors, client: resolveClient(config), onListen: config.onListen ?? onStart, onError: config.onError ?? onError }
183
185
 
184
186
  for (const key of Object.keys(resolved)) {
185
187
  if (resolved[key] === undefined)
@@ -1,5 +1,5 @@
1
1
  import type { BudgetConfig } from './build/budget'
2
- import type { ActionsConfig, AssetsConfig, CardConfig, ClientConfig, ConfigInput, CookieDefaults, DeprecatedMcp, DeprecatedOpenApi, DeprecatedPath, DeprecatedServe, DirsConfig, EndpointsConfig, FaviconConfig, HealthConfig, I18nInput, ImageFormats, ImageLimits, ImagesInput, JobsConfig, LimitsConfig, LiveConfig, LogConfig, ManifestConfig, MarkdownConfig, MetricsConfig, ObserveInput, OfflineConfig, OpsConfig, PreviewConfig, ProxyConfig, RemoteImages, RobotsConfig, SecurityConfig, SeoConfig, ServeConfig, SitemapConfig } from './config'
2
+ import type { ActionsConfig, AssetsConfig, CardConfig, ClientConfig, ConfigInput, CookieDefaults, DeprecatedMcp, DeprecatedOpenApi, DeprecatedPath, DeprecatedServe, DirsConfig, EndpointsConfig, FaviconConfig, HealthConfig, I18nInput, ImageFormats, ImageLimits, ImagesInput, JobsConfig, LimitsConfig, LiveConfig, LogConfig, ManifestConfig, ManifestShareTarget, MarkdownConfig, MetricsConfig, ObserveInput, OfflineConfig, OpsConfig, PreviewConfig, ProxyConfig, RemoteImages, RobotsConfig, SecurityConfig, SeoConfig, ServeConfig, SitemapConfig } from './config'
3
3
  import type { Rule } from './config-rules'
4
4
  import type { McpConfig } from './server/api-modules'
5
5
  import type { OpenApiConfig } from './server/openapi'
@@ -45,7 +45,7 @@ const JOBS: Record<keyof (JobsConfig & DeprecatedPath), Rule> = { guards: guardO
45
45
  const METRICS: Record<keyof (MetricsConfig & DeprecatedPath), Rule> = { path: str, token: either(lit(true), SECRET) }
46
46
  const BUDGET: Record<keyof BudgetConfig, Rule> = { js: bytes, css: bytes, weight: bytes, grade: oneOf('A', 'B', 'C', 'D', 'E', 'F', 'G') }
47
47
  const FAVICON: Record<keyof FaviconConfig, Rule> = { image: str, svg: str }
48
- const MANIFEST: Record<keyof ManifestConfig, Rule> = { shortName: str, themeColor: either(str, bag({ light: str, dark: str })), backgroundColor: str, display: oneOf('fullscreen', 'standalone', 'minimal-ui', 'browser'), orientation: oneOf('any', 'natural', 'landscape', 'landscape-primary', 'landscape-secondary', 'portrait', 'portrait-primary', 'portrait-secondary'), startUrl: str, scope: str, maskable: str, shortcuts: list(obj) }
48
+ const MANIFEST: Record<keyof ManifestConfig, Rule> = { shortName: str, themeColor: either(str, bag({ light: str, dark: str })), backgroundColor: str, display: oneOf('fullscreen', 'standalone', 'minimal-ui', 'browser'), orientation: oneOf('any', 'natural', 'landscape', 'landscape-primary', 'landscape-secondary', 'portrait', 'portrait-primary', 'portrait-secondary'), startUrl: str, scope: str, maskable: str, shortcuts: list(obj), shareTarget: bag({ action: str, files: list(str), params: bag({ title: str, text: str, url: str, files: str }) } satisfies Record<keyof ManifestShareTarget, Rule>) }
49
49
  const MARKDOWN: Record<keyof MarkdownConfig, Rule> = { highlight: fn, transform: fn, preprocess: fn, containers: bool, footnotes: bool, headingLinks: bool, readingSpeed: num, imageSizes: str }
50
50
  const CARD: Record<keyof CardConfig, Rule> = { font: bag({ family: str, weight: num }), background: str, color: str, logo: str }
51
51
  const AVIF = either(bool, bag({ quality: num }))
package/src/config.ts CHANGED
@@ -310,7 +310,7 @@ export interface EndpointsConfig {
310
310
  api?: string | undefined
311
311
  // Where the OpenAPI document is served, `/api/openapi.json` under the API prefix by default; its reference page is set in `openapi.reference`.
312
312
  openapi?: string | undefined
313
- // Where the MCP endpoint is served, `/_kay/mcp` by default. `/mcp`, where it was served before 1.105, redirects there with a 308 until 1.108 when this is not set.
313
+ // Where the MCP endpoint is served, `/_kay/mcp` by default. `/mcp`, where it was served before 1.105, is answered in place until 2.0 when this is not set.
314
314
  mcp?: string | undefined
315
315
  // Where the health check is served, `/_kay/health` by default.
316
316
  health?: string | undefined
@@ -439,6 +439,17 @@ export interface ManifestConfig {
439
439
  maskable?: string | undefined
440
440
  // The pages a launcher offers from the app's icon.
441
441
  shortcuts?: ManifestShortcut[] | undefined
442
+ // Lists the installed app among the apps a device's share sheet offers, the shared title, text, link and files posted to an action.
443
+ shareTarget?: ManifestShareTarget | undefined
444
+ }
445
+
446
+ export interface ManifestShareTarget {
447
+ // Where a share is posted: an action as `'src/routes/share.kay#receive'`, the page file relative to the root and the exported action's name, or a path of the site (`'/share'`) for a route of your own taking a POST. The action reads `title`, `text`, `url` and `files`, whichever the sharing app sent, all optional.
448
+ action: string
449
+ // The kinds of file the app takes, as MIME types or extensions (`['image/*', '.pdf']`); with some the share is posted as `multipart/form-data` and the action reads them as `files`, without any only text and a link are shared.
450
+ files?: string[] | undefined
451
+ // The field each part of a share is posted as, `title`, `text`, `url` and `files` by default.
452
+ params?: { title?: string | undefined, text?: string | undefined, url?: string | undefined, files?: string | undefined } | undefined
442
453
  }
443
454
 
444
455
  export interface ManifestShortcut {
@@ -626,8 +637,10 @@ export interface KayExtension<Server extends PluginInput = AnyElysia> {
626
637
  appFiles?: Record<string, string> | undefined
627
638
  // The server plugin named by the module that exports it, `{ path: './src/auth', export: 'auth' }` for `export const auth` (`default` by default): imported only as `pages()` builds the app, and baked into an executable `kay build --compile` makes, which a path built at run time inside a library could not be. The export is the plugin, a function building it, or an object carrying it as `plugin`, as a library's `authCore` result does. `kay check` types the locals off the module itself, and off the extension's `Server` argument when it has one; used beside `server`, the module wins. A path is relative to the project root. `prepare` runs with the export before the plugin is taken from it, for a library to hand the app's module what the extension was given; a throw stops the server.
628
639
  serverModule?: { path: string, export?: string | undefined, prepare?: ((exported: unknown) => void | Promise<void>) | undefined } | undefined
629
- // Config laid under the app's `kay.config.ts`: objects merged key by key, arrays joined with the extension's items first, any other value the app sets winning. Bun plugins the library's files need go in its `plugins`.
630
- config?: Omit<KayConfig, 'extensions'> | undefined
640
+ // Config laid under the app's `kay.config.ts`: objects merged key by key, arrays joined with the extension's items first, any other value the app sets winning. Bun plugins the library's files need go in its `plugins`. It takes what `kay.config.ts` does, the keys of before 1.105 included (`fonts`, `favicon`, `observe`...), which work until 1.108 under `deprecated-config-groups`.
641
+ config?: Omit<ConfigInput, 'extensions'> | undefined
642
+ // A module whose default export is `defineUi({ ... })`, written as `src/ui.ts` is (string and object literals only), absolute or relative to the project root: the parts and variants it sets for components, the app's own or a library's, reach every app listing the extension, under the app's own `src/ui.ts`. A part or a variant value the app sets replaces the extension's, and a later extension's replaces an earlier one's. Names and relative specifiers resolve from the app's `src/`.
643
+ ui?: string | undefined
631
644
  // A directory of `.kay` pages, layouts and guards laid over the app's routes under `prefix`, the root by default: a file of the app at the same path replaces the library's.
632
645
  // Its directories are absolute, as a library gives them from `import.meta.dir`, or relative to the project root.
633
646
  routes?: { dir: string, prefix?: string | undefined } | undefined
@@ -782,7 +795,10 @@ type CaseVariant<Key, Known> = { [Name in keyof Known & string]: Lowercase<Name>
782
795
  type Misspelled<Key, Known> = [CaseVariant<Key, Known>] extends [never] ? 'unknown option' : `unknown option, did you mean \`${CaseVariant<Key, Known> & string}\`?`
783
796
 
784
797
  // A symbol key is no option a config names, and an object a library returns may carry one, as `pgData()`'s `Symbol.asyncDispose` does.
785
- type UnknownKeys<Given, Known> = Given extends object ? { [Key in Exclude<keyof Given, keyof Known | symbol>]: Misspelled<Key, Known> } : unknown
798
+ type UnknownKeys<Given, Known> = Given extends object ? { [Key in Exclude<keyof Given, AllKeys<Known> | symbol>]: Misspelled<Key, Known> } : unknown
799
+
800
+ // The keys of every member of a union of object shapes (`{ env } | { file }`), where `keyof` keeps only the keys they share, none for that one.
801
+ type AllKeys<Known> = Known extends unknown ? keyof Known : never
786
802
 
787
803
  type Method = (...args: never[]) => unknown
788
804
 
@@ -102,8 +102,7 @@ export const LOADED_HTML: SanitizeOptions = { ...MARKDOWN_KEPT, relativeUrls: tr
102
102
  const LOADED: SanitizeOptions = { ...LOADED_HTML, attributes: { ...MARKDOWN_KEPT.attributes, h1: ['id'], h2: ['id'], h3: ['id'], h4: ['id'], h5: ['id'], h6: ['id'], code: ['class'] } }
103
103
  // A link the sanitizer wrote that stays on the site: its `href` names no http(s) URL.
104
104
  const OWN_LINK = /<a href="((?!https?:\/\/)[^"]*)" rel="nofollow ugc">/gi
105
- // The only class and id kept on a code block and a heading: the language Markdown writes, and a slug in its shape, so a loader's text cannot pick a utility class or a camelCase global name.
106
- const CODE_CLASS = /<code class="(?!language-[\w+#.-]+")[^"]*">/g
105
+ // The only id kept on a heading: a slug in its shape, so a loader's text cannot pick a camelCase global name (the sanitizer keeps no class on a code block but its language).
107
106
  const HEADING_ID = /<(h[1-6]) id="(?![\p{Ll}\p{N}][\p{Ll}\p{N}_-]*")[^"]*"/gu
108
107
  // The private characters standing for a component's placeholder while the sanitizer, which reads no tag name with a hyphen, goes over the rest.
109
108
  const HELD_PLACEHOLDER = /\uE010(\d+)\uE011|\uE012(\d+)\uE011|\uE013/g
@@ -241,7 +240,7 @@ export function countWords(html: string): number {
241
240
  function sanitizedComponents(html: string): string {
242
241
  const held = html.replace(PRIVATE_CHARS, char => `&#${char.codePointAt(0)};`).replace(PLACEHOLDER_TAG, (_, selfClosing: string | undefined, opening: string | undefined) => heldPlaceholder(selfClosing, opening))
243
242
 
244
- return withoutInnerRel(sanitizedMarkdown(held, LOADED, false).replace(CODE_CLASS, '<code>').replace(HEADING_ID, '<$1').replace(HELD_PLACEHOLDER, (_, selfClosing: string | undefined, opening: string | undefined) => restoredPlaceholder(selfClosing, opening)))
243
+ return withoutInnerRel(sanitizedMarkdown(held, LOADED, false).replace(HEADING_ID, '<$1').replace(HELD_PLACEHOLDER, (_, selfClosing: string | undefined, opening: string | undefined) => restoredPlaceholder(selfClosing, opening)))
245
244
  }
246
245
 
247
246
  // The sanitizer marks every link as a user's; a link to the site or to a heading is the entry's own, so only one leaving the site keeps its `rel`.
@@ -33,14 +33,14 @@ interface TypeDescription {
33
33
  }
34
34
 
35
35
  // The range of a 4-byte column, which a bare integer schema would let a post exceed.
36
- const INT4 = '{ minimum: -2147483648, maximum: 2147483647 }'
36
+ const INT4 = '{ min: -2147483648, max: 2147483647 }'
37
37
 
38
38
  const TYPES: Record<FieldType, TypeDescription> = {
39
- string: { column: 'f.varchar(200)', schema: 's.String({ minLength: 1, maxLength: 200 })', sample: '\'First\'', posted: '\'First\'', shown: 'First' },
40
- text: { column: 'f.text()', schema: 's.String({ minLength: 1, maxLength: 10_000 })', sample: '\'Some text\'', posted: '\'Some text\'', shown: 'Some text' },
41
- int: { column: 'f.integer()', schema: `s.Integer(${INT4})`, sample: '42', posted: '\'42\'', shown: '42' },
42
- float: { column: 'f.doublePrecision()', schema: 's.Number()', sample: '4.25', posted: '\'4.25\'', shown: '4.25' },
43
- boolean: { column: 'f.boolean().default(false)', schema: 's.Boolean()', sample: 'true', posted: '\'on\'', shown: 'true' },
39
+ string: { column: 'f.varchar(200)', schema: 's.string({ min: 1, max: 200 })', sample: '\'First\'', posted: '\'First\'', shown: 'First' },
40
+ text: { column: 'f.text()', schema: 's.string({ min: 1, max: 10_000 })', sample: '\'Some text\'', posted: '\'Some text\'', shown: 'Some text' },
41
+ int: { column: 'f.integer()', schema: `s.int(${INT4})`, sample: '42', posted: '\'42\'', shown: '42' },
42
+ float: { column: 'f.doublePrecision()', schema: 's.number()', sample: '4.25', posted: '\'4.25\'', shown: '4.25' },
43
+ boolean: { column: 'f.boolean().default(false)', schema: 's.boolean()', sample: 'true', posted: '\'on\'', shown: 'true' },
44
44
  }
45
45
 
46
46
  const ALIASES: Record<string, FieldType> = { string: 'string', text: 'text', int: 'int', integer: 'int', float: 'float', number: 'float', boolean: 'boolean', bool: 'boolean' }
@@ -170,19 +170,19 @@ const fields = {
170
170
  ${schemas}
171
171
  }
172
172
 
173
- export const create = action(s.Object(fields), async (input, ctx) => {
173
+ export const create = action(fields, async (input, ctx) => {
174
174
  await db.repo(${names.pascal}).write.insertOne(input)
175
175
 
176
176
  return ctx.redirect('${list}')
177
177
  })
178
178
 
179
- export const update = action(s.Object({ id: s.Integer(${INT4}), ...fields }), async ({ id, ...values }, ctx) => {
179
+ export const update = action({ id: s.int(${INT4}), ...fields }, async ({ id, ...values }, ctx) => {
180
180
  await db.repo(${names.pascal}).write.updateOne(values, { id })
181
181
 
182
182
  return ctx.redirect('${list}')
183
183
  })
184
184
 
185
- export const remove = action(s.Object({ id: s.Integer(${INT4}) }), async ({ id }, ctx) => {
185
+ export const remove = action({ id: s.int(${INT4}) }, async ({ id }, ctx) => {
186
186
  await db.repo(${names.pascal}).write.deleteOne({ id })
187
187
 
188
188
  return ctx.redirect('${list}')
package/src/generate.ts CHANGED
@@ -21,7 +21,7 @@ const WORD_BREAK = /[-_]+/g
21
21
  // Words an action cannot be exported as, or that its own file already names: the `action` and `s` it calls, `title` its handler reads.
22
22
  const RESERVED = new Set(['action', 's', 'title', 'await', 'break', 'case', 'catch', 'class', 'const', 'continue', 'debugger', 'default', 'delete', 'do', 'else', 'enum', 'export', 'extends', 'false', 'finally', 'for', 'function', 'if', 'import', 'in', 'instanceof', 'let', 'new', 'null', 'return', 'static', 'super', 'switch', 'this', 'throw', 'true', 'try', 'typeof', 'var', 'void', 'while', 'with', 'yield', 'implements', 'interface', 'package', 'private', 'protected', 'public', 'eval', 'arguments'])
23
23
  // The action added to an `_actions.kay`, or printed for the author to add when the file holds more than a server fence.
24
- const ACTION_BODY = (name: string) => `export const ${name} = action(\n s.Object({ title: s.String({ minLength: 1, maxLength: 200 }) }),\n ({ title }) => title,\n)\n`
24
+ const ACTION_BODY = (name: string) => `export const ${name} = action(\n { title: s.string({ min: 1, max: 200 }) },\n ({ title }) => title,\n)\n`
25
25
  const LINE_BREAK = /\r?\n/
26
26
  const LINE_BREAKS = /\r?\n/g
27
27
  const TABLES_FILE = 'src/db/tables.ts'
package/src/mcp/guards.ts CHANGED
@@ -50,7 +50,7 @@ export function optionalString(value: unknown, name: string): string | undefined
50
50
  return undefined
51
51
 
52
52
  if (typeof value !== 'string')
53
- throw new Error(`${name} takes a string`)
53
+ throw new TypeError(`${name} takes a string`)
54
54
 
55
55
  return value
56
56
  }
package/src/mcp/tools.ts CHANGED
@@ -216,7 +216,7 @@ function tools(root: string, write: boolean): Tool[] {
216
216
  return []
217
217
 
218
218
  if (typeof value !== 'number' || !Number.isInteger(value))
219
- throw new Error(`${name} takes a whole number of pixels`)
219
+ throw new TypeError(`${name} takes a whole number of pixels`)
220
220
 
221
221
  return [`--${name}=${value}`]
222
222
  })