create-foldkit-app 0.40.0-canary.f3be22cfeefe → 0.40.0-canary.fbc0bbd6fde6

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 (680) hide show
  1. package/README.md +3 -3
  2. package/dist/examples.js +4 -4
  3. package/dist/templates/base/AGENTS.md +0 -6
  4. package/dist/templates/base/FOLDKIT.md +42 -172
  5. package/dist/templates/examples/api-cache/package.json +4 -4
  6. package/dist/templates/examples/api-cache/src/data.ts +4 -1
  7. package/dist/templates/examples/api-cache/src/entry.ts +12 -6
  8. package/dist/templates/examples/api-cache/src/main.fixture.ts +71 -0
  9. package/dist/templates/examples/api-cache/src/main.ts +743 -0
  10. package/dist/templates/examples/api-cache/src/scene.test.ts +7 -11
  11. package/dist/templates/examples/api-cache/src/story.test.ts +24 -27
  12. package/dist/templates/examples/api-cache-query/package.json +4 -4
  13. package/dist/templates/examples/api-cache-query/src/data.ts +4 -1
  14. package/dist/templates/examples/api-cache-query/src/entry.ts +13 -6
  15. package/dist/templates/examples/api-cache-query/src/{model.fixture.ts → main.fixture.ts} +16 -20
  16. package/dist/templates/examples/api-cache-query/src/main.ts +651 -0
  17. package/dist/templates/examples/api-cache-query/src/scene.test.ts +4 -10
  18. package/dist/templates/examples/api-cache-query/src/story.test.ts +10 -22
  19. package/dist/templates/examples/auth/package.json +4 -4
  20. package/dist/templates/examples/auth/src/command.ts +31 -107
  21. package/dist/templates/examples/auth/src/domain/session.ts +2 -0
  22. package/dist/templates/examples/auth/src/entry.ts +17 -10
  23. package/dist/templates/examples/auth/src/main.ts +76 -0
  24. package/dist/templates/examples/auth/src/message.ts +6 -3
  25. package/dist/templates/examples/auth/src/model.ts +6 -6
  26. package/dist/templates/examples/auth/src/page/index.ts +2 -2
  27. package/dist/templates/examples/auth/src/page/loggedIn/index.ts +4 -1
  28. package/dist/templates/examples/auth/src/page/loggedIn/message.ts +8 -0
  29. package/dist/templates/examples/auth/src/page/loggedIn/model.ts +12 -0
  30. package/dist/templates/examples/auth/src/page/loggedIn/page/dashboard.ts +8 -7
  31. package/dist/templates/examples/auth/src/page/loggedIn/page/settings.ts +5 -7
  32. package/dist/templates/examples/auth/src/page/loggedIn/update.ts +14 -5
  33. package/dist/templates/examples/auth/src/page/loggedIn/view.ts +7 -5
  34. package/dist/templates/examples/auth/src/page/loggedOut/index.ts +4 -1
  35. package/dist/templates/examples/auth/src/page/loggedOut/message.ts +13 -1
  36. package/dist/templates/examples/auth/src/page/loggedOut/model.ts +13 -1
  37. package/dist/templates/examples/auth/src/page/loggedOut/page/home.ts +5 -5
  38. package/dist/templates/examples/auth/src/page/loggedOut/page/{login/scene.test.ts → login.scene.test.ts} +1 -3
  39. package/dist/templates/examples/auth/src/page/loggedOut/page/{login/story.test.ts → login.story.test.ts} +7 -2
  40. package/dist/templates/examples/auth/src/page/loggedOut/page/{login/view.ts → login.ts} +158 -11
  41. package/dist/templates/examples/auth/src/page/loggedOut/update.ts +25 -2
  42. package/dist/templates/examples/auth/src/page/loggedOut/view.ts +11 -8
  43. package/dist/templates/examples/auth/src/route.ts +14 -16
  44. package/dist/templates/examples/auth/src/scene.test.ts +10 -12
  45. package/dist/templates/examples/auth/src/update.ts +156 -63
  46. package/dist/templates/examples/auth/src/view.ts +20 -21
  47. package/dist/templates/examples/canvas-art/package.json +4 -4
  48. package/dist/templates/examples/canvas-art/src/entry.ts +12 -6
  49. package/dist/templates/examples/canvas-art/src/{application.ts → main.ts} +81 -121
  50. package/dist/templates/examples/canvas-art/src/scene.test.ts +4 -4
  51. package/dist/templates/examples/canvas-art/src/story.test.ts +4 -4
  52. package/dist/templates/examples/charting/package.json +4 -4
  53. package/dist/templates/examples/charting/src/chartHost.ts +19 -0
  54. package/dist/templates/examples/charting/src/command.ts +40 -56
  55. package/dist/templates/examples/charting/src/domain.ts +29 -21
  56. package/dist/templates/examples/charting/src/echarts.ts +11 -11
  57. package/dist/templates/examples/charting/src/entry.ts +15 -7
  58. package/dist/templates/examples/charting/src/githubApi.ts +2 -1
  59. package/dist/templates/examples/charting/src/init.ts +15 -4
  60. package/dist/templates/examples/charting/src/{model.fixture.ts → main.fixture.ts} +5 -12
  61. package/dist/templates/examples/charting/src/message.ts +8 -0
  62. package/dist/templates/examples/charting/src/model.ts +6 -8
  63. package/dist/templates/examples/charting/src/npmApi.ts +4 -3
  64. package/dist/templates/examples/charting/src/radioGroups.ts +3 -4
  65. package/dist/templates/examples/charting/src/scene.test.ts +4 -5
  66. package/dist/templates/examples/charting/src/story.test.ts +11 -19
  67. package/dist/templates/examples/charting/src/telemetry.ts +56 -69
  68. package/dist/templates/examples/charting/src/update.ts +183 -53
  69. package/dist/templates/examples/charting/src/view/chart.ts +127 -17
  70. package/dist/templates/examples/charting/src/view/layout.ts +12 -15
  71. package/dist/templates/examples/charting/src/view/sidebar.ts +121 -120
  72. package/dist/templates/examples/charting/src/view/view.ts +7 -3
  73. package/dist/templates/examples/counter/package.json +4 -4
  74. package/dist/templates/examples/counter/src/entry.ts +11 -6
  75. package/dist/templates/examples/counter/src/{application.ts → main.ts} +30 -37
  76. package/dist/templates/examples/counter/src/scene.test.ts +2 -2
  77. package/dist/templates/examples/counter/src/story.test.ts +2 -2
  78. package/dist/templates/examples/counters/package.json +4 -4
  79. package/dist/templates/examples/counters/src/counter.ts +24 -34
  80. package/dist/templates/examples/counters/src/entry.ts +11 -6
  81. package/dist/templates/examples/counters/src/main.ts +167 -0
  82. package/dist/templates/examples/counters/src/scene.test.ts +13 -13
  83. package/dist/templates/examples/counters/src/story.test.ts +53 -104
  84. package/dist/templates/examples/crash-view/package.json +4 -4
  85. package/dist/templates/examples/crash-view/src/entry.ts +13 -7
  86. package/dist/templates/examples/crash-view/src/{application.ts → main.ts} +21 -28
  87. package/dist/templates/examples/crash-view/src/scene.test.ts +1 -1
  88. package/dist/templates/examples/crash-view/src/story.test.ts +1 -1
  89. package/dist/templates/examples/embedding/package.json +4 -4
  90. package/dist/templates/examples/embedding/src/host.ts +4 -12
  91. package/dist/templates/examples/embedding/src/main.ts +151 -0
  92. package/dist/templates/examples/embedding/src/scene.test.ts +2 -2
  93. package/dist/templates/examples/embedding/src/story.test.ts +2 -2
  94. package/dist/templates/examples/form/package.json +4 -4
  95. package/dist/templates/examples/form/src/entry.ts +11 -6
  96. package/dist/templates/examples/form/src/{view.ts → main.ts} +239 -23
  97. package/dist/templates/examples/form/src/scene.test.ts +8 -5
  98. package/dist/templates/examples/form/src/story.test.ts +11 -8
  99. package/dist/templates/examples/generative-art/package.json +4 -4
  100. package/dist/templates/examples/generative-art/src/command.ts +84 -92
  101. package/dist/templates/examples/generative-art/src/entry.ts +10 -6
  102. package/dist/templates/examples/generative-art/src/main.ts +61 -0
  103. package/dist/templates/examples/generative-art/src/message.ts +6 -0
  104. package/dist/templates/examples/generative-art/src/model.ts +6 -3
  105. package/dist/templates/examples/generative-art/src/scene.test.ts +8 -12
  106. package/dist/templates/examples/generative-art/src/story.test.ts +7 -11
  107. package/dist/templates/examples/generative-art/src/subscription.ts +32 -21
  108. package/dist/templates/examples/generative-art/src/update.ts +121 -62
  109. package/dist/templates/examples/generative-art/src/view.ts +62 -80
  110. package/dist/templates/examples/interrupting-commands/package.json +4 -4
  111. package/dist/templates/examples/interrupting-commands/src/entry.ts +11 -6
  112. package/dist/templates/examples/interrupting-commands/src/main.ts +358 -0
  113. package/dist/templates/examples/interrupting-commands/src/scene.test.ts +11 -7
  114. package/dist/templates/examples/interrupting-commands/src/story.test.ts +14 -10
  115. package/dist/templates/examples/job-application/package.json +4 -4
  116. package/dist/templates/examples/job-application/src/command.ts +12 -18
  117. package/dist/templates/examples/job-application/src/domain/proficiencyLevel.ts +2 -2
  118. package/dist/templates/examples/job-application/src/domain/pronounOption.ts +2 -2
  119. package/dist/templates/examples/job-application/src/domain/step.ts +3 -2
  120. package/dist/templates/examples/job-application/src/entry.ts +11 -8
  121. package/dist/templates/examples/job-application/src/{model.fixture.ts → main.fixture.ts} +18 -17
  122. package/dist/templates/examples/job-application/src/main.ts +69 -0
  123. package/dist/templates/examples/job-application/src/message.ts +21 -0
  124. package/dist/templates/examples/job-application/src/model.ts +24 -15
  125. package/dist/templates/examples/job-application/src/scene.test.ts +3 -4
  126. package/dist/templates/examples/job-application/src/step/attachments/attachments.ts +106 -0
  127. package/dist/templates/examples/job-application/src/step/attachments/index.ts +2 -1
  128. package/dist/templates/examples/job-application/src/step/attachments/scene.test.ts +2 -3
  129. package/dist/templates/examples/job-application/src/step/attachments/story.test.ts +10 -22
  130. package/dist/templates/examples/job-application/src/step/attachments/view.ts +62 -65
  131. package/dist/templates/examples/job-application/src/step/coverLetter/{block.ts → coverLetter.ts} +25 -29
  132. package/dist/templates/examples/job-application/src/step/coverLetter/index.ts +1 -1
  133. package/dist/templates/examples/job-application/src/step/coverLetter/scene.test.ts +5 -5
  134. package/dist/templates/examples/job-application/src/step/coverLetter/story.test.ts +4 -6
  135. package/dist/templates/examples/job-application/src/step/education/education.ts +106 -0
  136. package/dist/templates/examples/job-application/src/step/education/entry/entry.ts +160 -0
  137. package/dist/templates/examples/job-application/src/step/education/entry/index.ts +11 -1
  138. package/dist/templates/examples/job-application/src/step/education/entry/story.test.ts +4 -6
  139. package/dist/templates/examples/job-application/src/step/education/entry/view.ts +47 -48
  140. package/dist/templates/examples/job-application/src/step/education/index.ts +12 -1
  141. package/dist/templates/examples/job-application/src/step/education/scene.test.ts +2 -3
  142. package/dist/templates/examples/job-application/src/step/education/story.test.ts +17 -38
  143. package/dist/templates/examples/job-application/src/step/education/view.ts +15 -19
  144. package/dist/templates/examples/job-application/src/step/index.ts +6 -9
  145. package/dist/templates/examples/job-application/src/step/personalInfo/index.ts +11 -1
  146. package/dist/templates/examples/job-application/src/step/personalInfo/personalInfo.ts +291 -0
  147. package/dist/templates/examples/job-application/src/step/personalInfo/scene.test.ts +4 -5
  148. package/dist/templates/examples/job-application/src/step/personalInfo/story.test.ts +3 -6
  149. package/dist/templates/examples/job-application/src/step/personalInfo/view.ts +76 -78
  150. package/dist/templates/examples/job-application/src/step/skills/entry/entry.ts +120 -0
  151. package/dist/templates/examples/job-application/src/step/skills/entry/index.ts +11 -1
  152. package/dist/templates/examples/job-application/src/step/skills/entry/story.test.ts +3 -5
  153. package/dist/templates/examples/job-application/src/step/skills/entry/view.ts +37 -38
  154. package/dist/templates/examples/job-application/src/step/skills/index.ts +12 -1
  155. package/dist/templates/examples/job-application/src/step/skills/scene.test.ts +2 -3
  156. package/dist/templates/examples/job-application/src/step/skills/skills.ts +103 -0
  157. package/dist/templates/examples/job-application/src/step/skills/story.test.ts +17 -39
  158. package/dist/templates/examples/job-application/src/step/skills/view.ts +13 -10
  159. package/dist/templates/examples/job-application/src/step/workHistory/entry/entry.ts +188 -0
  160. package/dist/templates/examples/job-application/src/step/workHistory/entry/index.ts +11 -1
  161. package/dist/templates/examples/job-application/src/step/workHistory/entry/story.test.ts +4 -6
  162. package/dist/templates/examples/job-application/src/step/workHistory/entry/view.ts +41 -43
  163. package/dist/templates/examples/job-application/src/step/workHistory/index.ts +12 -1
  164. package/dist/templates/examples/job-application/src/step/workHistory/scene.test.ts +2 -3
  165. package/dist/templates/examples/job-application/src/step/workHistory/story.test.ts +17 -41
  166. package/dist/templates/examples/job-application/src/step/workHistory/view.ts +16 -10
  167. package/dist/templates/examples/job-application/src/step/workHistory/workHistory.ts +106 -0
  168. package/dist/templates/examples/job-application/src/story.test.ts +70 -136
  169. package/dist/templates/examples/job-application/src/update.ts +163 -66
  170. package/dist/templates/examples/job-application/src/view/datePicker.ts +2 -2
  171. package/dist/templates/examples/job-application/src/view/preview.ts +10 -23
  172. package/dist/templates/examples/job-application/src/view/review.ts +34 -43
  173. package/dist/templates/examples/job-application/src/view/stepNav.ts +61 -67
  174. package/dist/templates/examples/job-application/src/view/view.ts +136 -160
  175. package/dist/templates/examples/kanban/package.json +4 -4
  176. package/dist/templates/examples/kanban/src/command.ts +35 -52
  177. package/dist/templates/examples/kanban/src/domain/card.ts +2 -0
  178. package/dist/templates/examples/kanban/src/domain/column.ts +13 -17
  179. package/dist/templates/examples/kanban/src/entry.ts +21 -8
  180. package/dist/templates/examples/kanban/src/main.ts +55 -0
  181. package/dist/templates/examples/kanban/src/message.ts +5 -0
  182. package/dist/templates/examples/kanban/src/model.ts +6 -2
  183. package/dist/templates/examples/kanban/src/scene.test.ts +5 -9
  184. package/dist/templates/examples/kanban/src/story.test.ts +69 -75
  185. package/dist/templates/examples/kanban/src/subscription.ts +17 -0
  186. package/dist/templates/examples/kanban/src/update.ts +185 -49
  187. package/dist/templates/examples/kanban/src/view/card.ts +21 -15
  188. package/dist/templates/examples/kanban/src/view/column.ts +55 -40
  189. package/dist/templates/examples/kanban/src/view/view.ts +19 -33
  190. package/dist/templates/examples/managed-resource-layer/package.json +4 -4
  191. package/dist/templates/examples/managed-resource-layer/src/entry.ts +12 -7
  192. package/dist/templates/examples/managed-resource-layer/src/{application.ts → main.ts} +93 -117
  193. package/dist/templates/examples/managed-resource-layer/src/scene.test.ts +2 -2
  194. package/dist/templates/examples/managed-resource-layer/src/story.test.ts +6 -12
  195. package/dist/templates/examples/map/package.json +4 -4
  196. package/dist/templates/examples/map/src/entry.ts +11 -7
  197. package/dist/templates/examples/map/src/locations.ts +2 -1
  198. package/dist/templates/examples/map/src/{model.fixture.ts → main.fixture.ts} +4 -4
  199. package/dist/templates/examples/map/src/main.ts +789 -0
  200. package/dist/templates/examples/map/src/mapHost.ts +21 -0
  201. package/dist/templates/examples/map/src/mount.test.ts +5 -9
  202. package/dist/templates/examples/map/src/scene.test.ts +12 -7
  203. package/dist/templates/examples/map/src/story.test.ts +10 -5
  204. package/dist/templates/examples/pixel-art/package.json +4 -4
  205. package/dist/templates/examples/pixel-art/src/command.ts +49 -53
  206. package/dist/templates/examples/pixel-art/src/comparison.bench.test.ts +7 -10
  207. package/dist/templates/examples/pixel-art/src/constant.ts +2 -2
  208. package/dist/templates/examples/pixel-art/src/entry.ts +21 -8
  209. package/dist/templates/examples/pixel-art/src/grid.ts +22 -31
  210. package/dist/templates/examples/pixel-art/src/{app.bench.ts → main.bench.ts} +14 -23
  211. package/dist/templates/examples/pixel-art/src/main.ts +84 -0
  212. package/dist/templates/examples/pixel-art/src/message.ts +10 -0
  213. package/dist/templates/examples/pixel-art/src/model.ts +19 -16
  214. package/dist/templates/examples/pixel-art/src/palette.ts +3 -7
  215. package/dist/templates/examples/pixel-art/src/scene.test.ts +50 -72
  216. package/dist/templates/examples/pixel-art/src/story.test.ts +29 -60
  217. package/dist/templates/examples/pixel-art/src/subscription.ts +29 -49
  218. package/dist/templates/examples/pixel-art/src/update.ts +443 -204
  219. package/dist/templates/examples/pixel-art/src/view/canvas.ts +9 -10
  220. package/dist/templates/examples/pixel-art/src/view/dialog.ts +135 -147
  221. package/dist/templates/examples/pixel-art/src/view/history.ts +9 -10
  222. package/dist/templates/examples/pixel-art/src/view/toolbar.ts +192 -197
  223. package/dist/templates/examples/pixel-art/src/view/view.ts +11 -11
  224. package/dist/templates/examples/query-sync/package.json +4 -4
  225. package/dist/templates/examples/query-sync/src/entry.ts +13 -8
  226. package/dist/templates/examples/query-sync/src/main.ts +893 -0
  227. package/dist/templates/examples/query-sync/src/scene.test.ts +10 -11
  228. package/dist/templates/examples/query-sync/src/story.test.ts +24 -25
  229. package/dist/templates/examples/route-transitions/package.json +4 -4
  230. package/dist/templates/examples/route-transitions/src/data.ts +3 -4
  231. package/dist/templates/examples/route-transitions/src/entry.ts +13 -8
  232. package/dist/templates/examples/route-transitions/src/{view.ts → main.ts} +286 -42
  233. package/dist/templates/examples/route-transitions/src/route.ts +9 -7
  234. package/dist/templates/examples/route-transitions/src/story.test.ts +29 -29
  235. package/dist/templates/examples/routing/package.json +4 -4
  236. package/dist/templates/examples/routing/src/entry.ts +14 -8
  237. package/dist/templates/examples/routing/src/fileTree.ts +2 -1
  238. package/dist/templates/examples/routing/src/{view.ts → main.ts} +204 -35
  239. package/dist/templates/examples/routing/src/page/index.ts +1 -1
  240. package/dist/templates/examples/routing/src/page/people.scene.test.ts +1 -3
  241. package/dist/templates/examples/routing/src/page/people.story.test.ts +10 -6
  242. package/dist/templates/examples/routing/src/page/people.ts +331 -0
  243. package/dist/templates/examples/routing/src/route.ts +12 -9
  244. package/dist/templates/examples/routing/src/scene.test.ts +12 -16
  245. package/dist/templates/examples/routing/src/story.test.ts +17 -26
  246. package/dist/templates/examples/shopping-cart/package.json +4 -4
  247. package/dist/templates/examples/shopping-cart/src/data/products.ts +1 -1
  248. package/dist/templates/examples/shopping-cart/src/domain/cart.ts +11 -13
  249. package/dist/templates/examples/shopping-cart/src/domain/item.ts +4 -0
  250. package/dist/templates/examples/shopping-cart/src/entry.ts +13 -8
  251. package/dist/templates/examples/shopping-cart/src/main.ts +299 -0
  252. package/dist/templates/examples/shopping-cart/src/page/cart.ts +5 -7
  253. package/dist/templates/examples/shopping-cart/src/page/checkout.ts +6 -5
  254. package/dist/templates/examples/shopping-cart/src/page/index.ts +1 -1
  255. package/dist/templates/examples/shopping-cart/src/page/{products/scene.test.ts → products.scene.test.ts} +3 -4
  256. package/dist/templates/examples/shopping-cart/src/page/{products/story.test.ts → products.story.test.ts} +6 -7
  257. package/dist/templates/examples/shopping-cart/src/page/{products/view.ts → products.ts} +97 -7
  258. package/dist/templates/examples/shopping-cart/src/route.ts +8 -9
  259. package/dist/templates/examples/shopping-cart/src/scene.test.ts +12 -16
  260. package/dist/templates/examples/shopping-cart/src/story.test.ts +15 -22
  261. package/dist/templates/examples/slow-warnings/package.json +4 -4
  262. package/dist/templates/examples/slow-warnings/src/entry.ts +20 -7
  263. package/dist/templates/examples/slow-warnings/src/handleSlow.test.ts +2 -4
  264. package/dist/templates/examples/slow-warnings/src/{view.ts → main.ts} +253 -31
  265. package/dist/templates/examples/slow-warnings/src/scene.test.ts +2 -4
  266. package/dist/templates/examples/slow-warnings/src/story.test.ts +2 -4
  267. package/dist/templates/examples/snake/package.json +4 -4
  268. package/dist/templates/examples/snake/src/domain/apple.ts +2 -2
  269. package/dist/templates/examples/snake/src/domain/direction.ts +5 -8
  270. package/dist/templates/examples/snake/src/domain/position.ts +6 -4
  271. package/dist/templates/examples/snake/src/domain/snake.ts +7 -16
  272. package/dist/templates/examples/snake/src/entry.ts +12 -6
  273. package/dist/templates/examples/snake/src/main.ts +338 -0
  274. package/dist/templates/examples/snake/src/scene.test.ts +2 -2
  275. package/dist/templates/examples/snake/src/story.test.ts +4 -9
  276. package/dist/templates/examples/ssg/package.json +4 -4
  277. package/dist/templates/examples/ssg/src/entry.server.ts +2 -3
  278. package/dist/templates/examples/ssg/src/entry.ts +13 -8
  279. package/dist/templates/examples/ssg/src/{application.ts → main.ts} +56 -75
  280. package/dist/templates/examples/ssg/src/route.ts +7 -8
  281. package/dist/templates/examples/ssr/package.json +6 -6
  282. package/dist/templates/examples/ssr/src/entry.server.ts +3 -4
  283. package/dist/templates/examples/ssr/src/entry.ts +11 -6
  284. package/dist/templates/examples/ssr/src/{application.ts → main.ts} +52 -63
  285. package/dist/templates/examples/ssr/src/scene.test.ts +1 -1
  286. package/dist/templates/examples/state-machine/package.json +4 -4
  287. package/dist/templates/examples/state-machine/src/entry.ts +12 -6
  288. package/dist/templates/examples/state-machine/src/{machine.ts → main.ts} +228 -5
  289. package/dist/templates/examples/state-machine/src/scene.test.ts +4 -8
  290. package/dist/templates/examples/state-machine/src/story.test.ts +35 -11
  291. package/dist/templates/examples/state-machine/src/view.ts +1621 -7
  292. package/dist/templates/examples/stopwatch/package.json +4 -4
  293. package/dist/templates/examples/stopwatch/src/entry.ts +12 -6
  294. package/dist/templates/examples/stopwatch/src/main.ts +230 -0
  295. package/dist/templates/examples/stopwatch/src/scene.test.ts +3 -13
  296. package/dist/templates/examples/stopwatch/src/story.test.ts +3 -3
  297. package/dist/templates/examples/todo/package.json +4 -4
  298. package/dist/templates/examples/todo/src/entry.ts +11 -10
  299. package/dist/templates/examples/todo/src/{view.ts → main.ts} +327 -37
  300. package/dist/templates/examples/todo/src/scene.test.ts +12 -8
  301. package/dist/templates/examples/todo/src/story.test.ts +16 -12
  302. package/dist/templates/examples/ui-showcase/package.json +4 -4
  303. package/dist/templates/examples/ui-showcase/src/entry.ts +23 -9
  304. package/dist/templates/examples/ui-showcase/src/main.ts +688 -0
  305. package/dist/templates/examples/ui-showcase/src/scene.test.ts +24 -29
  306. package/dist/templates/examples/ui-showcase/src/story.test.ts +20 -18
  307. package/dist/templates/examples/ui-showcase/src/ui/init.ts +133 -5
  308. package/dist/templates/examples/ui-showcase/src/ui/message.ts +61 -2
  309. package/dist/templates/examples/ui-showcase/src/ui/model.ts +99 -61
  310. package/dist/templates/examples/ui-showcase/src/ui/subscriptions.ts +49 -0
  311. package/dist/templates/examples/ui-showcase/src/ui/toast.ts +3 -2
  312. package/dist/templates/examples/ui-showcase/src/ui/update.ts +1184 -149
  313. package/dist/templates/examples/ui-showcase/src/ui/view/animation.ts +44 -37
  314. package/dist/templates/examples/ui-showcase/src/ui/view/button.ts +56 -51
  315. package/dist/templates/examples/ui-showcase/src/ui/view/calendar.ts +45 -36
  316. package/dist/templates/examples/ui-showcase/src/ui/view/checkbox.ts +69 -65
  317. package/dist/templates/examples/ui-showcase/src/ui/view/combobox.ts +141 -141
  318. package/dist/templates/examples/ui-showcase/src/ui/view/datePicker.ts +51 -40
  319. package/dist/templates/examples/ui-showcase/src/ui/view/dialog.ts +161 -151
  320. package/dist/templates/examples/ui-showcase/src/ui/view/disclosure.ts +180 -179
  321. package/dist/templates/examples/ui-showcase/src/ui/view/dragAndDrop.ts +78 -95
  322. package/dist/templates/examples/ui-showcase/src/ui/view/fieldset.ts +42 -40
  323. package/dist/templates/examples/ui-showcase/src/ui/view/fileDrop.ts +74 -65
  324. package/dist/templates/examples/ui-showcase/src/ui/view/hoverIntent.ts +62 -53
  325. package/dist/templates/examples/ui-showcase/src/ui/view/index.ts +0 -2
  326. package/dist/templates/examples/ui-showcase/src/ui/view/input.ts +73 -70
  327. package/dist/templates/examples/ui-showcase/src/ui/view/listbox.ts +124 -120
  328. package/dist/templates/examples/ui-showcase/src/ui/view/menu.ts +67 -60
  329. package/dist/templates/examples/ui-showcase/src/ui/view/meter.ts +79 -75
  330. package/dist/templates/examples/ui-showcase/src/ui/view/popover.ts +135 -124
  331. package/dist/templates/examples/ui-showcase/src/ui/view/progress.ts +81 -77
  332. package/dist/templates/examples/ui-showcase/src/ui/view/radioGroup.ts +120 -113
  333. package/dist/templates/examples/ui-showcase/src/ui/view/select.ts +97 -88
  334. package/dist/templates/examples/ui-showcase/src/ui/view/slider.ts +99 -91
  335. package/dist/templates/examples/ui-showcase/src/ui/view/switch.ts +47 -46
  336. package/dist/templates/examples/ui-showcase/src/ui/view/tabs.ts +89 -87
  337. package/dist/templates/examples/ui-showcase/src/ui/view/textarea.ts +76 -73
  338. package/dist/templates/examples/ui-showcase/src/ui/view/toast.ts +98 -95
  339. package/dist/templates/examples/ui-showcase/src/ui/view/tooltip.ts +98 -95
  340. package/dist/templates/examples/ui-showcase/src/ui/view/virtualList.ts +100 -79
  341. package/dist/templates/examples/view-transitions/package.json +4 -4
  342. package/dist/templates/examples/view-transitions/src/artwork.ts +3 -4
  343. package/dist/templates/examples/view-transitions/src/entry.ts +13 -8
  344. package/dist/templates/examples/view-transitions/src/{application.ts → main.ts} +73 -105
  345. package/dist/templates/examples/view-transitions/src/route.ts +7 -8
  346. package/dist/templates/examples/view-transitions/src/scene.test.ts +5 -15
  347. package/dist/templates/examples/weather/package.json +4 -4
  348. package/dist/templates/examples/weather/src/entry.ts +11 -7
  349. package/dist/templates/examples/weather/src/main.fixture.ts +59 -0
  350. package/dist/templates/examples/weather/src/main.ts +349 -0
  351. package/dist/templates/examples/weather/src/scene.test.ts +2 -6
  352. package/dist/templates/examples/weather/src/story.test.ts +82 -4
  353. package/dist/templates/examples/web-components/package.json +4 -4
  354. package/dist/templates/examples/web-components/src/entry.ts +11 -6
  355. package/dist/templates/examples/web-components/src/{application.ts → main.ts} +40 -60
  356. package/dist/templates/examples/web-components/src/scene.test.ts +1 -1
  357. package/dist/templates/examples/web-components/src/story.test.ts +2 -2
  358. package/dist/templates/examples/websocket-chat/package.json +4 -4
  359. package/dist/templates/examples/websocket-chat/src/entry.ts +21 -7
  360. package/dist/templates/examples/websocket-chat/src/main.ts +628 -0
  361. package/dist/templates/examples/websocket-chat/src/scene.test.ts +9 -21
  362. package/dist/templates/examples/websocket-chat/src/story.test.ts +7 -6
  363. package/dist/templates/release.json +14 -14
  364. package/dist/templates/rendering/ssg/src/entry.server.ts +2 -3
  365. package/dist/templates/rendering/ssg/src/entry.ts +14 -9
  366. package/dist/templates/rendering/ssg/src/{application.ts → main.ts} +56 -76
  367. package/dist/templates/rendering/ssg/src/route.ts +7 -8
  368. package/dist/templates/rendering/ssg/src/scene.test.ts +3 -6
  369. package/dist/templates/rendering/ssr/src/entry.server.ts +3 -4
  370. package/dist/templates/rendering/ssr/src/entry.ts +11 -6
  371. package/dist/templates/rendering/ssr/src/{application.ts → main.ts} +54 -57
  372. package/dist/templates/rendering/ssr/src/scene.test.ts +1 -1
  373. package/package.json +5 -5
  374. package/dist/templates/examples/api-cache/src/block.ts +0 -22
  375. package/dist/templates/examples/api-cache/src/command.ts +0 -69
  376. package/dist/templates/examples/api-cache/src/composition.ts +0 -77
  377. package/dist/templates/examples/api-cache/src/definition.ts +0 -11
  378. package/dist/templates/examples/api-cache/src/init.ts +0 -16
  379. package/dist/templates/examples/api-cache/src/layer.ts +0 -11
  380. package/dist/templates/examples/api-cache/src/message.ts +0 -23
  381. package/dist/templates/examples/api-cache/src/model.fixture.ts +0 -84
  382. package/dist/templates/examples/api-cache/src/model.ts +0 -40
  383. package/dist/templates/examples/api-cache/src/subscription.ts +0 -33
  384. package/dist/templates/examples/api-cache/src/update.ts +0 -75
  385. package/dist/templates/examples/api-cache/src/view/posts.ts +0 -254
  386. package/dist/templates/examples/api-cache/src/view/shared.ts +0 -63
  387. package/dist/templates/examples/api-cache/src/view/stats.ts +0 -140
  388. package/dist/templates/examples/api-cache/src/view/view.ts +0 -73
  389. package/dist/templates/examples/api-cache-query/src/block.ts +0 -21
  390. package/dist/templates/examples/api-cache-query/src/composition.ts +0 -48
  391. package/dist/templates/examples/api-cache-query/src/definition.ts +0 -11
  392. package/dist/templates/examples/api-cache-query/src/init.ts +0 -11
  393. package/dist/templates/examples/api-cache-query/src/message.ts +0 -13
  394. package/dist/templates/examples/api-cache-query/src/model.ts +0 -20
  395. package/dist/templates/examples/api-cache-query/src/query.ts +0 -75
  396. package/dist/templates/examples/api-cache-query/src/subscription.ts +0 -33
  397. package/dist/templates/examples/api-cache-query/src/update.ts +0 -33
  398. package/dist/templates/examples/api-cache-query/src/view/index.ts +0 -1
  399. package/dist/templates/examples/api-cache-query/src/view/posts.ts +0 -239
  400. package/dist/templates/examples/api-cache-query/src/view/shared.ts +0 -70
  401. package/dist/templates/examples/api-cache-query/src/view/stats.ts +0 -132
  402. package/dist/templates/examples/api-cache-query/src/view/view.ts +0 -99
  403. package/dist/templates/examples/auth/src/block.ts +0 -20
  404. package/dist/templates/examples/auth/src/composition/bindings.ts +0 -14
  405. package/dist/templates/examples/auth/src/composition/composition.ts +0 -10
  406. package/dist/templates/examples/auth/src/composition/index.ts +0 -2
  407. package/dist/templates/examples/auth/src/composition/loggedIn.ts +0 -22
  408. package/dist/templates/examples/auth/src/composition/loggedOut.ts +0 -22
  409. package/dist/templates/examples/auth/src/definition.ts +0 -12
  410. package/dist/templates/examples/auth/src/flags.ts +0 -26
  411. package/dist/templates/examples/auth/src/init.ts +0 -53
  412. package/dist/templates/examples/auth/src/page/loggedIn/block.ts +0 -18
  413. package/dist/templates/examples/auth/src/page/loggedIn/composition.ts +0 -17
  414. package/dist/templates/examples/auth/src/page/loggedIn/init.ts +0 -10
  415. package/dist/templates/examples/auth/src/page/loggedOut/block.ts +0 -18
  416. package/dist/templates/examples/auth/src/page/loggedOut/composition.ts +0 -21
  417. package/dist/templates/examples/auth/src/page/loggedOut/definition.ts +0 -10
  418. package/dist/templates/examples/auth/src/page/loggedOut/init.ts +0 -8
  419. package/dist/templates/examples/auth/src/page/loggedOut/page/login/block.ts +0 -18
  420. package/dist/templates/examples/auth/src/page/loggedOut/page/login/composition.ts +0 -6
  421. package/dist/templates/examples/auth/src/page/loggedOut/page/login/definition.ts +0 -32
  422. package/dist/templates/examples/auth/src/page/loggedOut/page/login/index.ts +0 -1
  423. package/dist/templates/examples/auth/src/page/loggedOut/page/login/login.ts +0 -126
  424. package/dist/templates/examples/auth/src/services.ts +0 -3
  425. package/dist/templates/examples/charting/src/block.ts +0 -20
  426. package/dist/templates/examples/charting/src/chartRegistry.ts +0 -42
  427. package/dist/templates/examples/charting/src/composition.ts +0 -122
  428. package/dist/templates/examples/charting/src/definition.ts +0 -11
  429. package/dist/templates/examples/charting/src/layer.ts +0 -10
  430. package/dist/templates/examples/charting/src/mount.ts +0 -130
  431. package/dist/templates/examples/charting/src/services.ts +0 -15
  432. package/dist/templates/examples/counters/src/application.ts +0 -171
  433. package/dist/templates/examples/embedding/src/application.ts +0 -156
  434. package/dist/templates/examples/form/src/block.ts +0 -20
  435. package/dist/templates/examples/form/src/command.ts +0 -71
  436. package/dist/templates/examples/form/src/composition.ts +0 -8
  437. package/dist/templates/examples/form/src/definition.ts +0 -11
  438. package/dist/templates/examples/form/src/init.ts +0 -15
  439. package/dist/templates/examples/form/src/message.ts +0 -13
  440. package/dist/templates/examples/form/src/model.ts +0 -17
  441. package/dist/templates/examples/form/src/update.ts +0 -72
  442. package/dist/templates/examples/form/src/validation.ts +0 -21
  443. package/dist/templates/examples/generative-art/src/block.ts +0 -22
  444. package/dist/templates/examples/generative-art/src/composition.ts +0 -65
  445. package/dist/templates/examples/generative-art/src/definition.ts +0 -11
  446. package/dist/templates/examples/generative-art/src/init.ts +0 -42
  447. package/dist/templates/examples/generative-art/src/layer.ts +0 -10
  448. package/dist/templates/examples/interrupting-commands/src/block.ts +0 -20
  449. package/dist/templates/examples/interrupting-commands/src/command.ts +0 -33
  450. package/dist/templates/examples/interrupting-commands/src/composition.ts +0 -8
  451. package/dist/templates/examples/interrupting-commands/src/definition.ts +0 -11
  452. package/dist/templates/examples/interrupting-commands/src/init.ts +0 -8
  453. package/dist/templates/examples/interrupting-commands/src/message.ts +0 -15
  454. package/dist/templates/examples/interrupting-commands/src/model.ts +0 -15
  455. package/dist/templates/examples/interrupting-commands/src/update.ts +0 -99
  456. package/dist/templates/examples/interrupting-commands/src/view.ts +0 -175
  457. package/dist/templates/examples/job-application/src/block.ts +0 -20
  458. package/dist/templates/examples/job-application/src/composition.ts +0 -118
  459. package/dist/templates/examples/job-application/src/definition.ts +0 -13
  460. package/dist/templates/examples/job-application/src/flags.ts +0 -25
  461. package/dist/templates/examples/job-application/src/init.ts +0 -15
  462. package/dist/templates/examples/job-application/src/navigationComponents.ts +0 -6
  463. package/dist/templates/examples/job-application/src/services.ts +0 -3
  464. package/dist/templates/examples/job-application/src/step/attachments/block.ts +0 -18
  465. package/dist/templates/examples/job-application/src/step/attachments/composition.ts +0 -50
  466. package/dist/templates/examples/job-application/src/step/attachments/definition.ts +0 -24
  467. package/dist/templates/examples/job-application/src/step/attachments/init.ts +0 -10
  468. package/dist/templates/examples/job-application/src/step/attachments/update.ts +0 -14
  469. package/dist/templates/examples/job-application/src/step/education/block.ts +0 -22
  470. package/dist/templates/examples/job-application/src/step/education/command.ts +0 -28
  471. package/dist/templates/examples/job-application/src/step/education/composition.ts +0 -36
  472. package/dist/templates/examples/job-application/src/step/education/definition.ts +0 -30
  473. package/dist/templates/examples/job-application/src/step/education/entry/block.ts +0 -20
  474. package/dist/templates/examples/job-application/src/step/education/entry/composition.ts +0 -30
  475. package/dist/templates/examples/job-application/src/step/education/entry/definition.ts +0 -40
  476. package/dist/templates/examples/job-application/src/step/education/entry/init.ts +0 -16
  477. package/dist/templates/examples/job-application/src/step/education/entry/update.ts +0 -67
  478. package/dist/templates/examples/job-application/src/step/education/init.ts +0 -10
  479. package/dist/templates/examples/job-application/src/step/education/update.ts +0 -47
  480. package/dist/templates/examples/job-application/src/step/personalInfo/block.ts +0 -22
  481. package/dist/templates/examples/job-application/src/step/personalInfo/command.ts +0 -46
  482. package/dist/templates/examples/job-application/src/step/personalInfo/composition.ts +0 -55
  483. package/dist/templates/examples/job-application/src/step/personalInfo/definition.ts +0 -45
  484. package/dist/templates/examples/job-application/src/step/personalInfo/init.ts +0 -20
  485. package/dist/templates/examples/job-application/src/step/personalInfo/update.ts +0 -130
  486. package/dist/templates/examples/job-application/src/step/skills/block.ts +0 -22
  487. package/dist/templates/examples/job-application/src/step/skills/command.ts +0 -28
  488. package/dist/templates/examples/job-application/src/step/skills/composition.ts +0 -29
  489. package/dist/templates/examples/job-application/src/step/skills/definition.ts +0 -26
  490. package/dist/templates/examples/job-application/src/step/skills/entry/block.ts +0 -20
  491. package/dist/templates/examples/job-application/src/step/skills/entry/composition.ts +0 -29
  492. package/dist/templates/examples/job-application/src/step/skills/entry/definition.ts +0 -37
  493. package/dist/templates/examples/job-application/src/step/skills/entry/init.ts +0 -12
  494. package/dist/templates/examples/job-application/src/step/skills/entry/update.ts +0 -38
  495. package/dist/templates/examples/job-application/src/step/skills/init.ts +0 -6
  496. package/dist/templates/examples/job-application/src/step/skills/update.ts +0 -47
  497. package/dist/templates/examples/job-application/src/step/workHistory/block.ts +0 -22
  498. package/dist/templates/examples/job-application/src/step/workHistory/command.ts +0 -28
  499. package/dist/templates/examples/job-application/src/step/workHistory/composition.ts +0 -32
  500. package/dist/templates/examples/job-application/src/step/workHistory/definition.ts +0 -30
  501. package/dist/templates/examples/job-application/src/step/workHistory/entry/block.ts +0 -20
  502. package/dist/templates/examples/job-application/src/step/workHistory/entry/composition.ts +0 -88
  503. package/dist/templates/examples/job-application/src/step/workHistory/entry/definition.ts +0 -48
  504. package/dist/templates/examples/job-application/src/step/workHistory/entry/init.ts +0 -20
  505. package/dist/templates/examples/job-application/src/step/workHistory/entry/update.ts +0 -60
  506. package/dist/templates/examples/job-application/src/step/workHistory/init.ts +0 -10
  507. package/dist/templates/examples/job-application/src/step/workHistory/update.ts +0 -47
  508. package/dist/templates/examples/kanban/src/block.ts +0 -20
  509. package/dist/templates/examples/kanban/src/composition/composition.ts +0 -11
  510. package/dist/templates/examples/kanban/src/composition/dragAndDrop.ts +0 -92
  511. package/dist/templates/examples/kanban/src/composition/index.ts +0 -3
  512. package/dist/templates/examples/kanban/src/definition.ts +0 -11
  513. package/dist/templates/examples/kanban/src/flags.ts +0 -23
  514. package/dist/templates/examples/kanban/src/init.ts +0 -23
  515. package/dist/templates/examples/kanban/src/services.ts +0 -8
  516. package/dist/templates/examples/managed-resource-layer/src/services.ts +0 -3
  517. package/dist/templates/examples/map/src/block.ts +0 -20
  518. package/dist/templates/examples/map/src/command.ts +0 -147
  519. package/dist/templates/examples/map/src/composition.ts +0 -11
  520. package/dist/templates/examples/map/src/definition.ts +0 -11
  521. package/dist/templates/examples/map/src/init.ts +0 -20
  522. package/dist/templates/examples/map/src/layer.ts +0 -19
  523. package/dist/templates/examples/map/src/mapRegistry.ts +0 -42
  524. package/dist/templates/examples/map/src/message.ts +0 -25
  525. package/dist/templates/examples/map/src/model.ts +0 -30
  526. package/dist/templates/examples/map/src/mount.ts +0 -173
  527. package/dist/templates/examples/map/src/services.ts +0 -3
  528. package/dist/templates/examples/map/src/update.ts +0 -101
  529. package/dist/templates/examples/map/src/view.ts +0 -346
  530. package/dist/templates/examples/pixel-art/src/block.ts +0 -22
  531. package/dist/templates/examples/pixel-art/src/components.ts +0 -12
  532. package/dist/templates/examples/pixel-art/src/composition.ts +0 -199
  533. package/dist/templates/examples/pixel-art/src/definition.ts +0 -12
  534. package/dist/templates/examples/pixel-art/src/flags.ts +0 -23
  535. package/dist/templates/examples/pixel-art/src/init.ts +0 -41
  536. package/dist/templates/examples/pixel-art/src/layer.ts +0 -10
  537. package/dist/templates/examples/pixel-art/src/services.ts +0 -3
  538. package/dist/templates/examples/query-sync/src/block.ts +0 -20
  539. package/dist/templates/examples/query-sync/src/command.ts +0 -52
  540. package/dist/templates/examples/query-sync/src/composition.ts +0 -75
  541. package/dist/templates/examples/query-sync/src/definition.ts +0 -12
  542. package/dist/templates/examples/query-sync/src/init.ts +0 -12
  543. package/dist/templates/examples/query-sync/src/message.ts +0 -16
  544. package/dist/templates/examples/query-sync/src/model.ts +0 -16
  545. package/dist/templates/examples/query-sync/src/route.ts +0 -172
  546. package/dist/templates/examples/query-sync/src/update.ts +0 -57
  547. package/dist/templates/examples/query-sync/src/view.ts +0 -531
  548. package/dist/templates/examples/route-transitions/src/block.ts +0 -20
  549. package/dist/templates/examples/route-transitions/src/command.ts +0 -71
  550. package/dist/templates/examples/route-transitions/src/composition.ts +0 -8
  551. package/dist/templates/examples/route-transitions/src/definition.ts +0 -12
  552. package/dist/templates/examples/route-transitions/src/init.ts +0 -21
  553. package/dist/templates/examples/route-transitions/src/message.ts +0 -15
  554. package/dist/templates/examples/route-transitions/src/model.ts +0 -27
  555. package/dist/templates/examples/route-transitions/src/transition.ts +0 -99
  556. package/dist/templates/examples/route-transitions/src/update.ts +0 -60
  557. package/dist/templates/examples/routing/src/block.ts +0 -22
  558. package/dist/templates/examples/routing/src/command.ts +0 -26
  559. package/dist/templates/examples/routing/src/composition.ts +0 -19
  560. package/dist/templates/examples/routing/src/definition.ts +0 -14
  561. package/dist/templates/examples/routing/src/init.ts +0 -19
  562. package/dist/templates/examples/routing/src/layer.ts +0 -10
  563. package/dist/templates/examples/routing/src/message.ts +0 -14
  564. package/dist/templates/examples/routing/src/model.ts +0 -9
  565. package/dist/templates/examples/routing/src/page/people/block.ts +0 -24
  566. package/dist/templates/examples/routing/src/page/people/command.ts +0 -34
  567. package/dist/templates/examples/routing/src/page/people/composition.ts +0 -6
  568. package/dist/templates/examples/routing/src/page/people/definition.ts +0 -12
  569. package/dist/templates/examples/routing/src/page/people/index.ts +0 -1
  570. package/dist/templates/examples/routing/src/page/people/message.ts +0 -16
  571. package/dist/templates/examples/routing/src/page/people/model.ts +0 -71
  572. package/dist/templates/examples/routing/src/page/people/update.ts +0 -59
  573. package/dist/templates/examples/routing/src/page/people/view.ts +0 -149
  574. package/dist/templates/examples/routing/src/subscription.ts +0 -37
  575. package/dist/templates/examples/routing/src/update.ts +0 -82
  576. package/dist/templates/examples/shopping-cart/src/block.ts +0 -20
  577. package/dist/templates/examples/shopping-cart/src/command.ts +0 -31
  578. package/dist/templates/examples/shopping-cart/src/composition.ts +0 -36
  579. package/dist/templates/examples/shopping-cart/src/definition.ts +0 -11
  580. package/dist/templates/examples/shopping-cart/src/init.ts +0 -15
  581. package/dist/templates/examples/shopping-cart/src/message.ts +0 -17
  582. package/dist/templates/examples/shopping-cart/src/model.ts +0 -13
  583. package/dist/templates/examples/shopping-cart/src/page/products/block.ts +0 -18
  584. package/dist/templates/examples/shopping-cart/src/page/products/composition.ts +0 -3
  585. package/dist/templates/examples/shopping-cart/src/page/products/definition.ts +0 -32
  586. package/dist/templates/examples/shopping-cart/src/page/products/index.ts +0 -1
  587. package/dist/templates/examples/shopping-cart/src/page/products/products.ts +0 -60
  588. package/dist/templates/examples/shopping-cart/src/update.ts +0 -47
  589. package/dist/templates/examples/shopping-cart/src/view.ts +0 -145
  590. package/dist/templates/examples/slow-warnings/src/block.ts +0 -21
  591. package/dist/templates/examples/slow-warnings/src/composition.ts +0 -8
  592. package/dist/templates/examples/slow-warnings/src/definition.ts +0 -11
  593. package/dist/templates/examples/slow-warnings/src/init.ts +0 -12
  594. package/dist/templates/examples/slow-warnings/src/message.ts +0 -12
  595. package/dist/templates/examples/slow-warnings/src/model.ts +0 -33
  596. package/dist/templates/examples/slow-warnings/src/subscription.ts +0 -111
  597. package/dist/templates/examples/slow-warnings/src/update.ts +0 -48
  598. package/dist/templates/examples/slow-warnings/src/workload.ts +0 -19
  599. package/dist/templates/examples/snake/src/application.ts +0 -365
  600. package/dist/templates/examples/state-machine/src/block.ts +0 -20
  601. package/dist/templates/examples/state-machine/src/command.ts +0 -22
  602. package/dist/templates/examples/state-machine/src/composition.ts +0 -36
  603. package/dist/templates/examples/state-machine/src/definition.ts +0 -11
  604. package/dist/templates/examples/state-machine/src/init.ts +0 -13
  605. package/dist/templates/examples/state-machine/src/message.ts +0 -16
  606. package/dist/templates/examples/state-machine/src/model.ts +0 -68
  607. package/dist/templates/examples/state-machine/src/transition.ts +0 -51
  608. package/dist/templates/examples/state-machine/src/update.ts +0 -23
  609. package/dist/templates/examples/state-machine/src/view/analysis.ts +0 -172
  610. package/dist/templates/examples/state-machine/src/view/cart.ts +0 -213
  611. package/dist/templates/examples/state-machine/src/view/checkout.ts +0 -201
  612. package/dist/templates/examples/state-machine/src/view/header.ts +0 -193
  613. package/dist/templates/examples/state-machine/src/view/payment.ts +0 -176
  614. package/dist/templates/examples/state-machine/src/view/review.ts +0 -322
  615. package/dist/templates/examples/state-machine/src/view/shared.ts +0 -136
  616. package/dist/templates/examples/state-machine/src/view/shipping.ts +0 -179
  617. package/dist/templates/examples/state-machine/src/view/status.ts +0 -131
  618. package/dist/templates/examples/stopwatch/src/application.ts +0 -260
  619. package/dist/templates/examples/todo/src/block.ts +0 -20
  620. package/dist/templates/examples/todo/src/command.ts +0 -42
  621. package/dist/templates/examples/todo/src/composition.ts +0 -8
  622. package/dist/templates/examples/todo/src/definition.ts +0 -11
  623. package/dist/templates/examples/todo/src/flags.ts +0 -20
  624. package/dist/templates/examples/todo/src/init.ts +0 -16
  625. package/dist/templates/examples/todo/src/message.ts +0 -25
  626. package/dist/templates/examples/todo/src/model.ts +0 -29
  627. package/dist/templates/examples/todo/src/services.ts +0 -3
  628. package/dist/templates/examples/todo/src/update.ts +0 -161
  629. package/dist/templates/examples/ui-showcase/src/block.ts +0 -20
  630. package/dist/templates/examples/ui-showcase/src/command.ts +0 -31
  631. package/dist/templates/examples/ui-showcase/src/composition.ts +0 -16
  632. package/dist/templates/examples/ui-showcase/src/definition.ts +0 -13
  633. package/dist/templates/examples/ui-showcase/src/flags.ts +0 -12
  634. package/dist/templates/examples/ui-showcase/src/init.ts +0 -14
  635. package/dist/templates/examples/ui-showcase/src/message.ts +0 -11
  636. package/dist/templates/examples/ui-showcase/src/model.ts +0 -9
  637. package/dist/templates/examples/ui-showcase/src/route.ts +0 -208
  638. package/dist/templates/examples/ui-showcase/src/ui/block.ts +0 -21
  639. package/dist/templates/examples/ui-showcase/src/ui/combobox.ts +0 -6
  640. package/dist/templates/examples/ui-showcase/src/ui/composition/animation.ts +0 -22
  641. package/dist/templates/examples/ui-showcase/src/ui/composition/composition.ts +0 -556
  642. package/dist/templates/examples/ui-showcase/src/ui/composition/dragAndDrop.ts +0 -71
  643. package/dist/templates/examples/ui-showcase/src/ui/composition/index.ts +0 -42
  644. package/dist/templates/examples/ui-showcase/src/ui/definition.ts +0 -13
  645. package/dist/templates/examples/ui-showcase/src/ui/domain/domain.ts +0 -37
  646. package/dist/templates/examples/ui-showcase/src/ui/domain/index.ts +0 -8
  647. package/dist/templates/examples/ui-showcase/src/ui/index.ts +0 -1
  648. package/dist/templates/examples/ui-showcase/src/ui/listbox.ts +0 -13
  649. package/dist/templates/examples/ui-showcase/src/ui/menu.ts +0 -5
  650. package/dist/templates/examples/ui-showcase/src/ui/radioGroup.ts +0 -5
  651. package/dist/templates/examples/ui-showcase/src/ui/tabs.ts +0 -5
  652. package/dist/templates/examples/ui-showcase/src/ui/view/mobileMenu.ts +0 -48
  653. package/dist/templates/examples/ui-showcase/src/ui/virtualList.ts +0 -16
  654. package/dist/templates/examples/ui-showcase/src/update.ts +0 -38
  655. package/dist/templates/examples/ui-showcase/src/view.ts +0 -412
  656. package/dist/templates/examples/weather/src/block.ts +0 -20
  657. package/dist/templates/examples/weather/src/command.ts +0 -141
  658. package/dist/templates/examples/weather/src/composition.ts +0 -8
  659. package/dist/templates/examples/weather/src/definition.ts +0 -11
  660. package/dist/templates/examples/weather/src/init.ts +0 -9
  661. package/dist/templates/examples/weather/src/message.ts +0 -11
  662. package/dist/templates/examples/weather/src/model.fixture.ts +0 -16
  663. package/dist/templates/examples/weather/src/model.ts +0 -19
  664. package/dist/templates/examples/weather/src/services.ts +0 -3
  665. package/dist/templates/examples/weather/src/update.ts +0 -30
  666. package/dist/templates/examples/weather/src/view.ts +0 -149
  667. package/dist/templates/examples/websocket-chat/src/block.ts +0 -24
  668. package/dist/templates/examples/websocket-chat/src/chatSocket.ts +0 -6
  669. package/dist/templates/examples/websocket-chat/src/command.ts +0 -69
  670. package/dist/templates/examples/websocket-chat/src/composition.ts +0 -8
  671. package/dist/templates/examples/websocket-chat/src/definition.ts +0 -12
  672. package/dist/templates/examples/websocket-chat/src/init.ts +0 -10
  673. package/dist/templates/examples/websocket-chat/src/layer.ts +0 -17
  674. package/dist/templates/examples/websocket-chat/src/managedResource.ts +0 -75
  675. package/dist/templates/examples/websocket-chat/src/message.ts +0 -21
  676. package/dist/templates/examples/websocket-chat/src/model.ts +0 -21
  677. package/dist/templates/examples/websocket-chat/src/services.ts +0 -3
  678. package/dist/templates/examples/websocket-chat/src/subscription.ts +0 -80
  679. package/dist/templates/examples/websocket-chat/src/update.ts +0 -78
  680. package/dist/templates/examples/websocket-chat/src/view.ts +0 -276
