create-foldkit-app 0.35.1 → 0.35.2
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/dist/templates/base/FOLDKIT.md +2 -2
- package/dist/templates/examples/api-cache/package.json +2 -2
- package/dist/templates/examples/api-cache/src/main.fixture.ts +4 -4
- package/dist/templates/examples/api-cache/src/main.ts +12 -12
- package/dist/templates/examples/api-cache/src/story.test.ts +6 -6
- package/dist/templates/examples/auth/package.json +2 -2
- package/dist/templates/examples/auth/src/page/loggedOut/page/login.scene.test.ts +2 -2
- package/dist/templates/examples/auth/src/page/loggedOut/page/login.story.test.ts +2 -2
- package/dist/templates/examples/auth/src/page/loggedOut/page/login.ts +5 -5
- package/dist/templates/examples/auth/src/page/loggedOut/update.ts +2 -2
- package/dist/templates/examples/auth/src/scene.test.ts +2 -2
- package/dist/templates/examples/auth/src/update.ts +3 -3
- package/dist/templates/examples/canvas-art/package.json +2 -2
- package/dist/templates/examples/canvas-art/src/main.ts +6 -6
- package/dist/templates/examples/canvas-art/src/scene.test.ts +3 -3
- package/dist/templates/examples/canvas-art/src/story.test.ts +3 -3
- package/dist/templates/examples/charting/package.json +2 -2
- package/dist/templates/examples/charting/src/main.fixture.ts +2 -2
- package/dist/templates/examples/charting/src/scene.test.ts +3 -3
- package/dist/templates/examples/charting/src/story.test.ts +2 -2
- package/dist/templates/examples/charting/src/update.ts +18 -16
- package/dist/templates/examples/counter/package.json +2 -2
- package/dist/templates/examples/counter/src/main.ts +4 -4
- package/dist/templates/examples/counters/package.json +2 -2
- package/dist/templates/examples/counters/src/counter.ts +3 -3
- package/dist/templates/examples/counters/src/main.ts +7 -5
- package/dist/templates/examples/crash-view/package.json +2 -2
- package/dist/templates/examples/embedding/package.json +2 -2
- package/dist/templates/examples/embedding/src/main.ts +5 -3
- 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 +2 -2
- package/dist/templates/examples/form/src/main.ts +9 -9
- package/dist/templates/examples/form/src/scene.test.ts +5 -5
- package/dist/templates/examples/form/src/story.test.ts +4 -4
- package/dist/templates/examples/generative-art/package.json +2 -2
- package/dist/templates/examples/generative-art/src/scene.test.ts +2 -2
- package/dist/templates/examples/generative-art/src/story.test.ts +3 -3
- package/dist/templates/examples/generative-art/src/update.ts +11 -11
- package/dist/templates/examples/interrupting-commands/package.json +2 -2
- package/dist/templates/examples/interrupting-commands/src/main.ts +8 -6
- package/dist/templates/examples/job-application/package.json +2 -2
- package/dist/templates/examples/job-application/src/main.fixture.ts +9 -9
- package/dist/templates/examples/job-application/src/scene.test.ts +13 -13
- package/dist/templates/examples/job-application/src/step/attachments/attachments.ts +7 -7
- package/dist/templates/examples/job-application/src/step/coverLetter/coverLetter.ts +2 -2
- package/dist/templates/examples/job-application/src/step/education/education.ts +6 -6
- package/dist/templates/examples/job-application/src/step/education/entry/entry.ts +14 -8
- package/dist/templates/examples/job-application/src/step/personalInfo/personalInfo.ts +20 -15
- package/dist/templates/examples/job-application/src/step/personalInfo/story.test.ts +2 -2
- package/dist/templates/examples/job-application/src/step/skills/entry/entry.ts +7 -5
- package/dist/templates/examples/job-application/src/step/skills/skills.ts +6 -6
- package/dist/templates/examples/job-application/src/step/workHistory/entry/entry.ts +13 -12
- package/dist/templates/examples/job-application/src/step/workHistory/workHistory.ts +6 -6
- package/dist/templates/examples/job-application/src/story.test.ts +10 -10
- package/dist/templates/examples/job-application/src/update.ts +25 -18
- package/dist/templates/examples/kanban/package.json +2 -2
- package/dist/templates/examples/kanban/src/domain/column.ts +9 -6
- package/dist/templates/examples/kanban/src/update.ts +8 -8
- package/dist/templates/examples/managed-resource-layer/package.json +2 -2
- package/dist/templates/examples/managed-resource-layer/src/main.ts +11 -7
- package/dist/templates/examples/managed-resource-layer/src/story.test.ts +3 -3
- package/dist/templates/examples/map/package.json +2 -2
- package/dist/templates/examples/map/src/main.fixture.ts +2 -2
- package/dist/templates/examples/map/src/main.ts +11 -11
- package/dist/templates/examples/map/src/scene.test.ts +4 -4
- package/dist/templates/examples/map/src/story.test.ts +4 -4
- package/dist/templates/examples/pixel-art/package.json +2 -2
- package/dist/templates/examples/pixel-art/src/comparison.bench.test.ts +2 -2
- package/dist/templates/examples/pixel-art/src/main.bench.ts +7 -3
- package/dist/templates/examples/pixel-art/src/scene.test.ts +5 -5
- package/dist/templates/examples/pixel-art/src/story.test.ts +4 -4
- package/dist/templates/examples/pixel-art/src/subscription.ts +2 -2
- package/dist/templates/examples/pixel-art/src/update.ts +49 -33
- package/dist/templates/examples/query-sync/package.json +2 -2
- package/dist/templates/examples/query-sync/src/main.ts +4 -4
- package/dist/templates/examples/query-sync/src/scene.test.ts +4 -4
- package/dist/templates/examples/query-sync/src/story.test.ts +2 -2
- package/dist/templates/examples/route-transitions/package.json +2 -2
- package/dist/templates/examples/route-transitions/src/main.ts +10 -10
- package/dist/templates/examples/route-transitions/src/story.test.ts +10 -6
- package/dist/templates/examples/routing/package.json +2 -2
- package/dist/templates/examples/routing/src/main.ts +13 -17
- package/dist/templates/examples/routing/src/page/people.ts +4 -4
- package/dist/templates/examples/shopping-cart/package.json +2 -2
- package/dist/templates/examples/shopping-cart/src/domain/cart.ts +4 -4
- package/dist/templates/examples/shopping-cart/src/main.ts +12 -12
- package/dist/templates/examples/shopping-cart/src/page/products.ts +2 -2
- package/dist/templates/examples/shopping-cart/src/scene.test.ts +10 -8
- package/dist/templates/examples/shopping-cart/src/story.test.ts +7 -7
- package/dist/templates/examples/slow-warnings/package.json +2 -2
- package/dist/templates/examples/slow-warnings/src/handleSlow.test.ts +2 -2
- package/dist/templates/examples/slow-warnings/src/main.ts +8 -8
- package/dist/templates/examples/slow-warnings/src/scene.test.ts +2 -2
- package/dist/templates/examples/slow-warnings/src/story.test.ts +2 -2
- package/dist/templates/examples/snake/package.json +2 -2
- package/dist/templates/examples/snake/src/main.ts +10 -10
- package/dist/templates/examples/snake/src/scene.test.ts +10 -5
- package/dist/templates/examples/snake/src/story.test.ts +6 -6
- package/dist/templates/examples/ssg/package.json +2 -2
- package/dist/templates/examples/ssg/src/main.ts +3 -3
- package/dist/templates/examples/ssr/package.json +4 -4
- package/dist/templates/examples/ssr/src/main.ts +3 -3
- package/dist/templates/examples/state-machine/package.json +2 -2
- package/dist/templates/examples/state-machine/src/main.ts +14 -10
- package/dist/templates/examples/stopwatch/package.json +2 -2
- package/dist/templates/examples/stopwatch/src/main.ts +5 -5
- package/dist/templates/examples/stopwatch/src/story.test.ts +2 -2
- package/dist/templates/examples/todo/package.json +2 -2
- package/dist/templates/examples/todo/src/main.ts +17 -17
- package/dist/templates/examples/todo/src/scene.test.ts +4 -4
- package/dist/templates/examples/todo/src/story.test.ts +22 -16
- package/dist/templates/examples/ui-showcase/package.json +2 -2
- package/dist/templates/examples/ui-showcase/src/main.ts +8 -5
- package/dist/templates/examples/ui-showcase/src/story.test.ts +3 -3
- package/dist/templates/examples/ui-showcase/src/ui/init.ts +4 -1
- package/dist/templates/examples/ui-showcase/src/ui/subscriptions.ts +10 -0
- package/dist/templates/examples/ui-showcase/src/ui/update.ts +119 -91
- package/dist/templates/examples/ui-showcase/src/ui/view/toast.ts +20 -3
- package/dist/templates/examples/view-transitions/package.json +2 -2
- package/dist/templates/examples/view-transitions/src/main.ts +3 -3
- package/dist/templates/examples/weather/package.json +2 -2
- package/dist/templates/examples/weather/src/main.ts +5 -5
- package/dist/templates/examples/web-components/package.json +2 -2
- package/dist/templates/examples/web-components/src/main.ts +4 -4
- package/dist/templates/examples/websocket-chat/package.json +2 -2
- package/dist/templates/examples/websocket-chat/src/main.ts +8 -8
- package/dist/templates/examples/websocket-chat/src/scene.test.ts +18 -6
- package/dist/templates/examples/websocket-chat/src/story.test.ts +15 -9
- package/dist/templates/release.json +13 -13
- package/dist/templates/rendering/ssg/src/main.ts +3 -3
- package/dist/templates/rendering/ssr/scripts/serve.ts +2 -2
- package/dist/templates/rendering/ssr/src/main.ts +3 -3
- package/package.json +5 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Array, Option, Result, pipe } from 'effect'
|
|
2
2
|
import { AsyncData, Command, Update } from 'foldkit'
|
|
3
|
-
import {
|
|
3
|
+
import { modifyFields } from 'foldkit/struct'
|
|
4
4
|
|
|
5
5
|
import { RadioGroup } from '@foldkit/ui'
|
|
6
6
|
|
|
@@ -45,7 +45,7 @@ const refetchTelemetry = (model: Model): UpdateReturn =>
|
|
|
45
45
|
Option.match(AsyncData.revalidateOrLoad(model.telemetry), {
|
|
46
46
|
onNone: () => ({ model }),
|
|
47
47
|
onSome: nextTelemetry => ({
|
|
48
|
-
model:
|
|
48
|
+
model: modifyFields(model, { telemetry: () => nextTelemetry }),
|
|
49
49
|
commands: [FetchTelemetry()],
|
|
50
50
|
}),
|
|
51
51
|
})
|
|
@@ -54,7 +54,7 @@ const selectedControl =
|
|
|
54
54
|
(updateModel: (model: Model) => Model): Update.Step<Model, Message> =>
|
|
55
55
|
model => {
|
|
56
56
|
const nextModel = updateModel(
|
|
57
|
-
|
|
57
|
+
modifyFields(model, { maybeSelectedDatumId: () => Option.none() }),
|
|
58
58
|
)
|
|
59
59
|
|
|
60
60
|
return {
|
|
@@ -74,14 +74,15 @@ const foldChartModeRadioGroupOutMessage = RadioGroup.OutMessage.match<
|
|
|
74
74
|
Update.Step<Model, Message>,
|
|
75
75
|
RadioGroup.OutMessage<ChartMode>
|
|
76
76
|
>({
|
|
77
|
-
Selected: ({ value }) =>
|
|
77
|
+
Selected: ({ value }) =>
|
|
78
|
+
selectedControl(modifyFields({ chartMode: () => value })),
|
|
78
79
|
})
|
|
79
80
|
|
|
80
81
|
const foldChartModeRadioGroup = Update.foldChild({
|
|
81
82
|
update: ChartModeRadioGroup.update,
|
|
82
83
|
read: (model: Model) => Option.some(model.chartModeRadioGroup),
|
|
83
84
|
write: (model, nextChartModeRadioGroup) =>
|
|
84
|
-
|
|
85
|
+
modifyFields(model, { chartModeRadioGroup: () => nextChartModeRadioGroup }),
|
|
85
86
|
toParentMessage: message =>
|
|
86
87
|
Message.GotChartModeRadioGroupMessage({ message }),
|
|
87
88
|
foldOutMessage: foldChartModeRadioGroupOutMessage,
|
|
@@ -91,14 +92,15 @@ const foldPeriodRadioGroupOutMessage = RadioGroup.OutMessage.match<
|
|
|
91
92
|
Update.Step<Model, Message>,
|
|
92
93
|
RadioGroup.OutMessage<Period>
|
|
93
94
|
>({
|
|
94
|
-
Selected: ({ value }) =>
|
|
95
|
+
Selected: ({ value }) =>
|
|
96
|
+
selectedControl(modifyFields({ period: () => value })),
|
|
95
97
|
})
|
|
96
98
|
|
|
97
99
|
const foldPeriodRadioGroup = Update.foldChild({
|
|
98
100
|
update: PeriodRadioGroup.update,
|
|
99
101
|
read: (model: Model) => Option.some(model.periodRadioGroup),
|
|
100
102
|
write: (model, nextPeriodRadioGroup) =>
|
|
101
|
-
|
|
103
|
+
modifyFields(model, { periodRadioGroup: () => nextPeriodRadioGroup }),
|
|
102
104
|
toParentMessage: message => Message.GotPeriodRadioGroupMessage({ message }),
|
|
103
105
|
foldOutMessage: foldPeriodRadioGroupOutMessage,
|
|
104
106
|
})
|
|
@@ -108,14 +110,14 @@ const foldPackageRadioGroupOutMessage = RadioGroup.OutMessage.match<
|
|
|
108
110
|
RadioGroup.OutMessage<PackageId>
|
|
109
111
|
>({
|
|
110
112
|
Selected: ({ value }) =>
|
|
111
|
-
selectedControl(
|
|
113
|
+
selectedControl(modifyFields({ selectedPackageId: () => value })),
|
|
112
114
|
})
|
|
113
115
|
|
|
114
116
|
const foldPackageRadioGroup = Update.foldChild({
|
|
115
117
|
update: PackageRadioGroup.update,
|
|
116
118
|
read: (model: Model) => Option.some(model.packageRadioGroup),
|
|
117
119
|
write: (model, nextPackageRadioGroup) =>
|
|
118
|
-
|
|
120
|
+
modifyFields(model, { packageRadioGroup: () => nextPackageRadioGroup }),
|
|
119
121
|
toParentMessage: message => Message.GotPackageRadioGroupMessage({ message }),
|
|
120
122
|
foldOutMessage: foldPackageRadioGroupOutMessage,
|
|
121
123
|
})
|
|
@@ -136,7 +138,7 @@ export const update = (model: Model, message: Message) =>
|
|
|
136
138
|
ClickedRetry: () => refetchTelemetry(model),
|
|
137
139
|
|
|
138
140
|
ClickedChartDatum: ({ datumId }) => ({
|
|
139
|
-
model:
|
|
141
|
+
model: modifyFields(model, {
|
|
140
142
|
maybeSelectedDatumId: () => Option.some(datumId),
|
|
141
143
|
}),
|
|
142
144
|
commands: syncChart({
|
|
@@ -150,7 +152,7 @@ export const update = (model: Model, message: Message) =>
|
|
|
150
152
|
}),
|
|
151
153
|
|
|
152
154
|
SucceededFetchTelemetry: ({ telemetry }) => {
|
|
153
|
-
const nextModel =
|
|
155
|
+
const nextModel = modifyFields(model, {
|
|
154
156
|
telemetry: () => TelemetryAsyncData.Success({ data: telemetry }),
|
|
155
157
|
})
|
|
156
158
|
return {
|
|
@@ -167,13 +169,13 @@ export const update = (model: Model, message: Message) =>
|
|
|
167
169
|
},
|
|
168
170
|
|
|
169
171
|
FailedFetchTelemetry: ({ error }) => ({
|
|
170
|
-
model:
|
|
172
|
+
model: modifyFields(model, {
|
|
171
173
|
telemetry: () => AsyncData.settle(model.telemetry, Result.fail(error)),
|
|
172
174
|
}),
|
|
173
175
|
}),
|
|
174
176
|
|
|
175
177
|
SucceededMountChart: ({ hostId }) => ({
|
|
176
|
-
model:
|
|
178
|
+
model: modifyFields(model, {
|
|
177
179
|
maybeChartHostId: () => Option.some(hostId),
|
|
178
180
|
maybeChartError: () => Option.none(),
|
|
179
181
|
}),
|
|
@@ -188,19 +190,19 @@ export const update = (model: Model, message: Message) =>
|
|
|
188
190
|
}),
|
|
189
191
|
|
|
190
192
|
FailedMountChart: ({ reason }) => ({
|
|
191
|
-
model:
|
|
193
|
+
model: modifyFields(model, {
|
|
192
194
|
maybeChartError: () => Option.some(reason),
|
|
193
195
|
}),
|
|
194
196
|
}),
|
|
195
197
|
|
|
196
198
|
SucceededSyncChart: () => ({
|
|
197
|
-
model:
|
|
199
|
+
model: modifyFields(model, {
|
|
198
200
|
maybeChartError: () => Option.none(),
|
|
199
201
|
}),
|
|
200
202
|
}),
|
|
201
203
|
|
|
202
204
|
FailedSyncChart: ({ reason }) => ({
|
|
203
|
-
model:
|
|
205
|
+
model: modifyFields(model, {
|
|
204
206
|
maybeChartError: () => Option.some(reason),
|
|
205
207
|
}),
|
|
206
208
|
}),
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"test": "vitest run"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@effect/platform-browser": "4.0.0-rc.
|
|
12
|
+
"@effect/platform-browser": "4.0.0-rc.116",
|
|
13
13
|
"@foldkit/ui": "workspace:*",
|
|
14
|
-
"effect": "4.0.0-rc.
|
|
14
|
+
"effect": "4.0.0-rc.116",
|
|
15
15
|
"foldkit": "workspace:*"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
@@ -2,7 +2,7 @@ import { Schema } from 'effect'
|
|
|
2
2
|
import { Runtime, type Update } from 'foldkit'
|
|
3
3
|
import { Document, HtmlBuilder } from 'foldkit/html'
|
|
4
4
|
import { defineMessageUnion } from 'foldkit/message'
|
|
5
|
-
import {
|
|
5
|
+
import { modifyFields } from 'foldkit/struct'
|
|
6
6
|
|
|
7
7
|
import { Button } from '@foldkit/ui'
|
|
8
8
|
|
|
@@ -25,12 +25,12 @@ export type Message = typeof Message.Type
|
|
|
25
25
|
export const update = (model: Model, message: Message) =>
|
|
26
26
|
Message.match<Update.Return<Model, Message>>(message, {
|
|
27
27
|
ClickedDecrement: () => ({
|
|
28
|
-
model:
|
|
28
|
+
model: modifyFields(model, { count: count => count - 1 }),
|
|
29
29
|
}),
|
|
30
30
|
ClickedIncrement: () => ({
|
|
31
|
-
model:
|
|
31
|
+
model: modifyFields(model, { count: count => count + 1 }),
|
|
32
32
|
}),
|
|
33
|
-
ClickedReset: () => ({ model:
|
|
33
|
+
ClickedReset: () => ({ model: modifyFields(model, { count: () => 0 }) }),
|
|
34
34
|
})
|
|
35
35
|
|
|
36
36
|
// INIT
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"test": "vitest run"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@effect/platform-browser": "4.0.0-rc.
|
|
12
|
+
"@effect/platform-browser": "4.0.0-rc.116",
|
|
13
13
|
"@foldkit/ui": "workspace:*",
|
|
14
|
-
"effect": "4.0.0-rc.
|
|
14
|
+
"effect": "4.0.0-rc.116",
|
|
15
15
|
"foldkit": "workspace:*"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Schema } from 'effect'
|
|
2
2
|
import { Submodel, type Update } from 'foldkit'
|
|
3
3
|
import { defineMessageUnion } from 'foldkit/message'
|
|
4
|
-
import {
|
|
4
|
+
import { modifyFields } from 'foldkit/struct'
|
|
5
5
|
|
|
6
6
|
import { Button } from '@foldkit/ui'
|
|
7
7
|
|
|
@@ -26,10 +26,10 @@ export type Message = typeof Message.Type
|
|
|
26
26
|
export const update = (model: Model, message: Message) =>
|
|
27
27
|
Message.match<Update.Return<Model, Message>>(message, {
|
|
28
28
|
ClickedDecrement: () => ({
|
|
29
|
-
model:
|
|
29
|
+
model: modifyFields(model, { count: count => count - 1 }),
|
|
30
30
|
}),
|
|
31
31
|
ClickedIncrement: () => ({
|
|
32
|
-
model:
|
|
32
|
+
model: modifyFields(model, { count: count => count + 1 }),
|
|
33
33
|
}),
|
|
34
34
|
})
|
|
35
35
|
|
|
@@ -2,7 +2,7 @@ import { Array, Option, Schema, pipe } from 'effect'
|
|
|
2
2
|
import { Runtime, Update } from 'foldkit'
|
|
3
3
|
import { Document, Html, HtmlBuilder } from 'foldkit/html'
|
|
4
4
|
import { defineMessageUnion } from 'foldkit/message'
|
|
5
|
-
import {
|
|
5
|
+
import { modifyFields } from 'foldkit/struct'
|
|
6
6
|
|
|
7
7
|
import { Button } from '@foldkit/ui'
|
|
8
8
|
|
|
@@ -46,9 +46,11 @@ const foldCounter = (id: string) =>
|
|
|
46
46
|
Option.map(row => row.counter),
|
|
47
47
|
),
|
|
48
48
|
write: (model, nextCounter) =>
|
|
49
|
-
|
|
49
|
+
modifyFields(model, {
|
|
50
50
|
rows: Array.map(row =>
|
|
51
|
-
row.id === id
|
|
51
|
+
row.id === id
|
|
52
|
+
? modifyFields(row, { counter: () => nextCounter })
|
|
53
|
+
: row,
|
|
52
54
|
),
|
|
53
55
|
}),
|
|
54
56
|
toParentMessage: message => Message.GotCounterMessage({ id, message }),
|
|
@@ -57,7 +59,7 @@ const foldCounter = (id: string) =>
|
|
|
57
59
|
export const update = (model: Model, message: Message) =>
|
|
58
60
|
Message.match<Update.Return<Model, Message>>(message, {
|
|
59
61
|
ClickedAddRow: () => ({
|
|
60
|
-
model:
|
|
62
|
+
model: modifyFields(model, {
|
|
61
63
|
rows: Array.append({
|
|
62
64
|
id: `counter-${model.nextRowId}`,
|
|
63
65
|
counter: Counter.init,
|
|
@@ -66,7 +68,7 @@ export const update = (model: Model, message: Message) =>
|
|
|
66
68
|
}),
|
|
67
69
|
}),
|
|
68
70
|
ClickedRemoveRow: ({ id }) => ({
|
|
69
|
-
model:
|
|
71
|
+
model: modifyFields(model, {
|
|
70
72
|
rows: Array.filter(row => row.id !== id),
|
|
71
73
|
}),
|
|
72
74
|
}),
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"test": "vitest run"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@effect/platform-browser": "4.0.0-rc.
|
|
12
|
+
"@effect/platform-browser": "4.0.0-rc.116",
|
|
13
13
|
"@foldkit/ui": "workspace:*",
|
|
14
|
-
"effect": "4.0.0-rc.
|
|
14
|
+
"effect": "4.0.0-rc.116",
|
|
15
15
|
"foldkit": "workspace:*"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"test": "vitest run"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@effect/platform-browser": "4.0.0-rc.
|
|
12
|
+
"@effect/platform-browser": "4.0.0-rc.116",
|
|
13
13
|
"@foldkit/ui": "workspace:*",
|
|
14
|
-
"effect": "4.0.0-rc.
|
|
14
|
+
"effect": "4.0.0-rc.116",
|
|
15
15
|
"foldkit": "workspace:*"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
@@ -2,7 +2,7 @@ import { Duration, Effect, Schema, Stream } from 'effect'
|
|
|
2
2
|
import { Command, Port, Runtime, Subscription, type Update } from 'foldkit'
|
|
3
3
|
import { Html, HtmlBuilder } from 'foldkit/html'
|
|
4
4
|
import { defineMessageUnion } from 'foldkit/message'
|
|
5
|
-
import {
|
|
5
|
+
import { modifyFields } from 'foldkit/struct'
|
|
6
6
|
|
|
7
7
|
import { Button } from '@foldkit/ui'
|
|
8
8
|
|
|
@@ -59,7 +59,7 @@ type UpdateReturn = Update.Return<Model, Message>
|
|
|
59
59
|
const advance = (model: Model): UpdateReturn => {
|
|
60
60
|
const count = model.count + model.step
|
|
61
61
|
return {
|
|
62
|
-
model:
|
|
62
|
+
model: modifyFields(model, { count: () => count }),
|
|
63
63
|
commands: [ReportCount({ count })],
|
|
64
64
|
}
|
|
65
65
|
}
|
|
@@ -68,7 +68,9 @@ export const update = (model: Model, message: Message) =>
|
|
|
68
68
|
Message.match<UpdateReturn>(message, {
|
|
69
69
|
Ticked: () => advance(model),
|
|
70
70
|
ClickedAdvance: () => advance(model),
|
|
71
|
-
ChangedStep: ({ step }) => ({
|
|
71
|
+
ChangedStep: ({ step }) => ({
|
|
72
|
+
model: modifyFields(model, { step: () => step }),
|
|
73
|
+
}),
|
|
72
74
|
CompletedReportCount: () => ({ model }),
|
|
73
75
|
})
|
|
74
76
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Command, click, expect, given, role, scene, text } from 'foldkit/scene'
|
|
2
|
-
import {
|
|
2
|
+
import { modifyFields } from 'foldkit/struct'
|
|
3
3
|
import { describe, test } from 'vitest'
|
|
4
4
|
|
|
5
5
|
import { Message, type Model, ReportCount, update, view } from './main'
|
|
@@ -20,7 +20,7 @@ describe('view', () => {
|
|
|
20
20
|
test('clicking the advance button moves the count by the step', () => {
|
|
21
21
|
scene(
|
|
22
22
|
{ update, view },
|
|
23
|
-
given(
|
|
23
|
+
given(modifyFields(initialModel, { step: () => 4 })),
|
|
24
24
|
click(role('button', { name: 'Advance by 4' })),
|
|
25
25
|
Command.resolve(ReportCount, Message.CompletedReportCount()),
|
|
26
26
|
expect(text('14')).toExist(),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Command, given, message, model, story } from 'foldkit/story'
|
|
2
|
-
import {
|
|
2
|
+
import { modifyFields } from 'foldkit/struct'
|
|
3
3
|
import { describe, expect, test } from 'vitest'
|
|
4
4
|
|
|
5
5
|
import { Message, type Model, ReportCount, update } from './main'
|
|
@@ -11,7 +11,7 @@ describe('update', () => {
|
|
|
11
11
|
test('Ticked advances the count by the step and reports it on the outbound port', () => {
|
|
12
12
|
story(
|
|
13
13
|
update,
|
|
14
|
-
given(
|
|
14
|
+
given(modifyFields(initialModel, { step: () => 3 })),
|
|
15
15
|
message(Message.Ticked()),
|
|
16
16
|
model(model => {
|
|
17
17
|
expect(model.count).toBe(13)
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
"test": "vitest run"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@effect/platform-browser": "4.0.0-rc.
|
|
12
|
+
"@effect/platform-browser": "4.0.0-rc.116",
|
|
13
13
|
"@foldkit/ui": "workspace:*",
|
|
14
14
|
"clsx": "^2.1.1",
|
|
15
|
-
"effect": "4.0.0-rc.
|
|
15
|
+
"effect": "4.0.0-rc.116",
|
|
16
16
|
"foldkit": "workspace:*"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
import { type Attribute, Document, Html, HtmlBuilder } from 'foldkit/html'
|
|
16
16
|
import { defineMessageUnion } from 'foldkit/message'
|
|
17
17
|
import { defineTaggedUnion } from 'foldkit/schema'
|
|
18
|
-
import {
|
|
18
|
+
import { modifyFields } from 'foldkit/struct'
|
|
19
19
|
|
|
20
20
|
import { Button, Input, Textarea } from '@foldkit/ui'
|
|
21
21
|
|
|
@@ -122,7 +122,7 @@ const isFormValid = (model: Model): boolean =>
|
|
|
122
122
|
export const update = (model: Model, message: Message) =>
|
|
123
123
|
Message.match<Update.Return<Model, Message>>(message, {
|
|
124
124
|
UpdatedName: ({ value }) => ({
|
|
125
|
-
model:
|
|
125
|
+
model: modifyFields(model, {
|
|
126
126
|
name: () => validateName(value),
|
|
127
127
|
}),
|
|
128
128
|
}),
|
|
@@ -132,14 +132,14 @@ export const update = (model: Model, message: Message) =>
|
|
|
132
132
|
|
|
133
133
|
if (validateEmailResult._tag === 'Valid') {
|
|
134
134
|
return {
|
|
135
|
-
model:
|
|
135
|
+
model: modifyFields(model, {
|
|
136
136
|
email: () => Validating({ value }),
|
|
137
137
|
}),
|
|
138
138
|
commands: [ValidateEmail({ email: value })],
|
|
139
139
|
}
|
|
140
140
|
} else {
|
|
141
141
|
return {
|
|
142
|
-
model:
|
|
142
|
+
model: modifyFields(model, {
|
|
143
143
|
email: () => validateEmailResult,
|
|
144
144
|
}),
|
|
145
145
|
}
|
|
@@ -149,7 +149,7 @@ export const update = (model: Model, message: Message) =>
|
|
|
149
149
|
CompletedValidateEmail: ({ field }) => {
|
|
150
150
|
if (field.value === model.email.value) {
|
|
151
151
|
return {
|
|
152
|
-
model:
|
|
152
|
+
model: modifyFields(model, {
|
|
153
153
|
email: () => field,
|
|
154
154
|
}),
|
|
155
155
|
}
|
|
@@ -159,7 +159,7 @@ export const update = (model: Model, message: Message) =>
|
|
|
159
159
|
},
|
|
160
160
|
|
|
161
161
|
UpdatedMessageText: ({ value }) => ({
|
|
162
|
-
model:
|
|
162
|
+
model: modifyFields(model, {
|
|
163
163
|
messageText: () => Valid({ value }),
|
|
164
164
|
}),
|
|
165
165
|
}),
|
|
@@ -174,7 +174,7 @@ export const update = (model: Model, message: Message) =>
|
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
return {
|
|
177
|
-
model:
|
|
177
|
+
model: modifyFields(model, {
|
|
178
178
|
submission: () => Submission.Submitting(),
|
|
179
179
|
}),
|
|
180
180
|
commands: [
|
|
@@ -188,7 +188,7 @@ export const update = (model: Model, message: Message) =>
|
|
|
188
188
|
},
|
|
189
189
|
|
|
190
190
|
SucceededSubmitForm: ({ name }) => ({
|
|
191
|
-
model:
|
|
191
|
+
model: modifyFields(model, {
|
|
192
192
|
submission: () =>
|
|
193
193
|
Submission.SubmitSuccess({
|
|
194
194
|
confirmationText: `Welcome to the waitlist, ${name}! We'll be in touch soon.`,
|
|
@@ -197,7 +197,7 @@ export const update = (model: Model, message: Message) =>
|
|
|
197
197
|
}),
|
|
198
198
|
|
|
199
199
|
FailedSubmitForm: () => ({
|
|
200
|
-
model:
|
|
200
|
+
model: modifyFields(model, {
|
|
201
201
|
submission: () =>
|
|
202
202
|
Submission.SubmitError({
|
|
203
203
|
error:
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
submit,
|
|
11
11
|
type,
|
|
12
12
|
} from 'foldkit/scene'
|
|
13
|
-
import {
|
|
13
|
+
import { modifyFields } from 'foldkit/struct'
|
|
14
14
|
import { describe, test } from 'vitest'
|
|
15
15
|
|
|
16
16
|
import {
|
|
@@ -58,7 +58,7 @@ describe('view', () => {
|
|
|
58
58
|
})
|
|
59
59
|
|
|
60
60
|
test('typing a well-formed email triggers async validation', () => {
|
|
61
|
-
const modelWithValidName =
|
|
61
|
+
const modelWithValidName = modifyFields(initialModel, {
|
|
62
62
|
name: () => FieldValidation.Valid({ value: 'Alice' }),
|
|
63
63
|
})
|
|
64
64
|
|
|
@@ -101,7 +101,7 @@ describe('view', () => {
|
|
|
101
101
|
})
|
|
102
102
|
|
|
103
103
|
test('submit becomes enabled once name and email are valid', () => {
|
|
104
|
-
const validModel =
|
|
104
|
+
const validModel = modifyFields(initialModel, {
|
|
105
105
|
name: () => FieldValidation.Valid({ value: 'Alice' }),
|
|
106
106
|
email: () => FieldValidation.Valid({ value: 'alice@example.com' }),
|
|
107
107
|
})
|
|
@@ -114,7 +114,7 @@ describe('view', () => {
|
|
|
114
114
|
})
|
|
115
115
|
|
|
116
116
|
test('submitting a valid form shows the loading label then a success banner', () => {
|
|
117
|
-
const validModel =
|
|
117
|
+
const validModel = modifyFields(initialModel, {
|
|
118
118
|
name: () => FieldValidation.Valid({ value: 'Alice' }),
|
|
119
119
|
email: () => FieldValidation.Valid({ value: 'alice@example.com' }),
|
|
120
120
|
})
|
|
@@ -135,7 +135,7 @@ describe('view', () => {
|
|
|
135
135
|
})
|
|
136
136
|
|
|
137
137
|
test('a failed submission renders an error banner', () => {
|
|
138
|
-
const validModel =
|
|
138
|
+
const validModel = modifyFields(initialModel, {
|
|
139
139
|
name: () => FieldValidation.Valid({ value: 'Alice' }),
|
|
140
140
|
email: () => FieldValidation.Valid({ value: 'alice@example.com' }),
|
|
141
141
|
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FieldValidation } from 'foldkit'
|
|
2
2
|
import { Command, given, message, model, story } from 'foldkit/story'
|
|
3
|
-
import {
|
|
3
|
+
import { modifyFields } from 'foldkit/struct'
|
|
4
4
|
import { describe, expect, test } from 'vitest'
|
|
5
5
|
|
|
6
6
|
import {
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
update,
|
|
13
13
|
} from './main'
|
|
14
14
|
|
|
15
|
-
const validModel: Model =
|
|
15
|
+
const validModel: Model = modifyFields(initialModel, {
|
|
16
16
|
name: () => FieldValidation.Valid({ value: 'Alice' }),
|
|
17
17
|
email: () => FieldValidation.Valid({ value: 'alice@example.com' }),
|
|
18
18
|
})
|
|
@@ -83,7 +83,7 @@ describe('update', () => {
|
|
|
83
83
|
})
|
|
84
84
|
|
|
85
85
|
test('a validation result for a superseded email value is ignored', () => {
|
|
86
|
-
const inFlightModel: Model =
|
|
86
|
+
const inFlightModel: Model = modifyFields(initialModel, {
|
|
87
87
|
email: () => FieldValidation.Validating({ value: 'alice@example.com' }),
|
|
88
88
|
})
|
|
89
89
|
|
|
@@ -102,7 +102,7 @@ describe('update', () => {
|
|
|
102
102
|
})
|
|
103
103
|
|
|
104
104
|
test('a validation result for the current email value updates the field', () => {
|
|
105
|
-
const inFlightModel: Model =
|
|
105
|
+
const inFlightModel: Model = modifyFields(initialModel, {
|
|
106
106
|
email: () => FieldValidation.Validating({ value: 'taken@example.com' }),
|
|
107
107
|
})
|
|
108
108
|
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"test": "vitest run"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@effect/platform-browser": "4.0.0-rc.
|
|
12
|
+
"@effect/platform-browser": "4.0.0-rc.116",
|
|
13
13
|
"@foldkit/ui": "workspace:*",
|
|
14
|
-
"effect": "4.0.0-rc.
|
|
14
|
+
"effect": "4.0.0-rc.116",
|
|
15
15
|
"foldkit": "workspace:*"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Option } from 'effect'
|
|
2
2
|
import { click, expect, given, label, role, scene, text } from 'foldkit/scene'
|
|
3
|
-
import {
|
|
3
|
+
import { modifyFields } from 'foldkit/struct'
|
|
4
4
|
import { describe, test } from 'vitest'
|
|
5
5
|
|
|
6
6
|
import { Slider } from '@foldkit/ui'
|
|
@@ -55,7 +55,7 @@ const makeParticle = (id: number, x: number, y: number): Particle => ({
|
|
|
55
55
|
})
|
|
56
56
|
|
|
57
57
|
const modelWithParticles = (count: number): Model =>
|
|
58
|
-
|
|
58
|
+
modifyFields(initialModel, {
|
|
59
59
|
particles: () =>
|
|
60
60
|
Array.from({ length: count }, (_, index) =>
|
|
61
61
|
makeParticle(index, 100 + index * 5, 100),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Array, Option } from 'effect'
|
|
2
2
|
import { Command, given, message, model, story } from 'foldkit/story'
|
|
3
|
-
import {
|
|
3
|
+
import { modifyFields } from 'foldkit/struct'
|
|
4
4
|
import { describe, expect, test } from 'vitest'
|
|
5
5
|
|
|
6
6
|
import { Slider } from '@foldkit/ui'
|
|
@@ -77,7 +77,7 @@ describe('update', () => {
|
|
|
77
77
|
story(
|
|
78
78
|
update,
|
|
79
79
|
given(
|
|
80
|
-
|
|
80
|
+
modifyFields(initialModel, {
|
|
81
81
|
particles: () => [
|
|
82
82
|
makeParticle(0, 100, 100),
|
|
83
83
|
makeParticle(1, 200, 200),
|
|
@@ -140,7 +140,7 @@ describe('update', () => {
|
|
|
140
140
|
story(
|
|
141
141
|
update,
|
|
142
142
|
given(
|
|
143
|
-
|
|
143
|
+
modifyFields(initialModel, {
|
|
144
144
|
particles: () => startingParticles,
|
|
145
145
|
nextId: () => startingParticleCount,
|
|
146
146
|
}),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Array, Number, Option, Result } from 'effect'
|
|
2
2
|
import { Command, Update } from 'foldkit'
|
|
3
|
-
import {
|
|
3
|
+
import { modifyFields } from 'foldkit/struct'
|
|
4
4
|
|
|
5
5
|
import { Slider } from '@foldkit/ui'
|
|
6
6
|
|
|
@@ -155,7 +155,7 @@ const advanceParticle =
|
|
|
155
155
|
const appendedTrail = Array.append(particle.trail, nextPosition)
|
|
156
156
|
const trimmedTrail = Array.takeRight(appendedTrail, TRAIL_LENGTH)
|
|
157
157
|
return Result.succeed(
|
|
158
|
-
|
|
158
|
+
modifyFields(particle, {
|
|
159
159
|
trail: () => trimmedTrail,
|
|
160
160
|
ageMs: () => nextAgeMs,
|
|
161
161
|
}),
|
|
@@ -216,7 +216,7 @@ const appendGeneratedParticle =
|
|
|
216
216
|
initialSpeedScale: generatedParticle.initialSpeedScale,
|
|
217
217
|
}
|
|
218
218
|
return {
|
|
219
|
-
model:
|
|
219
|
+
model: modifyFields(model, {
|
|
220
220
|
particles: Array.append(newParticle),
|
|
221
221
|
nextId: Number.increment,
|
|
222
222
|
}),
|
|
@@ -228,14 +228,14 @@ const foldFlowStrengthSliderOutMessage = Slider.OutMessage.match<
|
|
|
228
228
|
>({
|
|
229
229
|
ChangedValue:
|
|
230
230
|
({ value }) =>
|
|
231
|
-
model => ({ model:
|
|
231
|
+
model => ({ model: modifyFields(model, { flowStrength: () => value }) }),
|
|
232
232
|
})
|
|
233
233
|
|
|
234
234
|
const foldFlowStrengthSlider = Update.foldChild({
|
|
235
235
|
update: Slider.update,
|
|
236
236
|
read: (model: Model) => Option.some(model.flowStrengthSlider),
|
|
237
237
|
write: (model, nextFlowStrengthSlider) =>
|
|
238
|
-
|
|
238
|
+
modifyFields(model, { flowStrengthSlider: () => nextFlowStrengthSlider }),
|
|
239
239
|
toParentMessage: message => Message.GotFlowStrengthSliderMessage({ message }),
|
|
240
240
|
foldOutMessage: foldFlowStrengthSliderOutMessage,
|
|
241
241
|
})
|
|
@@ -245,14 +245,14 @@ const foldNoiseScaleSliderOutMessage = Slider.OutMessage.match<
|
|
|
245
245
|
>({
|
|
246
246
|
ChangedValue:
|
|
247
247
|
({ value }) =>
|
|
248
|
-
model => ({ model:
|
|
248
|
+
model => ({ model: modifyFields(model, { noiseScale: () => value }) }),
|
|
249
249
|
})
|
|
250
250
|
|
|
251
251
|
const foldNoiseScaleSlider = Update.foldChild({
|
|
252
252
|
update: Slider.update,
|
|
253
253
|
read: (model: Model) => Option.some(model.noiseScaleSlider),
|
|
254
254
|
write: (model, nextNoiseScaleSlider) =>
|
|
255
|
-
|
|
255
|
+
modifyFields(model, { noiseScaleSlider: () => nextNoiseScaleSlider }),
|
|
256
256
|
toParentMessage: message => Message.GotNoiseScaleSliderMessage({ message }),
|
|
257
257
|
foldOutMessage: foldNoiseScaleSliderOutMessage,
|
|
258
258
|
})
|
|
@@ -272,7 +272,7 @@ export const update = (model: Model, message: Message) =>
|
|
|
272
272
|
model.maybeMousePosition,
|
|
273
273
|
),
|
|
274
274
|
)
|
|
275
|
-
const nextModel =
|
|
275
|
+
const nextModel = modifyFields(model, {
|
|
276
276
|
particles: () => advancedParticles,
|
|
277
277
|
elapsedSeconds: () => nextElapsedSeconds,
|
|
278
278
|
})
|
|
@@ -296,17 +296,17 @@ export const update = (model: Model, message: Message) =>
|
|
|
296
296
|
}),
|
|
297
297
|
|
|
298
298
|
MovedPointer: ({ x, y }) => ({
|
|
299
|
-
model:
|
|
299
|
+
model: modifyFields(model, {
|
|
300
300
|
maybeMousePosition: () => Option.some(Point.make({ x, y })),
|
|
301
301
|
}),
|
|
302
302
|
}),
|
|
303
303
|
|
|
304
304
|
ClickedTogglePlay: () => ({
|
|
305
|
-
model:
|
|
305
|
+
model: modifyFields(model, { isRunning: running => !running }),
|
|
306
306
|
}),
|
|
307
307
|
|
|
308
308
|
ClickedReset: () => ({
|
|
309
|
-
model:
|
|
309
|
+
model: modifyFields(model, {
|
|
310
310
|
particles: () => [],
|
|
311
311
|
maybeMousePosition: () => Option.none(),
|
|
312
312
|
}),
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"test": "vitest run"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@effect/platform-browser": "4.0.0-rc.
|
|
12
|
+
"@effect/platform-browser": "4.0.0-rc.116",
|
|
13
13
|
"clsx": "^2.1.1",
|
|
14
|
-
"effect": "4.0.0-rc.
|
|
14
|
+
"effect": "4.0.0-rc.116",
|
|
15
15
|
"foldkit": "workspace:*"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|