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
|
@@ -23,7 +23,8 @@ const variantClassName = (variant: Variant): string =>
|
|
|
23
23
|
Match.exhaustive,
|
|
24
24
|
)
|
|
25
25
|
|
|
26
|
-
const entryClassName =
|
|
26
|
+
const entryClassName =
|
|
27
|
+
'w-80 motion-safe:data-[swipe=settling]:transition-[translate] motion-safe:data-[swipe=settling]:duration-150 motion-safe:data-[swipe=settling]:ease-out motion-safe:data-[swipe=end]:transition-[translate] motion-safe:data-[swipe=end]:duration-[240ms] motion-safe:data-[swipe=end]:ease-in'
|
|
27
28
|
|
|
28
29
|
const renderToastEntry = (
|
|
29
30
|
entry: Entry,
|
|
@@ -37,11 +38,27 @@ const renderToastEntry = (
|
|
|
37
38
|
),
|
|
38
39
|
],
|
|
39
40
|
[
|
|
40
|
-
h.p(
|
|
41
|
+
h.p(
|
|
42
|
+
[h.Class('font-semibold text-sm')],
|
|
43
|
+
[
|
|
44
|
+
h.span(
|
|
45
|
+
[h.DataAttribute('toast-swipe-ignore', '')],
|
|
46
|
+
[entry.payload.title],
|
|
47
|
+
),
|
|
48
|
+
],
|
|
49
|
+
),
|
|
41
50
|
...Option.match(entry.payload.maybeDescription, {
|
|
42
51
|
onNone: () => [],
|
|
43
52
|
onSome: description => [
|
|
44
|
-
h.p(
|
|
53
|
+
h.p(
|
|
54
|
+
[h.Class('text-sm text-gray-700 mt-0.5')],
|
|
55
|
+
[
|
|
56
|
+
h.span(
|
|
57
|
+
[h.DataAttribute('toast-swipe-ignore', '')],
|
|
58
|
+
[description],
|
|
59
|
+
),
|
|
60
|
+
],
|
|
61
|
+
),
|
|
45
62
|
],
|
|
46
63
|
}),
|
|
47
64
|
h.button(
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"test": "vitest run"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@effect/platform-browser": "4.0.0-rc.
|
|
13
|
-
"effect": "4.0.0-rc.
|
|
12
|
+
"@effect/platform-browser": "4.0.0-rc.116",
|
|
13
|
+
"effect": "4.0.0-rc.116",
|
|
14
14
|
"foldkit": "workspace:*"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
@@ -4,7 +4,7 @@ import { Document, Html, HtmlBuilder } from 'foldkit/html'
|
|
|
4
4
|
import { defineMessageUnion } from 'foldkit/message'
|
|
5
5
|
import { UrlRequest, load, pushUrl } from 'foldkit/navigation'
|
|
6
6
|
import { Transition } from 'foldkit/route'
|
|
7
|
-
import {
|
|
7
|
+
import { modifyFields } from 'foldkit/struct'
|
|
8
8
|
import { Url, toString as urlToString } from 'foldkit/url'
|
|
9
9
|
|
|
10
10
|
import { Artwork, artworks, findArtwork } from './artwork'
|
|
@@ -76,11 +76,11 @@ export const update = (model: Model, message: Message) =>
|
|
|
76
76
|
}),
|
|
77
77
|
|
|
78
78
|
ChangedUrl: ({ url }) => ({
|
|
79
|
-
model:
|
|
79
|
+
model: modifyFields(model, { route: () => urlToAppRoute(url) }),
|
|
80
80
|
}),
|
|
81
81
|
|
|
82
82
|
UpdatedFilterText: ({ filterText }) => ({
|
|
83
|
-
model:
|
|
83
|
+
model: modifyFields(model, { filterText: () => filterText }),
|
|
84
84
|
}),
|
|
85
85
|
})
|
|
86
86
|
|
|
@@ -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": {
|
|
@@ -3,7 +3,7 @@ import { HttpClient, HttpClientRequest } from 'effect/unstable/http'
|
|
|
3
3
|
import { AsyncData, Command, Http, Runtime, type Update } from 'foldkit'
|
|
4
4
|
import { Document, Html, HtmlBuilder } from 'foldkit/html'
|
|
5
5
|
import { defineMessageUnion } from 'foldkit/message'
|
|
6
|
-
import {
|
|
6
|
+
import { modifyFields } from 'foldkit/struct'
|
|
7
7
|
|
|
8
8
|
import { Button, Input } from '@foldkit/ui'
|
|
9
9
|
|
|
@@ -42,7 +42,7 @@ export type Message = typeof Message.Type
|
|
|
42
42
|
export const update = (model: Model, message: Message) =>
|
|
43
43
|
Message.match<Update.Return<Model, Message>>(message, {
|
|
44
44
|
UpdatedZipCodeInput: ({ value }) => ({
|
|
45
|
-
model:
|
|
45
|
+
model: modifyFields(model, {
|
|
46
46
|
zipCodeInput: () => value,
|
|
47
47
|
}),
|
|
48
48
|
}),
|
|
@@ -52,7 +52,7 @@ export const update = (model: Model, message: Message) =>
|
|
|
52
52
|
return { model }
|
|
53
53
|
}
|
|
54
54
|
return {
|
|
55
|
-
model:
|
|
55
|
+
model: modifyFields(model, {
|
|
56
56
|
weather: () => WeatherAsyncData.Loading(),
|
|
57
57
|
}),
|
|
58
58
|
commands: [FetchWeather({ zipCode: model.zipCodeInput })],
|
|
@@ -60,13 +60,13 @@ export const update = (model: Model, message: Message) =>
|
|
|
60
60
|
},
|
|
61
61
|
|
|
62
62
|
SucceededFetchWeather: ({ weather }) => ({
|
|
63
|
-
model:
|
|
63
|
+
model: modifyFields(model, {
|
|
64
64
|
weather: () => WeatherAsyncData.Success({ data: weather }),
|
|
65
65
|
}),
|
|
66
66
|
}),
|
|
67
67
|
|
|
68
68
|
FailedFetchWeather: ({ error }) => ({
|
|
69
|
-
model:
|
|
69
|
+
model: modifyFields(model, {
|
|
70
70
|
weather: () => WeatherAsyncData.Failure({ error }),
|
|
71
71
|
}),
|
|
72
72
|
}),
|
|
@@ -9,11 +9,11 @@
|
|
|
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
|
"@shoelace-style/shoelace": "^2.20.1",
|
|
15
15
|
"clsx": "^2.1.1",
|
|
16
|
-
"effect": "4.0.0-rc.
|
|
16
|
+
"effect": "4.0.0-rc.116",
|
|
17
17
|
"foldkit": "workspace:*",
|
|
18
18
|
"vanilla-colorful": "^0.7.2"
|
|
19
19
|
},
|
|
@@ -3,7 +3,7 @@ import { Schema } from 'effect'
|
|
|
3
3
|
import { CustomElement, Runtime, type Update } from 'foldkit'
|
|
4
4
|
import { Document, Html, HtmlBuilder } from 'foldkit/html'
|
|
5
5
|
import { defineMessageUnion } from 'foldkit/message'
|
|
6
|
-
import {
|
|
6
|
+
import { modifyFields } from 'foldkit/struct'
|
|
7
7
|
import 'vanilla-colorful/hex-color-picker.js'
|
|
8
8
|
|
|
9
9
|
import { Button, Input } from '@foldkit/ui'
|
|
@@ -47,13 +47,13 @@ export const init: Runtime.ApplicationInit<Model, Message> = () => ({
|
|
|
47
47
|
export const update = (model: Model, message: Message) =>
|
|
48
48
|
Message.match<Update.Return<Model, Message>>(message, {
|
|
49
49
|
UpdatedContent: ({ value }) => ({
|
|
50
|
-
model:
|
|
50
|
+
model: modifyFields(model, { content: () => value }),
|
|
51
51
|
}),
|
|
52
52
|
ChangedFillColor: ({ value }) => ({
|
|
53
|
-
model:
|
|
53
|
+
model: modifyFields(model, { fillColor: () => value }),
|
|
54
54
|
}),
|
|
55
55
|
ChangedBackgroundColor: ({ value }) => ({
|
|
56
|
-
model:
|
|
56
|
+
model: modifyFields(model, { backgroundColor: () => value }),
|
|
57
57
|
}),
|
|
58
58
|
})
|
|
59
59
|
|
|
@@ -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": {
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
import { Document, Html, HtmlBuilder } from 'foldkit/html'
|
|
21
21
|
import { defineMessageUnion } from 'foldkit/message'
|
|
22
22
|
import { defineTaggedUnion } from 'foldkit/schema'
|
|
23
|
-
import {
|
|
23
|
+
import { modifyFields } from 'foldkit/struct'
|
|
24
24
|
|
|
25
25
|
import { Button, Input } from '@foldkit/ui'
|
|
26
26
|
|
|
@@ -87,32 +87,32 @@ type UpdateReturn = Update.Return<Model, Message, ChatSocketService>
|
|
|
87
87
|
export const update = (model: Model, message: Message) =>
|
|
88
88
|
Message.match<UpdateReturn>(message, {
|
|
89
89
|
ClickedConnect: () => ({
|
|
90
|
-
model:
|
|
90
|
+
model: modifyFields(model, {
|
|
91
91
|
connection: () => ConnectionState.Connecting(),
|
|
92
92
|
}),
|
|
93
93
|
}),
|
|
94
94
|
|
|
95
95
|
Connected: () => ({
|
|
96
|
-
model:
|
|
96
|
+
model: modifyFields(model, {
|
|
97
97
|
connection: () => ConnectionState.Connected(),
|
|
98
98
|
}),
|
|
99
99
|
}),
|
|
100
100
|
|
|
101
101
|
Disconnected: () => ({
|
|
102
|
-
model:
|
|
102
|
+
model: modifyFields(model, {
|
|
103
103
|
connection: () => ConnectionState.Disconnected(),
|
|
104
104
|
messages: () => [],
|
|
105
105
|
}),
|
|
106
106
|
}),
|
|
107
107
|
|
|
108
108
|
FailedConnect: ({ error }) => ({
|
|
109
|
-
model:
|
|
109
|
+
model: modifyFields(model, {
|
|
110
110
|
connection: () => ConnectionState.Error({ error }),
|
|
111
111
|
}),
|
|
112
112
|
}),
|
|
113
113
|
|
|
114
114
|
UpdatedMessageInput: ({ value }) => ({
|
|
115
|
-
model:
|
|
115
|
+
model: modifyFields(model, {
|
|
116
116
|
messageInput: () => value,
|
|
117
117
|
}),
|
|
118
118
|
}),
|
|
@@ -127,7 +127,7 @@ export const update = (model: Model, message: Message) =>
|
|
|
127
127
|
return Match.value(model.connection).pipe(
|
|
128
128
|
Match.withReturnType<UpdateReturn>(),
|
|
129
129
|
Match.tag('Connected', () => ({
|
|
130
|
-
model:
|
|
130
|
+
model: modifyFields(model, {
|
|
131
131
|
messageInput: () => '',
|
|
132
132
|
}),
|
|
133
133
|
commands: [SendMessage({ text: trimmedMessage })],
|
|
@@ -150,7 +150,7 @@ export const update = (model: Model, message: Message) =>
|
|
|
150
150
|
const newMessage = ChatMessage.make({ text, zoned, isSent })
|
|
151
151
|
|
|
152
152
|
return {
|
|
153
|
-
model:
|
|
153
|
+
model: modifyFields(model, {
|
|
154
154
|
messages: messages => [...messages, newMessage],
|
|
155
155
|
}),
|
|
156
156
|
}
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
text,
|
|
13
13
|
type,
|
|
14
14
|
} from 'foldkit/scene'
|
|
15
|
-
import {
|
|
15
|
+
import { modifyFields } from 'foldkit/struct'
|
|
16
16
|
import { describe, test } from 'vitest'
|
|
17
17
|
|
|
18
18
|
import {
|
|
@@ -51,7 +51,11 @@ describe('view', () => {
|
|
|
51
51
|
test('connecting state renders the Connecting message', () => {
|
|
52
52
|
scene(
|
|
53
53
|
{ update, view },
|
|
54
|
-
given(
|
|
54
|
+
given(
|
|
55
|
+
modifyFields(idleModel, {
|
|
56
|
+
connection: () => ConnectionState.Connecting(),
|
|
57
|
+
}),
|
|
58
|
+
),
|
|
55
59
|
expect(text('Connecting...')).toExist(),
|
|
56
60
|
)
|
|
57
61
|
})
|
|
@@ -59,7 +63,11 @@ describe('view', () => {
|
|
|
59
63
|
test('connected state shows the message input and Send button', () => {
|
|
60
64
|
scene(
|
|
61
65
|
{ update, view },
|
|
62
|
-
given(
|
|
66
|
+
given(
|
|
67
|
+
modifyFields(idleModel, {
|
|
68
|
+
connection: () => ConnectionState.Connected(),
|
|
69
|
+
}),
|
|
70
|
+
),
|
|
63
71
|
expect(placeholder('Type a message...')).toExist(),
|
|
64
72
|
expect(role('button', { name: 'Send' })).toBeDisabled(),
|
|
65
73
|
type(placeholder('Type a message...'), 'hi'),
|
|
@@ -71,7 +79,7 @@ describe('view', () => {
|
|
|
71
79
|
scene(
|
|
72
80
|
{ update, view },
|
|
73
81
|
given(
|
|
74
|
-
|
|
82
|
+
modifyFields(idleModel, {
|
|
75
83
|
connection: () =>
|
|
76
84
|
ConnectionState.Error({
|
|
77
85
|
error: 'Connection refused',
|
|
@@ -88,7 +96,7 @@ describe('view', () => {
|
|
|
88
96
|
scene(
|
|
89
97
|
{ update, view },
|
|
90
98
|
given(
|
|
91
|
-
|
|
99
|
+
modifyFields(idleModel, {
|
|
92
100
|
connection: () => ConnectionState.Connected(),
|
|
93
101
|
messages: () => [
|
|
94
102
|
{ text: 'Hello there', zoned: zonedAt(0), isSent: true },
|
|
@@ -149,7 +157,11 @@ describe('view', () => {
|
|
|
149
157
|
test('a message arriving on the socket Subscription lands in the conversation', () => {
|
|
150
158
|
scene(
|
|
151
159
|
{ update, view },
|
|
152
|
-
given(
|
|
160
|
+
given(
|
|
161
|
+
modifyFields(idleModel, {
|
|
162
|
+
connection: () => ConnectionState.Connected(),
|
|
163
|
+
}),
|
|
164
|
+
),
|
|
153
165
|
Subscription.emit(Message.ReceivedMessage({ text: 'hello from echo' })),
|
|
154
166
|
Command.expectExact(
|
|
155
167
|
TimestampReceivedMessage({ text: 'hello from echo' }),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DateTime } 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 {
|
|
@@ -19,7 +19,7 @@ const idleModel: Model = {
|
|
|
19
19
|
messageInput: '',
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
const connectedModel: Model =
|
|
22
|
+
const connectedModel: Model = modifyFields(idleModel, {
|
|
23
23
|
connection: () => ConnectionState.Connected(),
|
|
24
24
|
})
|
|
25
25
|
|
|
@@ -42,7 +42,9 @@ describe('update', () => {
|
|
|
42
42
|
story(
|
|
43
43
|
update,
|
|
44
44
|
given(
|
|
45
|
-
|
|
45
|
+
modifyFields(idleModel, {
|
|
46
|
+
connection: () => ConnectionState.Connecting(),
|
|
47
|
+
}),
|
|
46
48
|
),
|
|
47
49
|
message(Message.Connected()),
|
|
48
50
|
model(model => {
|
|
@@ -55,7 +57,7 @@ describe('update', () => {
|
|
|
55
57
|
story(
|
|
56
58
|
update,
|
|
57
59
|
given(
|
|
58
|
-
|
|
60
|
+
modifyFields(connectedModel, {
|
|
59
61
|
messages: () => [{ text: 'old', zoned: zonedNow, isSent: true }],
|
|
60
62
|
}),
|
|
61
63
|
),
|
|
@@ -71,7 +73,9 @@ describe('update', () => {
|
|
|
71
73
|
story(
|
|
72
74
|
update,
|
|
73
75
|
given(
|
|
74
|
-
|
|
76
|
+
modifyFields(idleModel, {
|
|
77
|
+
connection: () => ConnectionState.Connecting(),
|
|
78
|
+
}),
|
|
75
79
|
),
|
|
76
80
|
message(Message.FailedConnect({ error: 'Timeout' })),
|
|
77
81
|
model(model => {
|
|
@@ -102,7 +106,7 @@ describe('update', () => {
|
|
|
102
106
|
test('an empty input is ignored', () => {
|
|
103
107
|
story(
|
|
104
108
|
update,
|
|
105
|
-
given(
|
|
109
|
+
given(modifyFields(connectedModel, { messageInput: () => '' })),
|
|
106
110
|
message(Message.SubmittedMessage()),
|
|
107
111
|
Command.expectNone(),
|
|
108
112
|
)
|
|
@@ -111,7 +115,7 @@ describe('update', () => {
|
|
|
111
115
|
test('whitespace-only input is ignored', () => {
|
|
112
116
|
story(
|
|
113
117
|
update,
|
|
114
|
-
given(
|
|
118
|
+
given(modifyFields(connectedModel, { messageInput: () => ' ' })),
|
|
115
119
|
message(Message.SubmittedMessage()),
|
|
116
120
|
Command.expectNone(),
|
|
117
121
|
)
|
|
@@ -120,7 +124,9 @@ describe('update', () => {
|
|
|
120
124
|
test('connected client fires SendMessage and clears the input', () => {
|
|
121
125
|
story(
|
|
122
126
|
update,
|
|
123
|
-
given(
|
|
127
|
+
given(
|
|
128
|
+
modifyFields(connectedModel, { messageInput: () => 'Hello there' }),
|
|
129
|
+
),
|
|
124
130
|
message(Message.SubmittedMessage()),
|
|
125
131
|
model(model => {
|
|
126
132
|
expect(model.messageInput).toBe('')
|
|
@@ -150,7 +156,7 @@ describe('update', () => {
|
|
|
150
156
|
test('disconnected client ignores SubmittedMessage', () => {
|
|
151
157
|
story(
|
|
152
158
|
update,
|
|
153
|
-
given(
|
|
159
|
+
given(modifyFields(idleModel, { messageInput: () => 'Hello' })),
|
|
154
160
|
message(Message.SubmittedMessage()),
|
|
155
161
|
Command.expectNone(),
|
|
156
162
|
model(model => {
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"channel": "stable",
|
|
4
|
-
"sourceCommit": "
|
|
4
|
+
"sourceCommit": "b415a3e22be572abb1785010e23bd3e57f2e24f2",
|
|
5
5
|
"packages": {
|
|
6
|
-
"create-foldkit-app": "0.35.
|
|
7
|
-
"@foldkit/devtools": "0.
|
|
8
|
-
"@foldkit/devtools-mcp": "0.
|
|
9
|
-
"foldkit": "0.
|
|
10
|
-
"@foldkit/markdown": "0.
|
|
11
|
-
"@foldkit/oxlint-plugin": "0.
|
|
12
|
-
"@foldkit/ui": "0.
|
|
13
|
-
"@foldkit/vite-plugin": "0.
|
|
6
|
+
"create-foldkit-app": "0.35.2",
|
|
7
|
+
"@foldkit/devtools": "0.163.0",
|
|
8
|
+
"@foldkit/devtools-mcp": "0.22.0",
|
|
9
|
+
"foldkit": "0.163.0",
|
|
10
|
+
"@foldkit/markdown": "0.12.0",
|
|
11
|
+
"@foldkit/oxlint-plugin": "0.15.0",
|
|
12
|
+
"@foldkit/ui": "0.163.0",
|
|
13
|
+
"@foldkit/vite-plugin": "0.24.0"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@foldkit/devtools": "0.
|
|
17
|
-
"@foldkit/vite-plugin": "0.
|
|
18
|
-
"@foldkit/devtools-mcp": "0.
|
|
19
|
-
"@foldkit/oxlint-plugin": "0.
|
|
16
|
+
"@foldkit/devtools": "0.163.0",
|
|
17
|
+
"@foldkit/vite-plugin": "0.24.0",
|
|
18
|
+
"@foldkit/devtools-mcp": "0.22.0",
|
|
19
|
+
"@foldkit/oxlint-plugin": "0.15.0",
|
|
20
20
|
"@types/node": "^26.4.0",
|
|
21
21
|
"happy-dom": "^20.11.13",
|
|
22
22
|
"oxfmt": "^0.66.0",
|
|
@@ -3,7 +3,7 @@ import { Command, Runtime, type Update } from 'foldkit'
|
|
|
3
3
|
import { type Document, type Html, type HtmlBuilder } from 'foldkit/html'
|
|
4
4
|
import { defineMessageUnion } from 'foldkit/message'
|
|
5
5
|
import { UrlRequest, load, pushUrl } from 'foldkit/navigation'
|
|
6
|
-
import {
|
|
6
|
+
import { modifyFields } from 'foldkit/struct'
|
|
7
7
|
import { Url, toString as urlToString } from 'foldkit/url'
|
|
8
8
|
|
|
9
9
|
import { AppRoute, aboutRouter, homeRouter, urlToAppRoute } from './route'
|
|
@@ -57,7 +57,7 @@ type UpdateReturn = Update.Return<Model, Message>
|
|
|
57
57
|
export const update = (model: Model, message: Message) =>
|
|
58
58
|
Message.match<UpdateReturn>(message, {
|
|
59
59
|
ClickedIncrement: () => ({
|
|
60
|
-
model:
|
|
60
|
+
model: modifyFields(model, { count: count => count + 1 }),
|
|
61
61
|
}),
|
|
62
62
|
ClickedLink: ({ request }) =>
|
|
63
63
|
UrlRequest.match<UpdateReturn>(request, {
|
|
@@ -71,7 +71,7 @@ export const update = (model: Model, message: Message) =>
|
|
|
71
71
|
}),
|
|
72
72
|
}),
|
|
73
73
|
ChangedUrl: ({ url }) => ({
|
|
74
|
-
model:
|
|
74
|
+
model: modifyFields(model, { route: () => urlToAppRoute(url) }),
|
|
75
75
|
}),
|
|
76
76
|
CompletedNavigateInternal: () => ({ model }),
|
|
77
77
|
CompletedLoadExternal: () => ({ model }),
|
|
@@ -97,8 +97,8 @@ const makeHandler = Effect.gen(function* () {
|
|
|
97
97
|
() => `http://localhost:${globalThis.String(port)}`,
|
|
98
98
|
)
|
|
99
99
|
const app = yield* loadFetchHandler
|
|
100
|
-
// NOTE: `
|
|
101
|
-
//
|
|
100
|
+
// NOTE: directory requests reach `fetch` even when a generated index file
|
|
101
|
+
// exists. This host serves assets as files and renders pages at request time.
|
|
102
102
|
const staticFiles = yield* HttpStaticServer.make({
|
|
103
103
|
root: CLIENT_DIR,
|
|
104
104
|
index: undefined,
|
|
@@ -2,7 +2,7 @@ import { Effect, Schema } from 'effect'
|
|
|
2
2
|
import { Command, Runtime, type Update } from 'foldkit'
|
|
3
3
|
import { type Document, type 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
|
|
|
@@ -43,14 +43,14 @@ export const update = (model: Model, message: Message) =>
|
|
|
43
43
|
ClickedDecrement: () => {
|
|
44
44
|
const nextCount = model.count - 1
|
|
45
45
|
return {
|
|
46
|
-
model:
|
|
46
|
+
model: modifyFields(model, { count: () => nextCount }),
|
|
47
47
|
commands: [PersistCount({ count: nextCount })],
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
50
|
ClickedIncrement: () => {
|
|
51
51
|
const nextCount = model.count + 1
|
|
52
52
|
return {
|
|
53
|
-
model:
|
|
53
|
+
model: modifyFields(model, { count: () => nextCount }),
|
|
54
54
|
commands: [PersistCount({ count: nextCount })],
|
|
55
55
|
}
|
|
56
56
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-foldkit-app",
|
|
3
|
-
"version": "0.35.
|
|
3
|
+
"version": "0.35.2",
|
|
4
4
|
"description": "Create Foldkit applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -11,15 +11,15 @@
|
|
|
11
11
|
"dist"
|
|
12
12
|
],
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@effect/platform-node": "4.0.0-rc.
|
|
15
|
-
"@effect/platform-node-shared": "4.0.0-rc.
|
|
14
|
+
"@effect/platform-node": "4.0.0-rc.116",
|
|
15
|
+
"@effect/platform-node-shared": "4.0.0-rc.116",
|
|
16
16
|
"chalk": "^6.0.0",
|
|
17
|
-
"effect": "4.0.0-rc.
|
|
17
|
+
"effect": "4.0.0-rc.116",
|
|
18
18
|
"rimraf": "^6.1.3",
|
|
19
19
|
"typescript": "^7.0.2"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@effect/vitest": "4.0.0-rc.
|
|
22
|
+
"@effect/vitest": "4.0.0-rc.116",
|
|
23
23
|
"@types/node": "^26.4.0",
|
|
24
24
|
"vitest": "^5.0.0"
|
|
25
25
|
},
|