create-foldkit-app 0.30.1 → 0.31.0
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 +3 -1
- package/dist/templates/examples/auth/src/main.ts +3 -3
- package/dist/templates/examples/auth/src/page/loggedIn/model.ts +2 -2
- package/dist/templates/examples/auth/src/page/loggedOut/model.ts +2 -2
- package/dist/templates/examples/auth/src/route.ts +19 -29
- package/dist/templates/examples/auth/src/scene.test.ts +2 -2
- package/dist/templates/examples/auth/src/update.ts +3 -4
- package/dist/templates/examples/form/src/main.ts +12 -21
- package/dist/templates/examples/interrupting-commands/src/scene.test.ts +2 -2
- package/dist/templates/examples/interrupting-commands/src/story.test.ts +7 -7
- package/dist/templates/examples/job-application/src/main.ts +2 -2
- package/dist/templates/examples/job-application/src/model.ts +7 -12
- package/dist/templates/examples/job-application/src/scene.test.ts +5 -11
- package/dist/templates/examples/job-application/src/story.test.ts +4 -4
- package/dist/templates/examples/job-application/src/update.ts +8 -4
- package/dist/templates/examples/job-application/src/view/review.ts +92 -94
- package/dist/templates/examples/managed-resource-layer/src/main.ts +23 -27
- package/dist/templates/examples/managed-resource-layer/src/scene.test.ts +3 -4
- package/dist/templates/examples/managed-resource-layer/src/story.test.ts +11 -20
- package/dist/templates/examples/map/src/main.fixtures.ts +2 -2
- package/dist/templates/examples/map/src/main.ts +23 -21
- package/dist/templates/examples/map/src/scene.test.ts +4 -2
- package/dist/templates/examples/map/src/story.test.ts +9 -10
- package/dist/templates/examples/query-sync/src/main.ts +30 -29
- package/dist/templates/examples/query-sync/src/scene.test.ts +8 -15
- package/dist/templates/examples/query-sync/src/story.test.ts +21 -8
- package/dist/templates/examples/route-transitions/src/main.ts +15 -25
- package/dist/templates/examples/route-transitions/src/route.ts +21 -26
- package/dist/templates/examples/route-transitions/src/story.test.ts +20 -26
- package/dist/templates/examples/routing/src/fileTree.ts +3 -3
- package/dist/templates/examples/routing/src/main.ts +2 -12
- package/dist/templates/examples/routing/src/page/people.ts +18 -16
- package/dist/templates/examples/routing/src/route.ts +18 -32
- package/dist/templates/examples/routing/src/scene.test.ts +12 -20
- package/dist/templates/examples/routing/src/story.test.ts +9 -6
- package/dist/templates/examples/shopping-cart/src/route.ts +11 -19
- package/dist/templates/examples/shopping-cart/src/scene.test.ts +10 -8
- package/dist/templates/examples/shopping-cart/src/story.test.ts +2 -2
- package/dist/templates/examples/ssg/src/route.ts +9 -8
- package/dist/templates/examples/state-machine/src/main.ts +68 -63
- package/dist/templates/examples/state-machine/src/story.test.ts +8 -7
- package/dist/templates/examples/state-machine/src/view.ts +7 -13
- package/dist/templates/examples/todo/src/main.ts +11 -17
- package/dist/templates/examples/todo/src/scene.test.ts +2 -2
- package/dist/templates/examples/todo/src/story.test.ts +11 -12
- package/dist/templates/examples/ui-showcase/src/main.ts +64 -85
- package/dist/templates/examples/ui-showcase/src/scene.test.ts +14 -30
- package/dist/templates/examples/ui-showcase/src/story.test.ts +2 -2
- package/dist/templates/examples/ui-showcase/src/ui/message.ts +0 -70
- package/dist/templates/examples/view-transitions/src/main.ts +1 -1
- package/dist/templates/examples/view-transitions/src/route.ts +9 -12
- package/dist/templates/examples/view-transitions/src/scene.test.ts +5 -14
- package/dist/templates/examples/websocket-chat/src/main.ts +29 -37
- package/dist/templates/examples/websocket-chat/src/scene.test.ts +18 -10
- package/dist/templates/examples/websocket-chat/src/story.test.ts +19 -15
- package/dist/templates/release.json +13 -13
- package/dist/templates/rendering/ssg/src/route.ts +9 -8
- package/dist/templates/rendering/ssg/src/scene.test.ts +2 -2
- package/package.json +1 -1
|
@@ -3,9 +3,7 @@ import { Command, given, message, model, story } from 'foldkit/story'
|
|
|
3
3
|
import { describe, expect, test } from 'vitest'
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
ConnectionConnecting,
|
|
8
|
-
ConnectionDisconnected,
|
|
6
|
+
ConnectionState,
|
|
9
7
|
Message,
|
|
10
8
|
type Model,
|
|
11
9
|
SendMessage,
|
|
@@ -15,43 +13,46 @@ import {
|
|
|
15
13
|
} from './main'
|
|
16
14
|
|
|
17
15
|
const idleModel: Model = {
|
|
18
|
-
connection:
|
|
16
|
+
connection: ConnectionState.Disconnected(),
|
|
19
17
|
messages: [],
|
|
20
18
|
messageInput: '',
|
|
21
19
|
}
|
|
22
20
|
|
|
23
21
|
const connectedModel: Model = {
|
|
24
22
|
...idleModel,
|
|
25
|
-
connection:
|
|
23
|
+
connection: ConnectionState.Connected(),
|
|
26
24
|
}
|
|
27
25
|
|
|
28
26
|
const zonedNow = DateTime.makeZonedUnsafe(0, { timeZone: 'UTC' })
|
|
29
27
|
|
|
30
28
|
describe('update', () => {
|
|
31
29
|
describe('connection state', () => {
|
|
32
|
-
test('ClickedConnect moves into
|
|
30
|
+
test('ClickedConnect moves into Connecting', () => {
|
|
33
31
|
story(
|
|
34
32
|
update,
|
|
35
33
|
given(idleModel),
|
|
36
34
|
message(Message.ClickedConnect()),
|
|
37
35
|
model(model => {
|
|
38
|
-
expect(model.connection._tag).toBe('
|
|
36
|
+
expect(model.connection._tag).toBe('Connecting')
|
|
39
37
|
}),
|
|
40
38
|
)
|
|
41
39
|
})
|
|
42
40
|
|
|
43
|
-
test('Connected moves into
|
|
41
|
+
test('Connected moves into Connected', () => {
|
|
44
42
|
story(
|
|
45
43
|
update,
|
|
46
|
-
given({
|
|
44
|
+
given({
|
|
45
|
+
...idleModel,
|
|
46
|
+
connection: ConnectionState.Connecting(),
|
|
47
|
+
}),
|
|
47
48
|
message(Message.Connected()),
|
|
48
49
|
model(model => {
|
|
49
|
-
expect(model.connection._tag).toBe('
|
|
50
|
+
expect(model.connection._tag).toBe('Connected')
|
|
50
51
|
}),
|
|
51
52
|
)
|
|
52
53
|
})
|
|
53
54
|
|
|
54
|
-
test('Disconnected returns to
|
|
55
|
+
test('Disconnected returns to Disconnected and clears messages', () => {
|
|
55
56
|
story(
|
|
56
57
|
update,
|
|
57
58
|
given({
|
|
@@ -60,7 +61,7 @@ describe('update', () => {
|
|
|
60
61
|
}),
|
|
61
62
|
message(Message.Disconnected()),
|
|
62
63
|
model(model => {
|
|
63
|
-
expect(model.connection._tag).toBe('
|
|
64
|
+
expect(model.connection._tag).toBe('Disconnected')
|
|
64
65
|
expect(model.messages).toHaveLength(0)
|
|
65
66
|
}),
|
|
66
67
|
)
|
|
@@ -69,13 +70,16 @@ describe('update', () => {
|
|
|
69
70
|
test('FailedConnect captures the error message', () => {
|
|
70
71
|
story(
|
|
71
72
|
update,
|
|
72
|
-
given({
|
|
73
|
+
given({
|
|
74
|
+
...idleModel,
|
|
75
|
+
connection: ConnectionState.Connecting(),
|
|
76
|
+
}),
|
|
73
77
|
message(Message.FailedConnect({ error: 'Timeout' })),
|
|
74
78
|
model(model => {
|
|
75
|
-
if (model.connection._tag === '
|
|
79
|
+
if (model.connection._tag === 'Error') {
|
|
76
80
|
expect(model.connection.error).toBe('Timeout')
|
|
77
81
|
} else {
|
|
78
|
-
throw new Error('Expected
|
|
82
|
+
throw new Error('Expected Error')
|
|
79
83
|
}
|
|
80
84
|
}),
|
|
81
85
|
)
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"channel": "stable",
|
|
4
|
-
"sourceCommit": "
|
|
4
|
+
"sourceCommit": "51ee84596c4ff4c6141d2642c7c76446d6bf7890",
|
|
5
5
|
"packages": {
|
|
6
|
-
"create-foldkit-app": "0.
|
|
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.31.0",
|
|
7
|
+
"@foldkit/devtools": "0.153.0",
|
|
8
|
+
"@foldkit/devtools-mcp": "0.19.0",
|
|
9
|
+
"foldkit": "0.153.0",
|
|
10
|
+
"@foldkit/markdown": "0.8.0",
|
|
11
|
+
"@foldkit/oxlint-plugin": "0.9.0",
|
|
12
|
+
"@foldkit/ui": "0.153.0",
|
|
13
|
+
"@foldkit/vite-plugin": "0.19.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.153.0",
|
|
17
|
+
"@foldkit/vite-plugin": "0.19.0",
|
|
18
|
+
"@foldkit/devtools-mcp": "0.19.0",
|
|
19
|
+
"@foldkit/oxlint-plugin": "0.9.0",
|
|
20
20
|
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
|
|
21
21
|
"@types/node": "^25.9.3",
|
|
22
22
|
"happy-dom": "^20.10.4",
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { Schema as S, pipe } from 'effect'
|
|
2
2
|
import { Route } from 'foldkit'
|
|
3
|
-
import {
|
|
3
|
+
import { defineRouteUnion, literal } from 'foldkit/route'
|
|
4
4
|
|
|
5
|
-
export const
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
export const AppRoute = defineRouteUnion({
|
|
6
|
+
Home: {},
|
|
7
|
+
About: {},
|
|
8
|
+
NotFound: { path: S.String },
|
|
9
|
+
})
|
|
8
10
|
|
|
9
|
-
export const AppRoute = S.Union([HomeRoute, AboutRoute, NotFoundRoute])
|
|
10
11
|
export type AppRoute = typeof AppRoute.Type
|
|
11
12
|
|
|
12
|
-
export const homeRouter = pipe(Route.root, Route.mapTo(
|
|
13
|
-
export const aboutRouter = pipe(literal('about'), Route.mapTo(
|
|
13
|
+
export const homeRouter = pipe(Route.root, Route.mapTo(AppRoute.Home))
|
|
14
|
+
export const aboutRouter = pipe(literal('about'), Route.mapTo(AppRoute.About))
|
|
14
15
|
|
|
15
16
|
const routeParser = Route.oneOf(aboutRouter, homeRouter)
|
|
16
17
|
|
|
17
18
|
export const urlToAppRoute = Route.parseUrlWithFallback(
|
|
18
19
|
routeParser,
|
|
19
|
-
|
|
20
|
+
AppRoute.NotFound,
|
|
20
21
|
)
|
|
@@ -2,9 +2,9 @@ import { click, expect, given, role, scene, text } from 'foldkit/scene'
|
|
|
2
2
|
import { describe, test } from 'vitest'
|
|
3
3
|
|
|
4
4
|
import { Model, update, view } from './main'
|
|
5
|
-
import {
|
|
5
|
+
import { AppRoute } from './route'
|
|
6
6
|
|
|
7
|
-
const initialModel = Model.make({ route:
|
|
7
|
+
const initialModel = Model.make({ route: AppRoute.Home(), count: 0 })
|
|
8
8
|
|
|
9
9
|
describe('view', () => {
|
|
10
10
|
test('renders the statically generated home page', () => {
|