create-foldkit-app 0.31.1 → 0.32.0-canary.0053b7691fcd

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/dist/templates/base/FOLDKIT.md +5 -3
  2. package/dist/templates/examples/api-cache/package.json +7 -7
  3. package/dist/templates/examples/api-cache/src/data.ts +14 -14
  4. package/dist/templates/examples/api-cache/src/main.ts +36 -33
  5. package/dist/templates/examples/auth/package.json +7 -7
  6. package/dist/templates/examples/auth/src/command.ts +3 -3
  7. package/dist/templates/examples/auth/src/domain/session.ts +8 -6
  8. package/dist/templates/examples/auth/src/main.ts +11 -11
  9. package/dist/templates/examples/auth/src/message.ts +3 -3
  10. package/dist/templates/examples/auth/src/model.ts +2 -2
  11. package/dist/templates/examples/auth/src/page/loggedIn/view.ts +3 -3
  12. package/dist/templates/examples/auth/src/page/loggedOut/page/login.ts +37 -52
  13. package/dist/templates/examples/auth/src/page/loggedOut/update.ts +3 -3
  14. package/dist/templates/examples/auth/src/page/loggedOut/view.ts +3 -3
  15. package/dist/templates/examples/auth/src/route.ts +2 -2
  16. package/dist/templates/examples/auth/src/update.ts +35 -35
  17. package/dist/templates/examples/auth/src/view.ts +6 -6
  18. package/dist/templates/examples/canvas-art/package.json +7 -7
  19. package/dist/templates/examples/canvas-art/src/main.ts +22 -30
  20. package/dist/templates/examples/charting/package.json +7 -7
  21. package/dist/templates/examples/charting/src/command.ts +3 -3
  22. package/dist/templates/examples/charting/src/domain.ts +53 -48
  23. package/dist/templates/examples/charting/src/echarts.ts +6 -6
  24. package/dist/templates/examples/charting/src/githubApi.ts +33 -34
  25. package/dist/templates/examples/charting/src/http.ts +7 -7
  26. package/dist/templates/examples/charting/src/message.ts +6 -6
  27. package/dist/templates/examples/charting/src/model.ts +6 -6
  28. package/dist/templates/examples/charting/src/npmApi.ts +19 -15
  29. package/dist/templates/examples/charting/src/subscription.ts +5 -5
  30. package/dist/templates/examples/charting/src/telemetry.test.ts +18 -12
  31. package/dist/templates/examples/charting/src/telemetry.ts +11 -18
  32. package/dist/templates/examples/charting/src/update.ts +10 -10
  33. package/dist/templates/examples/charting/src/view/chart.ts +44 -46
  34. package/dist/templates/examples/counter/package.json +7 -7
  35. package/dist/templates/examples/counter/src/main.ts +2 -2
  36. package/dist/templates/examples/counters/package.json +7 -7
  37. package/dist/templates/examples/counters/src/counter.ts +2 -2
  38. package/dist/templates/examples/counters/src/main.ts +8 -8
  39. package/dist/templates/examples/crash-view/package.json +7 -7
  40. package/dist/templates/examples/embedding/package.json +7 -7
  41. package/dist/templates/examples/embedding/src/main.ts +10 -7
  42. package/dist/templates/examples/form/package.json +7 -7
  43. package/dist/templates/examples/form/src/main.ts +76 -87
  44. package/dist/templates/examples/generative-art/package.json +7 -7
  45. package/dist/templates/examples/generative-art/src/command.ts +7 -2
  46. package/dist/templates/examples/generative-art/src/message.ts +14 -14
  47. package/dist/templates/examples/generative-art/src/model.ts +21 -21
  48. package/dist/templates/examples/generative-art/src/update.ts +7 -7
  49. package/dist/templates/examples/interrupting-commands/package.json +7 -7
  50. package/dist/templates/examples/interrupting-commands/src/main.ts +36 -36
  51. package/dist/templates/examples/job-application/package.json +7 -7
  52. package/dist/templates/examples/job-application/src/domain/proficiencyLevel.ts +2 -2
  53. package/dist/templates/examples/job-application/src/domain/pronounOption.ts +2 -2
  54. package/dist/templates/examples/job-application/src/domain/step.ts +11 -11
  55. package/dist/templates/examples/job-application/src/main.ts +5 -5
  56. package/dist/templates/examples/job-application/src/message.ts +2 -2
  57. package/dist/templates/examples/job-application/src/model.ts +5 -5
  58. package/dist/templates/examples/job-application/src/step/attachments.ts +21 -20
  59. package/dist/templates/examples/job-application/src/step/coverLetter.ts +4 -4
  60. package/dist/templates/examples/job-application/src/step/education/education.ts +9 -9
  61. package/dist/templates/examples/job-application/src/step/education/entry.ts +23 -22
  62. package/dist/templates/examples/job-application/src/step/personalInfo.ts +30 -38
  63. package/dist/templates/examples/job-application/src/step/skills/entry.ts +8 -8
  64. package/dist/templates/examples/job-application/src/step/skills/skills.ts +9 -9
  65. package/dist/templates/examples/job-application/src/step/workHistory/entry.ts +19 -19
  66. package/dist/templates/examples/job-application/src/step/workHistory/workHistory.ts +9 -9
  67. package/dist/templates/examples/job-application/src/update.ts +7 -7
  68. package/dist/templates/examples/job-application/src/view/attachments.ts +5 -5
  69. package/dist/templates/examples/job-application/src/view/datePicker.ts +3 -3
  70. package/dist/templates/examples/job-application/src/view/education.ts +31 -32
  71. package/dist/templates/examples/job-application/src/view/field.ts +12 -13
  72. package/dist/templates/examples/job-application/src/view/index.ts +28 -22
  73. package/dist/templates/examples/job-application/src/view/workHistory.ts +40 -41
  74. package/dist/templates/examples/kanban/package.json +8 -8
  75. package/dist/templates/examples/kanban/src/command.ts +4 -4
  76. package/dist/templates/examples/kanban/src/domain/card.ts +6 -6
  77. package/dist/templates/examples/kanban/src/domain/column.ts +9 -9
  78. package/dist/templates/examples/kanban/src/main.ts +4 -4
  79. package/dist/templates/examples/kanban/src/message.ts +6 -6
  80. package/dist/templates/examples/kanban/src/model.ts +11 -9
  81. package/dist/templates/examples/kanban/src/update.ts +5 -5
  82. package/dist/templates/examples/managed-resource-layer/package.json +7 -7
  83. package/dist/templates/examples/managed-resource-layer/src/main.ts +30 -31
  84. package/dist/templates/examples/map/package.json +8 -8
  85. package/dist/templates/examples/map/src/locations.ts +7 -7
  86. package/dist/templates/examples/map/src/main.ts +89 -93
  87. package/dist/templates/examples/map/src/vite-env.d.ts +1 -0
  88. package/dist/templates/examples/pixel-art/package.json +7 -7
  89. package/dist/templates/examples/pixel-art/src/command.ts +12 -5
  90. package/dist/templates/examples/pixel-art/src/main.ts +4 -4
  91. package/dist/templates/examples/pixel-art/src/message.ts +7 -7
  92. package/dist/templates/examples/pixel-art/src/model.ts +34 -29
  93. package/dist/templates/examples/pixel-art/src/scene.test.ts +3 -3
  94. package/dist/templates/examples/pixel-art/src/story.test.ts +3 -3
  95. package/dist/templates/examples/pixel-art/src/subscription.ts +2 -2
  96. package/dist/templates/examples/pixel-art/src/update.ts +62 -57
  97. package/dist/templates/examples/query-sync/package.json +7 -7
  98. package/dist/templates/examples/query-sync/src/main.ts +101 -103
  99. package/dist/templates/examples/route-transitions/package.json +7 -7
  100. package/dist/templates/examples/route-transitions/src/data.ts +6 -6
  101. package/dist/templates/examples/route-transitions/src/main.ts +47 -61
  102. package/dist/templates/examples/route-transitions/src/route.ts +3 -3
  103. package/dist/templates/examples/routing/package.json +7 -7
  104. package/dist/templates/examples/routing/src/fileTree.ts +10 -8
  105. package/dist/templates/examples/routing/src/main.ts +47 -51
  106. package/dist/templates/examples/routing/src/page/people.ts +94 -108
  107. package/dist/templates/examples/routing/src/route.ts +7 -7
  108. package/dist/templates/examples/shopping-cart/package.json +7 -7
  109. package/dist/templates/examples/shopping-cart/src/main.ts +32 -38
  110. package/dist/templates/examples/shopping-cart/src/page/products.ts +10 -10
  111. package/dist/templates/examples/shopping-cart/src/route.ts +6 -4
  112. package/dist/templates/examples/slow-warnings/package.json +7 -7
  113. package/dist/templates/examples/slow-warnings/src/main.ts +35 -43
  114. package/dist/templates/examples/snake/package.json +7 -7
  115. package/dist/templates/examples/snake/src/domain/snake.ts +2 -2
  116. package/dist/templates/examples/snake/src/main.ts +39 -47
  117. package/dist/templates/examples/ssg/package.json +6 -8
  118. package/dist/templates/examples/ssg/src/main.ts +69 -79
  119. package/dist/templates/examples/ssg/src/route.ts +2 -2
  120. package/dist/templates/examples/ssr/package.json +8 -9
  121. package/dist/templates/examples/ssr/src/cookie.ts +3 -3
  122. package/dist/templates/examples/ssr/src/main.ts +10 -10
  123. package/dist/templates/examples/state-machine/package.json +7 -7
  124. package/dist/templates/examples/state-machine/src/main.ts +57 -53
  125. package/dist/templates/examples/state-machine/src/view.ts +57 -66
  126. package/dist/templates/examples/stopwatch/package.json +7 -7
  127. package/dist/templates/examples/stopwatch/src/main.ts +10 -10
  128. package/dist/templates/examples/todo/package.json +7 -7
  129. package/dist/templates/examples/todo/src/main.ts +70 -71
  130. package/dist/templates/examples/ui-showcase/package.json +7 -7
  131. package/dist/templates/examples/ui-showcase/src/main.ts +61 -54
  132. package/dist/templates/examples/ui-showcase/src/scene.test.ts +11 -0
  133. package/dist/templates/examples/ui-showcase/src/ui/init.ts +2 -0
  134. package/dist/templates/examples/ui-showcase/src/ui/message.ts +17 -15
  135. package/dist/templates/examples/ui-showcase/src/ui/model.ts +50 -44
  136. package/dist/templates/examples/ui-showcase/src/ui/toast.ts +4 -4
  137. package/dist/templates/examples/ui-showcase/src/ui/update.ts +108 -84
  138. package/dist/templates/examples/ui-showcase/src/ui/view/calendar.ts +3 -3
  139. package/dist/templates/examples/ui-showcase/src/ui/view/datePicker.ts +3 -3
  140. package/dist/templates/examples/ui-showcase/src/ui/view/fileDrop.ts +5 -5
  141. package/dist/templates/examples/ui-showcase/src/ui/view/hoverIntent.ts +78 -0
  142. package/dist/templates/examples/ui-showcase/src/ui/view/index.ts +1 -0
  143. package/dist/templates/examples/ui-showcase/src/ui/view/menu.ts +14 -14
  144. package/dist/templates/examples/ui-showcase/src/ui/view/tabs.ts +6 -6
  145. package/dist/templates/examples/ui-showcase/src/ui/view/toast.ts +7 -7
  146. package/dist/templates/examples/ui-showcase/src/ui/view/virtualList.ts +6 -6
  147. package/dist/templates/examples/view-transitions/package.json +7 -7
  148. package/dist/templates/examples/view-transitions/src/artwork.ts +7 -7
  149. package/dist/templates/examples/view-transitions/src/main.ts +34 -45
  150. package/dist/templates/examples/view-transitions/src/route.ts +3 -3
  151. package/dist/templates/examples/weather/package.json +7 -7
  152. package/dist/templates/examples/weather/src/main.ts +42 -42
  153. package/dist/templates/examples/weather/src/story.test.ts +5 -5
  154. package/dist/templates/examples/web-components/package.json +7 -7
  155. package/dist/templates/examples/web-components/src/main.ts +16 -16
  156. package/dist/templates/examples/websocket-chat/package.json +7 -7
  157. package/dist/templates/examples/websocket-chat/src/main.ts +52 -62
  158. package/dist/templates/release.json +19 -19
  159. package/dist/templates/rendering/ssg/README.md +8 -7
  160. package/dist/templates/rendering/ssg/package.json +2 -2
  161. package/dist/templates/rendering/ssg/src/main.ts +65 -74
  162. package/dist/templates/rendering/ssg/src/route.ts +2 -2
  163. package/dist/templates/rendering/ssg/tsconfig.json +1 -1
  164. package/dist/templates/rendering/ssg/vite.config.ts +22 -1
  165. package/dist/templates/rendering/ssr/README.md +10 -7
  166. package/dist/templates/rendering/ssr/package.json +2 -2
  167. package/dist/templates/rendering/ssr/server/main.ts +15 -15
  168. package/dist/templates/rendering/ssr/src/cookie.ts +3 -3
  169. package/dist/templates/rendering/ssr/src/main.ts +10 -10
  170. package/dist/templates/rendering/ssr/vite.config.ts +22 -1
  171. package/package.json +5 -5
  172. package/dist/templates/rendering/ssg/scripts/build.mjs +0 -27
  173. package/dist/templates/rendering/ssg/scripts/prerender.ts +0 -120
  174. package/dist/templates/rendering/ssr/scripts/build.mjs +0 -23
