create-foldkit-app 0.31.1 → 0.32.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 +1 -1
- package/dist/templates/examples/api-cache/package.json +7 -7
- package/dist/templates/examples/auth/package.json +7 -7
- package/dist/templates/examples/auth/src/page/loggedOut/page/login.ts +28 -35
- package/dist/templates/examples/auth/src/update.ts +10 -13
- package/dist/templates/examples/canvas-art/package.json +7 -7
- package/dist/templates/examples/charting/package.json +7 -7
- package/dist/templates/examples/charting/src/view/chart.ts +43 -45
- package/dist/templates/examples/counter/package.json +7 -7
- package/dist/templates/examples/counters/package.json +7 -7
- package/dist/templates/examples/crash-view/package.json +7 -7
- package/dist/templates/examples/embedding/package.json +7 -7
- package/dist/templates/examples/form/package.json +7 -7
- package/dist/templates/examples/form/src/main.ts +59 -74
- package/dist/templates/examples/generative-art/package.json +7 -7
- package/dist/templates/examples/interrupting-commands/package.json +7 -7
- package/dist/templates/examples/interrupting-commands/src/main.ts +6 -9
- package/dist/templates/examples/job-application/package.json +7 -7
- package/dist/templates/examples/job-application/src/view/education.ts +31 -32
- package/dist/templates/examples/job-application/src/view/field.ts +7 -8
- package/dist/templates/examples/job-application/src/view/workHistory.ts +40 -41
- package/dist/templates/examples/kanban/package.json +8 -8
- package/dist/templates/examples/managed-resource-layer/package.json +7 -7
- package/dist/templates/examples/managed-resource-layer/src/main.ts +10 -11
- package/dist/templates/examples/map/package.json +8 -8
- package/dist/templates/examples/map/src/main.ts +59 -63
- package/dist/templates/examples/map/src/vite-env.d.ts +1 -0
- package/dist/templates/examples/pixel-art/package.json +7 -7
- package/dist/templates/examples/pixel-art/src/scene.test.ts +3 -3
- package/dist/templates/examples/pixel-art/src/story.test.ts +3 -3
- package/dist/templates/examples/query-sync/package.json +7 -7
- package/dist/templates/examples/query-sync/src/main.ts +25 -37
- package/dist/templates/examples/route-transitions/package.json +7 -7
- package/dist/templates/examples/route-transitions/src/main.ts +24 -32
- package/dist/templates/examples/routing/package.json +7 -7
- package/dist/templates/examples/routing/src/main.ts +24 -30
- package/dist/templates/examples/routing/src/page/people.ts +80 -86
- package/dist/templates/examples/shopping-cart/package.json +7 -7
- package/dist/templates/examples/shopping-cart/src/main.ts +16 -22
- package/dist/templates/examples/slow-warnings/package.json +7 -7
- package/dist/templates/examples/snake/package.json +7 -7
- package/dist/templates/examples/ssg/package.json +6 -8
- package/dist/templates/examples/ssg/src/main.ts +65 -75
- package/dist/templates/examples/ssr/package.json +8 -9
- package/dist/templates/examples/state-machine/package.json +7 -7
- package/dist/templates/examples/state-machine/src/view.ts +50 -59
- package/dist/templates/examples/stopwatch/package.json +7 -7
- package/dist/templates/examples/todo/package.json +7 -7
- package/dist/templates/examples/todo/src/main.ts +29 -37
- package/dist/templates/examples/ui-showcase/package.json +7 -7
- package/dist/templates/examples/ui-showcase/src/main.ts +49 -42
- package/dist/templates/examples/ui-showcase/src/scene.test.ts +11 -0
- package/dist/templates/examples/ui-showcase/src/ui/init.ts +2 -0
- package/dist/templates/examples/ui-showcase/src/ui/message.ts +2 -0
- package/dist/templates/examples/ui-showcase/src/ui/model.ts +2 -0
- package/dist/templates/examples/ui-showcase/src/ui/update.ts +21 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/hoverIntent.ts +89 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/index.ts +1 -0
- package/dist/templates/examples/view-transitions/package.json +7 -7
- package/dist/templates/examples/view-transitions/src/main.ts +29 -40
- package/dist/templates/examples/weather/package.json +7 -7
- package/dist/templates/examples/web-components/package.json +7 -7
- package/dist/templates/examples/websocket-chat/package.json +7 -7
- package/dist/templates/examples/websocket-chat/src/main.ts +22 -32
- package/dist/templates/release.json +18 -18
- package/dist/templates/rendering/ssg/README.md +8 -7
- package/dist/templates/rendering/ssg/package.json +2 -2
- package/dist/templates/rendering/ssg/src/main.ts +61 -70
- package/dist/templates/rendering/ssg/tsconfig.json +1 -1
- package/dist/templates/rendering/ssg/vite.config.ts +22 -1
- package/dist/templates/rendering/ssr/README.md +10 -7
- package/dist/templates/rendering/ssr/package.json +2 -2
- package/dist/templates/rendering/ssr/vite.config.ts +22 -1
- package/package.json +5 -5
- package/dist/templates/rendering/ssg/scripts/build.mjs +0 -27
- package/dist/templates/rendering/ssg/scripts/prerender.ts +0 -120
- package/dist/templates/rendering/ssr/scripts/build.mjs +0 -23
|
@@ -181,17 +181,14 @@ export const update = (model: Model, message: Message) =>
|
|
|
181
181
|
}),
|
|
182
182
|
|
|
183
183
|
CompletedCancelUploadFile: ({ uploadId, outcome }) =>
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
model: evo(model, {
|
|
189
|
-
uploads: setStatusForId(uploadId, 'Cancelled'),
|
|
190
|
-
}),
|
|
184
|
+
Command.Interruptible.Outcome.match<UpdateReturn>(outcome, {
|
|
185
|
+
Interrupted: () => ({
|
|
186
|
+
model: evo(model, {
|
|
187
|
+
uploads: setStatusForId(uploadId, 'Cancelled'),
|
|
191
188
|
}),
|
|
192
|
-
NotFound: () => ({ model }),
|
|
193
189
|
}),
|
|
194
|
-
|
|
190
|
+
NotFound: () => ({ model }),
|
|
191
|
+
}),
|
|
195
192
|
})
|
|
196
193
|
|
|
197
194
|
// VIEW
|
|
@@ -18,13 +18,13 @@
|
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@foldkit/devtools": "workspace:*",
|
|
20
20
|
"@foldkit/vite-plugin": "workspace:*",
|
|
21
|
-
"@tailwindcss/vite": "^4.3.
|
|
21
|
+
"@tailwindcss/vite": "^4.3.3",
|
|
22
22
|
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
|
|
23
|
-
"happy-dom": "^20.
|
|
24
|
-
"prettier": "^3.
|
|
25
|
-
"tailwindcss": "^4.3.
|
|
26
|
-
"typescript": "^
|
|
27
|
-
"vite": "^8.
|
|
28
|
-
"vitest": "^4.1.
|
|
23
|
+
"happy-dom": "^20.11.13",
|
|
24
|
+
"prettier": "^3.9.6",
|
|
25
|
+
"tailwindcss": "^4.3.3",
|
|
26
|
+
"typescript": "^7.0.2",
|
|
27
|
+
"vite": "^8.2.2",
|
|
28
|
+
"vitest": "^4.1.11"
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -27,37 +27,36 @@ const entryView = (
|
|
|
27
27
|
export const educationView = Submodel.defineView<
|
|
28
28
|
Education.Model,
|
|
29
29
|
Education.Message
|
|
30
|
-
>(
|
|
31
|
-
(
|
|
32
|
-
h.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
h.
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
>((model, h): Html =>
|
|
31
|
+
h.div(
|
|
32
|
+
[h.Class('space-y-6')],
|
|
33
|
+
[
|
|
34
|
+
h.p(
|
|
35
|
+
[h.Class('text-sm text-gray-500')],
|
|
36
|
+
['Add your educational background.'],
|
|
37
|
+
),
|
|
38
|
+
h.div(
|
|
39
|
+
[h.Class('divide-y divide-gray-200')],
|
|
40
|
+
model.entries.map(entry =>
|
|
41
|
+
lazyEntry(entry.id, entryView, [entry, model.today, h]),
|
|
38
42
|
),
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
},
|
|
59
|
-
h,
|
|
60
|
-
),
|
|
61
|
-
],
|
|
62
|
-
),
|
|
43
|
+
),
|
|
44
|
+
Button.view(
|
|
45
|
+
{
|
|
46
|
+
onClick: Message.ClickedAddEntry(),
|
|
47
|
+
toView: attributes =>
|
|
48
|
+
h.button(
|
|
49
|
+
[
|
|
50
|
+
...attributes.button,
|
|
51
|
+
h.Class(
|
|
52
|
+
'w-full rounded-lg border-2 border-dashed border-gray-300 px-4 py-3 text-sm font-medium text-gray-600 hover:border-indigo-400 hover:text-indigo-600 transition cursor-pointer',
|
|
53
|
+
),
|
|
54
|
+
],
|
|
55
|
+
['+ Add Education'],
|
|
56
|
+
),
|
|
57
|
+
},
|
|
58
|
+
h,
|
|
59
|
+
),
|
|
60
|
+
],
|
|
61
|
+
),
|
|
63
62
|
)
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import clsx from 'clsx'
|
|
2
2
|
import { Match as M } from 'effect'
|
|
3
|
+
import { FieldValidation } from 'foldkit'
|
|
3
4
|
import { type Field } from 'foldkit/fieldValidation'
|
|
4
5
|
import type { Html, HtmlBuilder } from 'foldkit/html'
|
|
5
6
|
|
|
6
7
|
import { Checkbox, Input, Textarea } from '@foldkit/ui'
|
|
7
8
|
|
|
8
9
|
const borderClass = (field: Field<string>): string =>
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}),
|
|
16
|
-
)
|
|
10
|
+
FieldValidation.match(field, {
|
|
11
|
+
onNotValidated: () => 'border-gray-300',
|
|
12
|
+
onValidating: () => 'border-blue-300',
|
|
13
|
+
onValid: () => 'border-green-500',
|
|
14
|
+
onInvalid: () => 'border-red-500',
|
|
15
|
+
})
|
|
17
16
|
|
|
18
17
|
export const inputField = <ParentMessage>(
|
|
19
18
|
config: Readonly<{
|
|
@@ -10,46 +10,45 @@ import { workEntryView } from './workEntry'
|
|
|
10
10
|
export const workHistoryView = Submodel.defineView<
|
|
11
11
|
WorkHistory.Model,
|
|
12
12
|
WorkHistory.Message
|
|
13
|
-
>(
|
|
14
|
-
(
|
|
15
|
-
h.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
h.
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
>((model, h): Html =>
|
|
14
|
+
h.div(
|
|
15
|
+
[h.Class('space-y-6')],
|
|
16
|
+
[
|
|
17
|
+
h.p(
|
|
18
|
+
[h.Class('text-sm text-gray-500')],
|
|
19
|
+
['Add your relevant work experience, starting with the most recent.'],
|
|
20
|
+
),
|
|
21
|
+
h.div(
|
|
22
|
+
[h.Class('divide-y divide-gray-200')],
|
|
23
|
+
model.entries.map(entry =>
|
|
24
|
+
h.submodel({
|
|
25
|
+
slotId: entry.id,
|
|
26
|
+
model: entry,
|
|
27
|
+
view: workEntryView,
|
|
28
|
+
toParentMessage: message =>
|
|
29
|
+
Message.GotEntryMessage({
|
|
30
|
+
entryId: entry.id,
|
|
31
|
+
message,
|
|
32
|
+
}),
|
|
33
|
+
}),
|
|
21
34
|
),
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
h.button(
|
|
42
|
-
[
|
|
43
|
-
...attributes.button,
|
|
44
|
-
h.Class(
|
|
45
|
-
'w-full rounded-lg border-2 border-dashed border-gray-300 px-4 py-3 text-sm font-medium text-gray-600 hover:border-indigo-400 hover:text-indigo-600 transition cursor-pointer',
|
|
46
|
-
),
|
|
47
|
-
],
|
|
48
|
-
['+ Add Position'],
|
|
49
|
-
),
|
|
50
|
-
},
|
|
51
|
-
h,
|
|
52
|
-
),
|
|
53
|
-
],
|
|
54
|
-
),
|
|
35
|
+
),
|
|
36
|
+
Button.view(
|
|
37
|
+
{
|
|
38
|
+
onClick: Message.ClickedAddEntry(),
|
|
39
|
+
toView: attributes =>
|
|
40
|
+
h.button(
|
|
41
|
+
[
|
|
42
|
+
...attributes.button,
|
|
43
|
+
h.Class(
|
|
44
|
+
'w-full rounded-lg border-2 border-dashed border-gray-300 px-4 py-3 text-sm font-medium text-gray-600 hover:border-indigo-400 hover:text-indigo-600 transition cursor-pointer',
|
|
45
|
+
),
|
|
46
|
+
],
|
|
47
|
+
['+ Add Position'],
|
|
48
|
+
),
|
|
49
|
+
},
|
|
50
|
+
h,
|
|
51
|
+
),
|
|
52
|
+
],
|
|
53
|
+
),
|
|
55
54
|
)
|
|
@@ -14,18 +14,18 @@
|
|
|
14
14
|
"clsx": "^2.1.1",
|
|
15
15
|
"effect": "4.0.0-rc.112",
|
|
16
16
|
"foldkit": "workspace:*",
|
|
17
|
-
"fractional-indexing": "^
|
|
17
|
+
"fractional-indexing": "^4.0.0"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@foldkit/devtools": "workspace:*",
|
|
21
21
|
"@foldkit/vite-plugin": "workspace:*",
|
|
22
|
-
"@tailwindcss/vite": "^4.3.
|
|
22
|
+
"@tailwindcss/vite": "^4.3.3",
|
|
23
23
|
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
|
|
24
|
-
"happy-dom": "^20.
|
|
25
|
-
"prettier": "^3.
|
|
26
|
-
"tailwindcss": "^4.3.
|
|
27
|
-
"typescript": "^
|
|
28
|
-
"vite": "^8.
|
|
29
|
-
"vitest": "^4.1.
|
|
24
|
+
"happy-dom": "^20.11.13",
|
|
25
|
+
"prettier": "^3.9.6",
|
|
26
|
+
"tailwindcss": "^4.3.3",
|
|
27
|
+
"typescript": "^7.0.2",
|
|
28
|
+
"vite": "^8.2.2",
|
|
29
|
+
"vitest": "^4.1.11"
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -17,13 +17,13 @@
|
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@foldkit/devtools": "workspace:*",
|
|
19
19
|
"@foldkit/vite-plugin": "workspace:*",
|
|
20
|
-
"@tailwindcss/vite": "^4.3.
|
|
20
|
+
"@tailwindcss/vite": "^4.3.3",
|
|
21
21
|
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
|
|
22
|
-
"happy-dom": "^20.
|
|
23
|
-
"prettier": "^3.
|
|
24
|
-
"tailwindcss": "^4.3.
|
|
25
|
-
"typescript": "^
|
|
26
|
-
"vite": "^8.
|
|
27
|
-
"vitest": "^4.1.
|
|
22
|
+
"happy-dom": "^20.11.13",
|
|
23
|
+
"prettier": "^3.9.6",
|
|
24
|
+
"tailwindcss": "^4.3.3",
|
|
25
|
+
"typescript": "^7.0.2",
|
|
26
|
+
"vite": "^8.2.2",
|
|
27
|
+
"vitest": "^4.1.11"
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -199,25 +199,24 @@ const engineStatusView = (
|
|
|
199
199
|
engine: EngineState,
|
|
200
200
|
h: HtmlBuilder<Message>,
|
|
201
201
|
): Html => {
|
|
202
|
-
const status =
|
|
203
|
-
|
|
202
|
+
const status = EngineState.match(engine, {
|
|
203
|
+
Off: () => ({
|
|
204
204
|
colorClassName: 'text-gray-500',
|
|
205
205
|
text: 'Engine is off.',
|
|
206
|
-
})
|
|
207
|
-
|
|
206
|
+
}),
|
|
207
|
+
Booting: () => ({
|
|
208
208
|
colorClassName: 'text-amber-600',
|
|
209
209
|
text: 'Booting engine...',
|
|
210
|
-
})
|
|
211
|
-
|
|
210
|
+
}),
|
|
211
|
+
Ready: ({ engineId }) => ({
|
|
212
212
|
colorClassName: 'text-green-600',
|
|
213
213
|
text: `Engine ready: ${engineId}`,
|
|
214
|
-
})
|
|
215
|
-
|
|
214
|
+
}),
|
|
215
|
+
Failed: ({ reason }) => ({
|
|
216
216
|
colorClassName: 'text-red-600',
|
|
217
217
|
text: `Engine failed: ${reason}`,
|
|
218
|
-
})
|
|
219
|
-
|
|
220
|
-
)
|
|
218
|
+
}),
|
|
219
|
+
})
|
|
221
220
|
|
|
222
221
|
return h.p([h.Class(status.colorClassName)], [status.text])
|
|
223
222
|
}
|
|
@@ -14,18 +14,18 @@
|
|
|
14
14
|
"clsx": "^2.1.1",
|
|
15
15
|
"effect": "4.0.0-rc.112",
|
|
16
16
|
"foldkit": "workspace:*",
|
|
17
|
-
"maplibre-gl": "^
|
|
17
|
+
"maplibre-gl": "^6.6.0"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@foldkit/devtools": "workspace:*",
|
|
21
21
|
"@foldkit/vite-plugin": "workspace:*",
|
|
22
|
-
"@tailwindcss/vite": "^4.3.
|
|
22
|
+
"@tailwindcss/vite": "^4.3.3",
|
|
23
23
|
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
|
|
24
|
-
"happy-dom": "^20.
|
|
25
|
-
"prettier": "^3.
|
|
26
|
-
"tailwindcss": "^4.3.
|
|
27
|
-
"typescript": "^
|
|
28
|
-
"vite": "^8.
|
|
29
|
-
"vitest": "^4.1.
|
|
24
|
+
"happy-dom": "^20.11.13",
|
|
25
|
+
"prettier": "^3.9.6",
|
|
26
|
+
"tailwindcss": "^4.3.3",
|
|
27
|
+
"typescript": "^7.0.2",
|
|
28
|
+
"vite": "^8.2.2",
|
|
29
|
+
"vitest": "^4.1.11"
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -4,7 +4,6 @@ import {
|
|
|
4
4
|
Effect,
|
|
5
5
|
Equal,
|
|
6
6
|
Function,
|
|
7
|
-
Match as M,
|
|
8
7
|
Option,
|
|
9
8
|
Queue,
|
|
10
9
|
Schema as S,
|
|
@@ -19,6 +18,7 @@ import { defineMessageUnion } from 'foldkit/message'
|
|
|
19
18
|
import { defineTaggedUnion } from 'foldkit/schema'
|
|
20
19
|
import { evo } from 'foldkit/struct'
|
|
21
20
|
import type { Map as MapInstance } from 'maplibre-gl'
|
|
21
|
+
import maplibreWorkerUrl from 'maplibre-gl/dist/maplibre-gl-worker.mjs?worker&url'
|
|
22
22
|
|
|
23
23
|
import { Button, Input } from '@foldkit/ui'
|
|
24
24
|
|
|
@@ -310,61 +310,59 @@ export const init: Runtime.ApplicationInit<Model, Message> = () => ({
|
|
|
310
310
|
|
|
311
311
|
// MAP MOUNT
|
|
312
312
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
)
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
313
|
+
const mountMap = (element: Element, hostId: string) =>
|
|
314
|
+
Effect.gen(function* () {
|
|
315
|
+
if (!(element instanceof HTMLElement)) {
|
|
316
|
+
return Message.FailedMountMap({
|
|
317
|
+
reason: 'Map host is not an HTMLElement.',
|
|
318
|
+
})
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
return yield* Effect.gen(function* () {
|
|
322
|
+
yield* Effect.acquireRelease(
|
|
323
|
+
Effect.gen(function* () {
|
|
324
|
+
const maplibre = yield* Effect.tryPromise(() => import('maplibre-gl'))
|
|
325
|
+
maplibre.setWorkerUrl(maplibreWorkerUrl)
|
|
326
|
+
const map = new maplibre.Map({
|
|
327
|
+
container: element,
|
|
328
|
+
style: 'https://demotiles.maplibre.org/style.json',
|
|
329
|
+
center: [0, 20],
|
|
330
|
+
zoom: INITIAL_MAP_ZOOM,
|
|
325
331
|
})
|
|
326
|
-
}
|
|
327
|
-
return yield* Effect.gen(function* () {
|
|
328
|
-
yield* Effect.acquireRelease(
|
|
329
|
-
Effect.gen(function* () {
|
|
330
|
-
const maplibre = yield* Effect.tryPromise(
|
|
331
|
-
() => import('maplibre-gl'),
|
|
332
|
-
)
|
|
333
|
-
const map = new maplibre.Map({
|
|
334
|
-
container: element,
|
|
335
|
-
style: 'https://demotiles.maplibre.org/style.json',
|
|
336
|
-
center: [0, 20],
|
|
337
|
-
zoom: INITIAL_MAP_ZOOM,
|
|
338
|
-
})
|
|
339
|
-
|
|
340
|
-
Array.forEach(featuredLocations, ({ id, lng, lat }) => {
|
|
341
|
-
const markerElement = document.createElement('button')
|
|
342
|
-
markerElement.setAttribute('data-location-id', id)
|
|
343
|
-
markerElement.setAttribute('aria-label', `Marker: ${id}`)
|
|
344
|
-
markerElement.className = markerStyle
|
|
345
|
-
new maplibre.Marker({ element: markerElement })
|
|
346
|
-
.setLngLat([lng, lat])
|
|
347
|
-
.addTo(map)
|
|
348
|
-
})
|
|
349
|
-
|
|
350
|
-
setMap(hostId, map)
|
|
351
|
-
return map
|
|
352
|
-
}),
|
|
353
|
-
() => Effect.sync(() => removeMap(hostId)),
|
|
354
|
-
)
|
|
355
332
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
)
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
333
|
+
Array.forEach(featuredLocations, ({ id, lng, lat }) => {
|
|
334
|
+
const markerElement = document.createElement('button')
|
|
335
|
+
markerElement.setAttribute('data-location-id', id)
|
|
336
|
+
markerElement.setAttribute('aria-label', `Marker: ${id}`)
|
|
337
|
+
markerElement.className = markerStyle
|
|
338
|
+
new maplibre.Marker({ element: markerElement })
|
|
339
|
+
.setLngLat([lng, lat])
|
|
340
|
+
.addTo(map)
|
|
341
|
+
})
|
|
342
|
+
|
|
343
|
+
setMap(hostId, map)
|
|
344
|
+
return map
|
|
345
|
+
}),
|
|
346
|
+
() => Effect.sync(() => removeMap(hostId)),
|
|
347
|
+
)
|
|
348
|
+
|
|
349
|
+
return Message.SucceededMountMap({ hostId })
|
|
350
|
+
}).pipe(
|
|
351
|
+
Effect.catch(error =>
|
|
352
|
+
Effect.succeed(
|
|
353
|
+
Message.FailedMountMap({
|
|
354
|
+
reason: error instanceof Error ? error.message : `${error}`,
|
|
355
|
+
}),
|
|
356
|
+
),
|
|
357
|
+
),
|
|
358
|
+
)
|
|
359
|
+
})
|
|
360
|
+
|
|
361
|
+
export const MountMap = Mount.define('MountMap', {
|
|
362
|
+
args: { hostId: S.String },
|
|
363
|
+
messages: [Message.SucceededMountMap, Message.FailedMountMap],
|
|
364
|
+
execute: ({ element, hostId }) => mountMap(element, hostId),
|
|
365
|
+
})
|
|
368
366
|
|
|
369
367
|
// SUBSCRIPTIONS
|
|
370
368
|
|
|
@@ -680,15 +678,13 @@ const geolocateOverlayView = (
|
|
|
680
678
|
state: GeolocateState,
|
|
681
679
|
h: HtmlBuilder<Message>,
|
|
682
680
|
): Html =>
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
}),
|
|
691
|
-
)
|
|
681
|
+
GeolocateState.match(state, {
|
|
682
|
+
Idle: () => h.empty,
|
|
683
|
+
Locating: () =>
|
|
684
|
+
geolocateOverlayShellView(geolocateLocatingContentView(h), h),
|
|
685
|
+
Failed: ({ reason }) =>
|
|
686
|
+
geolocateOverlayShellView(geolocateFailedContentView(reason, h), h),
|
|
687
|
+
})
|
|
692
688
|
|
|
693
689
|
const geolocateOverlayShellView = (
|
|
694
690
|
content: Html,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@foldkit/devtools": "workspace:*",
|
|
21
21
|
"@foldkit/vite-plugin": "workspace:*",
|
|
22
|
-
"@tailwindcss/vite": "^4.3.
|
|
22
|
+
"@tailwindcss/vite": "^4.3.3",
|
|
23
23
|
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
|
|
24
|
-
"happy-dom": "^20.
|
|
25
|
-
"prettier": "^3.
|
|
26
|
-
"tailwindcss": "^4.3.
|
|
27
|
-
"typescript": "^
|
|
28
|
-
"vite": "^8.
|
|
29
|
-
"vitest": "^4.1.
|
|
24
|
+
"happy-dom": "^20.11.13",
|
|
25
|
+
"prettier": "^3.9.6",
|
|
26
|
+
"tailwindcss": "^4.3.3",
|
|
27
|
+
"typescript": "^7.0.2",
|
|
28
|
+
"vite": "^8.2.2",
|
|
29
|
+
"vitest": "^4.1.11"
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -69,7 +69,7 @@ describe('export workflow', () => {
|
|
|
69
69
|
ExportPng,
|
|
70
70
|
Message.FailedExportPng({ error: 'Canvas 2D context not available' }),
|
|
71
71
|
),
|
|
72
|
-
Command.resolve(Dialog.ShowDialog, DialogMessage.
|
|
72
|
+
Command.resolve(Dialog.ShowDialog, DialogMessage.SucceededShowDialog()),
|
|
73
73
|
expect(text('Export Failed')).toExist(),
|
|
74
74
|
expect(text('Canvas 2D context not available')).toExist(),
|
|
75
75
|
expect(role('button', { name: 'Dismiss' })).toExist(),
|
|
@@ -85,7 +85,7 @@ describe('export workflow', () => {
|
|
|
85
85
|
ExportPng,
|
|
86
86
|
Message.FailedExportPng({ error: 'Canvas 2D context not available' }),
|
|
87
87
|
),
|
|
88
|
-
Command.resolve(Dialog.ShowDialog, DialogMessage.
|
|
88
|
+
Command.resolve(Dialog.ShowDialog, DialogMessage.SucceededShowDialog()),
|
|
89
89
|
expect(text('Export Failed')).toExist(),
|
|
90
90
|
click(role('button', { name: 'Dismiss' })),
|
|
91
91
|
Command.resolve(Dialog.CloseDialog, DialogMessage.CompletedCloseDialog()),
|
|
@@ -196,7 +196,7 @@ describe('grid size change', () => {
|
|
|
196
196
|
given(createPaintedModel()),
|
|
197
197
|
click(role('radio', { name: '8' })),
|
|
198
198
|
resolveFocusOption,
|
|
199
|
-
Command.resolve(Dialog.ShowDialog, DialogMessage.
|
|
199
|
+
Command.resolve(Dialog.ShowDialog, DialogMessage.SucceededShowDialog()),
|
|
200
200
|
expect(text('Change to 8\u00d78?')).toExist(),
|
|
201
201
|
expect(
|
|
202
202
|
text('This will clear your canvas and reset undo history.'),
|
|
@@ -304,7 +304,7 @@ describe('grid size', () => {
|
|
|
304
304
|
update,
|
|
305
305
|
given(paintedModel),
|
|
306
306
|
message(Message.SelectedGridSize({ size: 8 })),
|
|
307
|
-
Command.resolve(Dialog.ShowDialog, DialogMessage.
|
|
307
|
+
Command.resolve(Dialog.ShowDialog, DialogMessage.SucceededShowDialog()),
|
|
308
308
|
model(model => {
|
|
309
309
|
expect(model.maybePendingGridSize).toEqual(Option.some(8))
|
|
310
310
|
expect(model.gridSizeConfirmDialog.isOpen).toBe(true)
|
|
@@ -449,7 +449,7 @@ describe('export failure', () => {
|
|
|
449
449
|
message(
|
|
450
450
|
Message.FailedExportPng({ error: 'Canvas 2D context not available' }),
|
|
451
451
|
),
|
|
452
|
-
Command.resolve(Dialog.ShowDialog, DialogMessage.
|
|
452
|
+
Command.resolve(Dialog.ShowDialog, DialogMessage.SucceededShowDialog()),
|
|
453
453
|
model(model => {
|
|
454
454
|
expect(model.maybeExportError).toEqual(
|
|
455
455
|
Option.some('Canvas 2D context not available'),
|
|
@@ -466,7 +466,7 @@ describe('export failure', () => {
|
|
|
466
466
|
message(
|
|
467
467
|
Message.FailedExportPng({ error: 'Canvas 2D context not available' }),
|
|
468
468
|
),
|
|
469
|
-
Command.resolve(Dialog.ShowDialog, DialogMessage.
|
|
469
|
+
Command.resolve(Dialog.ShowDialog, DialogMessage.SucceededShowDialog()),
|
|
470
470
|
message(
|
|
471
471
|
Message.GotErrorDialogMessage({
|
|
472
472
|
message: DialogMessage.RequestedClose(),
|
|
@@ -18,13 +18,13 @@
|
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@foldkit/devtools": "workspace:*",
|
|
20
20
|
"@foldkit/vite-plugin": "workspace:*",
|
|
21
|
-
"@tailwindcss/vite": "^4.3.
|
|
21
|
+
"@tailwindcss/vite": "^4.3.3",
|
|
22
22
|
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
|
|
23
|
-
"happy-dom": "^20.
|
|
24
|
-
"prettier": "^3.
|
|
25
|
-
"tailwindcss": "^4.3.
|
|
26
|
-
"typescript": "^
|
|
27
|
-
"vite": "^8.
|
|
28
|
-
"vitest": "^4.1.
|
|
23
|
+
"happy-dom": "^20.11.13",
|
|
24
|
+
"prettier": "^3.9.6",
|
|
25
|
+
"tailwindcss": "^4.3.3",
|
|
26
|
+
"typescript": "^7.0.2",
|
|
27
|
+
"vite": "^8.2.2",
|
|
28
|
+
"vitest": "^4.1.11"
|
|
29
29
|
}
|
|
30
30
|
}
|