create-foldkit-app 0.32.0 → 0.32.1
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/commands/create.js +9 -7
- package/dist/templates/base/FOLDKIT.md +22 -6
- package/dist/templates/examples/api-cache/src/data.ts +14 -14
- package/dist/templates/examples/api-cache/src/main.ts +42 -39
- package/dist/templates/examples/auth/src/command.ts +3 -3
- package/dist/templates/examples/auth/src/domain/session.ts +8 -6
- package/dist/templates/examples/auth/src/main.ts +11 -11
- package/dist/templates/examples/auth/src/message.ts +3 -3
- package/dist/templates/examples/auth/src/model.ts +2 -2
- package/dist/templates/examples/auth/src/page/loggedIn/index.ts +1 -1
- package/dist/templates/examples/auth/src/page/loggedIn/view.ts +3 -3
- package/dist/templates/examples/auth/src/page/loggedOut/index.ts +1 -1
- package/dist/templates/examples/auth/src/page/loggedOut/page/login.ts +9 -17
- package/dist/templates/examples/auth/src/page/loggedOut/update.ts +4 -6
- package/dist/templates/examples/auth/src/page/loggedOut/view.ts +3 -3
- package/dist/templates/examples/auth/src/route.ts +2 -2
- package/dist/templates/examples/auth/src/update.ts +37 -40
- package/dist/templates/examples/auth/src/view.ts +6 -6
- package/dist/templates/examples/canvas-art/src/main.ts +22 -30
- package/dist/templates/examples/charting/src/command.ts +3 -3
- package/dist/templates/examples/charting/src/domain.ts +53 -48
- package/dist/templates/examples/charting/src/echarts.ts +6 -6
- package/dist/templates/examples/charting/src/githubApi.ts +33 -34
- package/dist/templates/examples/charting/src/http.ts +7 -7
- package/dist/templates/examples/charting/src/message.ts +6 -6
- package/dist/templates/examples/charting/src/model.ts +6 -6
- package/dist/templates/examples/charting/src/npmApi.ts +19 -15
- package/dist/templates/examples/charting/src/subscription.ts +5 -5
- package/dist/templates/examples/charting/src/telemetry.test.ts +18 -12
- package/dist/templates/examples/charting/src/telemetry.ts +11 -18
- package/dist/templates/examples/charting/src/update.ts +17 -23
- package/dist/templates/examples/charting/src/view/chart.ts +2 -2
- package/dist/templates/examples/counter/src/main.ts +2 -2
- package/dist/templates/examples/counters/src/counter.ts +2 -2
- package/dist/templates/examples/counters/src/main.ts +8 -8
- package/dist/templates/examples/embedding/src/main.ts +10 -7
- package/dist/templates/examples/form/src/main.ts +18 -14
- package/dist/templates/examples/generative-art/src/command.ts +7 -2
- package/dist/templates/examples/generative-art/src/message.ts +14 -14
- package/dist/templates/examples/generative-art/src/model.ts +21 -21
- package/dist/templates/examples/generative-art/src/update.ts +15 -17
- package/dist/templates/examples/interrupting-commands/src/main.ts +30 -27
- package/dist/templates/examples/job-application/src/domain/proficiencyLevel.ts +2 -2
- package/dist/templates/examples/job-application/src/domain/pronounOption.ts +2 -2
- package/dist/templates/examples/job-application/src/domain/step.ts +11 -11
- package/dist/templates/examples/job-application/src/main.ts +5 -5
- package/dist/templates/examples/job-application/src/message.ts +2 -2
- package/dist/templates/examples/job-application/src/model.ts +5 -5
- package/dist/templates/examples/job-application/src/step/attachments.ts +32 -34
- package/dist/templates/examples/job-application/src/step/coverLetter.ts +4 -4
- package/dist/templates/examples/job-application/src/step/education/education.ts +11 -14
- package/dist/templates/examples/job-application/src/step/education/entry.ts +21 -22
- package/dist/templates/examples/job-application/src/step/personalInfo.ts +44 -54
- package/dist/templates/examples/job-application/src/step/skills/entry.ts +12 -14
- package/dist/templates/examples/job-application/src/step/skills/skills.ts +11 -14
- package/dist/templates/examples/job-application/src/step/workHistory/entry.ts +43 -45
- package/dist/templates/examples/job-application/src/step/workHistory/workHistory.ts +11 -14
- package/dist/templates/examples/job-application/src/update.ts +17 -17
- package/dist/templates/examples/job-application/src/view/attachments.ts +5 -5
- package/dist/templates/examples/job-application/src/view/datePicker.ts +3 -3
- package/dist/templates/examples/job-application/src/view/field.ts +5 -5
- package/dist/templates/examples/job-application/src/view/index.ts +28 -22
- package/dist/templates/examples/kanban/src/command.ts +4 -4
- package/dist/templates/examples/kanban/src/domain/card.ts +6 -6
- package/dist/templates/examples/kanban/src/domain/column.ts +9 -9
- package/dist/templates/examples/kanban/src/main.ts +4 -4
- package/dist/templates/examples/kanban/src/message.ts +6 -6
- package/dist/templates/examples/kanban/src/model.ts +11 -9
- package/dist/templates/examples/kanban/src/update.ts +5 -5
- package/dist/templates/examples/managed-resource-layer/src/main.ts +20 -20
- package/dist/templates/examples/map/src/locations.ts +7 -7
- package/dist/templates/examples/map/src/main.ts +83 -44
- package/dist/templates/examples/map/src/mount.test.ts +127 -0
- package/dist/templates/examples/pixel-art/src/command.ts +12 -5
- package/dist/templates/examples/pixel-art/src/main.ts +4 -4
- package/dist/templates/examples/pixel-art/src/message.ts +7 -7
- package/dist/templates/examples/pixel-art/src/model.ts +34 -29
- package/dist/templates/examples/pixel-art/src/subscription.ts +2 -2
- package/dist/templates/examples/pixel-art/src/update.ts +79 -86
- package/dist/templates/examples/query-sync/src/main.ts +106 -102
- package/dist/templates/examples/route-transitions/src/data.ts +6 -6
- package/dist/templates/examples/route-transitions/src/main.ts +23 -29
- package/dist/templates/examples/route-transitions/src/route.ts +3 -3
- package/dist/templates/examples/routing/src/fileTree.ts +10 -8
- package/dist/templates/examples/routing/src/main.ts +23 -21
- package/dist/templates/examples/routing/src/page/people.ts +14 -22
- package/dist/templates/examples/routing/src/route.ts +7 -7
- package/dist/templates/examples/shopping-cart/src/main.ts +30 -31
- package/dist/templates/examples/shopping-cart/src/page/products.ts +10 -10
- package/dist/templates/examples/shopping-cart/src/route.ts +6 -4
- package/dist/templates/examples/slow-warnings/src/main.ts +35 -43
- package/dist/templates/examples/snake/src/domain/snake.ts +2 -2
- package/dist/templates/examples/snake/src/main.ts +39 -47
- package/dist/templates/examples/ssg/src/main.ts +5 -5
- package/dist/templates/examples/ssg/src/route.ts +2 -2
- package/dist/templates/examples/ssr/src/cookie.ts +3 -3
- package/dist/templates/examples/ssr/src/main.ts +10 -10
- package/dist/templates/examples/state-machine/src/main.ts +55 -53
- package/dist/templates/examples/state-machine/src/view.ts +7 -7
- package/dist/templates/examples/stopwatch/src/main.ts +10 -10
- package/dist/templates/examples/todo/src/main.ts +41 -34
- package/dist/templates/examples/ui-showcase/src/main.ts +54 -42
- package/dist/templates/examples/ui-showcase/src/scene.test.ts +1 -1
- package/dist/templates/examples/ui-showcase/src/ui/init.ts +1 -2
- package/dist/templates/examples/ui-showcase/src/ui/message.ts +17 -18
- package/dist/templates/examples/ui-showcase/src/ui/model.ts +47 -44
- package/dist/templates/examples/ui-showcase/src/ui/subscriptions.ts +1 -1
- package/dist/templates/examples/ui-showcase/src/ui/toast.ts +4 -4
- package/dist/templates/examples/ui-showcase/src/ui/update.ts +287 -298
- package/dist/templates/examples/ui-showcase/src/ui/view/animation.ts +2 -2
- package/dist/templates/examples/ui-showcase/src/ui/view/button.ts +1 -1
- package/dist/templates/examples/ui-showcase/src/ui/view/calendar.ts +4 -4
- package/dist/templates/examples/ui-showcase/src/ui/view/checkbox.ts +1 -1
- package/dist/templates/examples/ui-showcase/src/ui/view/combobox.ts +1 -1
- package/dist/templates/examples/ui-showcase/src/ui/view/datePicker.ts +4 -4
- package/dist/templates/examples/ui-showcase/src/ui/view/dialog.ts +1 -1
- package/dist/templates/examples/ui-showcase/src/ui/view/disclosure.ts +1 -1
- package/dist/templates/examples/ui-showcase/src/ui/view/dragAndDrop.ts +1 -1
- package/dist/templates/examples/ui-showcase/src/ui/view/fieldset.ts +1 -1
- package/dist/templates/examples/ui-showcase/src/ui/view/fileDrop.ts +6 -6
- package/dist/templates/examples/ui-showcase/src/ui/view/hoverIntent.ts +9 -20
- package/dist/templates/examples/ui-showcase/src/ui/view/input.ts +1 -1
- package/dist/templates/examples/ui-showcase/src/ui/view/listbox.ts +1 -1
- package/dist/templates/examples/ui-showcase/src/ui/view/menu.ts +15 -15
- package/dist/templates/examples/ui-showcase/src/ui/view/popover.ts +1 -1
- package/dist/templates/examples/ui-showcase/src/ui/view/radioGroup.ts +1 -1
- package/dist/templates/examples/ui-showcase/src/ui/view/select.ts +1 -1
- package/dist/templates/examples/ui-showcase/src/ui/view/slider.ts +1 -1
- package/dist/templates/examples/ui-showcase/src/ui/view/switch.ts +1 -1
- package/dist/templates/examples/ui-showcase/src/ui/view/tabs.ts +7 -7
- package/dist/templates/examples/ui-showcase/src/ui/view/textarea.ts +1 -1
- package/dist/templates/examples/ui-showcase/src/ui/view/toast.ts +8 -8
- package/dist/templates/examples/ui-showcase/src/ui/view/tooltip.ts +1 -1
- package/dist/templates/examples/ui-showcase/src/ui/view/virtualList.ts +7 -7
- package/dist/templates/examples/view-transitions/src/artwork.ts +7 -7
- package/dist/templates/examples/view-transitions/src/main.ts +6 -6
- package/dist/templates/examples/view-transitions/src/route.ts +3 -3
- package/dist/templates/examples/weather/src/main.ts +42 -42
- package/dist/templates/examples/weather/src/story.test.ts +5 -5
- package/dist/templates/examples/web-components/src/main.ts +16 -16
- package/dist/templates/examples/websocket-chat/src/main.ts +30 -30
- package/dist/templates/release.json +13 -13
- package/dist/templates/rendering/ssg/src/main.ts +5 -5
- package/dist/templates/rendering/ssg/src/route.ts +2 -2
- package/dist/templates/rendering/ssr/server/main.ts +15 -15
- package/dist/templates/rendering/ssr/src/cookie.ts +3 -3
- package/dist/templates/rendering/ssr/src/main.ts +10 -10
- package/dist/utils/packages.js +17 -0
- package/package.json +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Schema
|
|
1
|
+
import { Schema } from 'effect'
|
|
2
2
|
import { AsyncData } from 'foldkit'
|
|
3
3
|
|
|
4
4
|
import { RadioGroup } from '@foldkit/ui'
|
|
5
5
|
|
|
6
6
|
import { ChartMode, PackageId, Period, Telemetry } from './domain'
|
|
7
7
|
|
|
8
|
-
export const TelemetryAsyncData = AsyncData.Schema(Telemetry,
|
|
8
|
+
export const TelemetryAsyncData = AsyncData.Schema(Telemetry, Schema.String)
|
|
9
9
|
|
|
10
|
-
export const Model =
|
|
10
|
+
export const Model = Schema.Struct({
|
|
11
11
|
telemetry: TelemetryAsyncData.schema,
|
|
12
12
|
chartMode: ChartMode,
|
|
13
13
|
chartModeRadioGroup: RadioGroup.Model,
|
|
@@ -15,8 +15,8 @@ export const Model = S.Struct({
|
|
|
15
15
|
packageRadioGroup: RadioGroup.Model,
|
|
16
16
|
period: Period,
|
|
17
17
|
periodRadioGroup: RadioGroup.Model,
|
|
18
|
-
maybeChartHostId:
|
|
19
|
-
maybeChartError:
|
|
20
|
-
maybeSelectedDatumId:
|
|
18
|
+
maybeChartHostId: Schema.Option(Schema.String),
|
|
19
|
+
maybeChartError: Schema.Option(Schema.String),
|
|
20
|
+
maybeSelectedDatumId: Schema.Option(Schema.String),
|
|
21
21
|
})
|
|
22
22
|
export type Model = typeof Model.Type
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Context, Effect, Layer, Schema
|
|
1
|
+
import { Context, Effect, Layer, Schema } from 'effect'
|
|
2
2
|
import { HttpClient } from 'effect/unstable/http'
|
|
3
3
|
|
|
4
4
|
import type { PackageSpec } from './domain'
|
|
@@ -11,27 +11,31 @@ const NPM_REGISTRY_API = 'https://registry.npmjs.org'
|
|
|
11
11
|
|
|
12
12
|
// SCHEMA
|
|
13
13
|
|
|
14
|
-
export const NpmDownloadDay =
|
|
15
|
-
day:
|
|
16
|
-
downloads:
|
|
14
|
+
export const NpmDownloadDay = Schema.Struct({
|
|
15
|
+
day: Schema.String,
|
|
16
|
+
downloads: Schema.Number,
|
|
17
17
|
})
|
|
18
18
|
|
|
19
|
-
export const NpmDownloadsResponse =
|
|
20
|
-
downloads:
|
|
19
|
+
export const NpmDownloadsResponse = Schema.Struct({
|
|
20
|
+
downloads: Schema.Array(NpmDownloadDay),
|
|
21
21
|
})
|
|
22
22
|
|
|
23
|
-
export const NpmVersionMetadata =
|
|
24
|
-
dependencies:
|
|
25
|
-
|
|
23
|
+
export const NpmVersionMetadata = Schema.Struct({
|
|
24
|
+
dependencies: Schema.OptionFromOptional(
|
|
25
|
+
Schema.Record(Schema.String, Schema.String),
|
|
26
|
+
),
|
|
27
|
+
peerDependencies: Schema.OptionFromOptional(
|
|
28
|
+
Schema.Record(Schema.String, Schema.String),
|
|
29
|
+
),
|
|
26
30
|
})
|
|
27
31
|
export type NpmVersionMetadata = typeof NpmVersionMetadata.Type
|
|
28
32
|
|
|
29
|
-
export const NpmPackument =
|
|
30
|
-
name:
|
|
31
|
-
time:
|
|
32
|
-
versions:
|
|
33
|
-
'dist-tags':
|
|
34
|
-
latest:
|
|
33
|
+
export const NpmPackument = Schema.Struct({
|
|
34
|
+
name: Schema.String,
|
|
35
|
+
time: Schema.Record(Schema.String, Schema.String),
|
|
36
|
+
versions: Schema.Record(Schema.String, NpmVersionMetadata),
|
|
37
|
+
'dist-tags': Schema.Struct({
|
|
38
|
+
latest: Schema.String,
|
|
35
39
|
}),
|
|
36
40
|
})
|
|
37
41
|
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { Effect, Option, Queue, Schema
|
|
1
|
+
import { Effect, Option, Queue, Schema, Stream, pipe } from 'effect'
|
|
2
2
|
import { Subscription } from 'foldkit'
|
|
3
3
|
|
|
4
4
|
import { getChart } from './chartHost'
|
|
5
5
|
import { Message } from './message'
|
|
6
6
|
import type { Model } from './model'
|
|
7
7
|
|
|
8
|
-
const ChartClickPayload =
|
|
9
|
-
data:
|
|
8
|
+
const ChartClickPayload = Schema.Struct({
|
|
9
|
+
data: Schema.OptionFromOptional(Schema.Struct({ id: Schema.String })),
|
|
10
10
|
})
|
|
11
11
|
|
|
12
12
|
const chartClickToDatumId = (event: unknown): Option.Option<string> =>
|
|
13
13
|
pipe(
|
|
14
14
|
event,
|
|
15
|
-
|
|
15
|
+
Schema.decodeUnknownOption(ChartClickPayload),
|
|
16
16
|
Option.flatMap(({ data }) => data),
|
|
17
17
|
Option.map(({ id }) => id),
|
|
18
18
|
)
|
|
@@ -55,7 +55,7 @@ const chartEvents = (hostId: string): Stream.Stream<Message> =>
|
|
|
55
55
|
|
|
56
56
|
export const subscriptions = Subscription.make<Model, Message>()(entry => ({
|
|
57
57
|
chartEvents: entry(
|
|
58
|
-
{ maybeChartHostId:
|
|
58
|
+
{ maybeChartHostId: Schema.Option(Schema.String) },
|
|
59
59
|
{
|
|
60
60
|
modelToDependencies: model => ({
|
|
61
61
|
maybeChartHostId: model.maybeChartHostId,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Array, Effect, Layer, Match
|
|
1
|
+
import { Array, Effect, Layer, Match, String } from 'effect'
|
|
2
2
|
import { HttpClient, HttpClientResponse } from 'effect/unstable/http'
|
|
3
3
|
import { expect, test } from 'vitest'
|
|
4
4
|
|
|
@@ -14,13 +14,16 @@ import { fetchRawTelemetry, transformTelemetry } from './telemetry'
|
|
|
14
14
|
test('folds public API responses into a Telemetry value', async () => {
|
|
15
15
|
const mockClient = HttpClient.make(request =>
|
|
16
16
|
Effect.sync(() => {
|
|
17
|
-
const body =
|
|
18
|
-
|
|
17
|
+
const body = Match.value(request.url).pipe(
|
|
18
|
+
Match.when(String.includes('/contributors'), () => [
|
|
19
19
|
{ login: 'devin', contributions: 42 },
|
|
20
20
|
]),
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
Match.when(String.includes('/issues'), () => [
|
|
22
|
+
{},
|
|
23
|
+
{ pull_request: {} },
|
|
24
|
+
]),
|
|
25
|
+
Match.when(String.includes('/pulls'), () => [{ id: 1 }]),
|
|
26
|
+
Match.when(String.includes('/releases'), () => [
|
|
24
27
|
{
|
|
25
28
|
tag_name: 'v0.115.0',
|
|
26
29
|
published_at: '2026-06-20T12:00:00Z',
|
|
@@ -28,18 +31,21 @@ test('folds public API responses into a Telemetry value', async () => {
|
|
|
28
31
|
draft: false,
|
|
29
32
|
},
|
|
30
33
|
]),
|
|
31
|
-
|
|
34
|
+
Match.when(String.includes('/stargazers'), () => [
|
|
32
35
|
{ starred_at: '2026-06-15T12:00:00Z' },
|
|
33
36
|
]),
|
|
34
|
-
|
|
37
|
+
Match.when(String.includes('/stats/commit_activity'), () => [
|
|
35
38
|
{ week: 1781481600, total: 5 },
|
|
36
39
|
]),
|
|
37
|
-
|
|
40
|
+
Match.when(String.includes('/stats/code_frequency'), () => [
|
|
38
41
|
[1781481600, 120, -35],
|
|
39
42
|
]),
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
Match.when(String.includes('api.npmjs.org'), () => mockNpmDownloads),
|
|
44
|
+
Match.when(
|
|
45
|
+
String.includes('registry.npmjs.org'),
|
|
46
|
+
() => mockNpmPackument,
|
|
47
|
+
),
|
|
48
|
+
Match.orElse(() => mockGitHubRepository),
|
|
43
49
|
)
|
|
44
50
|
|
|
45
51
|
return HttpClientResponse.fromWeb(
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Array,
|
|
3
|
-
Clock,
|
|
4
|
-
Effect,
|
|
5
|
-
Option,
|
|
6
|
-
Order,
|
|
7
|
-
Record as Record_,
|
|
8
|
-
pipe,
|
|
9
|
-
} from 'effect'
|
|
1
|
+
import { Array, Clock, Effect, Option, Order, Record, pipe } from 'effect'
|
|
10
2
|
|
|
11
3
|
import {
|
|
12
4
|
ContributorSummary,
|
|
@@ -109,19 +101,20 @@ const lastWeekDownloads = (
|
|
|
109
101
|
}),
|
|
110
102
|
)
|
|
111
103
|
|
|
112
|
-
const recordSize = (
|
|
113
|
-
|
|
104
|
+
const recordSize = (
|
|
105
|
+
record: Readonly<globalThis.Record<string, string>>,
|
|
106
|
+
): number => Array.length(Record.keys(record))
|
|
114
107
|
|
|
115
108
|
const dependenciesOrEmpty = (
|
|
116
|
-
maybeDependencies: Option.Option<Readonly<Record<string, string>>>,
|
|
117
|
-
): Readonly<Record<string, string>> =>
|
|
118
|
-
Option.getOrElse(maybeDependencies,
|
|
109
|
+
maybeDependencies: Option.Option<Readonly<globalThis.Record<string, string>>>,
|
|
110
|
+
): Readonly<globalThis.Record<string, string>> =>
|
|
111
|
+
Option.getOrElse(maybeDependencies, Record.empty<string, string>)
|
|
119
112
|
|
|
120
113
|
const latestMetadata = (
|
|
121
114
|
packument: typeof NpmPackument.Type,
|
|
122
115
|
): NpmVersionMetadata =>
|
|
123
116
|
Option.getOrElse(
|
|
124
|
-
|
|
117
|
+
Record.get(packument.versions, packument['dist-tags'].latest),
|
|
125
118
|
() => ({
|
|
126
119
|
dependencies: Option.none(),
|
|
127
120
|
peerDependencies: Option.none(),
|
|
@@ -137,7 +130,7 @@ export const dependencyEdgesForPackage = (
|
|
|
137
130
|
|
|
138
131
|
const dependencyEdges = Array.map(
|
|
139
132
|
Array.filter(packageSpecs, spec =>
|
|
140
|
-
Array.contains(
|
|
133
|
+
Array.contains(Record.keys(dependencies), spec.npmName),
|
|
141
134
|
),
|
|
142
135
|
spec =>
|
|
143
136
|
DependencyEdge.make({
|
|
@@ -149,7 +142,7 @@ export const dependencyEdgesForPackage = (
|
|
|
149
142
|
|
|
150
143
|
const peerDependencyEdges = Array.map(
|
|
151
144
|
Array.filter(packageSpecs, spec =>
|
|
152
|
-
Array.contains(
|
|
145
|
+
Array.contains(Record.keys(peerDependencies), spec.npmName),
|
|
153
146
|
),
|
|
154
147
|
spec =>
|
|
155
148
|
DependencyEdge.make({
|
|
@@ -178,7 +171,7 @@ export const packageSnapshotFromResponses = (
|
|
|
178
171
|
const downloadsByWeek = weeklyDownloads(downloads, weekStarts)
|
|
179
172
|
|
|
180
173
|
const publishedAt = Option.getOrElse(
|
|
181
|
-
|
|
174
|
+
Record.get(packument.time, distTags.latest),
|
|
182
175
|
() => 'unknown',
|
|
183
176
|
)
|
|
184
177
|
const totalDownloads = Array.reduce(
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Array,
|
|
1
|
+
import { Array, Option, Result, pipe } from 'effect'
|
|
2
2
|
import { AsyncData, Command, Update } from 'foldkit'
|
|
3
3
|
import { evo } from 'foldkit/struct'
|
|
4
4
|
|
|
@@ -70,14 +70,12 @@ const selectedControl =
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
const foldChartModeRadioGroupOutMessage =
|
|
73
|
+
const foldChartModeRadioGroupOutMessage = RadioGroup.OutMessage.match<
|
|
74
|
+
Update.Step<Model, Message>,
|
|
74
75
|
RadioGroup.OutMessage<ChartMode>
|
|
75
|
-
>(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
Selected: ({ value }) => selectedControl(evo({ chartMode: () => value })),
|
|
79
|
-
}),
|
|
80
|
-
)
|
|
76
|
+
>({
|
|
77
|
+
Selected: ({ value }) => selectedControl(evo({ chartMode: () => value })),
|
|
78
|
+
})
|
|
81
79
|
|
|
82
80
|
const foldChartModeRadioGroup = Update.foldChild({
|
|
83
81
|
update: ChartModeRadioGroup.update,
|
|
@@ -89,14 +87,12 @@ const foldChartModeRadioGroup = Update.foldChild({
|
|
|
89
87
|
foldOutMessage: foldChartModeRadioGroupOutMessage,
|
|
90
88
|
})
|
|
91
89
|
|
|
92
|
-
const foldPeriodRadioGroupOutMessage =
|
|
90
|
+
const foldPeriodRadioGroupOutMessage = RadioGroup.OutMessage.match<
|
|
91
|
+
Update.Step<Model, Message>,
|
|
93
92
|
RadioGroup.OutMessage<Period>
|
|
94
|
-
>(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
Selected: ({ value }) => selectedControl(evo({ period: () => value })),
|
|
98
|
-
}),
|
|
99
|
-
)
|
|
93
|
+
>({
|
|
94
|
+
Selected: ({ value }) => selectedControl(evo({ period: () => value })),
|
|
95
|
+
})
|
|
100
96
|
|
|
101
97
|
const foldPeriodRadioGroup = Update.foldChild({
|
|
102
98
|
update: PeriodRadioGroup.update,
|
|
@@ -107,15 +103,13 @@ const foldPeriodRadioGroup = Update.foldChild({
|
|
|
107
103
|
foldOutMessage: foldPeriodRadioGroupOutMessage,
|
|
108
104
|
})
|
|
109
105
|
|
|
110
|
-
const foldPackageRadioGroupOutMessage =
|
|
106
|
+
const foldPackageRadioGroupOutMessage = RadioGroup.OutMessage.match<
|
|
107
|
+
Update.Step<Model, Message>,
|
|
111
108
|
RadioGroup.OutMessage<PackageId>
|
|
112
|
-
>(
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
selectedControl(evo({ selectedPackageId: () => value })),
|
|
117
|
-
}),
|
|
118
|
-
)
|
|
109
|
+
>({
|
|
110
|
+
Selected: ({ value }) =>
|
|
111
|
+
selectedControl(evo({ selectedPackageId: () => value })),
|
|
112
|
+
})
|
|
119
113
|
|
|
120
114
|
const foldPackageRadioGroup = Update.foldChild({
|
|
121
115
|
update: PackageRadioGroup.update,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as echarts from 'echarts/core'
|
|
2
|
-
import { Effect, Option, Schema
|
|
2
|
+
import { Effect, Option, Schema } from 'effect'
|
|
3
3
|
import { Mount } from 'foldkit'
|
|
4
4
|
import type { Html } from 'foldkit/html'
|
|
5
5
|
import { HtmlBuilder } from 'foldkit/html'
|
|
@@ -54,7 +54,7 @@ const mountChart = (element: Element, hostId: string) =>
|
|
|
54
54
|
})
|
|
55
55
|
|
|
56
56
|
export const MountChart = Mount.define('MountChart', {
|
|
57
|
-
args: { hostId:
|
|
57
|
+
args: { hostId: Schema.String },
|
|
58
58
|
messages: [Message.SucceededMountChart, Message.FailedMountChart],
|
|
59
59
|
execute: ({ element, hostId }) => mountChart(element, hostId),
|
|
60
60
|
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Schema
|
|
1
|
+
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'
|
|
@@ -8,7 +8,7 @@ import { Button } from '@foldkit/ui'
|
|
|
8
8
|
|
|
9
9
|
// MODEL
|
|
10
10
|
|
|
11
|
-
export const Model =
|
|
11
|
+
export const Model = Schema.Struct({ count: Schema.Number })
|
|
12
12
|
export type Model = typeof Model.Type
|
|
13
13
|
|
|
14
14
|
// MESSAGE
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Schema
|
|
1
|
+
import { Schema } from 'effect'
|
|
2
2
|
import { Submodel, type Update } from 'foldkit'
|
|
3
3
|
import { defineMessageUnion } from 'foldkit/message'
|
|
4
4
|
import { evo } from 'foldkit/struct'
|
|
@@ -7,7 +7,7 @@ import { Button } from '@foldkit/ui'
|
|
|
7
7
|
|
|
8
8
|
// MODEL
|
|
9
9
|
|
|
10
|
-
export const Model =
|
|
10
|
+
export const Model = Schema.Struct({ count: Schema.Number })
|
|
11
11
|
export type Model = typeof Model.Type
|
|
12
12
|
|
|
13
13
|
export const init: Model = { count: 0 }
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Array, Option, Schema
|
|
1
|
+
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'
|
|
@@ -10,15 +10,15 @@ import * as Counter from './counter'
|
|
|
10
10
|
|
|
11
11
|
// MODEL
|
|
12
12
|
|
|
13
|
-
const Row =
|
|
14
|
-
id:
|
|
13
|
+
const Row = Schema.Struct({
|
|
14
|
+
id: Schema.String,
|
|
15
15
|
counter: Counter.Model,
|
|
16
16
|
})
|
|
17
17
|
type Row = typeof Row.Type
|
|
18
18
|
|
|
19
|
-
export const Model =
|
|
20
|
-
rows:
|
|
21
|
-
nextRowId:
|
|
19
|
+
export const Model = Schema.Struct({
|
|
20
|
+
rows: Schema.Array(Row),
|
|
21
|
+
nextRowId: Schema.Number,
|
|
22
22
|
})
|
|
23
23
|
export type Model = typeof Model.Type
|
|
24
24
|
|
|
@@ -26,9 +26,9 @@ export type Model = typeof Model.Type
|
|
|
26
26
|
|
|
27
27
|
export const Message = defineMessageUnion({
|
|
28
28
|
ClickedAddRow: {},
|
|
29
|
-
ClickedRemoveRow: { id:
|
|
29
|
+
ClickedRemoveRow: { id: Schema.String },
|
|
30
30
|
GotCounterMessage: {
|
|
31
|
-
id:
|
|
31
|
+
id: Schema.String,
|
|
32
32
|
message: Counter.Message,
|
|
33
33
|
},
|
|
34
34
|
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Duration, Effect, Schema
|
|
1
|
+
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'
|
|
@@ -8,7 +8,10 @@ import { Button } from '@foldkit/ui'
|
|
|
8
8
|
|
|
9
9
|
// MODEL
|
|
10
10
|
|
|
11
|
-
export const Model =
|
|
11
|
+
export const Model = Schema.Struct({
|
|
12
|
+
count: Schema.Number,
|
|
13
|
+
step: Schema.Number,
|
|
14
|
+
})
|
|
12
15
|
export type Model = typeof Model.Type
|
|
13
16
|
|
|
14
17
|
// MESSAGE
|
|
@@ -16,7 +19,7 @@ export type Model = typeof Model.Type
|
|
|
16
19
|
export const Message = defineMessageUnion({
|
|
17
20
|
Ticked: {},
|
|
18
21
|
ClickedAdvance: {},
|
|
19
|
-
ChangedStep: { step:
|
|
22
|
+
ChangedStep: { step: Schema.Number },
|
|
20
23
|
CompletedReportCount: {},
|
|
21
24
|
})
|
|
22
25
|
|
|
@@ -25,13 +28,13 @@ export type Message = typeof Message.Type
|
|
|
25
28
|
// PORT
|
|
26
29
|
|
|
27
30
|
export const ports = {
|
|
28
|
-
inbound: { stepChanged: Port.inbound(
|
|
29
|
-
outbound: { countChanged: Port.outbound(
|
|
31
|
+
inbound: { stepChanged: Port.inbound(Schema.Number) },
|
|
32
|
+
outbound: { countChanged: Port.outbound(Schema.Number) },
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
// INIT
|
|
33
36
|
|
|
34
|
-
export const Flags =
|
|
37
|
+
export const Flags = Schema.Struct({ initialCount: Schema.Number })
|
|
35
38
|
export type Flags = typeof Flags.Type
|
|
36
39
|
|
|
37
40
|
export const init: Runtime.ElementInit<Model, Message, Flags> = flags => ({
|
|
@@ -41,7 +44,7 @@ export const init: Runtime.ElementInit<Model, Message, Flags> = flags => ({
|
|
|
41
44
|
// COMMAND
|
|
42
45
|
|
|
43
46
|
export const ReportCount = Command.define('ReportCount', {
|
|
44
|
-
args: { count:
|
|
47
|
+
args: { count: Schema.Number },
|
|
45
48
|
messages: [Message.CompletedReportCount],
|
|
46
49
|
execute: ({ count }) =>
|
|
47
50
|
Port.emit(ports.outbound.countChanged, count).pipe(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import clsx from 'clsx'
|
|
2
|
-
import { Array, Duration, Effect, Random, Schema
|
|
2
|
+
import { Array, Duration, Effect, Random, Schema } from 'effect'
|
|
3
3
|
import { Command, FieldValidation, Runtime, type Update } from 'foldkit'
|
|
4
4
|
import {
|
|
5
5
|
Field,
|
|
@@ -33,16 +33,16 @@ const emailRules = makeRules({
|
|
|
33
33
|
const Submission = defineTaggedUnion({
|
|
34
34
|
NotSubmitted: {},
|
|
35
35
|
Submitting: {},
|
|
36
|
-
SubmitSuccess: { confirmationText:
|
|
37
|
-
SubmitError: { error:
|
|
36
|
+
SubmitSuccess: { confirmationText: Schema.String },
|
|
37
|
+
SubmitError: { error: Schema.String },
|
|
38
38
|
})
|
|
39
39
|
|
|
40
40
|
type Submission = typeof Submission.Type
|
|
41
41
|
|
|
42
|
-
export const Model =
|
|
43
|
-
name: Field(
|
|
44
|
-
email: Field(
|
|
45
|
-
messageText: Field(
|
|
42
|
+
export const Model = Schema.Struct({
|
|
43
|
+
name: Field(Schema.String),
|
|
44
|
+
email: Field(Schema.String),
|
|
45
|
+
messageText: Field(Schema.String),
|
|
46
46
|
submission: Submission,
|
|
47
47
|
})
|
|
48
48
|
export type Model = typeof Model.Type
|
|
@@ -50,12 +50,12 @@ export type Model = typeof Model.Type
|
|
|
50
50
|
// MESSAGE
|
|
51
51
|
|
|
52
52
|
export const Message = defineMessageUnion({
|
|
53
|
-
UpdatedName: { value:
|
|
54
|
-
UpdatedEmail: { value:
|
|
55
|
-
CompletedValidateEmail: { field: Field(
|
|
56
|
-
UpdatedMessageText: { value:
|
|
53
|
+
UpdatedName: { value: Schema.String },
|
|
54
|
+
UpdatedEmail: { value: Schema.String },
|
|
55
|
+
CompletedValidateEmail: { field: Field(Schema.String) },
|
|
56
|
+
UpdatedMessageText: { value: Schema.String },
|
|
57
57
|
ClickedFormSubmit: {},
|
|
58
|
-
SucceededSubmitForm: { name:
|
|
58
|
+
SucceededSubmitForm: { name: Schema.String },
|
|
59
59
|
FailedSubmitForm: {},
|
|
60
60
|
})
|
|
61
61
|
|
|
@@ -89,7 +89,7 @@ const isEmailOnWaitlist = (email: string): Effect.Effect<boolean> =>
|
|
|
89
89
|
})
|
|
90
90
|
|
|
91
91
|
export const ValidateEmail = Command.define('ValidateEmail', {
|
|
92
|
-
args: { email:
|
|
92
|
+
args: { email: Schema.String },
|
|
93
93
|
messages: [Message.CompletedValidateEmail],
|
|
94
94
|
execute: ({ email }) =>
|
|
95
95
|
Effect.gen(function* () {
|
|
@@ -212,7 +212,11 @@ export const update = (model: Model, message: Message) =>
|
|
|
212
212
|
const FAKE_API_DELAY_MS = 500
|
|
213
213
|
|
|
214
214
|
export const SubmitForm = Command.define('SubmitForm', {
|
|
215
|
-
args: {
|
|
215
|
+
args: {
|
|
216
|
+
name: Schema.String,
|
|
217
|
+
email: Schema.String,
|
|
218
|
+
messageText: Schema.String,
|
|
219
|
+
},
|
|
216
220
|
messages: [Message.SucceededSubmitForm, Message.FailedSubmitForm],
|
|
217
221
|
execute: ({ name }) =>
|
|
218
222
|
Effect.gen(function* () {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Effect, Option, Random, Schema
|
|
1
|
+
import { Effect, Option, Random, Schema } from 'effect'
|
|
2
2
|
import { Command } from 'foldkit'
|
|
3
3
|
|
|
4
4
|
import {
|
|
@@ -63,7 +63,12 @@ const BURST_INITIAL_SPEED_SCALE_MAX = 2.2
|
|
|
63
63
|
const BURST_HUE_JITTER_DEGREES = 30
|
|
64
64
|
|
|
65
65
|
export const GenerateBurstParticle = Command.define('GenerateBurstParticle', {
|
|
66
|
-
args: {
|
|
66
|
+
args: {
|
|
67
|
+
x: Schema.Number,
|
|
68
|
+
y: Schema.Number,
|
|
69
|
+
angle: Schema.Number,
|
|
70
|
+
hueAnchor: Schema.Number,
|
|
71
|
+
},
|
|
67
72
|
messages: [Message.CompletedGenerateBurstParticle],
|
|
68
73
|
execute: ({ x, y, angle, hueAnchor }) =>
|
|
69
74
|
Effect.gen(function* () {
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { Schema
|
|
1
|
+
import { Schema } from 'effect'
|
|
2
2
|
import { defineMessageUnion } from 'foldkit/message'
|
|
3
3
|
|
|
4
4
|
import { Slider } from '@foldkit/ui'
|
|
5
5
|
|
|
6
6
|
const generatedParticleFields = {
|
|
7
|
-
x:
|
|
8
|
-
y:
|
|
9
|
-
baseHue:
|
|
10
|
-
hueDriftPerSecond:
|
|
11
|
-
lifespanMs:
|
|
12
|
-
speed:
|
|
13
|
-
initialAngle:
|
|
14
|
-
initialSpeedScale:
|
|
7
|
+
x: Schema.Number,
|
|
8
|
+
y: Schema.Number,
|
|
9
|
+
baseHue: Schema.Number,
|
|
10
|
+
hueDriftPerSecond: Schema.Number,
|
|
11
|
+
lifespanMs: Schema.Number,
|
|
12
|
+
speed: Schema.Number,
|
|
13
|
+
initialAngle: Schema.Option(Schema.Number),
|
|
14
|
+
initialSpeedScale: Schema.Number,
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export const Message = defineMessageUnion({
|
|
18
|
-
TickedFrame: { deltaTimeMs:
|
|
18
|
+
TickedFrame: { deltaTimeMs: Schema.Number },
|
|
19
19
|
CompletedGenerateAmbientParticle: generatedParticleFields,
|
|
20
20
|
CompletedGenerateBurstParticle: generatedParticleFields,
|
|
21
21
|
PressedCanvas: {
|
|
22
|
-
x:
|
|
23
|
-
y:
|
|
22
|
+
x: Schema.Number,
|
|
23
|
+
y: Schema.Number,
|
|
24
24
|
},
|
|
25
25
|
MovedPointer: {
|
|
26
|
-
x:
|
|
27
|
-
y:
|
|
26
|
+
x: Schema.Number,
|
|
27
|
+
y: Schema.Number,
|
|
28
28
|
},
|
|
29
29
|
ClickedTogglePlay: {},
|
|
30
30
|
ClickedReset: {},
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { Schema
|
|
1
|
+
import { Schema } from 'effect'
|
|
2
2
|
|
|
3
3
|
import { Slider } from '@foldkit/ui'
|
|
4
4
|
|
|
5
|
-
export const Point =
|
|
5
|
+
export const Point = Schema.Struct({ x: Schema.Number, y: Schema.Number })
|
|
6
6
|
export type Point = typeof Point.Type
|
|
7
7
|
|
|
8
|
-
export const Particle =
|
|
9
|
-
id:
|
|
10
|
-
trail:
|
|
11
|
-
baseHue:
|
|
12
|
-
hueDriftPerSecond:
|
|
13
|
-
ageMs:
|
|
14
|
-
lifespanMs:
|
|
15
|
-
speed:
|
|
16
|
-
bornAtSeconds:
|
|
17
|
-
initialAngle:
|
|
18
|
-
initialSpeedScale:
|
|
8
|
+
export const Particle = Schema.Struct({
|
|
9
|
+
id: Schema.Number,
|
|
10
|
+
trail: Schema.Array(Point),
|
|
11
|
+
baseHue: Schema.Number,
|
|
12
|
+
hueDriftPerSecond: Schema.Number,
|
|
13
|
+
ageMs: Schema.Number,
|
|
14
|
+
lifespanMs: Schema.Number,
|
|
15
|
+
speed: Schema.Number,
|
|
16
|
+
bornAtSeconds: Schema.Number,
|
|
17
|
+
initialAngle: Schema.Option(Schema.Number),
|
|
18
|
+
initialSpeedScale: Schema.Number,
|
|
19
19
|
})
|
|
20
20
|
export type Particle = typeof Particle.Type
|
|
21
21
|
|
|
22
|
-
export const Model =
|
|
23
|
-
particles:
|
|
24
|
-
nextId:
|
|
25
|
-
elapsedSeconds:
|
|
26
|
-
maybeMousePosition:
|
|
27
|
-
isRunning:
|
|
28
|
-
flowStrength:
|
|
22
|
+
export const Model = Schema.Struct({
|
|
23
|
+
particles: Schema.Array(Particle),
|
|
24
|
+
nextId: Schema.Number,
|
|
25
|
+
elapsedSeconds: Schema.Number,
|
|
26
|
+
maybeMousePosition: Schema.Option(Point),
|
|
27
|
+
isRunning: Schema.Boolean,
|
|
28
|
+
flowStrength: Schema.Number,
|
|
29
29
|
flowStrengthSlider: Slider.Model,
|
|
30
|
-
noiseScale:
|
|
30
|
+
noiseScale: Schema.Number,
|
|
31
31
|
noiseScaleSlider: Slider.Model,
|
|
32
32
|
})
|
|
33
33
|
export type Model = typeof Model.Type
|