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.
- package/README.md +3 -3
- package/dist/examples.js +4 -4
- package/dist/templates/base/AGENTS.md +0 -6
- package/dist/templates/base/FOLDKIT.md +42 -172
- package/dist/templates/examples/api-cache/package.json +4 -4
- package/dist/templates/examples/api-cache/src/data.ts +4 -1
- package/dist/templates/examples/api-cache/src/entry.ts +12 -6
- package/dist/templates/examples/api-cache/src/main.fixture.ts +71 -0
- package/dist/templates/examples/api-cache/src/main.ts +743 -0
- package/dist/templates/examples/api-cache/src/scene.test.ts +7 -11
- package/dist/templates/examples/api-cache/src/story.test.ts +24 -27
- package/dist/templates/examples/api-cache-query/package.json +4 -4
- package/dist/templates/examples/api-cache-query/src/data.ts +4 -1
- package/dist/templates/examples/api-cache-query/src/entry.ts +13 -6
- package/dist/templates/examples/api-cache-query/src/{model.fixture.ts → main.fixture.ts} +16 -20
- package/dist/templates/examples/api-cache-query/src/main.ts +651 -0
- package/dist/templates/examples/api-cache-query/src/scene.test.ts +4 -10
- package/dist/templates/examples/api-cache-query/src/story.test.ts +10 -22
- package/dist/templates/examples/auth/package.json +4 -4
- package/dist/templates/examples/auth/src/command.ts +31 -107
- package/dist/templates/examples/auth/src/domain/session.ts +2 -0
- package/dist/templates/examples/auth/src/entry.ts +17 -10
- package/dist/templates/examples/auth/src/main.ts +76 -0
- package/dist/templates/examples/auth/src/message.ts +6 -3
- package/dist/templates/examples/auth/src/model.ts +6 -6
- package/dist/templates/examples/auth/src/page/index.ts +2 -2
- package/dist/templates/examples/auth/src/page/loggedIn/index.ts +4 -1
- package/dist/templates/examples/auth/src/page/loggedIn/message.ts +8 -0
- package/dist/templates/examples/auth/src/page/loggedIn/model.ts +12 -0
- package/dist/templates/examples/auth/src/page/loggedIn/page/dashboard.ts +8 -7
- package/dist/templates/examples/auth/src/page/loggedIn/page/settings.ts +5 -7
- package/dist/templates/examples/auth/src/page/loggedIn/update.ts +14 -5
- package/dist/templates/examples/auth/src/page/loggedIn/view.ts +7 -5
- package/dist/templates/examples/auth/src/page/loggedOut/index.ts +4 -1
- package/dist/templates/examples/auth/src/page/loggedOut/message.ts +13 -1
- package/dist/templates/examples/auth/src/page/loggedOut/model.ts +13 -1
- package/dist/templates/examples/auth/src/page/loggedOut/page/home.ts +5 -5
- package/dist/templates/examples/auth/src/page/loggedOut/page/{login/scene.test.ts → login.scene.test.ts} +1 -3
- package/dist/templates/examples/auth/src/page/loggedOut/page/{login/story.test.ts → login.story.test.ts} +7 -2
- package/dist/templates/examples/auth/src/page/loggedOut/page/{login/view.ts → login.ts} +158 -11
- package/dist/templates/examples/auth/src/page/loggedOut/update.ts +25 -2
- package/dist/templates/examples/auth/src/page/loggedOut/view.ts +11 -8
- package/dist/templates/examples/auth/src/route.ts +14 -16
- package/dist/templates/examples/auth/src/scene.test.ts +10 -12
- package/dist/templates/examples/auth/src/update.ts +156 -63
- package/dist/templates/examples/auth/src/view.ts +20 -21
- package/dist/templates/examples/canvas-art/package.json +4 -4
- package/dist/templates/examples/canvas-art/src/entry.ts +12 -6
- package/dist/templates/examples/canvas-art/src/{application.ts → main.ts} +81 -121
- package/dist/templates/examples/canvas-art/src/scene.test.ts +4 -4
- package/dist/templates/examples/canvas-art/src/story.test.ts +4 -4
- package/dist/templates/examples/charting/package.json +4 -4
- package/dist/templates/examples/charting/src/chartHost.ts +19 -0
- package/dist/templates/examples/charting/src/command.ts +40 -56
- package/dist/templates/examples/charting/src/domain.ts +29 -21
- package/dist/templates/examples/charting/src/echarts.ts +11 -11
- package/dist/templates/examples/charting/src/entry.ts +15 -7
- package/dist/templates/examples/charting/src/githubApi.ts +2 -1
- package/dist/templates/examples/charting/src/init.ts +15 -4
- package/dist/templates/examples/charting/src/{model.fixture.ts → main.fixture.ts} +5 -12
- package/dist/templates/examples/charting/src/message.ts +8 -0
- package/dist/templates/examples/charting/src/model.ts +6 -8
- package/dist/templates/examples/charting/src/npmApi.ts +4 -3
- package/dist/templates/examples/charting/src/radioGroups.ts +3 -4
- package/dist/templates/examples/charting/src/scene.test.ts +4 -5
- package/dist/templates/examples/charting/src/story.test.ts +11 -19
- package/dist/templates/examples/charting/src/telemetry.ts +56 -69
- package/dist/templates/examples/charting/src/update.ts +183 -53
- package/dist/templates/examples/charting/src/view/chart.ts +127 -17
- package/dist/templates/examples/charting/src/view/layout.ts +12 -15
- package/dist/templates/examples/charting/src/view/sidebar.ts +121 -120
- package/dist/templates/examples/charting/src/view/view.ts +7 -3
- package/dist/templates/examples/counter/package.json +4 -4
- package/dist/templates/examples/counter/src/entry.ts +11 -6
- package/dist/templates/examples/counter/src/{application.ts → main.ts} +30 -37
- package/dist/templates/examples/counter/src/scene.test.ts +2 -2
- package/dist/templates/examples/counter/src/story.test.ts +2 -2
- package/dist/templates/examples/counters/package.json +4 -4
- package/dist/templates/examples/counters/src/counter.ts +24 -34
- package/dist/templates/examples/counters/src/entry.ts +11 -6
- package/dist/templates/examples/counters/src/main.ts +167 -0
- package/dist/templates/examples/counters/src/scene.test.ts +13 -13
- package/dist/templates/examples/counters/src/story.test.ts +53 -104
- package/dist/templates/examples/crash-view/package.json +4 -4
- package/dist/templates/examples/crash-view/src/entry.ts +13 -7
- package/dist/templates/examples/crash-view/src/{application.ts → main.ts} +21 -28
- package/dist/templates/examples/crash-view/src/scene.test.ts +1 -1
- package/dist/templates/examples/crash-view/src/story.test.ts +1 -1
- package/dist/templates/examples/embedding/package.json +4 -4
- package/dist/templates/examples/embedding/src/host.ts +4 -12
- package/dist/templates/examples/embedding/src/main.ts +151 -0
- package/dist/templates/examples/embedding/src/scene.test.ts +2 -2
- package/dist/templates/examples/embedding/src/story.test.ts +2 -2
- package/dist/templates/examples/form/package.json +4 -4
- package/dist/templates/examples/form/src/entry.ts +11 -6
- package/dist/templates/examples/form/src/{view.ts → main.ts} +239 -23
- package/dist/templates/examples/form/src/scene.test.ts +8 -5
- package/dist/templates/examples/form/src/story.test.ts +11 -8
- package/dist/templates/examples/generative-art/package.json +4 -4
- package/dist/templates/examples/generative-art/src/command.ts +84 -92
- package/dist/templates/examples/generative-art/src/entry.ts +10 -6
- package/dist/templates/examples/generative-art/src/main.ts +61 -0
- package/dist/templates/examples/generative-art/src/message.ts +6 -0
- package/dist/templates/examples/generative-art/src/model.ts +6 -3
- package/dist/templates/examples/generative-art/src/scene.test.ts +8 -12
- package/dist/templates/examples/generative-art/src/story.test.ts +7 -11
- package/dist/templates/examples/generative-art/src/subscription.ts +32 -21
- package/dist/templates/examples/generative-art/src/update.ts +121 -62
- package/dist/templates/examples/generative-art/src/view.ts +62 -80
- package/dist/templates/examples/interrupting-commands/package.json +4 -4
- package/dist/templates/examples/interrupting-commands/src/entry.ts +11 -6
- package/dist/templates/examples/interrupting-commands/src/main.ts +358 -0
- package/dist/templates/examples/interrupting-commands/src/scene.test.ts +11 -7
- package/dist/templates/examples/interrupting-commands/src/story.test.ts +14 -10
- package/dist/templates/examples/job-application/package.json +4 -4
- package/dist/templates/examples/job-application/src/command.ts +12 -18
- package/dist/templates/examples/job-application/src/domain/proficiencyLevel.ts +2 -2
- package/dist/templates/examples/job-application/src/domain/pronounOption.ts +2 -2
- package/dist/templates/examples/job-application/src/domain/step.ts +3 -2
- package/dist/templates/examples/job-application/src/entry.ts +11 -8
- package/dist/templates/examples/job-application/src/{model.fixture.ts → main.fixture.ts} +18 -17
- package/dist/templates/examples/job-application/src/main.ts +69 -0
- package/dist/templates/examples/job-application/src/message.ts +21 -0
- package/dist/templates/examples/job-application/src/model.ts +24 -15
- package/dist/templates/examples/job-application/src/scene.test.ts +3 -4
- package/dist/templates/examples/job-application/src/step/attachments/attachments.ts +106 -0
- package/dist/templates/examples/job-application/src/step/attachments/index.ts +2 -1
- package/dist/templates/examples/job-application/src/step/attachments/scene.test.ts +2 -3
- package/dist/templates/examples/job-application/src/step/attachments/story.test.ts +10 -22
- package/dist/templates/examples/job-application/src/step/attachments/view.ts +62 -65
- package/dist/templates/examples/job-application/src/step/coverLetter/{block.ts → coverLetter.ts} +25 -29
- package/dist/templates/examples/job-application/src/step/coverLetter/index.ts +1 -1
- package/dist/templates/examples/job-application/src/step/coverLetter/scene.test.ts +5 -5
- package/dist/templates/examples/job-application/src/step/coverLetter/story.test.ts +4 -6
- package/dist/templates/examples/job-application/src/step/education/education.ts +106 -0
- package/dist/templates/examples/job-application/src/step/education/entry/entry.ts +160 -0
- package/dist/templates/examples/job-application/src/step/education/entry/index.ts +11 -1
- package/dist/templates/examples/job-application/src/step/education/entry/story.test.ts +4 -6
- package/dist/templates/examples/job-application/src/step/education/entry/view.ts +47 -48
- package/dist/templates/examples/job-application/src/step/education/index.ts +12 -1
- package/dist/templates/examples/job-application/src/step/education/scene.test.ts +2 -3
- package/dist/templates/examples/job-application/src/step/education/story.test.ts +17 -38
- package/dist/templates/examples/job-application/src/step/education/view.ts +15 -19
- package/dist/templates/examples/job-application/src/step/index.ts +6 -9
- package/dist/templates/examples/job-application/src/step/personalInfo/index.ts +11 -1
- package/dist/templates/examples/job-application/src/step/personalInfo/personalInfo.ts +291 -0
- package/dist/templates/examples/job-application/src/step/personalInfo/scene.test.ts +4 -5
- package/dist/templates/examples/job-application/src/step/personalInfo/story.test.ts +3 -6
- package/dist/templates/examples/job-application/src/step/personalInfo/view.ts +76 -78
- package/dist/templates/examples/job-application/src/step/skills/entry/entry.ts +120 -0
- package/dist/templates/examples/job-application/src/step/skills/entry/index.ts +11 -1
- package/dist/templates/examples/job-application/src/step/skills/entry/story.test.ts +3 -5
- package/dist/templates/examples/job-application/src/step/skills/entry/view.ts +37 -38
- package/dist/templates/examples/job-application/src/step/skills/index.ts +12 -1
- package/dist/templates/examples/job-application/src/step/skills/scene.test.ts +2 -3
- package/dist/templates/examples/job-application/src/step/skills/skills.ts +103 -0
- package/dist/templates/examples/job-application/src/step/skills/story.test.ts +17 -39
- package/dist/templates/examples/job-application/src/step/skills/view.ts +13 -10
- package/dist/templates/examples/job-application/src/step/workHistory/entry/entry.ts +188 -0
- package/dist/templates/examples/job-application/src/step/workHistory/entry/index.ts +11 -1
- package/dist/templates/examples/job-application/src/step/workHistory/entry/story.test.ts +4 -6
- package/dist/templates/examples/job-application/src/step/workHistory/entry/view.ts +41 -43
- package/dist/templates/examples/job-application/src/step/workHistory/index.ts +12 -1
- package/dist/templates/examples/job-application/src/step/workHistory/scene.test.ts +2 -3
- package/dist/templates/examples/job-application/src/step/workHistory/story.test.ts +17 -41
- package/dist/templates/examples/job-application/src/step/workHistory/view.ts +16 -10
- package/dist/templates/examples/job-application/src/step/workHistory/workHistory.ts +106 -0
- package/dist/templates/examples/job-application/src/story.test.ts +70 -136
- package/dist/templates/examples/job-application/src/update.ts +163 -66
- package/dist/templates/examples/job-application/src/view/datePicker.ts +2 -2
- package/dist/templates/examples/job-application/src/view/preview.ts +10 -23
- package/dist/templates/examples/job-application/src/view/review.ts +34 -43
- package/dist/templates/examples/job-application/src/view/stepNav.ts +61 -67
- package/dist/templates/examples/job-application/src/view/view.ts +136 -160
- package/dist/templates/examples/kanban/package.json +4 -4
- package/dist/templates/examples/kanban/src/command.ts +35 -52
- package/dist/templates/examples/kanban/src/domain/card.ts +2 -0
- package/dist/templates/examples/kanban/src/domain/column.ts +13 -17
- package/dist/templates/examples/kanban/src/entry.ts +21 -8
- package/dist/templates/examples/kanban/src/main.ts +55 -0
- package/dist/templates/examples/kanban/src/message.ts +5 -0
- package/dist/templates/examples/kanban/src/model.ts +6 -2
- package/dist/templates/examples/kanban/src/scene.test.ts +5 -9
- package/dist/templates/examples/kanban/src/story.test.ts +69 -75
- package/dist/templates/examples/kanban/src/subscription.ts +17 -0
- package/dist/templates/examples/kanban/src/update.ts +185 -49
- package/dist/templates/examples/kanban/src/view/card.ts +21 -15
- package/dist/templates/examples/kanban/src/view/column.ts +55 -40
- package/dist/templates/examples/kanban/src/view/view.ts +19 -33
- package/dist/templates/examples/managed-resource-layer/package.json +4 -4
- package/dist/templates/examples/managed-resource-layer/src/entry.ts +12 -7
- package/dist/templates/examples/managed-resource-layer/src/{application.ts → main.ts} +93 -117
- package/dist/templates/examples/managed-resource-layer/src/scene.test.ts +2 -2
- package/dist/templates/examples/managed-resource-layer/src/story.test.ts +6 -12
- package/dist/templates/examples/map/package.json +4 -4
- package/dist/templates/examples/map/src/entry.ts +11 -7
- package/dist/templates/examples/map/src/locations.ts +2 -1
- package/dist/templates/examples/map/src/{model.fixture.ts → main.fixture.ts} +4 -4
- package/dist/templates/examples/map/src/main.ts +789 -0
- package/dist/templates/examples/map/src/mapHost.ts +21 -0
- package/dist/templates/examples/map/src/mount.test.ts +5 -9
- package/dist/templates/examples/map/src/scene.test.ts +12 -7
- package/dist/templates/examples/map/src/story.test.ts +10 -5
- package/dist/templates/examples/pixel-art/package.json +4 -4
- package/dist/templates/examples/pixel-art/src/command.ts +49 -53
- package/dist/templates/examples/pixel-art/src/comparison.bench.test.ts +7 -10
- package/dist/templates/examples/pixel-art/src/constant.ts +2 -2
- package/dist/templates/examples/pixel-art/src/entry.ts +21 -8
- package/dist/templates/examples/pixel-art/src/grid.ts +22 -31
- package/dist/templates/examples/pixel-art/src/{app.bench.ts → main.bench.ts} +14 -23
- package/dist/templates/examples/pixel-art/src/main.ts +84 -0
- package/dist/templates/examples/pixel-art/src/message.ts +10 -0
- package/dist/templates/examples/pixel-art/src/model.ts +19 -16
- package/dist/templates/examples/pixel-art/src/palette.ts +3 -7
- package/dist/templates/examples/pixel-art/src/scene.test.ts +50 -72
- package/dist/templates/examples/pixel-art/src/story.test.ts +29 -60
- package/dist/templates/examples/pixel-art/src/subscription.ts +29 -49
- package/dist/templates/examples/pixel-art/src/update.ts +443 -204
- package/dist/templates/examples/pixel-art/src/view/canvas.ts +9 -10
- package/dist/templates/examples/pixel-art/src/view/dialog.ts +135 -147
- package/dist/templates/examples/pixel-art/src/view/history.ts +9 -10
- package/dist/templates/examples/pixel-art/src/view/toolbar.ts +192 -197
- package/dist/templates/examples/pixel-art/src/view/view.ts +11 -11
- package/dist/templates/examples/query-sync/package.json +4 -4
- package/dist/templates/examples/query-sync/src/entry.ts +13 -8
- package/dist/templates/examples/query-sync/src/main.ts +893 -0
- package/dist/templates/examples/query-sync/src/scene.test.ts +10 -11
- package/dist/templates/examples/query-sync/src/story.test.ts +24 -25
- package/dist/templates/examples/route-transitions/package.json +4 -4
- package/dist/templates/examples/route-transitions/src/data.ts +3 -4
- package/dist/templates/examples/route-transitions/src/entry.ts +13 -8
- package/dist/templates/examples/route-transitions/src/{view.ts → main.ts} +286 -42
- package/dist/templates/examples/route-transitions/src/route.ts +9 -7
- package/dist/templates/examples/route-transitions/src/story.test.ts +29 -29
- package/dist/templates/examples/routing/package.json +4 -4
- package/dist/templates/examples/routing/src/entry.ts +14 -8
- package/dist/templates/examples/routing/src/fileTree.ts +2 -1
- package/dist/templates/examples/routing/src/{view.ts → main.ts} +204 -35
- package/dist/templates/examples/routing/src/page/index.ts +1 -1
- package/dist/templates/examples/routing/src/page/people.scene.test.ts +1 -3
- package/dist/templates/examples/routing/src/page/people.story.test.ts +10 -6
- package/dist/templates/examples/routing/src/page/people.ts +331 -0
- package/dist/templates/examples/routing/src/route.ts +12 -9
- package/dist/templates/examples/routing/src/scene.test.ts +12 -16
- package/dist/templates/examples/routing/src/story.test.ts +17 -26
- package/dist/templates/examples/shopping-cart/package.json +4 -4
- package/dist/templates/examples/shopping-cart/src/data/products.ts +1 -1
- package/dist/templates/examples/shopping-cart/src/domain/cart.ts +11 -13
- package/dist/templates/examples/shopping-cart/src/domain/item.ts +4 -0
- package/dist/templates/examples/shopping-cart/src/entry.ts +13 -8
- package/dist/templates/examples/shopping-cart/src/main.ts +299 -0
- package/dist/templates/examples/shopping-cart/src/page/cart.ts +5 -7
- package/dist/templates/examples/shopping-cart/src/page/checkout.ts +6 -5
- package/dist/templates/examples/shopping-cart/src/page/index.ts +1 -1
- package/dist/templates/examples/shopping-cart/src/page/{products/scene.test.ts → products.scene.test.ts} +3 -4
- package/dist/templates/examples/shopping-cart/src/page/{products/story.test.ts → products.story.test.ts} +6 -7
- package/dist/templates/examples/shopping-cart/src/page/{products/view.ts → products.ts} +97 -7
- package/dist/templates/examples/shopping-cart/src/route.ts +8 -9
- package/dist/templates/examples/shopping-cart/src/scene.test.ts +12 -16
- package/dist/templates/examples/shopping-cart/src/story.test.ts +15 -22
- package/dist/templates/examples/slow-warnings/package.json +4 -4
- package/dist/templates/examples/slow-warnings/src/entry.ts +20 -7
- package/dist/templates/examples/slow-warnings/src/handleSlow.test.ts +2 -4
- package/dist/templates/examples/slow-warnings/src/{view.ts → main.ts} +253 -31
- package/dist/templates/examples/slow-warnings/src/scene.test.ts +2 -4
- package/dist/templates/examples/slow-warnings/src/story.test.ts +2 -4
- package/dist/templates/examples/snake/package.json +4 -4
- package/dist/templates/examples/snake/src/domain/apple.ts +2 -2
- package/dist/templates/examples/snake/src/domain/direction.ts +5 -8
- package/dist/templates/examples/snake/src/domain/position.ts +6 -4
- package/dist/templates/examples/snake/src/domain/snake.ts +7 -16
- package/dist/templates/examples/snake/src/entry.ts +12 -6
- package/dist/templates/examples/snake/src/main.ts +338 -0
- package/dist/templates/examples/snake/src/scene.test.ts +2 -2
- package/dist/templates/examples/snake/src/story.test.ts +4 -9
- package/dist/templates/examples/ssg/package.json +4 -4
- package/dist/templates/examples/ssg/src/entry.server.ts +2 -3
- package/dist/templates/examples/ssg/src/entry.ts +13 -8
- package/dist/templates/examples/ssg/src/{application.ts → main.ts} +56 -75
- package/dist/templates/examples/ssg/src/route.ts +7 -8
- package/dist/templates/examples/ssr/package.json +6 -6
- package/dist/templates/examples/ssr/src/entry.server.ts +3 -4
- package/dist/templates/examples/ssr/src/entry.ts +11 -6
- package/dist/templates/examples/ssr/src/{application.ts → main.ts} +52 -63
- package/dist/templates/examples/ssr/src/scene.test.ts +1 -1
- package/dist/templates/examples/state-machine/package.json +4 -4
- package/dist/templates/examples/state-machine/src/entry.ts +12 -6
- package/dist/templates/examples/state-machine/src/{machine.ts → main.ts} +228 -5
- package/dist/templates/examples/state-machine/src/scene.test.ts +4 -8
- package/dist/templates/examples/state-machine/src/story.test.ts +35 -11
- package/dist/templates/examples/state-machine/src/view.ts +1621 -7
- package/dist/templates/examples/stopwatch/package.json +4 -4
- package/dist/templates/examples/stopwatch/src/entry.ts +12 -6
- package/dist/templates/examples/stopwatch/src/main.ts +230 -0
- package/dist/templates/examples/stopwatch/src/scene.test.ts +3 -13
- package/dist/templates/examples/stopwatch/src/story.test.ts +3 -3
- package/dist/templates/examples/todo/package.json +4 -4
- package/dist/templates/examples/todo/src/entry.ts +11 -10
- package/dist/templates/examples/todo/src/{view.ts → main.ts} +327 -37
- package/dist/templates/examples/todo/src/scene.test.ts +12 -8
- package/dist/templates/examples/todo/src/story.test.ts +16 -12
- package/dist/templates/examples/ui-showcase/package.json +4 -4
- package/dist/templates/examples/ui-showcase/src/entry.ts +23 -9
- package/dist/templates/examples/ui-showcase/src/main.ts +688 -0
- package/dist/templates/examples/ui-showcase/src/scene.test.ts +24 -29
- package/dist/templates/examples/ui-showcase/src/story.test.ts +20 -18
- package/dist/templates/examples/ui-showcase/src/ui/init.ts +133 -5
- package/dist/templates/examples/ui-showcase/src/ui/message.ts +61 -2
- package/dist/templates/examples/ui-showcase/src/ui/model.ts +99 -61
- package/dist/templates/examples/ui-showcase/src/ui/subscriptions.ts +49 -0
- package/dist/templates/examples/ui-showcase/src/ui/toast.ts +3 -2
- package/dist/templates/examples/ui-showcase/src/ui/update.ts +1184 -149
- package/dist/templates/examples/ui-showcase/src/ui/view/animation.ts +44 -37
- package/dist/templates/examples/ui-showcase/src/ui/view/button.ts +56 -51
- package/dist/templates/examples/ui-showcase/src/ui/view/calendar.ts +45 -36
- package/dist/templates/examples/ui-showcase/src/ui/view/checkbox.ts +69 -65
- package/dist/templates/examples/ui-showcase/src/ui/view/combobox.ts +141 -141
- package/dist/templates/examples/ui-showcase/src/ui/view/datePicker.ts +51 -40
- package/dist/templates/examples/ui-showcase/src/ui/view/dialog.ts +161 -151
- package/dist/templates/examples/ui-showcase/src/ui/view/disclosure.ts +180 -179
- package/dist/templates/examples/ui-showcase/src/ui/view/dragAndDrop.ts +78 -95
- package/dist/templates/examples/ui-showcase/src/ui/view/fieldset.ts +42 -40
- package/dist/templates/examples/ui-showcase/src/ui/view/fileDrop.ts +74 -65
- package/dist/templates/examples/ui-showcase/src/ui/view/hoverIntent.ts +62 -53
- package/dist/templates/examples/ui-showcase/src/ui/view/index.ts +0 -2
- package/dist/templates/examples/ui-showcase/src/ui/view/input.ts +73 -70
- package/dist/templates/examples/ui-showcase/src/ui/view/listbox.ts +124 -120
- package/dist/templates/examples/ui-showcase/src/ui/view/menu.ts +67 -60
- package/dist/templates/examples/ui-showcase/src/ui/view/meter.ts +79 -75
- package/dist/templates/examples/ui-showcase/src/ui/view/popover.ts +135 -124
- package/dist/templates/examples/ui-showcase/src/ui/view/progress.ts +81 -77
- package/dist/templates/examples/ui-showcase/src/ui/view/radioGroup.ts +120 -113
- package/dist/templates/examples/ui-showcase/src/ui/view/select.ts +97 -88
- package/dist/templates/examples/ui-showcase/src/ui/view/slider.ts +99 -91
- package/dist/templates/examples/ui-showcase/src/ui/view/switch.ts +47 -46
- package/dist/templates/examples/ui-showcase/src/ui/view/tabs.ts +89 -87
- package/dist/templates/examples/ui-showcase/src/ui/view/textarea.ts +76 -73
- package/dist/templates/examples/ui-showcase/src/ui/view/toast.ts +98 -95
- package/dist/templates/examples/ui-showcase/src/ui/view/tooltip.ts +98 -95
- package/dist/templates/examples/ui-showcase/src/ui/view/virtualList.ts +100 -79
- package/dist/templates/examples/view-transitions/package.json +4 -4
- package/dist/templates/examples/view-transitions/src/artwork.ts +3 -4
- package/dist/templates/examples/view-transitions/src/entry.ts +13 -8
- package/dist/templates/examples/view-transitions/src/{application.ts → main.ts} +73 -105
- package/dist/templates/examples/view-transitions/src/route.ts +7 -8
- package/dist/templates/examples/view-transitions/src/scene.test.ts +5 -15
- package/dist/templates/examples/weather/package.json +4 -4
- package/dist/templates/examples/weather/src/entry.ts +11 -7
- package/dist/templates/examples/weather/src/main.fixture.ts +59 -0
- package/dist/templates/examples/weather/src/main.ts +349 -0
- package/dist/templates/examples/weather/src/scene.test.ts +2 -6
- package/dist/templates/examples/weather/src/story.test.ts +82 -4
- package/dist/templates/examples/web-components/package.json +4 -4
- package/dist/templates/examples/web-components/src/entry.ts +11 -6
- package/dist/templates/examples/web-components/src/{application.ts → main.ts} +40 -60
- package/dist/templates/examples/web-components/src/scene.test.ts +1 -1
- package/dist/templates/examples/web-components/src/story.test.ts +2 -2
- package/dist/templates/examples/websocket-chat/package.json +4 -4
- package/dist/templates/examples/websocket-chat/src/entry.ts +21 -7
- package/dist/templates/examples/websocket-chat/src/main.ts +628 -0
- package/dist/templates/examples/websocket-chat/src/scene.test.ts +9 -21
- package/dist/templates/examples/websocket-chat/src/story.test.ts +7 -6
- package/dist/templates/release.json +14 -14
- package/dist/templates/rendering/ssg/src/entry.server.ts +2 -3
- package/dist/templates/rendering/ssg/src/entry.ts +14 -9
- package/dist/templates/rendering/ssg/src/{application.ts → main.ts} +56 -76
- package/dist/templates/rendering/ssg/src/route.ts +7 -8
- package/dist/templates/rendering/ssg/src/scene.test.ts +3 -6
- package/dist/templates/rendering/ssr/src/entry.server.ts +3 -4
- package/dist/templates/rendering/ssr/src/entry.ts +11 -6
- package/dist/templates/rendering/ssr/src/{application.ts → main.ts} +54 -57
- package/dist/templates/rendering/ssr/src/scene.test.ts +1 -1
- package/package.json +5 -5
- package/dist/templates/examples/api-cache/src/block.ts +0 -22
- package/dist/templates/examples/api-cache/src/command.ts +0 -69
- package/dist/templates/examples/api-cache/src/composition.ts +0 -77
- package/dist/templates/examples/api-cache/src/definition.ts +0 -11
- package/dist/templates/examples/api-cache/src/init.ts +0 -16
- package/dist/templates/examples/api-cache/src/layer.ts +0 -11
- package/dist/templates/examples/api-cache/src/message.ts +0 -23
- package/dist/templates/examples/api-cache/src/model.fixture.ts +0 -84
- package/dist/templates/examples/api-cache/src/model.ts +0 -40
- package/dist/templates/examples/api-cache/src/subscription.ts +0 -33
- package/dist/templates/examples/api-cache/src/update.ts +0 -75
- package/dist/templates/examples/api-cache/src/view/posts.ts +0 -254
- package/dist/templates/examples/api-cache/src/view/shared.ts +0 -63
- package/dist/templates/examples/api-cache/src/view/stats.ts +0 -140
- package/dist/templates/examples/api-cache/src/view/view.ts +0 -73
- package/dist/templates/examples/api-cache-query/src/block.ts +0 -21
- package/dist/templates/examples/api-cache-query/src/composition.ts +0 -48
- package/dist/templates/examples/api-cache-query/src/definition.ts +0 -11
- package/dist/templates/examples/api-cache-query/src/init.ts +0 -11
- package/dist/templates/examples/api-cache-query/src/message.ts +0 -13
- package/dist/templates/examples/api-cache-query/src/model.ts +0 -20
- package/dist/templates/examples/api-cache-query/src/query.ts +0 -75
- package/dist/templates/examples/api-cache-query/src/subscription.ts +0 -33
- package/dist/templates/examples/api-cache-query/src/update.ts +0 -33
- package/dist/templates/examples/api-cache-query/src/view/index.ts +0 -1
- package/dist/templates/examples/api-cache-query/src/view/posts.ts +0 -239
- package/dist/templates/examples/api-cache-query/src/view/shared.ts +0 -70
- package/dist/templates/examples/api-cache-query/src/view/stats.ts +0 -132
- package/dist/templates/examples/api-cache-query/src/view/view.ts +0 -99
- package/dist/templates/examples/auth/src/block.ts +0 -20
- package/dist/templates/examples/auth/src/composition/bindings.ts +0 -14
- package/dist/templates/examples/auth/src/composition/composition.ts +0 -10
- package/dist/templates/examples/auth/src/composition/index.ts +0 -2
- package/dist/templates/examples/auth/src/composition/loggedIn.ts +0 -22
- package/dist/templates/examples/auth/src/composition/loggedOut.ts +0 -22
- package/dist/templates/examples/auth/src/definition.ts +0 -12
- package/dist/templates/examples/auth/src/flags.ts +0 -26
- package/dist/templates/examples/auth/src/init.ts +0 -53
- package/dist/templates/examples/auth/src/page/loggedIn/block.ts +0 -18
- package/dist/templates/examples/auth/src/page/loggedIn/composition.ts +0 -17
- package/dist/templates/examples/auth/src/page/loggedIn/init.ts +0 -10
- package/dist/templates/examples/auth/src/page/loggedOut/block.ts +0 -18
- package/dist/templates/examples/auth/src/page/loggedOut/composition.ts +0 -21
- package/dist/templates/examples/auth/src/page/loggedOut/definition.ts +0 -10
- package/dist/templates/examples/auth/src/page/loggedOut/init.ts +0 -8
- package/dist/templates/examples/auth/src/page/loggedOut/page/login/block.ts +0 -18
- package/dist/templates/examples/auth/src/page/loggedOut/page/login/composition.ts +0 -6
- package/dist/templates/examples/auth/src/page/loggedOut/page/login/definition.ts +0 -32
- package/dist/templates/examples/auth/src/page/loggedOut/page/login/index.ts +0 -1
- package/dist/templates/examples/auth/src/page/loggedOut/page/login/login.ts +0 -126
- package/dist/templates/examples/auth/src/services.ts +0 -3
- package/dist/templates/examples/charting/src/block.ts +0 -20
- package/dist/templates/examples/charting/src/chartRegistry.ts +0 -42
- package/dist/templates/examples/charting/src/composition.ts +0 -122
- package/dist/templates/examples/charting/src/definition.ts +0 -11
- package/dist/templates/examples/charting/src/layer.ts +0 -10
- package/dist/templates/examples/charting/src/mount.ts +0 -130
- package/dist/templates/examples/charting/src/services.ts +0 -15
- package/dist/templates/examples/counters/src/application.ts +0 -171
- package/dist/templates/examples/embedding/src/application.ts +0 -156
- package/dist/templates/examples/form/src/block.ts +0 -20
- package/dist/templates/examples/form/src/command.ts +0 -71
- package/dist/templates/examples/form/src/composition.ts +0 -8
- package/dist/templates/examples/form/src/definition.ts +0 -11
- package/dist/templates/examples/form/src/init.ts +0 -15
- package/dist/templates/examples/form/src/message.ts +0 -13
- package/dist/templates/examples/form/src/model.ts +0 -17
- package/dist/templates/examples/form/src/update.ts +0 -72
- package/dist/templates/examples/form/src/validation.ts +0 -21
- package/dist/templates/examples/generative-art/src/block.ts +0 -22
- package/dist/templates/examples/generative-art/src/composition.ts +0 -65
- package/dist/templates/examples/generative-art/src/definition.ts +0 -11
- package/dist/templates/examples/generative-art/src/init.ts +0 -42
- package/dist/templates/examples/generative-art/src/layer.ts +0 -10
- package/dist/templates/examples/interrupting-commands/src/block.ts +0 -20
- package/dist/templates/examples/interrupting-commands/src/command.ts +0 -33
- package/dist/templates/examples/interrupting-commands/src/composition.ts +0 -8
- package/dist/templates/examples/interrupting-commands/src/definition.ts +0 -11
- package/dist/templates/examples/interrupting-commands/src/init.ts +0 -8
- package/dist/templates/examples/interrupting-commands/src/message.ts +0 -15
- package/dist/templates/examples/interrupting-commands/src/model.ts +0 -15
- package/dist/templates/examples/interrupting-commands/src/update.ts +0 -99
- package/dist/templates/examples/interrupting-commands/src/view.ts +0 -175
- package/dist/templates/examples/job-application/src/block.ts +0 -20
- package/dist/templates/examples/job-application/src/composition.ts +0 -118
- package/dist/templates/examples/job-application/src/definition.ts +0 -13
- package/dist/templates/examples/job-application/src/flags.ts +0 -25
- package/dist/templates/examples/job-application/src/init.ts +0 -15
- package/dist/templates/examples/job-application/src/navigationComponents.ts +0 -6
- package/dist/templates/examples/job-application/src/services.ts +0 -3
- package/dist/templates/examples/job-application/src/step/attachments/block.ts +0 -18
- package/dist/templates/examples/job-application/src/step/attachments/composition.ts +0 -50
- package/dist/templates/examples/job-application/src/step/attachments/definition.ts +0 -24
- package/dist/templates/examples/job-application/src/step/attachments/init.ts +0 -10
- package/dist/templates/examples/job-application/src/step/attachments/update.ts +0 -14
- package/dist/templates/examples/job-application/src/step/education/block.ts +0 -22
- package/dist/templates/examples/job-application/src/step/education/command.ts +0 -28
- package/dist/templates/examples/job-application/src/step/education/composition.ts +0 -36
- package/dist/templates/examples/job-application/src/step/education/definition.ts +0 -30
- package/dist/templates/examples/job-application/src/step/education/entry/block.ts +0 -20
- package/dist/templates/examples/job-application/src/step/education/entry/composition.ts +0 -30
- package/dist/templates/examples/job-application/src/step/education/entry/definition.ts +0 -40
- package/dist/templates/examples/job-application/src/step/education/entry/init.ts +0 -16
- package/dist/templates/examples/job-application/src/step/education/entry/update.ts +0 -67
- package/dist/templates/examples/job-application/src/step/education/init.ts +0 -10
- package/dist/templates/examples/job-application/src/step/education/update.ts +0 -47
- package/dist/templates/examples/job-application/src/step/personalInfo/block.ts +0 -22
- package/dist/templates/examples/job-application/src/step/personalInfo/command.ts +0 -46
- package/dist/templates/examples/job-application/src/step/personalInfo/composition.ts +0 -55
- package/dist/templates/examples/job-application/src/step/personalInfo/definition.ts +0 -45
- package/dist/templates/examples/job-application/src/step/personalInfo/init.ts +0 -20
- package/dist/templates/examples/job-application/src/step/personalInfo/update.ts +0 -130
- package/dist/templates/examples/job-application/src/step/skills/block.ts +0 -22
- package/dist/templates/examples/job-application/src/step/skills/command.ts +0 -28
- package/dist/templates/examples/job-application/src/step/skills/composition.ts +0 -29
- package/dist/templates/examples/job-application/src/step/skills/definition.ts +0 -26
- package/dist/templates/examples/job-application/src/step/skills/entry/block.ts +0 -20
- package/dist/templates/examples/job-application/src/step/skills/entry/composition.ts +0 -29
- package/dist/templates/examples/job-application/src/step/skills/entry/definition.ts +0 -37
- package/dist/templates/examples/job-application/src/step/skills/entry/init.ts +0 -12
- package/dist/templates/examples/job-application/src/step/skills/entry/update.ts +0 -38
- package/dist/templates/examples/job-application/src/step/skills/init.ts +0 -6
- package/dist/templates/examples/job-application/src/step/skills/update.ts +0 -47
- package/dist/templates/examples/job-application/src/step/workHistory/block.ts +0 -22
- package/dist/templates/examples/job-application/src/step/workHistory/command.ts +0 -28
- package/dist/templates/examples/job-application/src/step/workHistory/composition.ts +0 -32
- package/dist/templates/examples/job-application/src/step/workHistory/definition.ts +0 -30
- package/dist/templates/examples/job-application/src/step/workHistory/entry/block.ts +0 -20
- package/dist/templates/examples/job-application/src/step/workHistory/entry/composition.ts +0 -88
- package/dist/templates/examples/job-application/src/step/workHistory/entry/definition.ts +0 -48
- package/dist/templates/examples/job-application/src/step/workHistory/entry/init.ts +0 -20
- package/dist/templates/examples/job-application/src/step/workHistory/entry/update.ts +0 -60
- package/dist/templates/examples/job-application/src/step/workHistory/init.ts +0 -10
- package/dist/templates/examples/job-application/src/step/workHistory/update.ts +0 -47
- package/dist/templates/examples/kanban/src/block.ts +0 -20
- package/dist/templates/examples/kanban/src/composition/composition.ts +0 -11
- package/dist/templates/examples/kanban/src/composition/dragAndDrop.ts +0 -92
- package/dist/templates/examples/kanban/src/composition/index.ts +0 -3
- package/dist/templates/examples/kanban/src/definition.ts +0 -11
- package/dist/templates/examples/kanban/src/flags.ts +0 -23
- package/dist/templates/examples/kanban/src/init.ts +0 -23
- package/dist/templates/examples/kanban/src/services.ts +0 -8
- package/dist/templates/examples/managed-resource-layer/src/services.ts +0 -3
- package/dist/templates/examples/map/src/block.ts +0 -20
- package/dist/templates/examples/map/src/command.ts +0 -147
- package/dist/templates/examples/map/src/composition.ts +0 -11
- package/dist/templates/examples/map/src/definition.ts +0 -11
- package/dist/templates/examples/map/src/init.ts +0 -20
- package/dist/templates/examples/map/src/layer.ts +0 -19
- package/dist/templates/examples/map/src/mapRegistry.ts +0 -42
- package/dist/templates/examples/map/src/message.ts +0 -25
- package/dist/templates/examples/map/src/model.ts +0 -30
- package/dist/templates/examples/map/src/mount.ts +0 -173
- package/dist/templates/examples/map/src/services.ts +0 -3
- package/dist/templates/examples/map/src/update.ts +0 -101
- package/dist/templates/examples/map/src/view.ts +0 -346
- package/dist/templates/examples/pixel-art/src/block.ts +0 -22
- package/dist/templates/examples/pixel-art/src/components.ts +0 -12
- package/dist/templates/examples/pixel-art/src/composition.ts +0 -199
- package/dist/templates/examples/pixel-art/src/definition.ts +0 -12
- package/dist/templates/examples/pixel-art/src/flags.ts +0 -23
- package/dist/templates/examples/pixel-art/src/init.ts +0 -41
- package/dist/templates/examples/pixel-art/src/layer.ts +0 -10
- package/dist/templates/examples/pixel-art/src/services.ts +0 -3
- package/dist/templates/examples/query-sync/src/block.ts +0 -20
- package/dist/templates/examples/query-sync/src/command.ts +0 -52
- package/dist/templates/examples/query-sync/src/composition.ts +0 -75
- package/dist/templates/examples/query-sync/src/definition.ts +0 -12
- package/dist/templates/examples/query-sync/src/init.ts +0 -12
- package/dist/templates/examples/query-sync/src/message.ts +0 -16
- package/dist/templates/examples/query-sync/src/model.ts +0 -16
- package/dist/templates/examples/query-sync/src/route.ts +0 -172
- package/dist/templates/examples/query-sync/src/update.ts +0 -57
- package/dist/templates/examples/query-sync/src/view.ts +0 -531
- package/dist/templates/examples/route-transitions/src/block.ts +0 -20
- package/dist/templates/examples/route-transitions/src/command.ts +0 -71
- package/dist/templates/examples/route-transitions/src/composition.ts +0 -8
- package/dist/templates/examples/route-transitions/src/definition.ts +0 -12
- package/dist/templates/examples/route-transitions/src/init.ts +0 -21
- package/dist/templates/examples/route-transitions/src/message.ts +0 -15
- package/dist/templates/examples/route-transitions/src/model.ts +0 -27
- package/dist/templates/examples/route-transitions/src/transition.ts +0 -99
- package/dist/templates/examples/route-transitions/src/update.ts +0 -60
- package/dist/templates/examples/routing/src/block.ts +0 -22
- package/dist/templates/examples/routing/src/command.ts +0 -26
- package/dist/templates/examples/routing/src/composition.ts +0 -19
- package/dist/templates/examples/routing/src/definition.ts +0 -14
- package/dist/templates/examples/routing/src/init.ts +0 -19
- package/dist/templates/examples/routing/src/layer.ts +0 -10
- package/dist/templates/examples/routing/src/message.ts +0 -14
- package/dist/templates/examples/routing/src/model.ts +0 -9
- package/dist/templates/examples/routing/src/page/people/block.ts +0 -24
- package/dist/templates/examples/routing/src/page/people/command.ts +0 -34
- package/dist/templates/examples/routing/src/page/people/composition.ts +0 -6
- package/dist/templates/examples/routing/src/page/people/definition.ts +0 -12
- package/dist/templates/examples/routing/src/page/people/index.ts +0 -1
- package/dist/templates/examples/routing/src/page/people/message.ts +0 -16
- package/dist/templates/examples/routing/src/page/people/model.ts +0 -71
- package/dist/templates/examples/routing/src/page/people/update.ts +0 -59
- package/dist/templates/examples/routing/src/page/people/view.ts +0 -149
- package/dist/templates/examples/routing/src/subscription.ts +0 -37
- package/dist/templates/examples/routing/src/update.ts +0 -82
- package/dist/templates/examples/shopping-cart/src/block.ts +0 -20
- package/dist/templates/examples/shopping-cart/src/command.ts +0 -31
- package/dist/templates/examples/shopping-cart/src/composition.ts +0 -36
- package/dist/templates/examples/shopping-cart/src/definition.ts +0 -11
- package/dist/templates/examples/shopping-cart/src/init.ts +0 -15
- package/dist/templates/examples/shopping-cart/src/message.ts +0 -17
- package/dist/templates/examples/shopping-cart/src/model.ts +0 -13
- package/dist/templates/examples/shopping-cart/src/page/products/block.ts +0 -18
- package/dist/templates/examples/shopping-cart/src/page/products/composition.ts +0 -3
- package/dist/templates/examples/shopping-cart/src/page/products/definition.ts +0 -32
- package/dist/templates/examples/shopping-cart/src/page/products/index.ts +0 -1
- package/dist/templates/examples/shopping-cart/src/page/products/products.ts +0 -60
- package/dist/templates/examples/shopping-cart/src/update.ts +0 -47
- package/dist/templates/examples/shopping-cart/src/view.ts +0 -145
- package/dist/templates/examples/slow-warnings/src/block.ts +0 -21
- package/dist/templates/examples/slow-warnings/src/composition.ts +0 -8
- package/dist/templates/examples/slow-warnings/src/definition.ts +0 -11
- package/dist/templates/examples/slow-warnings/src/init.ts +0 -12
- package/dist/templates/examples/slow-warnings/src/message.ts +0 -12
- package/dist/templates/examples/slow-warnings/src/model.ts +0 -33
- package/dist/templates/examples/slow-warnings/src/subscription.ts +0 -111
- package/dist/templates/examples/slow-warnings/src/update.ts +0 -48
- package/dist/templates/examples/slow-warnings/src/workload.ts +0 -19
- package/dist/templates/examples/snake/src/application.ts +0 -365
- package/dist/templates/examples/state-machine/src/block.ts +0 -20
- package/dist/templates/examples/state-machine/src/command.ts +0 -22
- package/dist/templates/examples/state-machine/src/composition.ts +0 -36
- package/dist/templates/examples/state-machine/src/definition.ts +0 -11
- package/dist/templates/examples/state-machine/src/init.ts +0 -13
- package/dist/templates/examples/state-machine/src/message.ts +0 -16
- package/dist/templates/examples/state-machine/src/model.ts +0 -68
- package/dist/templates/examples/state-machine/src/transition.ts +0 -51
- package/dist/templates/examples/state-machine/src/update.ts +0 -23
- package/dist/templates/examples/state-machine/src/view/analysis.ts +0 -172
- package/dist/templates/examples/state-machine/src/view/cart.ts +0 -213
- package/dist/templates/examples/state-machine/src/view/checkout.ts +0 -201
- package/dist/templates/examples/state-machine/src/view/header.ts +0 -193
- package/dist/templates/examples/state-machine/src/view/payment.ts +0 -176
- package/dist/templates/examples/state-machine/src/view/review.ts +0 -322
- package/dist/templates/examples/state-machine/src/view/shared.ts +0 -136
- package/dist/templates/examples/state-machine/src/view/shipping.ts +0 -179
- package/dist/templates/examples/state-machine/src/view/status.ts +0 -131
- package/dist/templates/examples/stopwatch/src/application.ts +0 -260
- package/dist/templates/examples/todo/src/block.ts +0 -20
- package/dist/templates/examples/todo/src/command.ts +0 -42
- package/dist/templates/examples/todo/src/composition.ts +0 -8
- package/dist/templates/examples/todo/src/definition.ts +0 -11
- package/dist/templates/examples/todo/src/flags.ts +0 -20
- package/dist/templates/examples/todo/src/init.ts +0 -16
- package/dist/templates/examples/todo/src/message.ts +0 -25
- package/dist/templates/examples/todo/src/model.ts +0 -29
- package/dist/templates/examples/todo/src/services.ts +0 -3
- package/dist/templates/examples/todo/src/update.ts +0 -161
- package/dist/templates/examples/ui-showcase/src/block.ts +0 -20
- package/dist/templates/examples/ui-showcase/src/command.ts +0 -31
- package/dist/templates/examples/ui-showcase/src/composition.ts +0 -16
- package/dist/templates/examples/ui-showcase/src/definition.ts +0 -13
- package/dist/templates/examples/ui-showcase/src/flags.ts +0 -12
- package/dist/templates/examples/ui-showcase/src/init.ts +0 -14
- package/dist/templates/examples/ui-showcase/src/message.ts +0 -11
- package/dist/templates/examples/ui-showcase/src/model.ts +0 -9
- package/dist/templates/examples/ui-showcase/src/route.ts +0 -208
- package/dist/templates/examples/ui-showcase/src/ui/block.ts +0 -21
- package/dist/templates/examples/ui-showcase/src/ui/combobox.ts +0 -6
- package/dist/templates/examples/ui-showcase/src/ui/composition/animation.ts +0 -22
- package/dist/templates/examples/ui-showcase/src/ui/composition/composition.ts +0 -556
- package/dist/templates/examples/ui-showcase/src/ui/composition/dragAndDrop.ts +0 -71
- package/dist/templates/examples/ui-showcase/src/ui/composition/index.ts +0 -42
- package/dist/templates/examples/ui-showcase/src/ui/definition.ts +0 -13
- package/dist/templates/examples/ui-showcase/src/ui/domain/domain.ts +0 -37
- package/dist/templates/examples/ui-showcase/src/ui/domain/index.ts +0 -8
- package/dist/templates/examples/ui-showcase/src/ui/index.ts +0 -1
- package/dist/templates/examples/ui-showcase/src/ui/listbox.ts +0 -13
- package/dist/templates/examples/ui-showcase/src/ui/menu.ts +0 -5
- package/dist/templates/examples/ui-showcase/src/ui/radioGroup.ts +0 -5
- package/dist/templates/examples/ui-showcase/src/ui/tabs.ts +0 -5
- package/dist/templates/examples/ui-showcase/src/ui/view/mobileMenu.ts +0 -48
- package/dist/templates/examples/ui-showcase/src/ui/virtualList.ts +0 -16
- package/dist/templates/examples/ui-showcase/src/update.ts +0 -38
- package/dist/templates/examples/ui-showcase/src/view.ts +0 -412
- package/dist/templates/examples/weather/src/block.ts +0 -20
- package/dist/templates/examples/weather/src/command.ts +0 -141
- package/dist/templates/examples/weather/src/composition.ts +0 -8
- package/dist/templates/examples/weather/src/definition.ts +0 -11
- package/dist/templates/examples/weather/src/init.ts +0 -9
- package/dist/templates/examples/weather/src/message.ts +0 -11
- package/dist/templates/examples/weather/src/model.fixture.ts +0 -16
- package/dist/templates/examples/weather/src/model.ts +0 -19
- package/dist/templates/examples/weather/src/services.ts +0 -3
- package/dist/templates/examples/weather/src/update.ts +0 -30
- package/dist/templates/examples/weather/src/view.ts +0 -149
- package/dist/templates/examples/websocket-chat/src/block.ts +0 -24
- package/dist/templates/examples/websocket-chat/src/chatSocket.ts +0 -6
- package/dist/templates/examples/websocket-chat/src/command.ts +0 -69
- package/dist/templates/examples/websocket-chat/src/composition.ts +0 -8
- package/dist/templates/examples/websocket-chat/src/definition.ts +0 -12
- package/dist/templates/examples/websocket-chat/src/init.ts +0 -10
- package/dist/templates/examples/websocket-chat/src/layer.ts +0 -17
- package/dist/templates/examples/websocket-chat/src/managedResource.ts +0 -75
- package/dist/templates/examples/websocket-chat/src/message.ts +0 -21
- package/dist/templates/examples/websocket-chat/src/model.ts +0 -21
- package/dist/templates/examples/websocket-chat/src/services.ts +0 -3
- package/dist/templates/examples/websocket-chat/src/subscription.ts +0 -80
- package/dist/templates/examples/websocket-chat/src/update.ts +0 -78
- 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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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,
|
|
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 `
|
|
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
|
-
|
|
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 =
|
|
80
|
-
|
|
81
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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 `
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
109
|
+
### File Organization
|
|
204
110
|
|
|
205
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 `
|
|
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 `
|
|
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
|
-
-
|
|
263
|
-
-
|
|
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
|
-
-
|
|
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
|
-
|
|
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),
|
|
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.
|
|
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
|
|
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.
|
|
12
|
+
"@effect/platform-browser": "4.1.0",
|
|
13
13
|
"@foldkit/ui": "workspace:*",
|
|
14
|
-
"effect": "4.
|
|
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.
|
|
24
|
-
"vite": "^8.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<
|
|
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 {
|
|
1
|
+
import { Runtime } from 'foldkit'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { Message, Model, init, subscriptions, update, view } from './main'
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
|
|
5
|
+
const application = Runtime.makeApplication({
|
|
6
|
+
Model,
|
|
7
|
+
init,
|
|
8
|
+
update,
|
|
9
|
+
view,
|
|
10
|
+
subscriptions,
|
|
7
11
|
container: document.getElementById('root'),
|
|
8
|
-
devTools: {
|
|
12
|
+
devTools: {
|
|
13
|
+
Message,
|
|
14
|
+
},
|
|
9
15
|
})
|
|
10
16
|
|
|
11
|
-
Runtime.run(
|
|
17
|
+
Runtime.run(application)
|