package/README.md CHANGED
@@ -31,7 +31,7 @@ The starter examples apply to `spa` rendering. The `ssg` and `ssr` modes scaffol
31
31
  | Example | Description |
32
32
  | ------------------------ | ------------------------------------------------------------------------------------------------------ |
33
33
  | `counter` | Simple increment/decrement with reset |
34
- | `counters` | A dynamic list of Counter Blocks with generated per-instance delivery |
34
+ | `counters` | A dynamic list of Counter Submodels with per-instance routing via a wrapper Message |
35
35
  | `todo` | CRUD operations with localStorage persistence |
36
36
  | `stopwatch` | Timer with start/stop/reset |
37
37
  | `crash-view` | Custom crash fallback UI with crash.view and crash.report |
@@ -48,7 +48,7 @@ The starter examples apply to `spa` rendering. The `ssg` and `ssr` modes scaffol
48
48
  | `snake` | Classic game built with Subscriptions |
49
49
  | `canvas-art` | Declarative 2D canvas with shapes, animation-frame Subscriptions, and pointer events |
50
50
  | `generative-art` | Perlin-noise flow field with evolving particle trails, mouse vortex, and high-frequency Messages |
51
- | `auth` | Authentication with Blocks, OutMessage, and protected routes |
51
+ | `auth` | Authentication with Submodels, OutMessage, and protected routes |
52
52
  | `shopping-cart` | Complex state management with nested Models and routing |