@@ -74,7 +74,7 @@ Use `evo()` from `foldkit/struct` for immutable model updates. Never spread or `
74
74
 
75
75
  ### View
76
76
 
77
- 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, `M.value().pipe(M.tagsExhaustive({...}))` for discriminated unions, and `Array.match` for lists that may be empty.
77
+ 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.
78
78
 
79
79
  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.
80
80
 
@@ -84,9 +84,11 @@ Omit the children argument when an element has none: `h.div([h.Class('divider')]
84
84
 
85
85
  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.
86
86
 
87
+ 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.
88
+
87
89
  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.
88
90
 
89
- For DOM operations (focus, scroll, modals, scroll lock), Foldkit ships a `Dom` module. For time, randomness, UUIDs, and delays, use Effect's built-ins directly (`Clock`, `Random`, `Effect.uuid`, `Effect.sleep`). Don't reach for raw `document.querySelector`, `setTimeout`, `Date.now()`, or `Math.random()`.
91
+ 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`, `Crypto.Crypto`, `Effect.sleep`). Provide the platform Crypto layer when using `Crypto.Crypto`. Don't reach for raw `document.querySelector`, `setTimeout`, `Date.now()`, or `Math.random()`.
90
92
 
91
93
  ### File Organization
92
94
 
@@ -126,7 +128,7 @@ Declare the whole Message union with `defineMessageUnion()`, then put `type Mess
126
128
  ```ts
127
129
  const Message = defineMessageUnion({
128
130
  ClickedSubmit: {},
129
- UpdatedEmail: { value: S.String },
131
+ UpdatedEmail: { value: Schema.String },
130
132
  })
131
133
  type Message = typeof Message.Type
132
134
  ```
@@ -17,13 +17,13 @@
17
17
  "devDependencies": {
18
18
  "@foldkit/devtools": "workspace:*",
19
19
  "@foldkit/vite-plugin": "workspace:*",
20
- "@tailwindcss/vite": "^4.3.1",
20
+ "@tailwindcss/vite": "^4.3.3",
21
21
  "@trivago/prettier-plugin-sort-imports": "^6.0.2",
22
- "happy-dom": "^20.10.4",
23
- "prettier": "^3.8.4",
24
- "tailwindcss": "^4.3.1",
25
- "typescript": "^6.0.3",
26
- "vite": "^8.0.16",
27
- "vitest": "^4.1.9"
22
+ "happy-dom": "^20.11.13",
23
+ "prettier": "^3.9.6",
24
+ "tailwindcss": "^4.3.3",
25
+ "typescript": "^7.0.2",
26
+ "vite": "^8.2.2",
27
+ "vitest": "^4.1.11"
28
28
  }
29
29
  }