53
53
  | `state-machine` | Experimental state machine checkout with guarded branches and edge Commands |
54
54
  | `pixel-art` | Pixel editor with undo/redo, UI components, and localStorage persistence |
@@ -58,7 +58,7 @@ The starter examples apply to `spa` rendering. The `ssg` and `ssr` modes scaffol
58
58
  | `map` | Interactive MapLibre GL map with Mount and Subscriptions |
59
59
  | `web-components` | QR code designer wiring third-party web components into Foldkit with CustomElement.define |
60
60
  | `embedding` | A Foldkit widget embedded in a plain TypeScript host page with Ports and dispose |
61
- | `ui-showcase` | Every Foldkit UI component with routing and Blocks |
61
+ | `ui-showcase` | Every Foldkit UI component with routing and Submodels |
62
62
 
63
63
  ## License
64
64
 
package/dist/examples.js CHANGED
@@ -40,7 +40,7 @@ export const examples = [
40
40
  {
41
41
  value: 'counters',
42
42
  title: 'counters',
43
- description: 'A dynamic list of Counter Blocks with generated per-instance delivery',
43
+ description: 'A dynamic list of Counter Submodels with per-instance routing via a wrapper Message',
44
44
  },
45
45
  {
46
46
  value: 'todo',
@@ -85,7 +85,7 @@ export const examples = [
85
85
  {
86
86
  value: 'api-cache-query',
87
87
  title: 'api-cache-query',
88
- description: 'The API Cache app rewritten with experimental Query.define. Fetching and retained entries live in Query Blocks',
88
+ description: 'The API Cache app rewritten with experimental Query.define. Fetching and retained entries live in Query Submodels',
89
89
  },
90
90
  {
91
91
  value: 'charting',
@@ -135,7 +135,7 @@ export const examples = [
135
135
  {
136
136
  value: 'auth',
137
137
  title: 'auth',
138
- description: 'Authentication with Blocks, OutMessage, and protected routes',
138
+ description: 'Authentication with Submodels, OutMessage, and protected routes',
139
139
  },
140
140
  {
141
141
  value: 'shopping-cart',
@@ -185,6 +185,6 @@ export const examples = [
185
185
  {
186
186
  value: 'ui-showcase',
187
187
  title: 'ui-showcase',
188
- description: 'Every Foldkit UI component with routing and Blocks',
188
+ description: 'Every Foldkit UI component with routing and Submodels',
189
189
  },
190
190
  ];
@@ -2,10 +2,6 @@
2
2
 
3
3
  This is a Foldkit app. Read [`FOLDKIT.md`](./FOLDKIT.md) before writing any code in this project. It covers the architecture, the APIs, and the conventions the project is built on.
4
4
 
5
- A root uses one of two complete layouts. A genuinely compact root keeps Model, Message, init, update, view, `ApplicationDefinition`, `ApplicationComposition`, `ApplicationBlock`, and any small local handler bundle together in `application.ts`. Once any root responsibility is extracted, split the whole root: retain `definition.ts` for `ApplicationDefinition` when authoring methods use it, or put a top-level `Block.makeDefinition('Application', ...).makeComposition()` chain in `composition.ts` when they do not; `model.ts`, `message.ts`, `init.ts`, `update.ts`, `view.ts`, and optional `flags.ts` own their named responsibilities; `composition.ts` owns Bindings, OutMessage folds, complete child/Mount registration, `ApplicationComposition`, and an optional `ApplicationViewBuilder`; and `block.ts` assembles `ApplicationBlock`. Even a graphless split root has `composition.ts`. A split `definition.ts` exports the Step helpers its implementation uses, and those implementation modules named-import the helpers from that file. A compact feature destructures Step helpers beside its Definition. Keep Definition-qualified calls when several Definitions in one module need visible ownership. Feature barrels do not re-export these authoring helpers. Remove the emptied `application.ts` instead of using it as a forwarding barrel. A simple root `EffectsLayer` stays with its Command definitions in `command.ts`; use `layer.ts` only for substantial or reused Layer composition. Composition imports the Definition and child or Mount definitions, never root init, update, or view. Create every root with `Block.makeDefinition('Application', { Model, Message })`, author init, update, and the primary view through its Composition, then pass them explicitly to `ApplicationComposition.prepareBlock(...)` inside the private `prepare` producer. Put the adjacent `ApplicationBlock: Block.FromAssemblyWithView<typeof Model, typeof prepare> = Block.assemble(prepare)` export on the next line with no blank line. A split feature uses composition.ts, including for Mount-only registrations. Shared Mount definitions live in mount.ts. Parent-owned Bindings from `ApplicationDefinition.makeBinding(...)` are passive relationship configuration; including them in the Composition's `bindings` registers them. `entry.ts` imports `ApplicationBlock`, owns the browser container and startup inputs, creates the host with `Program.make` or `Program.makeElement`, calls `program.provide(ApplicationLayer)` when needed, and starts the Runtime. Keep root `ApplicationLayer` composition in `services.ts`. Tests and server entries import the passive Block without starting the browser Runtime. Name the root Route union `ApplicationRoute` and the root provider `ApplicationLayer` (`ApplicationTestLayer` for its test alternative).
6
-
7
- Give every named Model-first Step value a descriptive name ending in `Step`, such as `refreshStep`. Give a purposeful transition factory that returns a Step an operation name ending in `Step` too. Factory methods, imported authoring helpers, named OutMessage folds and matchers, direct inline handlers, public operation keys, Message tags, and applied update-like results keep their established names.
8
-
9
5
  Foldkit owns `FOLDKIT.md` and replaces it whole on upgrade. This file is yours. Anything you want an agent to know about this project goes below, where an upgrade won't touch it.
10
6
 
11
7
  `FOLDKIT.md` reads the line below to decide whether it has already offered to vendor the Foldkit source. Leave it in place.
@@ -15,5 +11,3 @@ subtree_prompted: false
15
11
  ## Project Notes
16
12
 
17
13
  Domain vocabulary, deployment steps, local conventions that differ from Foldkit's defaults: write them here.
18
-
19
- For a required direct child field, omit `init` when its initializer accepts no arguments; use `init: { contextToArgs }` for required inputs or `init: false` when the parent supplies that field. Optional, keyed, and accessor storage remains parent-owned when `init` is omitted; explicit `init.contextToArgs`, keyed `init.instances` / `init.toItem`, or a checked custom projection chooses automatic startup. An optional `ChildInitContext` Schema on the parent Definition contextually types selectors that prepare arguments for direct child initializers. Author root startup through `ApplicationComposition.makeInit`, returning parent-owned `model` fields plus optional ephemeral `childInitContext`, parent `commands`, and post-assembly `steps`. Composition initializes and places child Models and collects their Commands. Use an exhaustive `ApplicationComposition.makeUpdate` handler record for parent transitions; registered Bindings route generated child envelopes before local handlers. Use `makeUpdate({})` when the parent has no locally authored Messages and `.withContext` when handlers need dispatch context. Put delivery admission in `delivery.when`, derive required child update context with `delivery.toUpdateContext`, and provide `keySchema` for a custom keyed Binding. See FOLDKIT.md for optional presence, exact keyed identity and startup Steps.
@@ -12,7 +12,7 @@ If `./repos/foldkit` exists, it contains the full Foldkit repository, vendored i
12
12
 
13
13
  - `repos/foldkit/examples/`: runnable example apps spanning every complexity tier. Usually your first stop when looking for a precedent for how to write something.
14
14
  - `repos/foldkit/packages/foldkit/src/`: framework source. Ground truth for API signatures.
15
- - `repos/foldkit/packages/typing-game/client/src/` and `repos/foldkit/packages/website/src/`: production apps built with Foldkit. Highest-fidelity reference for application architecture, Blocks, and OutMessage.
15
+ - `repos/foldkit/packages/typing-game/client/src/` and `repos/foldkit/packages/website/src/`: production apps built with Foldkit. Highest-fidelity reference for application architecture, Submodels, and OutMessage.
16
16
 
17
17
  Treat the subtree as read-only reference: never import from `repos/foldkit/` in your project source. Imports must come from the `foldkit` npm package.
18
18
 
@@ -42,257 +42,127 @@ Then replace this file whole. Foldkit's conventions change with its APIs, and a
42
42
 
43
43
  ## Project Conventions
44
44
 
45
- - Name a concrete typed Block authoring value `<BlockId>Definition`, such as `SearchDefinition = Block.makeDefinition('Search', ...)` and `ApplicationDefinition = Block.makeDefinition('Application', ...)`. Keep the runtime ID unchanged. Name the corresponding Composition `<BlockId>Composition` or `ApplicationComposition`. Export ordinary completed values as `SearchBlock` and `ApplicationBlock`; a generic factory returns an exact completed Block that its caller names locally.
46
45
  - Foldkit is tightly coupled to the Effect ecosystem. Do not suggest solutions outside of Effect-TS.
47
46
  - Model fields must be Schema types (the model is a schema). Plain TypeScript types are fine elsewhere (function return types, local variables, etc.).
48
47
  - Use full names like `Message` (not `Msg`), and `withReturnType` (not `as const` or type casting).
49
- - Suffix Model fields containing an `AsyncData` value with `AsyncData`, such as `workspaceAsyncData` or `weatherAsyncData`. A field storing a Query Model is a child Block Model and does not take this suffix.
50
48
  - Declare every variant together: `defineMessageUnion()` for Messages, `defineTaggedUnion()` for other domain unions, and `defineRouteUnion()` for Routes.
51
- - Keep constructors on their union: `Message.ClickedSubmit()`, `FetchState.Ok({ data })`, and `ApplicationRoute.Home()`.
49
+ - Keep constructors on their union: `Message.ClickedSubmit()`, `FetchState.Ok({ data })`, and `AppRoute.Home()`.
52
50
  - Use `taggedStruct()` only when the variants cannot be declared together, such as a recursive union.
53
51
  - Push back on any direction that violates Elm Architecture principles: unidirectional data flow, messages as facts (not commands), model as single source of truth, side effects confined to commands. If a prompt suggests mutating state, imperative event handlers, or two-way bindings, flag the issue and propose the idiomatic Foldkit approach.
54
52
  - Never use `NoOp`. Every message must describe what happened. A command's result message is named from the command, not from the fact it reports, whether or not it carries a payload: `LockScroll` → `CompletedLockScroll`, `DetermineStartTime` → `CompletedDetermineStartTime` (never `DeterminedStartTime`).
55
53
 
56
54
  ## Foldkit Patterns
57
55
 
58
- ### Asynchronous data
59
-
60
- Use `AsyncData` directly when the owning Block's Messages and Commands participate in application-specific transitions, such as reconciling mutation results or optimistic rollback. Consider experimental `Query.define` when Query should own fetching, retained data, refresh, and stale-response protection. Keep one authoritative collection rather than copying Query data into a second Model field. Parent coordination uses the child's public operations and OutMessages; do not modify a Query Model's internal data to bypass a missing operation.
61
-
62
- Experimental Query and KeyedQuery values are completed viewless Blocks. Bind them with the same parent `makeBinding` method and include the Binding under `bindings`; use the Binding's `requestReset`, `requestRevalidation`, `requestRevalidationOrLoad`, and `requestLoadIfMissing` operations. The Query value itself retains direct `read` and `run` conveniences. Query preserves Fetch identity, handler completeness, host delegation, constructor errors and Service requirements, request generations, stale-response protection, and cache-key typing through standard Block composition. KeyedQuery entries are cache data inside one child Model, not keyed Block instances. A canonical Query supplies `query.EffectsLayer`; a host-owned Query omits `handler` and is completed with `query.provideHandlers(query.toLayer(...))` before binding.
63
-
64
- ### State ownership
65
-
66
- Keep the canonical domain data with its owner. Give each editor its own baseline, draft, and submission state. A baseline is an intentional historical value; current display data such as comments belongs in view inputs. Use update context (`delivery.toUpdateContext`) for current parent data needed while handling a Message. Use an `inform*` operation when an external event requires the child to transition, return a Command, or emit an OutMessage. Changing inputs or context does not dispatch a Message. Avoid acknowledgement informs that repeat a transition the child already performed.
67
-
68
- Build around the application's requirements and normal user workflows, including reasonable failure and retry behavior. Introduce abstractions for concrete repeated responsibilities; unusual event combinations do not by themselves justify additional framework APIs or application orchestration.
69
-
70
- Independent interactions need independent pending and failure state. A project save should not block an unrelated issue move or share feedback that a background response can clear. Keep exclusivity explicit when operations really must serialize.
71
-
72
- Decide what navigation does to unfinished work. Repeated URL delivery or a refresh should not silently replace a dirty draft. Retaining a keyed editor lets its draft and pending save survive navigation. Removing its occurrence ends its lifecycle and invalidates later delivery; keep the owner present when its result must still update the application. Apply mutation results to the data that operation owns, so a delayed response cannot replace unrelated newer state.
73
-
74
56
  ### Update
75
57
 
76
- Author init, update, and the canonical view through the same named Composition. Updates accept one exhaustive handler record. Each case receives the contextual Model and its exact Message; registered child envelopes route before local handlers:
58
+ `init` and `update` both return a record with the next Model and optional Commands. Inline the return type when the matcher is its only use:
77
59
 
78
60
  ```ts
79
- const update = ApplicationComposition.makeUpdate({
80
- ClickedIncrement: model => ({
81
- model: modifyFields(model, { count: count => count + 1 }),
82
- }),
83
- })
61
+ const update = (model: Model, message: Message) =>
62
+ Message.match<Update.Return<Model, Message>>(message, {
63
+ ClickedIncrement: () => ({
64
+ model: modifyFields(model, { count: count => count + 1 }),
65
+ }),
66
+ })
84
67
  ```
85
68
 
86
- Use `makeUpdate({})` when there are no local Messages. Use `makeUpdate.withContext(context => cases)` for extra dispatch arguments. The factory runs for local dispatch, not routed child-only delivery. Keep purposeful parameter types for operation inputs and context; let owned callbacks infer Model, Message, returns, and Command requirements. Do not hide inference failures with casts or broad return annotations.
87
-
88
- Return ordinary handler results directly. Use Step helpers for reusable transitions, sequencing, OutMessage policies, or useful specialized shorthand; do not wrap every handler in `makeStep`. Steps can live in `update.ts` or an owning helper module as well as composition files. Colocate parent coordination with its Bindings and policies. Name an extracted single-Message handler `handle<MessageTag>` and pass it directly when its signature fits. Give every named Model-first Step value a descriptive name ending in `Step`, such as `refreshStep`. Give a purposeful transition factory that returns a Step an operation name ending in `Step` too. Factory methods, imported authoring helpers, named OutMessage folds and matchers, direct inline handlers, public operation keys, Message tags, and applied update-like results keep their established names. An existing compatible Model-first Step can be the record value, such as `ClickedOpenSearch: SearchBinding.requestOpen()` or `CompletedSave: makeNoopStep()`. Keep a callback when it adapts payloads, reads Model-dependent arguments, defers argument construction, supplies context, or is needed for contextual inference.
89
-
90
- In a split feature, `definition.ts` exports the Step helpers used by its implementation, such as `export const { makeStep, makeFieldsStep, makeNoopStep } = FeatureDefinition`. Import those helpers by name in `update.ts`, policy modules, and other implementation files. A compact feature destructures them beside its Definition in the scope that uses them. Keep Definition-qualified calls when a module works with several Definitions and the qualifier identifies the owner. Keep authoring helpers out of the feature barrel; export the completed Block there.
91
-
92
- If one handler mixes connected Binding recipes with local results, author its local branches through Definition-owned Steps. A raw `{ model }` beside a connected recipe is rejected because it can erase channels. Generic Steps in a context factory may likewise need `model => step(model)` for inference. Ordinary raw-only handlers need no Step wrapper.
93
-
94
- The update is dual: `update(model, message, ...context)` and `update(message)(model, ...context)`. The curried form is an internal Step. Record-authored updates retain each selected Message's Command and OutMessage contract; utilities inspecting the whole update retain their union. Extracted helpers must preserve those channels too. Avoid a fixed `Update.Return<Model, Message>` annotation on a Command-producing handler: its default requirement is `never`.
95
-
96
- Use `modifyFields` from `foldkit/struct` for immutable Model updates, including nested updates. Never spread or `Object.assign` an existing Model. Keep an update-like result together under an operation name such as `homeInit` or `dialogClose`, then access its fields. Do not destructure or rename `model`, `commands`, or `outMessage`. Pass optional Commands directly to APIs that accept them, such as `Command.mapMessages`; use `commands ?? []` only when a concrete array is required.
97
-
98
- Omit `commands` when a producer statically creates none. Return a computed collection directly, even when empty. Never write a literal `commands: []`. A Boolean-conditioned Command group uses `Array.filter(commands, () => condition)`. Actual optional absence still uses `Option`.
99
-
100
- ### Steps
101
-
102
- Choose the helper for the result the Step produces:
103
-
104
- | Result | Helper |
105
- | ------------------------------------------------------------------------------------------- | ------------------------------------------------- |
106
- | Own Model field changes | `Definition.makeFieldsStep(model => transforms)` |
107
- | Unchanged Model | `Definition.makeNoopStep()` |
108
- | Commands with unchanged Model | `Definition.makeCommandsStep(model => commands)` |
109
- | One declared OutMessage with unchanged Model | `Definition.makeOutMessageStep(() => outMessage)` |
110
- | Conditional or composed results, initialization, connected operations, or combined channels | `Definition.makeStep(model => result)` |
111
-
112
- All three focused helpers take producer callbacks. An ordinary producer receives the current Model and, in a Message-dependent handler, its exact Message. Use `.fromMessage(message => value)` for payload-only producers and `() => value` for fixed producers. Pass the returned compatible Step or handler directly to `makeUpdate`; keep cohesive mixed transitions as direct results.
113
-
114
- Step construction is passive. Producers run when applied. Commands-only and OutMessage-only helpers preserve the same Model object. Runtime executes effects later. An extracted Message-dependent producer needs a precise Message variant parameter when no surrounding handler record supplies it. Map payloads explicitly when constructing a different Message or OutMessage; do not forward its incoming `_tag` through a constructor reference.
115
-
116
- Inside a local `makeStep` callback, return results directly, including `{ model }` for an unchanged Model. Do not construct and immediately apply another local Step merely to express a branch. Keep reusable operations, sequential composition, and canonical local Steps required by mixed connected recipes. An empty `makeFieldsStep` record preserves Model identity. For a helper that gates editing, a Model-to-Model callback keeps `modifyFields` validation at the call site without duplicating generic machinery. `FieldTransforms<Model>` is a structural convenience type, not an exact-key or union-variant validator.
117
-
118
- Use `Update.combineSteps` to apply Steps sequentially to the preceding Step's Model. Call a single Step directly. Name an inline parameter `stepModel`. Commands join one batch; their collection order does not sequence completion. The combinator rejects OutMessage-producing Steps. Include an already-known OutMessage directly in a new result, or attach one to an existing plain result with `Update.withOutMessage`. The latter cannot recover an OutMessage discarded upstream.
119
-
120
- ### Blocks and Bindings
121
-
122
- Define `ChildDefinition = Block.makeDefinition('Child', { Model, Message, OutMessage? })`, establish `ChildComposition`, and author its init, update, and view. Return `ChildComposition.prepareBlock(...)` from one private zero-argument producer named `prepare`. Immediately follow it, without a blank line, with the checked export initialized by `Block.assemble(prepare)`. Choose the actual `Block.FromAssemblyWithView`, `FromAssemblyWithViewAndOutMessage`, `FromAssemblyWithOutMessage`, or `FromAssemblyWithoutViewOrOutMessage` header using `typeof Model` and `typeof prepare`. Descriptive producer names are for files containing several producers.
123
-
124
- Preparation checks the implementation and returns an opaque unfinished value. Assembly returns the branded Block accepted by Bindings, Programs, and Server rendering. Both are passive. The explicit canonical Model header prevents parent Schema construction through `ChildBlock.Model` from inferring the whole implementation again. Keep this boundary; casts, broad annotations, `satisfies`, or calling the raw producer do not replace it. Feature barrels export only the completed Block. Shared Schemas and pure domain utilities belong in an explicit domain barrel.
125
-
126
- Use a Block when a feature owns interaction state, effects, or lifecycle. Pure domain functions and render-only helpers remain ordinary functions. A generic factory that needs shared early identity creates `FeatureNamespace = Block.makeNamespace('Feature')`, then its typed Definitions through that Namespace. Create the shared Namespace once at module scope. An ordinary feature likewise creates its Definition once at module scope.
127
-
128
- The root follows the same pattern and exports `ApplicationBlock`. `Program.make` or `Program.makeElement` adds the container, routing, Flags, and host configuration. Provide ordinary Services through `program.provide(ApplicationLayer)`; only the Runtime starts execution.
129
-
130
- Published packages also need a named declaration boundary: an interface extending the matching checked `FromAssembly*` header, followed by the same-name annotated value. Generic factories can use a named generic completed interface. Verify emitted declarations and external consumption, not only `noEmit`. This prevents repeated declaration expansion; it does not remove every source of TypeScript latency.
69
+ Create an `UpdateReturn` alias when another matcher, helper, or exported signature reuses the type. The match generic constrains the whole update, so do not repeat the return annotation on the function.
131
70
 
132
- If a large Composition needs an exact named Binding tuple for declaration emission, export that type from `composition.ts` so other modules can name it. Keep the feature barrel limited to the completed Block. Check type visibility before adding another implementation inventory to `block.ts`; Workspace retains ordinary assembly through this existing TypeScript boundary. Do not add tuple inventories to ordinary applications without a measured serialization failure.
71
+ Update, init, boot, and component helper producers return `{ model }` when they statically create no Commands. When they compute a Commands collection, return it directly without checking whether it is empty. Never write the literal `commands: []`; `foldkit/no-empty-commands-array` enforces this producer convention.
133
72
 
134
- The parent declares `ParentDefinition.makeBinding(ChildBlock, config)` and registers that Binding in its Composition's `bindings`. Registered Bindings contribute child handlers and lifecycle entries automatically. The parent's authored Message contains local facts only; `Composition.Message` and `ChildBlock.Message` add generated child envelopes. Use those complete contracts for cross-module dispatch types. Do not author `Got*` wrappers or Message mappers, inspect internal child Message tags in parent update, or update child fields directly.
73
+ When composing one of those results, bind the whole result to a value named after the operation and access its fields through that value. Use `homeInit`, `dialogClose`, or a trailing underscore such as `init_` when the operation name collides with the function. Do not destructure or rename `model`, `commands`, or `outMessage`. Dot access does not prevent someone from ignoring `outMessage`; it keeps the operation and all of its returned fields visible together. Name a child fold's `write` parameter after the next child Model, such as `nextSettings`.
135
74
 
136
- Choose storage from the parent Schema:
75
+ Pass optional Commands directly to APIs that accept them: `Command.mapMessages(homeInit.commands, toParentMessage)`. Use `result.commands ?? []` only when the next operation requires a concrete array for spreading, concatenating, execution, or an assertion.
137
76
 
138
- - An exact child or `Option<Child>` field uses `field`. `None` means absent; ordinary operations never create it. `presentWhen` gates the whole direct child; `subscriptions.when` gates only Streams.
139
- - A keyed array uses `field` and `key`, the name of a stable string or finite-number identity field. Wrapped arrays and an Option-wrapped instance also specify `childField`. Keyed identity does not imply multiple stored children.
140
- - Exact Record/HashMap storage uses `makeMapBinding` from `foldkit/mapBinding`. Use its field-derived key contract and preserve a separate ordered ID list when order matters.
141
- - Custom unkeyed storage uses `read` and `write`. General keyed storage uses `readAll`, function `key`, exact `keySchema`, `read`, and `writeAt`.
77
+ Use `Update.Return<Model, Message>` when an update cannot emit an OutMessage. It prevents a result containing an OutMessage from entering code that would keep only its Model and Commands. A result with no `outMessage` can still be used where `Update.ReturnWithOutMessage<Model, Message, OutMessage>` is expected. The missing field means that update emitted no OutMessage.
142
78
 
143
- Placement identifies a relationship in the graph. Direct and map fields default it to their field; keyed arrays, keyed Options, and static accessors default to the child Block ID. The occurrence key identifies one child within a keyed relationship. Override placement only for a sibling collision or deliberate stable identity.
79
+ Use `Update.foldChildInit` for one child `init` or `boot` result. Use `Update.foldChildInits` when several child results enter one parent Model. Both lift child Commands and handle child OutMessages. Use `Update.foldChild` for a child update that receives input, or `Update.foldChildStep` for a child helper that receives only its Model. Keep route-gated initialization or Model-only child construction separate when there is no shared set of child results to fold.
144
80
 
145
- A writer places the next child Model into its storage, preserving wrapper metadata and respecting absence and key identity. Parent reactions belong in OutMessage policy. If a required fact is missing, add a truthful child OutMessage instead of using the writer as an event hook. Use `delivery.when` for admission and `delivery.toUpdateContext` for exact update context; keyed policies receive the occurrence key. Message-free children (`Schema.Never`) need no delivery policy.
81
+ Use `Update.combine` when a later Step should receive the Model produced by an earlier Step. It takes two or more Steps. Do not wrap one Step in `Update.combine`; call that operation directly. Name an inline Step parameter `stepModel`; it contains the Model produced by the preceding Step.
146
82
 
147
- Parent-driven transitions invoke Binding operations. Under the child's `operations`, put a Message constructor directly when its payload is the public input; use a tuple producer for mapping, refinements, defaults, or exact context arguments. Assembly associates the operation with update without eagerly constructing Messages. Bound calls process the Message synchronously through child update. Name actions `requestCloseMenu` → `Message.RequestedCloseMenu`, and notifications `informJoined` → `Message.InformedOfJoin`. Avoid silent `reflect*` changes.
83
+ When the OutMessage is already known while constructing a new result, include it directly: `{ model, commands, outMessage }`. Use `Update.withOutMessage` when attaching an OutMessage to an existing plain return or when the value has the type `OutMessage | undefined`. Pipe an existing return into the helper: `pipe(dialogClose, Update.withOutMessage(outMessage))`. When constructing the plain return in the same expression, pass it first: `Update.withOutMessage({ model, commands }, outMessage)`.
148
84
 
149
- Connected Binding operations require the registered graph. Apply them in Composition-authored init/update or return them through the parent's `makeStep`; preserve opaque results intact. They expose no useful `.model` or `.commands` before checked execution. The Composition resolves their final channels. Completed `ChildBlock.operations.name(model, ...args)` accepts the child's raw Model and returns an executed result; ordinary pure Steps also remain callable. TypeScript can erase a connected function's result through `void`, but outside the graph that call only constructs and discards passive configuration.
85
+ Add `toParentOutMessage` only when at least one child OutMessage should continue to the current Submodel's parent. For partial forwarding, match every child variant and return `undefined` for the variants that stop here. Omit `toParentOutMessage` when every variant stops here. `foldOutMessage` still handles each variant locally, including variants that continue upward. Never write `toParentOutMessage: () => undefined`.
150
86
 
151
- ### OutMessage policies
87
+ When a `foldChildInits` entry can derive or forward an OutMessage, add `resolveOutMessage` to construct one parent OutMessage from the named OutMessages after every local fold completes. Combine their information when both results matter; choosing one discards the other. The callback also receives the final Model. If that Model alone contains everything needed, use local folds and attach a parent OutMessage afterward with `Update.withOutMessage`.
152
88
 
153
- Select every child OutMessage policy with `withOutMessagePolicy`. Keep folds callable and author both inline and extracted folds through `ParentDefinition.makeOutMessageFold(ChildBlock, cases)`, always passing the completed child explicitly. Name every variant, including singleton unions. The helper contextually types payloads and preserves inferred requirements and registration evidence. Do not substitute a raw child matcher or repetitive generic annotations. Take the inferred `FoldContext` argument only when using its lifters or previous Model.
154
-
155
- Keep ordinary policies fluent. For self-referential or reciprocal coordination, declare the operation-bearing Bindings first, then their folds and selected `FooBindingWithOutMessagePolicy` values. Register the selected values. Keep mutually coordinating policies together and defer sibling calls through callbacks to avoid initialization and import cycles.
156
-
157
- Include `forward` only when at least one child variant continues to this Block's parent. Author it with `makeOutMessageForward`, passing the child explicitly when extracted or adapted for keyed policy. Name every variant and return `undefined` for those that stop. Local `fold` policy still runs for forwarded variants; a derived parent OutMessage takes precedence over one-to-one forwarding. A no-op fold branch is point-free `Closed: makeNoopStep`; an update-record no-op calls the factory: `CompletedFocus: makeNoopStep()`.
158
-
159
- ### Child initialization
160
-
161
- Keep child state retention, rendering, and activity as separate decisions. A Route change can select another view while retaining child Models in the parent. Store multiple retained editors by entity identity when navigating A to B to A should preserve both. A retained occurrence can still receive pending results; gate its Subscriptions or other activity explicitly when necessary. Remove child state for an application reason such as deletion or eviction. Use `initialize...IfMissing` for application Steps that preserve an existing occurrence and initialize only an absent identity.
162
-
163
- Author one `Composition.makeInit` with a concrete signature; optional, default, and rest arguments remain exact. Return parent-owned fields under `model`, optional root `commands`, and `steps` for transitions after child fields exist. An optional Definition `ChildInitContext` Schema describes shared data produced by parent init; each child's `init.contextToArgs` selects initializer arguments from that context. Return the value as `childInitContext`. It does not describe the parent's own init arguments.
164
-
165
- For a required direct child whose initializer accepts no arguments, omit `init` for automatic initialization. Required inputs use `init.contextToArgs`; `init: false` makes the parent supply the field. Optional, keyed, and accessor storage remains parent-owned when `init` is omitted. An optional direct field's selector returns `Option<tuple>`. Keyed arrays use `init.instances` returning ordered `{ key, args }` records and `init.toItem`; custom accessors can use `init.toParentFields`. Preserve the planned key and exact initialized child Model inside plain wrapper records.
166
-
167
- Composition initializes selected children once in Binding order, then applies startup Steps. Parent Commands precede retained child init Commands; startup Step Commands follow. Commands are a batch, with no asynchronous completion-order guarantee. Init Commands for absent children are filtered out. Use existing meaningful operations in startup Steps; do not invent a separate boot phase or a Message solely for startup when init can accept the inputs.
168
-
169
- Dynamic creation or deliberate replacement returns `Binding.init({ key?, args, toParentModel })` intact from Composition-owned authoring. It is a passive, noncallable recipe with no `.model` or `.commands`. Reinitializing an existing occurrence does not create a fresh generation or cancel pending work; lifecycle-sensitive resets belong in a child operation.
170
-
171
- Use the optional `foldkit/bindingInit` helpers when initialization only places the child in declared storage. Pass the Binding, current parent Model, and `{ args }`, adding `key` for keyed storage:
172
-
173
- - `initAndSet` replaces a required or optional direct field, or a keyed Option wrapper containing only its key and child fields. Direct storage needs no startup policy. A custom unkeyed accessor can reuse its existing `init.toParentFields` projection.
174
- - `initAndAppend` appends an absent keyed array occurrence using an existing startup `init.instances` and `init.toItem` policy.
175
- - `initAndInsert` inserts an absent Record/HashMap key when `makeMapBinding` stores child Models directly.
176
-
177
- All return passive recipes retaining child init Commands and registration requirements. Append and insert reject existing keys; an `initialize...IfMissing` Step owns any presence check. Keep explicit `Binding.init` for additional wrapper metadata, sibling changes, parent Commands, custom storage without a projection, array/map replacement, or a whole tagged variant. Do not add an unnecessary startup policy for a helper. Same-key reinitialization does not establish a fresh generation or cancel pending work.
89
+ Use `modifyFields()` from `foldkit/struct` for immutable model updates. Never spread or `Object.assign`.
178
90
 
179
91
  ### View
180
92
 
181
- Every view receives `h`, the typed Html builder, as its last parameter. Define the canonical completed view through its owning Composition's `makeView` or `makeView.withInputs`. A completed Block's `makeView` method authors only an alternate embed view against its already fixed graph. Ordinary extracted helpers are plain functions. After establishing `FeatureComposition`, declare `type FeatureViewBuilder = Block.ViewBuilderFor<typeof FeatureComposition>` on the next line with no blank line and use that alias for feature-local helpers. Export it only when another file uses it. It retains the feature Message type and registered child and Mount capabilities without constructing a runtime builder. The owner prefix is deliberate even though internal structural contracts remain `Model`, `Message`, and `OutMessage`: the completed `FeatureBlock` owns those public contracts, while the builder alias identifies one Composition's capabilities at a plain type import site. Give each helper only the Model, domain value, or context parameters it actually reads, followed by `h`; let TypeScript infer whether it returns one `Html` value or an array. Rendering genuinely shared across owners takes the framework's general `HtmlBuilder<Message>` form, with capability requirements when needed. Never annotate the primary view's inferred `h` parameter. Never construct a builder; reach for `h.div`, `h.OnClick`, and other helpers from the parameter. Only where no builder is in scope, typically module scope, use `inertHtml` from `foldkit/html`, aliased `ih`. Use `h.empty` (not `null`) for conditional rendering, the union's own exhaustive `match` for discriminated unions, and `Array.match` for lists that may be empty.
93
+ Every view receives `h`, the typed Html builder, as its last parameter (`view: (model, h) => ...`; `Submodel.defineView` passes the child's own). Never construct a builder; reach for `h.div`, `h.OnClick`, etc. off the parameter, and give extracted view helpers an `h: HtmlBuilder<Message>` last parameter that callers thread through. Only where no builder is in scope, typically module scope, use `inertHtml` from `foldkit/html`, aliased `ih` so the two builders stay distinguishable. Use `h.empty` (not `null`) for conditional rendering, the union's own exhaustive `match` (`EditorMode.match(model.mode, {...})`) for discriminated unions, and `Array.match` for lists that may be empty.
182
94
 
183
- Key mapped list items and entity slots by stable identity: key each row by a stable Model identifier (`h.keyed('li')(item.id, [], [...])`), never by array position, and never derive a key from displayed data. Key an entity slot by entity ID when its identity changes at the same position. Never key branches; the build gives each view function's output its own identity, so branch switches replace DOM automatically. When switching an inline same-tag ternary must reset DOM state, extract each arm into its own named view function.
95
+ Keys are for mapped list items only: key each row by a stable Model identifier (`h.keyed('li')(item.id, [], [...])`), never by array position, and never derive a key from displayed data. Never key branches; the build gives each view function's output its own identity, so branch switches replace DOM automatically. When switching an inline same-tag ternary must reset DOM state, extract each arm into its own named view function.
184
96
 
185
97
  Omit the children argument when an element has none: `h.div([h.Class('divider')])`, never `h.div([h.Class('divider')], [])`. The same holds for `keyed`: `h.keyed('li')(key, [attrs])`, never `h.keyed('li')(key, [attrs], [])`. Attributes stay required on element builders, so `h.div([])` is an element with neither. Sibling elements that end up at different arities are expected and fine; void elements like `h.img` have always read that way.
186
98
 
187
99
  ### Commands
188
100
 
189
- Define a Command with `FeatureDefinition.makeCommand(name, { args, messages, handler })`; omit `args` when it takes none. Assign definitions to PascalCase constants. Keep the handler Layer beside its definition. Name the work the handler performs, not the later Model transition caused by its result: a timer that waits before update begins dismissal is `WaitBeforeDismissal`. Convert expected failures to result Messages with `Effect.catch(() => Effect.succeed(Message.FailedX(...)))`. Defects follow the application's crash handling. Commands belong beside the update that returns them.
190
-
191
- `handler` is a generator constructor. Foldkit applies `Effect.gen` once per Runtime start; capture stable Services there and return the invocation function. Requests, delays, time reads, and DOM operations happen inside that returned function with current args. A constructor needing no setup still returns the function directly. Omit `handler` only for an external host contract; provide its implementation Effect constructor through the original definition's `toLayer`.
192
-
193
- Compose attached `.layer` recipes in the feature's local `EffectsLayer`, including its Command, Subscription, Mount, and ManagedResource handlers. Registered child Bindings contribute their own recipes. `ApplicationLayer` supplies the remaining ordinary Services. Reserve `Layer` for Effect's module; create a standalone `<DefinitionName>Layer` only when that individual provider is independently public or reused, and name alternatives `<DefinitionName>TestLayer`. Ordinary execution tests retain the production handler Layer and replace the Services beneath it.
194
-
195
- Command args contain values already in the Model or Message. Read time, randomness, and UUIDs inside the invocation Effect and return them in result Messages. Use `Dom` for browser operations and Effect's `Clock`, `Random`, `Crypto.Crypto`, and `Effect.sleep`; provide the platform Crypto Layer when needed. Avoid raw `document.querySelector`, `setTimeout`, `Date.now()`, or `Math.random()` in app transitions.
101
+ Define a Command with `Command.define(name, { args, messages, execute })`; omit `args` when the Command takes none. Assign definitions to PascalCase constants. Never inline in pipe chains. Name the effect `execute` performs, not the later Model transition caused when update handles its result: a timer that only waits before update starts a dismissal is `WaitBeforeDismissal`, not `DismissAfter`. Commands catch all errors via `Effect.catch(() => Effect.succeed(Message.FailedX(...)))` so side effects never crash the app. Definitions live colocated with the update function that returns them.
196
102
 
197
- For with-args handlers, see `repos/foldkit/examples/weather/src/command.ts` or `repos/foldkit/examples/kanban/src/command.ts`; `FocusAddCardInput` in Kanban demonstrates an argless DOM Command.
103
+ Command args contain values already present in the Model or Message. Calling `Date.now()`, `crypto.randomUUID()`, or another source of time or randomness while preparing a Command happens before the Command executes, whether the call appears directly in the args object or its result is assigned to a local variable first. Obtain those values in `execute` and return them in the result Message.
198
104
 
199
- ### Lifecycle effects
105
+ For the with-args shape, see `repos/foldkit/examples/weather/src/main.ts` or `repos/foldkit/examples/kanban/src/command.ts`. For an argless DOM-side-effect Command, the argless form in `kanban/src/command.ts` (`FocusAddCardInput`) is the canonical reference.
200
106
 
201
- Create one `Definition.makeSubscriptions(...)` registry for all Subscriptions owned by a Block. Add entries to that record and extract substantial Stream implementations into helpers instead of creating another registry for the same owner. Distinct child Blocks retain their own registries. Subscriptions declare `messages`, their Model projection, and `handler` in the entry config. The handler generator returns a function from dependencies to a Stream. When every owned entry has an attached handler, include `subscriptions.layer` in the feature's `EffectsLayer`. When Subscription declarations are split from Block assembly, that module exports the Block's one registry; compose `Feature.subscriptions.layer` directly in `layer.ts`. When the registry supplies the complete local handler bundle, pass `EffectsLayer: subscriptions.layer` directly to `prepareBlock`. The registry Layer is a passive recipe, is `Layer.empty` for an empty record, and is unavailable for mixed host ownership. The entry key `layer` is reserved. Individual entry recipes remain available for intentionally selective assembly. Use `Subscription.aggregate` only at graph, adapter, or test boundaries that join independent records. The Message declaration limits what that Stream can emit; use `messages: []` for silent scoped work. The generator runs once for a runtime start. Restarting the Subscription reuses that factory and its application-lifetime providers. A host-owned entry may omit `handler` and receive its implementation through `toLayer`, which accepts the implementation Effect constructor.
107
+ For DOM operations (focus, scroll, modals, scroll lock), Foldkit ships a `Dom` module. For time, randomness, UUIDs, and delays, use Effect's APIs directly (`Clock`, `Random`, `SecureRandom.SecureRandom`, `Effect.sleep`). Import `SecureRandom` from `effect/crypto` and provide `BrowserCrypto.layerSecureRandom` when using its service in the browser. Don't reach for raw `document.querySelector`, `setTimeout`, `Date.now()`, or `Math.random()`.
202
108
 
203
- Before choosing a ManagedResource, identify the Command or other consumer that needs its handle. Model-gated listeners or scoped work with no handle consumer belong in a Subscription, including `messages: []` when they emit nothing. Installing a listener and removing it on cleanup is not enough reason to create a ManagedResource. Use a Mount when one rendered element owns the work. See [lifecycle ownership](https://foldkit.dev/core/subscriptions#lifecycle-ownership) for the decision rules.
109
+ ### File Organization
204
110
 
205
- Mounts use the same `config.handler` generator and `.layer` convention. The returned operation receives the live element; perform DOM work there. Include the definition in its owning Composition's `mounts`. A ManagedResource entry likewise stores a handler generator in its config. The generator returns an object with required `acquire` and `release` functions. Supply cleanup explicitly. A no-op release is appropriate when scoped acquisition already registered the real finalizers, as with `Layer.build`. Foldkit finishes explicit release and scoped cleanup before clearing the handle and emitting `onReleased`.
111
+ Keep the runtime boot separate from the pure definitions. `src/entry.ts` calls `Runtime.makeApplication`, then `Runtime.run` for a client-rendered app or `Runtime.hydrate` for an SSR or SSG app. A client-rendered app references that entry from `index.html`. An SSR or SSG app names it in `ssr.clientEntry` in `vite.config.ts`, imports CSS from it, and exports `renderDocument` from `src/entry.server.ts` to produce the complete document. Its source tree has no `index.html`.
206
112
 
207
- An owned `Definition.makeManagedResources(...)` registry exposes `managedResources.layer` only when every entry has an attached handler. Empty registries provide `Layer.empty`; mixed or host-owned registries require explicit entry providers. The registry key `layer` is reserved, matching Subscriptions. Merge the aggregate into local `EffectsLayer`; construction remains passive.
113
+ The definitions (Model, Messages, init, update, view, Commands) never call `Runtime.run` or `Runtime.hydrate`, so tests and server entries can import them without booting a browser runtime. Keep both calls out of `main.ts`.
208
114
 
209
- Keep the four lifetimes distinct. Application services such as RPC clients last for one Runtime start. A Command Effect lasts for one dispatch. Subscription Streams and ManagedResource handles follow Model conditions. Mount acquisition follows one DOM element. A handler generator may capture a stable service or accessor. It must not capture current time, Command args, Subscription dependencies, a DOM element, or an active ManagedResource handle. Captured services remain fixed for the Runtime start. Contextual lookups use the merged invocation context, where invocation services win. Looking up a service retrieves a provided instance; it does not construct the provider.
115
+ For a small app the definitions all fit in one `src/main.ts`. Split a unit into its own file when it has _both_ a distinct reason to change _and_ a name you'd give it unprompted: the pure domain core into `timer.ts` or `domain.ts`, the view into `view.ts` (or a `components/` directory), a Command's owned resource into its own module. Split on that revealed seam, not on line count alone. A file that has grown large is _evidence_ a seam has formed, so treat its size as a prompt to re-check for one. Two splits are forced: extract Messages to `message.ts` when Commands need the constructors (this breaks the cycle between `command.ts` and `main.ts`), and colocate Commands with the update that returns them. Exemplars: counter and stopwatch are a single `main.ts`; kanban splits `domain` / `command` / `message` / `model`; typing-game splits views by page.
210
116
 
211
- Handlers and services may own mutable execution bookkeeping, such as worker availability or protocol request IDs. The Model and update own pending work shown to the user, selections, and submission rules. A `Ref` created in the constructor must not become the source of truth for workflow decisions or state read by view.
212
-
213
- ### File organization
214
-
215
- When using Tailwind, keep reusable static control recipes in the stylesheet's `@layer components`, where ordinary utilities can override them. Use `@utility` when adding an actual utility that needs variants. Keep `clsx` for conditional classes. Avoid a TypeScript module whose only job is assembling and exporting static class strings.
216
-
217
- Keep a compact feature together. Split when a responsibility has a distinct reason to change and a meaningful name; do not add one file per Message or helper. Keep domain Schemas and pure domain operations in `domain/`, independent of Model, update, and view modules.
218
-
219
- A genuinely compact root lives in `application.ts`. Once the root is split, use the complete split layout:
220
-
221
- - `model.ts`, `message.ts`, `init.ts`, `update.ts`, and `view.ts` own their named responsibilities; use `view/` or `update/` when substantial behavior warrants it.
222
- - `definition.ts` contains the early contracts and `ApplicationDefinition` when its authoring methods are used. Otherwise chain the Definition factory into the Composition declaration and remove the empty file.
223
- - `composition.ts` owns Bindings, parent OutMessage policy, child/Mount registration, `ApplicationComposition`, and its optional builder alias. It does not import root init, update, view, or the completed Block.
224
- - `block.ts` imports those implementations and assembles `ApplicationBlock`. Remove an emptied `application.ts`; do not retain it as an aggregation wrapper.
225
- - Commands belong to the feature whose update returns them. Keep small definitions alongside update or use feature-local `command.ts`. Compose local recipes there; extract `layer.ts` when the bundle is substantial or reused.
226
- - `services.ts` supplies the root `ApplicationLayer` of ordinary Services. `entry.ts` chooses the Program host options, provides that Layer, and starts the Runtime. A test provider is `ApplicationTestLayer`.
227
-
228
- A split child follows the same Definition, Composition, implementation, and assembly direction. Keep `FooDefinition` only when its authoring members are used. The final `block.ts` may compose a small local EffectsLayer. Shared Mount definitions live in `mount.ts`. Feature barrels expose the completed Block; internal exports needed by siblings and tests do not widen that barrel.
229
-
230
- Extract substantial parent policy into `composition/<child>.ts`, with `composition/composition.ts` assembling the graph and `composition/index.ts` as an explicit barrel. Export extracted policies through child-name namespaces, such as `export * as Home from './home'`. Keep flat named exports for the Composition and straightforward local Bindings. Internal sibling imports can avoid barrel cycles; externally import through the public composition entry. Reciprocal policies remain together with deferred sibling calls. Do not move child policy into a generic utility module or duplicate registration lists.
231
-
232
- `index.ts` is always a barrel. Export intended names explicitly. Routine app annotations query `typeof Model.Type` inside the owner and `typeof ChildBlock.Model.Type` across a child boundary, with analogous Message and OutMessage queries. Keep aliases only for deliberate library contracts or useful generic, mapped, and conditional types, including the owner-specific ViewBuilder.
233
-
234
- Only entries start execution. Client rendering uses `Runtime.run`; SSR/SSG uses `Runtime.hydrate`. A client app references `entry.ts` from `index.html`. SSR/SSG instead names `ssr.clientEntry` in `vite.config.ts`, imports CSS there, and exports `renderDocument` from `entry.server.ts`; it has no source `index.html`. Keep passive definitions importable by tests and server rendering.
235
-
236
- Use section headers only when a long file needs wayfinding. Use `// NOTE:` for a surprising browser or timing constraint; ordinary behavior should be clear from names and structure.
117
+ Use uppercase section headers (`// MODEL`, `// MESSAGE`, `// INIT`, `// UPDATE`, `// COMMAND`, `// VIEW`) for wayfinding.
237
118
 
238
119
  ### Testing
239
120
 
240
121
  Test update functions with `foldkit/test`. Since update is pure, tests run without a runtime, DOM, or side effects. Use `story` for update-level tests (send Messages, assert on Model and Commands) and `scene` for feature-level testing through the view with accessible locators.
241
122
 
242
- For an execution test, use the production handler Layer and provide controlled external services beneath it before construction. The test then executes the real request, response mapping, or lifecycle logic with a deterministic API, storage, RPC, clock, or browser provider. Replacing a complete handler exercises the chosen result path and does not test that handler's implementation. Story and Scene tests resolve Commands without executing their handlers.
243
-
244
123
  Import the steps as named imports from `foldkit/story` or `foldkit/scene`: `import { Command, given, message, model, story } from 'foldkit/story'`. A test file needs only one of the two modules. If a single file ever tests both, import the namespaces instead (`import { Scene, Story } from 'foldkit'`) so `Story.given` and `Scene.given` stay distinguishable.
245
124
 
246
- Name each test file for its test style, beside the code under test: `story.test.ts` for the Story tests (which drive `update`) and `scene.test.ts` for the Scene tests (which drive the rendered view). The name describes how the test works, not a source file, so it stays correct whether `update` and `view` live in `application.ts` or in their own files. A test file lives in the folder that holds the code it drives, so in a multi-page app most of them sit in a page folder rather than at the root. When one folder holds more than one test of a kind (sibling pages, component variants), prefix with the subject: `login.story.test.ts`.
125
+ Name each test file for its test style, beside the code under test: `story.test.ts` for the Story tests (which drive `update`) and `scene.test.ts` for the Scene tests (which drive the rendered view). The name describes how the test works, not a source file, so it stays correct whether `update` and `view` live in `main.ts` or in their own files. A test file lives in the folder that holds the code it drives, so in a multi-page app most of them sit in a page folder rather than at the root. When one folder holds more than one test of a kind (sibling pages, component variants), prefix with the subject: `login.story.test.ts`.
247
126
 
248
127
  Scene runs at any level, since a page's own `update`/`view` pair drops into `scene` unmodified. Put a `scene.test.ts` in the page folder for behavior that page owns, which covers view states awkward to reach through the root Model, and keep a root-level `scene.test.ts` for flows that cross pages, which covers how the parent folds an OutMessage, a Command the parent lifts, a route change, and view inputs the parent computes. If the `repos/foldkit` subtree is available, study the `story.test.ts` and `scene.test.ts` files in `repos/foldkit/examples/`. `repos/foldkit/examples/auth` is the multi-page shape: a root `src/scene.test.ts` for the cross-page login flow alongside `src/page/loggedOut/page/login.scene.test.ts` and `login.story.test.ts` driving that page's own pair.
249
128
 
250
- Story can deliver Messages while Commands are pending. Use `messageWith(model => Message.Variant(...))` when the Message needs the current Model at that step, and `Subscription.from(FeatureBlock.subscriptions).emit(entry, message)` for a decoded Subscription Message through its registered parent mapping.
251
-
252
- When a Scene emits a Subscription Message, include the owning Composition and registered `subscriptions` in its config and call `Subscription.emit(entry, message)` with the exact registered entry. Each entry's `messages` collection declares the raw Messages accepted by that step. Select a bound entry when one source appears at multiple child placements. Silent `messages: []` entries accept no emissions. These steps do not start Streams or simulate Runtime activity and stale-generation admission.
253
-
254
- Use `Scene.Command.keepPending(Definition | instance)` when a real interaction must occur before one ordinary Command completes. Its matcher must select one invocation; a bound instance selects its occurrence and args. The Command stays visible to assertions and resolvers, and must be resolved before the Scene ends. This changes only the later-Message boundary check.
255
-
256
129
  ## Code Style
257
130
 
258
131
  - Encode state in discriminated unions, not booleans or nullable fields. `Idle | Loading | Error | Ok`, not `isLoading: boolean`. Make impossible states unrepresentable.
259
- - Use `Option` for absence in the Model and domain values instead of `null` or `undefined`. Foldkit return records are the exception: omit `commands` and `outMessage` when absent. A partial `withOutMessagePolicy({ forward })` mapper returns `undefined` for each child variant that stops at this Block. Prefix Option-typed values with `maybe*`. Match with `Option.match`; don't unwrap with `Option.map(...)` + `Option.getOrElse(...)` when you can just match.
132
+ - Use `Option` for absence in the Model and domain values instead of `null` or `undefined`. Foldkit return records are the exception: omit `commands` and `outMessage` when absent. A partial `toParentOutMessage` mapper returns `undefined` for each child variant that stops at this Submodel. Prefix Option-typed values with `maybe*`. Match with `Option.match`; don't unwrap with `Option.map(...)` + `Option.getOrElse(...)` when you can just match.
260
133
  - Use Effect modules over native methods in `pipe` chains (`Array.map`, `String.startsWith`, `Array.findFirst`). Native methods are fine when calling directly on a named variable.
261
134
  - Never cast Schema values with `as Type`. Use the callable constructor: `Message.SucceededLogin({ sessionId })`, not `{ _tag: 'SucceededLogin', sessionId } as Message`.
262
- - Use `Array.match` for empty/non-empty branches. Use `Array.isReadonlyArrayEmpty` / `Array.isReadonlyArrayNonEmpty` for readonly Model collections, or the mutable predicates for mutable arrays; avoid `.length === 0` / `.length > 0`.
263
- - Prefer `const` and pure collection transformations. Keep unavoidable mutation local to a tight algorithm or resource lifecycle; never hide workflow state in mutable module variables.
135
+ - Always `Array.isArrayEmpty` / `Array.isArrayNonEmpty` (not `.length === 0` / `.length > 0`). Use `Array.match` when handling both empty and non-empty cases.
136
+ - Never use `for` loops or `let` for iteration. Reach for `Array.map`, `Array.filterMap`, `Array.makeBy`, `Array.reduce`.
264
137
  - Never use `T[]`. Always `Array<T>` or `ReadonlyArray<T>`.
265
- - Author updates with exhaustive `makeUpdate` records. Branch on already-typed domain and Route variants through their owning union's guards and exhaustive `match`; use Effect `Match` for partial or grouped matches and unions without a matcher. Reserve Schema decoding or `Schema.is` for actual boundary validation. Never use `switch`.
266
- - Use `Calendar` for date-only values and Effect `DateTime` / `Duration` for timestamps and elapsed time. Read the current time in a Command, Subscription, or Flags.
138
+ - Use `Message.match` for exhaustive Message matching. Use Effect `Match` for other tagged unions, partial matching, fallbacks, and one handler shared across multiple tags. Never use `switch`.
267
139
  - Always use braces for control flow: `if (foo) { return true }`.
268
- - Use direct `value === undefined` and `value !== undefined` comparisons for undefined checks.
269
- - Use blank lines to show the phases of non-trivial control flow, and prefer a blank line when uncertain. Separate setup, a value read from the guard that consumes it, independent guards or validation cases, writes, and the final return. In a loop, give each skip, failure, or mutation condition its own visual paragraph. Keep statements together only when they form one operation or one explicit `if`/`else` chain. Preserve the required adjacency of a Composition and its ViewBuilder alias, and of `prepare` and its checked Block export. Formatting alone does not choose these logical boundaries; review them while authoring the code.
270
- - Name selectors for derived values (`visibleIssues`), pure transitions for the Model change they describe (`applyWorkspaceSnapshot`), and dedicated handlers `handle<MessageTag>`. Use `initialize...IfMissing` for conditional creation. Reserve `sync` and `observe` for actual synchronization or observation. Commands describe effects for Runtime; a Step only computes state and Commands.
271
140
  - Don't add inline comments to explain code. Use better names instead. Reserve `// NOTE:` for behavior that would mislead a careful reader.
272
141
 
273
142
  ## Message Layout
274
143
 
275
- Declare the whole Message union with `defineMessageUnion()`:
144
+ Declare the whole Message union with `defineMessageUnion()`, then put `type Message = typeof Message.Type` on the next line:
276
145
 
277
146
  ```ts
278
147
  const Message = defineMessageUnion({
279
148
  ClickedSubmit: {},
280
149
  UpdatedEmail: { value: Schema.String },
281
150
  })
151
+ type Message = typeof Message.Type
282
152
  ```
283
153
 
284
- When an explicit local annotation needs the decoded union, write `typeof Message.Type` directly. Definition, Composition, and completed Block helpers infer it from the Schema value, so do not add a routine colocated alias. Construct values through the namespace (`Message.ClickedSubmit()`) and handle local facts in the Composition's exhaustive `makeUpdate` record. Never destructure constructors from `Message` or `OutMessage`; the owning namespace stays visible at every call site.
154
+ Keep the `defineMessageUnion()` declaration and `type Message` alias adjacent. Construct values through the namespace (`Message.ClickedSubmit()`) and handle the union with `Message.match`. Never destructure constructors from `Message` or `OutMessage`; the owning namespace stays visible at every call site.
285
155
 
286
156
  Keep each case's payload object on one line when it fits. Let Oxfmt wrap payloads that need more space, so the declaration remains easy to scan as one variant per line.
287
157
 
288
- Messages are verb-first past-tense. Common prefixes: `Clicked*`, `Updated*` (input changes and external state updates), `Submitted*`, `Pressed*`, `Selected*`, `Succeeded*` / `Failed*` (paired async results), and `Completed*` (every other Command result). Keep the authored Message local; child delivery variants are generated by the Composition.
158
+ Messages are verb-first past-tense. Common prefixes: `Clicked*`, `Updated*` (input changes and external state updates), `Submitted*`, `Pressed*`, `Selected*`, `Succeeded*` / `Failed*` (paired async results), `Completed*` (every other Command result), `Got*` (child OutMessage in the Submodel pattern).
289
159
 
290
160
  ## Debugging
291
161
 
292
- This project ships with `@foldkit/devtools-mcp` pre-wired. When the dev server is running and the app is open in a browser, `foldkit_*` MCP tools let you inspect Model, Message history, and time-travel. The generated entry opts into external Message Schema discovery and dispatch with `devTools: { dispatch: true }`; Foldkit derives the Schema from the completed root Block, including generated child envelopes. Reach for those tools before adding `console.log` whenever the question is about state or Message flow.
162
+ This project ships with `@foldkit/devtools-mcp` pre-wired. When the dev server is running and the app is open in a browser, `foldkit_*` MCP tools let you inspect Model, Message history, and time-travel. Reach for them before adding `console.log` whenever the question is about state or Message flow.
293
163
 
294
164
  Treat those tools as privileged access to the application. They can return Models, Message payloads, and Command and Mount arguments to the agent. Keep credentials and private data out of browser state. Use Effect `Redacted` for sensitive values the browser must temporarily hold, and set `devToolsMcpPort: false` in the Foldkit Vite plugin options when an agent should not inspect the running application.
295
165
 
296
166
  ## Going Deeper
297
167
 
298
- For Blocks and OutMessage, Subscriptions, Mount / ManagedResource / CustomElement, field validation, routing, accessibility, and the full convention set, read the live Foldkit code in `repos/foldkit/`. The `examples/` directory and the production apps (`packages/typing-game/`, `packages/website/`) are the highest-fidelity references for any specific pattern. The `foldkit-skills` plugin's `generate-program` and `audit-program` skills carry written snapshot guides if you want a structured walkthrough.
168
+ For Submodels and OutMessage, Subscriptions, Mount / ManagedResource / CustomElement, field validation, routing, accessibility, and the full convention set, read the live Foldkit code in `repos/foldkit/`. The `examples/` directory and the production apps (`packages/typing-game/`, `packages/website/`) are the highest-fidelity references for any specific pattern. The `foldkit-skills` plugin's `generate-program` and `audit-program` skills carry written snapshot guides if you want a structured walkthrough.
@@ -9,9 +9,9 @@
9
9
  "test": "vitest run"
10
10
  },
11
11
  "dependencies": {
12
- "@effect/platform-browser": "4.0.0",
12
+ "@effect/platform-browser": "4.1.0",
13
13
  "@foldkit/ui": "workspace:*",
14
- "effect": "4.0.0",
14
+ "effect": "4.1.0",
15
15
  "foldkit": "workspace:*"
16
16
  },
17
17
  "devDependencies": {
@@ -20,8 +20,8 @@
20
20
  "@tailwindcss/vite": "^4.3.3",
21
21
  "happy-dom": "^20.14.5",
22
22
  "tailwindcss": "^4.3.3",
23
- "typescript": "7.1.0-beta",
24
- "vite": "^8.3.3",
23
+ "typescript": "^7.0.2",
24
+ "vite": "^8.3.1",
25
25
  "vitest": "^5.0.2"
26
26
  }
27
27
  }
@@ -5,6 +5,7 @@ export const Post = Schema.Struct({
5
5
  title: Schema.String,
6
6
  excerpt: Schema.String,
7
7
  })
8
+ export type Post = typeof Post.Type
8
9
 
9
10
  export const PostDetail = Schema.Struct({
10
11
  id: Schema.String,
@@ -12,12 +13,14 @@ export const PostDetail = Schema.Struct({
12
13
  author: Schema.String,
13
14
  body: Schema.String,
14
15
  })
16
+ export type PostDetail = typeof PostDetail.Type
15
17
 
16
18
  export const Stats = Schema.Struct({
17
19
  activeUsers: Schema.Number,
18
20
  requestsPerSecond: Schema.Number,
19
21
  cacheHitRatePercent: Schema.Number,
20
22
  })
23
+ export type Stats = typeof Stats.Type
21
24
 
22
25
  export const FLAKY_POST_ID = 'flaky-connection'
23
26
 
@@ -89,7 +92,7 @@ const flakyAttempts = { count: 0 }
89
92
 
90
93
  export const fetchPostDetail = (
91
94
  postId: string,
92
- ): Effect.Effect<typeof PostDetail.Type, string> =>
95
+ ): Effect.Effect<PostDetail, string> =>
93
96
  Effect.gen(function* () {
94
97
  yield* Effect.sleep(SERVER_LATENCY)
95
98
 
@@ -1,11 +1,17 @@
1
- import { Program, Runtime } from 'foldkit'
1
+ import { Runtime } from 'foldkit'
2
2
 
3
- import { ApplicationBlock } from './block'
3
+ import { Message, Model, init, subscriptions, update, view } from './main'
4
4
 
5
- const program = Program.make({
6
- block: ApplicationBlock,
5
+ const application = Runtime.makeApplication({
6
+ Model,
7
+ init,
8
+ update,
9
+ view,
10
+ subscriptions,
7
11
  container: document.getElementById('root'),
8
- devTools: { dispatch: true },
12
+ devTools: {
13
+ Message,
14
+ },
9
15
  })
10
16
 
11
- Runtime.run(program)
17
+ Runtime.run(application)