@@ -1,24 +1,24 @@
1
- import { Array, Duration, Effect, Option, Random, Schema as S } from 'effect'
1
+ import { Array, Duration, Effect, Option, Random, Schema } from 'effect'
2
2
 
3
- export const Post = S.Struct({
4
- id: S.String,
5
- title: S.String,
6
- excerpt: S.String,
3
+ export const Post = Schema.Struct({
4
+ id: Schema.String,
5
+ title: Schema.String,
6
+ excerpt: Schema.String,
7
7
  })
8
8
  export type Post = typeof Post.Type
9
9
 
10
- export const PostDetail = S.Struct({
11
- id: S.String,
12
- title: S.String,
13
- author: S.String,
14
- body: S.String,
10
+ export const PostDetail = Schema.Struct({
11
+ id: Schema.String,
12
+ title: Schema.String,
13
+ author: Schema.String,
14
+ body: Schema.String,
15
15
  })
16
16
  export type PostDetail = typeof PostDetail.Type
17
17
 
18
- export const Stats = S.Struct({
19
- activeUsers: S.Number,
20
- requestsPerSecond: S.Number,
21
- cacheHitRatePercent: S.Number,
18
+ export const Stats = Schema.Struct({
19
+ activeUsers: Schema.Number,
20
+ requestsPerSecond: Schema.Number,
21
+ cacheHitRatePercent: Schema.Number,
22
22
  })
23
23
  export type Stats = typeof Stats.Type
24
24
 
@@ -4,9 +4,9 @@ import {
4
4
  Duration,
5
5
  Effect,
6
6
  HashMap,
7
- Match as M,
7
+ Match,
8
8
  Option,
9
- Schema as S,
9
+ Schema,
10
10
  Stream,
11
11
  pipe,
12
12
  } from 'effect'
@@ -32,36 +32,39 @@ export const TABS_ID = 'api-cache-tabs'
32
32
 
33
33
  // MODEL
34
34
 
35
- const FetchedPosts = S.Struct({ posts: S.Array(Post), fetchedAt: S.Number })
35
+ const FetchedPosts = Schema.Struct({
36
+ posts: Schema.Array(Post),
37
+ fetchedAt: Schema.Number,
38
+ })
36
39
 
37
- const FetchedPostDetail = S.Struct({
40
+ const FetchedPostDetail = Schema.Struct({
38
41
  detail: PostDetail,
39
- fetchedAt: S.Number,
42
+ fetchedAt: Schema.Number,
40
43
  })
41
44
 
42
- const FetchedStats = S.Struct({ stats: Stats, fetchedAt: S.Number })
45
+ const FetchedStats = Schema.Struct({ stats: Stats, fetchedAt: Schema.Number })
43
46
 
44
- export const PostsData = AsyncData.Schema(FetchedPosts, S.String)
45
- export const PostDetailData = AsyncData.Schema(FetchedPostDetail, S.String)
46
- export const StatsData = AsyncData.Schema(FetchedStats, S.String)
47
+ export const PostsData = AsyncData.Schema(FetchedPosts, Schema.String)
48
+ export const PostDetailData = AsyncData.Schema(FetchedPostDetail, Schema.String)
49
+ export const StatsData = AsyncData.Schema(FetchedStats, Schema.String)
47
50
 
48
51
  type PostsData = typeof PostsData.schema.Type
49
52
  type PostDetailData = typeof PostDetailData.schema.Type
50
53
  type StatsData = typeof StatsData.schema.Type
51
54
 
52
- const Tab = S.Literals(['Posts', 'Stats'])
55
+ const Tab = Schema.Literals(['Posts', 'Stats'])
53
56
  type Tab = typeof Tab.Type
54
57
 
55
58
  const tabValues: ReadonlyArray<Tab> = Tab.literals
56
59
 
57
60
  export const AppTabs = Tabs.create<Tab>()
58
61
 
59
- export const Model = S.Struct({
62
+ export const Model = Schema.Struct({
60
63
  tabs: Tabs.Model,
61
64
  activeTab: Tab,
62
65
  posts: PostsData.schema,
63
- postDetailById: S.HashMap(S.String, PostDetailData.schema),
64
- maybeSelectedPostId: S.Option(S.String),
66
+ postDetailById: Schema.HashMap(Schema.String, PostDetailData.schema),
67
+ maybeSelectedPostId: Schema.Option(Schema.String),
65
68
  stats: StatsData.schema,
66
69
  })
67
70
  export type Model = typeof Model.Type
@@ -70,20 +73,20 @@ export type Model = typeof Model.Type
70
73
 
71
74
  export const Message = defineMessageUnion({
72
75
  GotTabsMessage: { message: Tabs.Message },
73
- ClickedPost: { postId: S.String },
76
+ ClickedPost: { postId: Schema.String },
74
77
  ClickedBackToPosts: {},
75
78
  ClickedInvalidatePosts: {},
76
79
  ClickedRetryPosts: {},
77
- ClickedRetryPostDetail: { postId: S.String },
80
+ ClickedRetryPostDetail: { postId: Schema.String },
78
81
  ClickedRefreshStats: {},
79
82
  ClickedRetryStats: {},
80
83
  TickedRevalidateStats: {},
81
- SettledFetchPosts: { result: S.Result(FetchedPosts, S.String) },
84
+ SettledFetchPosts: { result: Schema.Result(FetchedPosts, Schema.String) },
82
85
  SettledFetchPostDetail: {
83
- postId: S.String,
84
- result: S.Result(FetchedPostDetail, S.String),
86
+ postId: Schema.String,
87
+ result: Schema.Result(FetchedPostDetail, Schema.String),
85
88
  },
86
- SettledFetchStats: { result: S.Result(FetchedStats, S.String) },
89
+ SettledFetchStats: { result: Schema.Result(FetchedStats, Schema.String) },
87
90
  })
88
91
 
89
92
  export type Message = typeof Message.Type
@@ -122,27 +125,27 @@ const setPostDetail = (postId: string, postDetail: PostDetailData) =>
122
125
  const activateTab = (model: Model, tab: Tab): UpdateReturn => {
123
126
  const modelWithActiveTab = evo(model, { activeTab: () => tab })
124
127
 
125
- return M.value(tab).pipe(
126
- M.withReturnType<UpdateReturn>(),
127
- M.when('Posts', () =>
128
+ return Match.value(tab).pipe(
129
+ Match.withReturnType<UpdateReturn>(),
130
+ Match.when('Posts', () =>
128
131
  applyPostsTransition(
129
132
  modelWithActiveTab,
130
133
  AsyncData.loadIfMissing(modelWithActiveTab.posts),
131
134
  ),
132
135
  ),
133
- M.when('Stats', () =>
136
+ Match.when('Stats', () =>
134
137
  applyStatsTransition(
135
138
  modelWithActiveTab,
136
139
  AsyncData.loadIfMissing(modelWithActiveTab.stats),
137
140
  ),
138
141
  ),
139
- M.exhaustive,
142
+ Match.exhaustive,
140
143
  )
141
144
  }
142
145
 
143
- const foldTabsOutMessage = M.type<Tabs.OutMessage<Tab>>().pipe(
144
- M.withReturnType<Update.Step<Model, Message>>(),
145
- M.tagsExhaustive({
146
+ const foldTabsOutMessage = Match.type<Tabs.OutMessage<Tab>>().pipe(
147
+ Match.withReturnType<Update.Step<Model, Message>>(),
148
+ Match.tagsExhaustive({
146
149
  Selected:
147
150
  ({ value }) =>
148
151
  model =>
@@ -249,7 +252,7 @@ export const FetchPosts = Command.define('FetchPosts', {
249
252
  })
250
253
 
251
254
  export const FetchPostDetail = Command.define('FetchPostDetail', {
252
- args: { postId: S.String },
255
+ args: { postId: Schema.String },
253
256
  messages: [Message.SettledFetchPostDetail],
254
257
  execute: ({ postId }) =>
255
258
  pipe(
@@ -280,7 +283,7 @@ export const FetchStats = Command.define('FetchStats', {
280
283
 
281
284
  export const subscriptions = Subscription.make<Model, Message>()(entry => ({
282
285
  revalidateStats: entry(
283
- { isObservingStats: S.Boolean },
286
+ { isObservingStats: Schema.Boolean },
284
287
  {
285
288
  modelToDependencies: model => ({
286
289
  isObservingStats:
@@ -350,10 +353,10 @@ export const view = (model: Model, h: HtmlBuilder<Message>): Document => ({
350
353
  tabInfo.value,
351
354
  [...tabInfo.panel, h.Class('flex flex-col gap-4')],
352
355
  [
353
- M.value(tabInfo.value).pipe(
354
- M.when('Posts', () => postsTabView(model, h)),
355
- M.when('Stats', () => statsTabView(model, h)),
356
- M.exhaustive,
356
+ Match.value(tabInfo.value).pipe(
357
+ Match.when('Posts', () => postsTabView(model, h)),
358
+ Match.when('Stats', () => statsTabView(model, h)),
359
+ Match.exhaustive,
357
360
  ),
358
361
  ],
359
362
  ),
@@ -18,13 +18,13 @@
18
18
  "devDependencies": {
19
19
  "@foldkit/devtools": "workspace:*",
20
20
  "@foldkit/vite-plugin": "workspace:*",
21
- "@tailwindcss/vite": "^4.3.1",
21
+ "@tailwindcss/vite": "^4.3.3",
22
22
  "@trivago/prettier-plugin-sort-imports": "^6.0.2",
23
- "happy-dom": "^20.10.4",
24
- "prettier": "^3.8.4",
25
- "tailwindcss": "^4.3.1",
26
- "typescript": "^6.0.3",
27
- "vite": "^8.0.16",
28
- "vitest": "^4.1.9"
23
+ "happy-dom": "^20.11.13",
24
+ "prettier": "^3.9.6",
25
+ "tailwindcss": "^4.3.3",
26
+ "typescript": "^7.0.2",
27
+ "vite": "^8.2.2",
28
+ "vitest": "^4.1.11"
29
29
  }
30
30
  }
@@ -1,4 +1,4 @@
1
- import { Console, Effect, Schema as S } from 'effect'
1
+ import { Console, Effect, Schema } from 'effect'
2
2
  import { KeyValueStore } from 'effect/unstable/persistence'
3
3
  import { Command } from 'foldkit'
4
4
 
@@ -16,7 +16,7 @@ export const SaveSession = Command.define('SaveSession', {
16
16
  const store = yield* KeyValueStore.KeyValueStore
17
17
  yield* store.set(
18
18
  SESSION_STORAGE_KEY,
19
- S.encodeSync(SessionJsonString)(session),
19
+ Schema.encodeSync(SessionJsonString)(session),
20
20
  )
21
21
  return Message.SucceededSaveSession()
22
22
  }).pipe(
@@ -42,7 +42,7 @@ export const ClearSession = Command.define('ClearSession', {
42
42
  })
43
43
 
44
44
  export const LogError = Command.define('LogError', {
45
- args: { entries: S.Array(S.Unknown) },
45
+ args: { entries: Schema.Array(Schema.Unknown) },
46
46
  messages: [Message.CompletedLogError],
47
47
  execute: ({ entries }) =>
48
48
  Console.error(...entries).pipe(Effect.as(Message.CompletedLogError())),
@@ -1,11 +1,13 @@
1
- import { Schema as S } from 'effect'
1
+ import { Schema } from 'effect'
2
2
 
3
- export const Session = S.Struct({
4
- userId: S.String,
5
- email: S.String,
6
- name: S.String,
3
+ export const Session = Schema.Struct({
4
+ userId: Schema.String,
5
+ email: Schema.String,
6
+ name: Schema.String,
7
7
  })
8
8
 
9
9
  export type Session = typeof Session.Type
10
10
 
11
- export const SessionJsonString = S.fromJsonString(S.toCodecJson(Session))
11
+ export const SessionJsonString = Schema.fromJsonString(
12
+ Schema.toCodecJson(Session),
13
+ )
@@ -1,4 +1,4 @@
1
- import { Effect, Match as M, Option, Schema as S } from 'effect'
1
+ import { Effect, Match, Option, Schema } from 'effect'
2
2
  import { KeyValueStore } from 'effect/unstable/persistence'
3
3
  import { Runtime, type Update } from 'foldkit'
4
4
  import { Url } from 'foldkit/url'
@@ -14,8 +14,8 @@ import { RedirectToDashboard, RedirectToLogin } from './update'
14
14
 
15
15
  // FLAGS
16
16
 
17
- export const Flags = S.Struct({
18
- maybeSession: S.Option(Session),
17
+ export const Flags = Schema.Struct({
18
+ maybeSession: Schema.Option(Session),
19
19
  })
20
20
 
21
21
  export const flags: Effect.Effect<Flags> = Effect.gen(function* () {
@@ -24,7 +24,7 @@ export const flags: Effect.Effect<Flags> = Effect.gen(function* () {
24
24
  Option.fromNullishOr(yield* store.get(SESSION_STORAGE_KEY)),
25
25
  )
26
26
 
27
- const decodeSession = S.decodeEffect(SessionJsonString)
27
+ const decodeSession = Schema.decodeEffect(SessionJsonString)
28
28
  const session = yield* decodeSession(sessionJson)
29
29
 
30
30
  return Flags.make({ maybeSession: Option.some(session) })
@@ -40,7 +40,7 @@ export type Flags = typeof Flags.Type
40
40
  // INIT
41
41
 
42
42
  type InitReturn = Update.Return<Model, Message>
43
- const withInitReturn = M.withReturnType<InitReturn>()
43
+ const withInitReturn = Match.withReturnType<InitReturn>()
44
44
 
45
45
  export const init: Runtime.RoutingApplicationInit<Model, Message, Flags> = (
46
46
  flags: Flags,
@@ -50,24 +50,24 @@ export const init: Runtime.RoutingApplicationInit<Model, Message, Flags> = (
50
50
 
51
51
  return Option.match(flags.maybeSession, {
52
52
  onNone: () =>
53
- M.value(route).pipe(
53
+ Match.value(route).pipe(
54
54
  withInitReturn,
55
- M.tag('Home', 'Login', 'NotFound', route => ({
55
+ Match.tag('Home', 'Login', 'NotFound', route => ({
56
56
  model: LoggedOut.init(route),
57
57
  })),
58
- M.orElse(() => ({
58
+ Match.orElse(() => ({
59
59
  model: LoggedOut.init(AppRoute.Login()),
60
60
  commands: [RedirectToLogin()],
61
61
  })),
62
62
  ),
63
63
 
64
64
  onSome: session =>
65
- M.value(route).pipe(
65
+ Match.value(route).pipe(
66
66
  withInitReturn,
67
- M.tag('Dashboard', 'Settings', 'NotFound', route => ({
67
+ Match.tag('Dashboard', 'Settings', 'NotFound', route => ({
68
68
  model: LoggedIn.init(route, session),
69
69
  })),
70
- M.orElse(() => ({
70
+ Match.orElse(() => ({
71
71
  model: LoggedIn.init(AppRoute.Dashboard(), session),
72
72
  commands: [RedirectToDashboard()],
73
73
  })),
@@ -1,4 +1,4 @@
1
- import { Schema as S } from 'effect'
1
+ import { Schema } from 'effect'
2
2
  import { defineMessageUnion } from 'foldkit/message'
3
3
  import { UrlRequest } from 'foldkit/navigation'
4
4
  import { Url } from 'foldkit/url'
@@ -12,9 +12,9 @@ export const Message = defineMessageUnion({
12
12
  ClickedLink: { request: UrlRequest },
13
13
  ChangedUrl: { url: Url },
14
14
  SucceededSaveSession: {},
15
- FailedSaveSession: { error: S.String },
15
+ FailedSaveSession: { error: Schema.String },
16
16
  SucceededClearSession: {},
17
- FailedClearSession: { error: S.String },
17
+ FailedClearSession: { error: Schema.String },
18
18
  GotLoggedOutMessage: { message: LoggedOut.Message },
19
19
  GotLoggedInMessage: { message: LoggedIn.Message },
20
20
  })
@@ -1,8 +1,8 @@
1
- import { Schema as S } from 'effect'
1
+ import { Schema } from 'effect'
2
2
 
3
3
  import { LoggedIn, LoggedOut } from './page'
4
4
 
5
- export const Model = S.Union([LoggedOut.Model, LoggedIn.Model])
5
+ export const Model = Schema.Union([LoggedOut.Model, LoggedIn.Model])
6
6
 
7
7
  export type Model = typeof Model.Type
8
8
 
@@ -1,5 +1,5 @@
1
1
  import { clsx } from 'clsx'
2
- import { Match as M } from 'effect'
2
+ import { Match } from 'effect'
3
3
  import { Submodel } from 'foldkit'
4
4
  import { Html, HtmlBuilder } from 'foldkit/html'
5
5
 
@@ -72,8 +72,8 @@ export const view = Submodel.defineView<Model, Message>((model, h) =>
72
72
  h.main(
73
73
  [h.Class('py-8')],
74
74
  [
75
- M.value(model.route).pipe(
76
- M.tagsExhaustive({
75
+ Match.value(model.route).pipe(
76
+ Match.tagsExhaustive({
77
77
  Dashboard: () => Dashboard.view(model.session, h),
78
78
  Settings: () => Settings.view(model.session, h),
79
79
  NotFound: ({ path }) =>
@@ -1,15 +1,6 @@
1
1
  import { clsx } from 'clsx'
2
- import {
3
- Array,
4
- Duration,
5
- Effect,
6
- Match as M,
7
- Option,
8
- Schema as S,
9
- String,
10
- pipe,
11
- } from 'effect'
12
- import { Command, Submodel, type Update } from 'foldkit'
2
+ import { Array, Duration, Effect, Option, Schema, String, pipe } from 'effect'
3
+ import { Command, FieldValidation, Submodel, type Update } from 'foldkit'
13
4
  import {
14
5
  Field,
15
6
  Invalid,
@@ -30,10 +21,10 @@ import { homeRouter } from '../../../route'
30
21
 
31
22
  // MODEL
32
23
 
33
- export const Model = S.Struct({
34
- email: Field(S.String),
35
- password: Field(S.String),
36
- isSubmitting: S.Boolean,
24
+ export const Model = Schema.Struct({
25
+ email: Field(Schema.String),
26
+ password: Field(Schema.String),
27
+ isSubmitting: Schema.Boolean,
37
28
  })
38
29
 
39
30
  export type Model = typeof Model.Type
@@ -47,11 +38,11 @@ export const initModel = (): Model => ({
47
38
  // MESSAGE
48
39
 
49
40
  export const Message = defineMessageUnion({
50
- ChangedEmail: { value: S.String },
51
- ChangedPassword: { value: S.String },
41
+ ChangedEmail: { value: Schema.String },
42
+ ChangedPassword: { value: Schema.String },
52
43
  SubmittedForm: {},
53
44
  SucceededSimulateAuthRequest: { session: Session },
54
- FailedSimulateAuthRequest: { error: S.String },
45
+ FailedSimulateAuthRequest: { error: Schema.String },
55
46
  })
56
47
 
57
48
  export type Message = typeof Message.Type
@@ -87,7 +78,7 @@ const isFormValid = (model: Model): boolean =>
87
78
  // UPDATE
88
79
 
89
80
  export const SimulateAuthRequest = Command.define('SimulateAuthRequest', {
90
- args: { email: S.String, password: S.String },
81
+ args: { email: Schema.String, password: Schema.String },
91
82
  messages: [
92
83
  Message.SucceededSimulateAuthRequest,
93
84
  Message.FailedSimulateAuthRequest,
@@ -168,14 +159,12 @@ export const update = (model: Model, message: Message) =>
168
159
  // VIEW
169
160
 
170
161
  const fieldToBorderClass = (field: Field<string>) =>
171
- M.value(field).pipe(
172
- M.tagsExhaustive({
173
- NotValidated: () => 'border-gray-300',
174
- Validating: () => 'border-blue-300',
175
- Valid: () => 'border-green-500',
176
- Invalid: () => 'border-red-500',
177
- }),
178
- )
162
+ FieldValidation.match(field, {
163
+ onNotValidated: () => 'border-gray-300',
164
+ onValidating: () => 'border-blue-300',
165
+ onValid: () => 'border-green-500',
166
+ onInvalid: () => 'border-red-500',
167
+ })
179
168
 
180
169
  const fieldView = (
181
170
  id: string,
@@ -213,34 +202,30 @@ const fieldView = (
213
202
  ],
214
203
  [labelText],
215
204
  ),
216
- M.value(field).pipe(
217
- M.tagsExhaustive({
218
- NotValidated: () => h.empty,
219
- Validating: () =>
220
- h.span([h.Class('text-blue-600 text-sm')], ['...']),
221
- Valid: () =>
222
- h.span([h.Class('text-green-600 text-sm')], ['✓']),
223
- Invalid: () => h.empty,
224
- }),
225
- ),
205
+ FieldValidation.match(field, {
206
+ onNotValidated: () => h.empty,
207
+ onValidating: () =>
208
+ h.span([h.Class('text-blue-600 text-sm')], ['...']),
209
+ onValid: () =>
210
+ h.span([h.Class('text-green-600 text-sm')], ['✓']),
211
+ onInvalid: () => h.empty,
212
+ }),
226
213
  ],
227
214
  ),
228
215
  h.input([...attributes.input, h.Class(inputClass)]),
229
- M.value(field).pipe(
230
- M.tagsExhaustive({
231
- NotValidated: () => h.empty,
232
- Validating: () => h.empty,
233
- Valid: () => h.empty,
234
- Invalid: ({ errors }) =>
235
- h.div(
236
- [
237
- ...attributes.description,
238
- h.Class('text-red-600 text-sm mt-1'),
239
- ],
240
- [Array.headNonEmpty(errors)],
241
- ),
242
- }),
243
- ),
216
+ FieldValidation.match(field, {
217
+ onNotValidated: () => h.empty,
218
+ onValidating: () => h.empty,
219
+ onValid: () => h.empty,
220
+ onInvalid: ({ errors }) =>
221
+ h.div(
222
+ [
223
+ ...attributes.description,
224
+ h.Class('text-red-600 text-sm mt-1'),
225
+ ],
226
+ [Array.headNonEmpty(errors)],
227
+ ),
228
+ }),
244
229
  ],
245
230
  ),
246
231
  },
@@ -1,4 +1,4 @@
1
- import { Match as M, Option } from 'effect'
1
+ import { Match, Option } from 'effect'
2
2
  import { Update } from 'foldkit'
3
3
  import { evo } from 'foldkit/struct'
4
4
 
@@ -12,8 +12,8 @@ const foldLogin = Update.foldChild({
12
12
  write: (model, nextLoginModel) =>
13
13
  evo(model, { loginModel: () => nextLoginModel }),
14
14
  toParentMessage: message => Message.GotLoginMessage({ message }),
15
- toParentOutMessage: M.type<Login.OutMessage>().pipe(
16
- M.tagsExhaustive({
15
+ toParentOutMessage: Match.type<Login.OutMessage>().pipe(
16
+ Match.tagsExhaustive({
17
17
  SucceededLogin: ({ session }) => OutMessage.SucceededLogin({ session }),
18
18
  }),
19
19
  ),
@@ -1,4 +1,4 @@
1
- import { Match as M } from 'effect'
1
+ import { Match } from 'effect'
2
2
  import { Submodel } from 'foldkit'
3
3
 
4
4
  import { notFoundView } from '../../notFoundView'
@@ -12,8 +12,8 @@ export const view = Submodel.defineView<Model, Message>((model, h) =>
12
12
  h.div(
13
13
  [h.Class('py-8')],
14
14
  [
15
- M.value(model.route).pipe(
16
- M.tagsExhaustive({
15
+ Match.value(model.route).pipe(
16
+ Match.tagsExhaustive({
17
17
  Home: () => Home.view(h),
18
18
  Login: () =>
19
19
  h.submodel({
@@ -1,4 +1,4 @@
1
- import { Schema as S, pipe } from 'effect'
1
+ import { Schema, pipe } from 'effect'
2
2
  import { Route } from 'foldkit'
3
3
  import { defineRouteUnion, literal } from 'foldkit/route'
4
4
 
@@ -7,7 +7,7 @@ export const AppRoute = defineRouteUnion({
7
7
  Login: {},
8
8
  Dashboard: {},
9
9
  Settings: {},
10
- NotFound: { path: S.String },
10
+ NotFound: { path: Schema.String },
11
11
  })
12
12
 
13
13
  export type AppRoute = typeof AppRoute.Type