create-foldkit-app 0.40.0 → 0.41.0-canary.28664a17992a
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 +2 -2
- package/dist/templates/examples/api-cache-query/package.json +2 -2
- package/dist/templates/examples/auth/package.json +2 -2
- package/dist/templates/examples/canvas-art/package.json +2 -2
- package/dist/templates/examples/charting/package.json +2 -2
- package/dist/templates/examples/counter/package.json +2 -2
- package/dist/templates/examples/counters/package.json +2 -2
- package/dist/templates/examples/crash-view/package.json +2 -2
- package/dist/templates/examples/embedding/package.json +2 -2
- package/dist/templates/examples/form/package.json +2 -2
- package/dist/templates/examples/generative-art/package.json +2 -2
- package/dist/templates/examples/interrupting-commands/package.json +2 -2
- package/dist/templates/examples/job-application/package.json +2 -2
- package/dist/templates/examples/job-application/src/main.ts +7 -6
- package/dist/templates/examples/job-application/src/step/education/education.ts +9 -14
- package/dist/templates/examples/job-application/src/step/education/story.test.ts +1 -13
- package/dist/templates/examples/job-application/src/step/skills/skills.ts +9 -14
- package/dist/templates/examples/job-application/src/step/skills/story.test.ts +1 -13
- package/dist/templates/examples/job-application/src/step/workHistory/story.test.ts +1 -13
- package/dist/templates/examples/job-application/src/step/workHistory/workHistory.ts +9 -14
- package/dist/templates/examples/job-application/src/story.test.ts +3 -3
- package/dist/templates/examples/kanban/package.json +2 -2
- package/dist/templates/examples/kanban/src/command.ts +5 -4
- package/dist/templates/examples/managed-resource-layer/package.json +2 -2
- package/dist/templates/examples/managed-resource-layer/src/main.ts +5 -13
- package/dist/templates/examples/map/package.json +2 -2
- package/dist/templates/examples/map/src/main.ts +1 -0
- package/dist/templates/examples/pixel-art/package.json +2 -2
- package/dist/templates/examples/query-sync/package.json +2 -2
- package/dist/templates/examples/route-transitions/package.json +2 -2
- package/dist/templates/examples/routing/package.json +2 -2
- package/dist/templates/examples/shopping-cart/package.json +2 -2
- package/dist/templates/examples/slow-warnings/package.json +2 -2
- package/dist/templates/examples/snake/package.json +2 -2
- package/dist/templates/examples/ssg/package.json +2 -2
- package/dist/templates/examples/ssr/package.json +4 -4
- package/dist/templates/examples/state-machine/package.json +2 -2
- package/dist/templates/examples/stopwatch/package.json +2 -2
- package/dist/templates/examples/todo/package.json +2 -2
- package/dist/templates/examples/ui-showcase/package.json +2 -2
- package/dist/templates/examples/view-transitions/package.json +2 -2
- package/dist/templates/examples/weather/package.json +2 -2
- package/dist/templates/examples/web-components/package.json +2 -2
- package/dist/templates/examples/websocket-chat/package.json +2 -2
- package/dist/templates/release.json +15 -15
- package/package.json +5 -5
|
@@ -104,7 +104,7 @@ Command args contain values already present in the Model or Message. Calling `Da
|
|
|
104
104
|
|
|
105
105
|
For the with-args shape, see `repos/foldkit/examples/weather/src/main.ts` or `repos/foldkit/examples/kanban/src/command.ts`. For an argless DOM-side-effect Command, the argless form in `kanban/src/command.ts` (`FocusAddCardInput`) is the canonical reference.
|
|
106
106
|
|
|
107
|
-
For DOM operations (focus, scroll, modals, scroll lock), Foldkit ships a `Dom` module. For time, randomness, UUIDs, and delays, use Effect's APIs directly (`Clock`, `Random`, `
|
|
107
|
+
For DOM operations (focus, scroll, modals, scroll lock), Foldkit ships a `Dom` module. For time, randomness, UUIDs, and delays, use Effect's APIs directly (`Clock`, `Random`, `SecureRandom.SecureRandom`, `Effect.sleep`). Import `SecureRandom` from `effect/crypto` and provide `BrowserCrypto.layerSecureRandom` when using its service in the browser. Don't reach for raw `document.querySelector`, `setTimeout`, `Date.now()`, or `Math.random()`.
|
|
108
108
|
|
|
109
109
|
### File Organization
|
|
110
110
|
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"test": "vitest run"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@effect/platform-browser": "4.
|
|
12
|
+
"@effect/platform-browser": "4.1.0",
|
|
13
13
|
"@foldkit/ui": "workspace:*",
|
|
14
|
-
"effect": "4.
|
|
14
|
+
"effect": "4.1.0",
|
|
15
15
|
"foldkit": "workspace:*"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"test": "vitest run"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@effect/platform-browser": "4.
|
|
12
|
+
"@effect/platform-browser": "4.1.0",
|
|
13
13
|
"@foldkit/ui": "workspace:*",
|
|
14
|
-
"effect": "4.
|
|
14
|
+
"effect": "4.1.0",
|
|
15
15
|
"foldkit": "workspace:*"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
"test": "vitest run"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@effect/platform-browser": "4.
|
|
12
|
+
"@effect/platform-browser": "4.1.0",
|
|
13
13
|
"@foldkit/ui": "workspace:*",
|
|
14
14
|
"clsx": "^2.1.1",
|
|
15
|
-
"effect": "4.
|
|
15
|
+
"effect": "4.1.0",
|
|
16
16
|
"foldkit": "workspace:*"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"test": "vitest run"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@effect/platform-browser": "4.
|
|
12
|
+
"@effect/platform-browser": "4.1.0",
|
|
13
13
|
"@foldkit/ui": "workspace:*",
|
|
14
|
-
"effect": "4.
|
|
14
|
+
"effect": "4.1.0",
|
|
15
15
|
"foldkit": "workspace:*"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
"test": "vitest run"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@effect/platform-browser": "4.
|
|
12
|
+
"@effect/platform-browser": "4.1.0",
|
|
13
13
|
"@foldkit/ui": "workspace:*",
|
|
14
14
|
"clsx": "^2.1.1",
|
|
15
15
|
"echarts": "^6.1.0",
|
|
16
|
-
"effect": "4.
|
|
16
|
+
"effect": "4.1.0",
|
|
17
17
|
"foldkit": "workspace:*"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"test": "vitest run"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@effect/platform-browser": "4.
|
|
12
|
+
"@effect/platform-browser": "4.1.0",
|
|
13
13
|
"@foldkit/ui": "workspace:*",
|
|
14
|
-
"effect": "4.
|
|
14
|
+
"effect": "4.1.0",
|
|
15
15
|
"foldkit": "workspace:*"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"test": "vitest run"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@effect/platform-browser": "4.
|
|
12
|
+
"@effect/platform-browser": "4.1.0",
|
|
13
13
|
"@foldkit/ui": "workspace:*",
|
|
14
|
-
"effect": "4.
|
|
14
|
+
"effect": "4.1.0",
|
|
15
15
|
"foldkit": "workspace:*"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"test": "vitest run"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@effect/platform-browser": "4.
|
|
12
|
+
"@effect/platform-browser": "4.1.0",
|
|
13
13
|
"@foldkit/ui": "workspace:*",
|
|
14
|
-
"effect": "4.
|
|
14
|
+
"effect": "4.1.0",
|
|
15
15
|
"foldkit": "workspace:*"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"test": "vitest run"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@effect/platform-browser": "4.
|
|
12
|
+
"@effect/platform-browser": "4.1.0",
|
|
13
13
|
"@foldkit/ui": "workspace:*",
|
|
14
|
-
"effect": "4.
|
|
14
|
+
"effect": "4.1.0",
|
|
15
15
|
"foldkit": "workspace:*"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
"test": "vitest run"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@effect/platform-browser": "4.
|
|
12
|
+
"@effect/platform-browser": "4.1.0",
|
|
13
13
|
"@foldkit/ui": "workspace:*",
|
|
14
14
|
"clsx": "^2.1.1",
|
|
15
|
-
"effect": "4.
|
|
15
|
+
"effect": "4.1.0",
|
|
16
16
|
"foldkit": "workspace:*"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"test": "vitest run"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@effect/platform-browser": "4.
|
|
12
|
+
"@effect/platform-browser": "4.1.0",
|
|
13
13
|
"@foldkit/ui": "workspace:*",
|
|
14
|
-
"effect": "4.
|
|
14
|
+
"effect": "4.1.0",
|
|
15
15
|
"foldkit": "workspace:*"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
"test": "vitest run"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@effect/platform-browser": "4.
|
|
12
|
+
"@effect/platform-browser": "4.1.0",
|
|
13
13
|
"@foldkit/ui": "workspace:*",
|
|
14
14
|
"clsx": "^2.1.1",
|
|
15
|
-
"effect": "4.
|
|
15
|
+
"effect": "4.1.0",
|
|
16
16
|
"foldkit": "workspace:*"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Effect, Schema } from 'effect'
|
|
2
|
+
import { SecureRandom } from 'effect/crypto'
|
|
2
3
|
import { Calendar, Runtime } from 'foldkit'
|
|
3
4
|
|
|
4
5
|
import { BrowserCrypto } from '@effect/platform-browser'
|
|
@@ -29,17 +30,17 @@ export type Flags = typeof Flags.Type
|
|
|
29
30
|
|
|
30
31
|
export const flags: Effect.Effect<Flags> = Effect.gen(function* () {
|
|
31
32
|
const today = yield* Calendar.today.local
|
|
32
|
-
const
|
|
33
|
-
const initialWorkHistoryEntryId = yield*
|
|
34
|
-
const initialEducationEntryId = yield*
|
|
35
|
-
const initialSkillsEntryId = yield*
|
|
33
|
+
const secureRandom = yield* SecureRandom.SecureRandom
|
|
34
|
+
const initialWorkHistoryEntryId = yield* secureRandom.uuidV4()
|
|
35
|
+
const initialEducationEntryId = yield* secureRandom.uuidV4()
|
|
36
|
+
const initialSkillsEntryId = yield* secureRandom.uuidV4()
|
|
36
37
|
return {
|
|
37
38
|
today,
|
|
38
39
|
initialWorkHistoryEntryId,
|
|
39
40
|
initialEducationEntryId,
|
|
40
41
|
initialSkillsEntryId,
|
|
41
42
|
}
|
|
42
|
-
}).pipe(Effect.provide(BrowserCrypto.
|
|
43
|
+
}).pipe(Effect.provide(BrowserCrypto.layerSecureRandom))
|
|
43
44
|
|
|
44
45
|
// INIT
|
|
45
46
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Array,
|
|
1
|
+
import { Array, Effect, Schema } from 'effect'
|
|
2
|
+
import { SecureRandom } from 'effect/crypto'
|
|
2
3
|
import { Calendar, Command, Update } from 'foldkit'
|
|
3
4
|
import { type CalendarDate } from 'foldkit/calendar'
|
|
4
5
|
import { defineMessageUnion } from 'foldkit/message'
|
|
@@ -20,8 +21,7 @@ export type Model = typeof Model.Type
|
|
|
20
21
|
|
|
21
22
|
export const Message = defineMessageUnion({
|
|
22
23
|
ClickedAddEntry: {},
|
|
23
|
-
|
|
24
|
-
FailedGenerateEntryId: {},
|
|
24
|
+
CompletedGenerateEntryId: { entryId: Schema.String },
|
|
25
25
|
RemovedEntry: { entryId: Schema.String },
|
|
26
26
|
GotEntryMessage: {
|
|
27
27
|
entryId: Schema.String,
|
|
@@ -41,15 +41,12 @@ export const init = (today: CalendarDate, initialEntryId: string): Model => ({
|
|
|
41
41
|
// COMMAND
|
|
42
42
|
|
|
43
43
|
export const GenerateEntryId = Command.define('GenerateEntryId', {
|
|
44
|
-
messages: [Message.
|
|
44
|
+
messages: [Message.CompletedGenerateEntryId],
|
|
45
45
|
execute: Effect.gen(function* () {
|
|
46
|
-
const
|
|
47
|
-
const entryId = yield*
|
|
48
|
-
return Message.
|
|
49
|
-
}).pipe(
|
|
50
|
-
Effect.provide(BrowserCrypto.layer),
|
|
51
|
-
Effect.catch(() => Effect.succeed(Message.FailedGenerateEntryId())),
|
|
52
|
-
),
|
|
46
|
+
const secureRandom = yield* SecureRandom.SecureRandom
|
|
47
|
+
const entryId = yield* secureRandom.uuidV4()
|
|
48
|
+
return Message.CompletedGenerateEntryId({ entryId })
|
|
49
|
+
}).pipe(Effect.provide(BrowserCrypto.layerSecureRandom)),
|
|
53
50
|
})
|
|
54
51
|
|
|
55
52
|
// UPDATE
|
|
@@ -80,14 +77,12 @@ export const update = (model: Model, message: Message) =>
|
|
|
80
77
|
Message.match<Update.Return<Model, Message>>(message, {
|
|
81
78
|
ClickedAddEntry: () => ({ model, commands: [GenerateEntryId()] }),
|
|
82
79
|
|
|
83
|
-
|
|
80
|
+
CompletedGenerateEntryId: ({ entryId }) => ({
|
|
84
81
|
model: modifyFields(model, {
|
|
85
82
|
entries: Array.append(Entry.init(entryId)),
|
|
86
83
|
}),
|
|
87
84
|
}),
|
|
88
85
|
|
|
89
|
-
FailedGenerateEntryId: () => ({ model }),
|
|
90
|
-
|
|
91
86
|
RemovedEntry: ({ entryId }) => ({
|
|
92
87
|
model: modifyFields(model, {
|
|
93
88
|
entries: Array.filter(entry => entry.id !== entryId),
|
|
@@ -18,7 +18,7 @@ describe('education', () => {
|
|
|
18
18
|
Command.expectHas(GenerateEntryId),
|
|
19
19
|
Command.resolve(
|
|
20
20
|
GenerateEntryId,
|
|
21
|
-
Message.
|
|
21
|
+
Message.CompletedGenerateEntryId({ entryId: 'test-edu-1' }),
|
|
22
22
|
),
|
|
23
23
|
model(model => {
|
|
24
24
|
expect(model.entries).toHaveLength(2)
|
|
@@ -26,18 +26,6 @@ describe('education', () => {
|
|
|
26
26
|
)
|
|
27
27
|
})
|
|
28
28
|
|
|
29
|
-
test('FailedGenerateEntryId leaves the entries unchanged', () => {
|
|
30
|
-
story(
|
|
31
|
-
update,
|
|
32
|
-
givenInitial,
|
|
33
|
-
message(Message.FailedGenerateEntryId()),
|
|
34
|
-
Command.expectNone(),
|
|
35
|
-
model(model => {
|
|
36
|
-
expect(model).toEqual(init(today, 'education-entry-1'))
|
|
37
|
-
}),
|
|
38
|
-
)
|
|
39
|
-
})
|
|
40
|
-
|
|
41
29
|
test('an entry OutMessage.Removed removes that entry', () => {
|
|
42
30
|
const firstEntry = Option.getOrThrow(
|
|
43
31
|
Array.head(init(today, 'education-entry-1').entries),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Array,
|
|
1
|
+
import { Array, Effect, Schema } from 'effect'
|
|
2
|
+
import { SecureRandom } from 'effect/crypto'
|
|
2
3
|
import { Command, Update } from 'foldkit'
|
|
3
4
|
import { defineMessageUnion } from 'foldkit/message'
|
|
4
5
|
import { modifyFields } from 'foldkit/struct'
|
|
@@ -18,8 +19,7 @@ export type Model = typeof Model.Type
|
|
|
18
19
|
|
|
19
20
|
export const Message = defineMessageUnion({
|
|
20
21
|
ClickedAddEntry: {},
|
|
21
|
-
|
|
22
|
-
FailedGenerateEntryId: {},
|
|
22
|
+
CompletedGenerateEntryId: { entryId: Schema.String },
|
|
23
23
|
RemovedEntry: { entryId: Schema.String },
|
|
24
24
|
GotEntryMessage: {
|
|
25
25
|
entryId: Schema.String,
|
|
@@ -38,15 +38,12 @@ export const init = (initialEntryId: string): Model => ({
|
|
|
38
38
|
// COMMAND
|
|
39
39
|
|
|
40
40
|
export const GenerateEntryId = Command.define('GenerateEntryId', {
|
|
41
|
-
messages: [Message.
|
|
41
|
+
messages: [Message.CompletedGenerateEntryId],
|
|
42
42
|
execute: Effect.gen(function* () {
|
|
43
|
-
const
|
|
44
|
-
const entryId = yield*
|
|
45
|
-
return Message.
|
|
46
|
-
}).pipe(
|
|
47
|
-
Effect.provide(BrowserCrypto.layer),
|
|
48
|
-
Effect.catch(() => Effect.succeed(Message.FailedGenerateEntryId())),
|
|
49
|
-
),
|
|
43
|
+
const secureRandom = yield* SecureRandom.SecureRandom
|
|
44
|
+
const entryId = yield* secureRandom.uuidV4()
|
|
45
|
+
return Message.CompletedGenerateEntryId({ entryId })
|
|
46
|
+
}).pipe(Effect.provide(BrowserCrypto.layerSecureRandom)),
|
|
50
47
|
})
|
|
51
48
|
|
|
52
49
|
// UPDATE
|
|
@@ -77,14 +74,12 @@ export const update = (model: Model, message: Message) =>
|
|
|
77
74
|
Message.match<Update.Return<Model, Message>>(message, {
|
|
78
75
|
ClickedAddEntry: () => ({ model, commands: [GenerateEntryId()] }),
|
|
79
76
|
|
|
80
|
-
|
|
77
|
+
CompletedGenerateEntryId: ({ entryId }) => ({
|
|
81
78
|
model: modifyFields(model, {
|
|
82
79
|
entries: Array.append(Entry.init(entryId)),
|
|
83
80
|
}),
|
|
84
81
|
}),
|
|
85
82
|
|
|
86
|
-
FailedGenerateEntryId: () => ({ model }),
|
|
87
|
-
|
|
88
83
|
RemovedEntry: ({ entryId }) => ({
|
|
89
84
|
model: modifyFields(model, {
|
|
90
85
|
entries: Array.filter(entry => entry.id !== entryId),
|
|
@@ -16,7 +16,7 @@ describe('skills', () => {
|
|
|
16
16
|
Command.expectHas(GenerateEntryId),
|
|
17
17
|
Command.resolve(
|
|
18
18
|
GenerateEntryId,
|
|
19
|
-
Message.
|
|
19
|
+
Message.CompletedGenerateEntryId({ entryId: 'test-skill-1' }),
|
|
20
20
|
),
|
|
21
21
|
model(model => {
|
|
22
22
|
expect(model.entries).toHaveLength(2)
|
|
@@ -24,18 +24,6 @@ describe('skills', () => {
|
|
|
24
24
|
)
|
|
25
25
|
})
|
|
26
26
|
|
|
27
|
-
test('FailedGenerateEntryId leaves the entries unchanged', () => {
|
|
28
|
-
story(
|
|
29
|
-
update,
|
|
30
|
-
givenInitial,
|
|
31
|
-
message(Message.FailedGenerateEntryId()),
|
|
32
|
-
Command.expectNone(),
|
|
33
|
-
model(model => {
|
|
34
|
-
expect(model).toEqual(init('skills-entry-1'))
|
|
35
|
-
}),
|
|
36
|
-
)
|
|
37
|
-
})
|
|
38
|
-
|
|
39
27
|
test('an entry OutMessage.Removed removes that entry', () => {
|
|
40
28
|
const firstEntry = Option.getOrThrow(
|
|
41
29
|
Array.head(init('skills-entry-1').entries),
|
|
@@ -18,7 +18,7 @@ describe('workHistory', () => {
|
|
|
18
18
|
Command.expectHas(GenerateEntryId),
|
|
19
19
|
Command.resolve(
|
|
20
20
|
GenerateEntryId,
|
|
21
|
-
Message.
|
|
21
|
+
Message.CompletedGenerateEntryId({ entryId: 'test-work-1' }),
|
|
22
22
|
),
|
|
23
23
|
model(model => {
|
|
24
24
|
expect(model.entries).toHaveLength(2)
|
|
@@ -26,18 +26,6 @@ describe('workHistory', () => {
|
|
|
26
26
|
)
|
|
27
27
|
})
|
|
28
28
|
|
|
29
|
-
test('FailedGenerateEntryId leaves the entries unchanged', () => {
|
|
30
|
-
story(
|
|
31
|
-
update,
|
|
32
|
-
givenInitial,
|
|
33
|
-
message(Message.FailedGenerateEntryId()),
|
|
34
|
-
Command.expectNone(),
|
|
35
|
-
model(model => {
|
|
36
|
-
expect(model).toEqual(init(today, 'work-history-entry-1'))
|
|
37
|
-
}),
|
|
38
|
-
)
|
|
39
|
-
})
|
|
40
|
-
|
|
41
29
|
test('an entry OutMessage.Removed removes that entry', () => {
|
|
42
30
|
const firstEntry = Option.getOrThrow(
|
|
43
31
|
Array.head(init(today, 'work-history-entry-1').entries),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Array,
|
|
1
|
+
import { Array, Effect, Schema } from 'effect'
|
|
2
|
+
import { SecureRandom } from 'effect/crypto'
|
|
2
3
|
import { Calendar, Command, Update } from 'foldkit'
|
|
3
4
|
import { type CalendarDate } from 'foldkit/calendar'
|
|
4
5
|
import { defineMessageUnion } from 'foldkit/message'
|
|
@@ -20,8 +21,7 @@ export type Model = typeof Model.Type
|
|
|
20
21
|
|
|
21
22
|
export const Message = defineMessageUnion({
|
|
22
23
|
ClickedAddEntry: {},
|
|
23
|
-
|
|
24
|
-
FailedGenerateEntryId: {},
|
|
24
|
+
CompletedGenerateEntryId: { entryId: Schema.String },
|
|
25
25
|
RemovedEntry: { entryId: Schema.String },
|
|
26
26
|
GotEntryMessage: {
|
|
27
27
|
entryId: Schema.String,
|
|
@@ -41,15 +41,12 @@ export const init = (today: CalendarDate, initialEntryId: string): Model => ({
|
|
|
41
41
|
// COMMAND
|
|
42
42
|
|
|
43
43
|
export const GenerateEntryId = Command.define('GenerateEntryId', {
|
|
44
|
-
messages: [Message.
|
|
44
|
+
messages: [Message.CompletedGenerateEntryId],
|
|
45
45
|
execute: Effect.gen(function* () {
|
|
46
|
-
const
|
|
47
|
-
const entryId = yield*
|
|
48
|
-
return Message.
|
|
49
|
-
}).pipe(
|
|
50
|
-
Effect.provide(BrowserCrypto.layer),
|
|
51
|
-
Effect.catch(() => Effect.succeed(Message.FailedGenerateEntryId())),
|
|
52
|
-
),
|
|
46
|
+
const secureRandom = yield* SecureRandom.SecureRandom
|
|
47
|
+
const entryId = yield* secureRandom.uuidV4()
|
|
48
|
+
return Message.CompletedGenerateEntryId({ entryId })
|
|
49
|
+
}).pipe(Effect.provide(BrowserCrypto.layerSecureRandom)),
|
|
53
50
|
})
|
|
54
51
|
|
|
55
52
|
// UPDATE
|
|
@@ -80,14 +77,12 @@ export const update = (model: Model, message: Message) =>
|
|
|
80
77
|
Message.match<Update.Return<Model, Message>>(message, {
|
|
81
78
|
ClickedAddEntry: () => ({ model, commands: [GenerateEntryId()] }),
|
|
82
79
|
|
|
83
|
-
|
|
80
|
+
CompletedGenerateEntryId: ({ entryId }) => ({
|
|
84
81
|
model: modifyFields(model, {
|
|
85
82
|
entries: Array.append(Entry.init(entryId, model.today)),
|
|
86
83
|
}),
|
|
87
84
|
}),
|
|
88
85
|
|
|
89
|
-
FailedGenerateEntryId: () => ({ model }),
|
|
90
|
-
|
|
91
86
|
RemovedEntry: ({ entryId }) => ({
|
|
92
87
|
model: modifyFields(model, {
|
|
93
88
|
entries: Array.filter(entry => entry.id !== entryId),
|
|
@@ -162,7 +162,7 @@ describe('update', () => {
|
|
|
162
162
|
givenInitial,
|
|
163
163
|
message(
|
|
164
164
|
Message.GotWorkHistoryMessage({
|
|
165
|
-
message: WorkHistory.Message.
|
|
165
|
+
message: WorkHistory.Message.CompletedGenerateEntryId({
|
|
166
166
|
entryId: 'test-work-1',
|
|
167
167
|
}),
|
|
168
168
|
}),
|
|
@@ -179,7 +179,7 @@ describe('update', () => {
|
|
|
179
179
|
givenInitial,
|
|
180
180
|
message(
|
|
181
181
|
Message.GotEducationMessage({
|
|
182
|
-
message: Education.Message.
|
|
182
|
+
message: Education.Message.CompletedGenerateEntryId({
|
|
183
183
|
entryId: 'test-edu-1',
|
|
184
184
|
}),
|
|
185
185
|
}),
|
|
@@ -196,7 +196,7 @@ describe('update', () => {
|
|
|
196
196
|
givenInitial,
|
|
197
197
|
message(
|
|
198
198
|
Message.GotSkillsMessage({
|
|
199
|
-
message: Skills.Message.
|
|
199
|
+
message: Skills.Message.CompletedGenerateEntryId({
|
|
200
200
|
entryId: 'test-skill-1',
|
|
201
201
|
}),
|
|
202
202
|
}),
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
"test": "vitest run"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@effect/platform-browser": "4.
|
|
12
|
+
"@effect/platform-browser": "4.1.0",
|
|
13
13
|
"@foldkit/ui": "workspace:*",
|
|
14
14
|
"clsx": "^2.1.1",
|
|
15
|
-
"effect": "4.
|
|
15
|
+
"effect": "4.1.0",
|
|
16
16
|
"foldkit": "workspace:*",
|
|
17
17
|
"fractional-indexing": "^4.0.0"
|
|
18
18
|
},
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Effect, Schema } from 'effect'
|
|
2
|
+
import { SecureRandom } from 'effect/crypto'
|
|
2
3
|
import { KeyValueStore } from 'effect/persistence'
|
|
3
4
|
import { Command, Dom } from 'foldkit'
|
|
4
5
|
|
|
@@ -14,10 +15,10 @@ export const GenerateCardId = Command.define('GenerateCardId', {
|
|
|
14
15
|
messages: [Message.CompletedGenerateCardId],
|
|
15
16
|
execute: ({ columnId, title }) =>
|
|
16
17
|
Effect.gen(function* () {
|
|
17
|
-
const
|
|
18
|
-
const cardId = yield*
|
|
18
|
+
const secureRandom = yield* SecureRandom.SecureRandom
|
|
19
|
+
const cardId = yield* secureRandom.uuidV4()
|
|
19
20
|
return Message.CompletedGenerateCardId({ cardId, columnId, title })
|
|
20
|
-
}).pipe(Effect.provide(BrowserCrypto.
|
|
21
|
+
}).pipe(Effect.provide(BrowserCrypto.layerSecureRandom)),
|
|
21
22
|
})
|
|
22
23
|
|
|
23
24
|
export const SaveBoard = Command.define('SaveBoard', {
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"test": "vitest run"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@effect/platform-browser": "4.
|
|
12
|
+
"@effect/platform-browser": "4.1.0",
|
|
13
13
|
"@foldkit/ui": "workspace:*",
|
|
14
|
-
"effect": "4.
|
|
14
|
+
"effect": "4.1.0",
|
|
15
15
|
"foldkit": "workspace:*"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
Crypto,
|
|
4
|
-
Effect,
|
|
5
|
-
Layer,
|
|
6
|
-
Match,
|
|
7
|
-
Number,
|
|
8
|
-
Option,
|
|
9
|
-
Schema,
|
|
10
|
-
} from 'effect'
|
|
1
|
+
import { Context, Effect, Layer, Match, Number, Option, Schema } from 'effect'
|
|
2
|
+
import { SecureRandom } from 'effect/crypto'
|
|
11
3
|
import { Command, ManagedResource, Runtime, type Update } from 'foldkit'
|
|
12
4
|
import { Document, Html, HtmlBuilder } from 'foldkit/html'
|
|
13
5
|
import { defineMessageUnion } from 'foldkit/message'
|
|
@@ -33,11 +25,11 @@ const engineLayer: Layer.Layer<ComputeEngineService> = Layer.effect(
|
|
|
33
25
|
ComputeEngineService,
|
|
34
26
|
Effect.acquireRelease(
|
|
35
27
|
Effect.gen(function* () {
|
|
36
|
-
const
|
|
37
|
-
const id = yield*
|
|
28
|
+
const secureRandom = yield* SecureRandom.SecureRandom
|
|
29
|
+
const id = yield* secureRandom.uuidV4()
|
|
38
30
|
const engineId = `engine-${id.slice(0, 8)}`
|
|
39
31
|
return { engineId, square: (value: number) => value * value }
|
|
40
|
-
}).pipe(Effect.provide(BrowserCrypto.
|
|
32
|
+
}).pipe(Effect.provide(BrowserCrypto.layerSecureRandom)),
|
|
41
33
|
({ engineId }) => Effect.log(`Tore down ${engineId}`),
|
|
42
34
|
),
|
|
43
35
|
)
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
"test": "vitest run"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@effect/platform-browser": "4.
|
|
12
|
+
"@effect/platform-browser": "4.1.0",
|
|
13
13
|
"@foldkit/ui": "workspace:*",
|
|
14
14
|
"clsx": "^2.1.1",
|
|
15
|
-
"effect": "4.
|
|
15
|
+
"effect": "4.1.0",
|
|
16
16
|
"foldkit": "workspace:*",
|
|
17
17
|
"maplibre-gl": "^6.11.2"
|
|
18
18
|
},
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
"bench": "vitest run --config vitest.bench.config.ts"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@effect/platform-browser": "4.
|
|
13
|
+
"@effect/platform-browser": "4.1.0",
|
|
14
14
|
"@foldkit/ui": "workspace:*",
|
|
15
15
|
"clsx": "^2.1.1",
|
|
16
|
-
"effect": "4.
|
|
16
|
+
"effect": "4.1.0",
|
|
17
17
|
"foldkit": "workspace:*"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
"test": "vitest run"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@effect/platform-browser": "4.
|
|
12
|
+
"@effect/platform-browser": "4.1.0",
|
|
13
13
|
"@foldkit/ui": "workspace:*",
|
|
14
14
|
"clsx": "^2.1.1",
|
|
15
|
-
"effect": "4.
|
|
15
|
+
"effect": "4.1.0",
|
|
16
16
|
"foldkit": "workspace:*"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"test": "vitest run"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@effect/platform-browser": "4.
|
|
12
|
+
"@effect/platform-browser": "4.1.0",
|
|
13
13
|
"@foldkit/ui": "workspace:*",
|
|
14
|
-
"effect": "4.
|
|
14
|
+
"effect": "4.1.0",
|
|
15
15
|
"foldkit": "workspace:*"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"test": "vitest run"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@effect/platform-browser": "4.
|
|
12
|
+
"@effect/platform-browser": "4.1.0",
|
|
13
13
|
"@foldkit/ui": "workspace:*",
|
|
14
|
-
"effect": "4.
|
|
14
|
+
"effect": "4.1.0",
|
|
15
15
|
"foldkit": "workspace:*"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
"test": "vitest run"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@effect/platform-browser": "4.
|
|
15
|
-
"@effect/platform-node": "4.
|
|
16
|
-
"@effect/platform-node-shared": "4.
|
|
14
|
+
"@effect/platform-browser": "4.1.0",
|
|
15
|
+
"@effect/platform-node": "4.1.0",
|
|
16
|
+
"@effect/platform-node-shared": "4.1.0",
|
|
17
17
|
"@foldkit/node": "workspace:*",
|
|
18
18
|
"@foldkit/ui": "workspace:*",
|
|
19
|
-
"effect": "4.
|
|
19
|
+
"effect": "4.1.0",
|
|
20
20
|
"foldkit": "workspace:*"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
"test": "vitest run"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@effect/platform-browser": "4.
|
|
12
|
+
"@effect/platform-browser": "4.1.0",
|
|
13
13
|
"@foldkit/ui": "workspace:*",
|
|
14
14
|
"clsx": "^2.1.1",
|
|
15
|
-
"effect": "4.
|
|
15
|
+
"effect": "4.1.0",
|
|
16
16
|
"foldkit": "workspace:*"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"test": "vitest run"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@effect/platform-browser": "4.
|
|
12
|
+
"@effect/platform-browser": "4.1.0",
|
|
13
13
|
"@foldkit/ui": "workspace:*",
|
|
14
|
-
"effect": "4.
|
|
14
|
+
"effect": "4.1.0",
|
|
15
15
|
"foldkit": "workspace:*"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
"test": "vitest run"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@effect/platform-browser": "4.
|
|
12
|
+
"@effect/platform-browser": "4.1.0",
|
|
13
13
|
"@foldkit/ui": "workspace:*",
|
|
14
14
|
"clsx": "^2.1.1",
|
|
15
|
-
"effect": "4.
|
|
15
|
+
"effect": "4.1.0",
|
|
16
16
|
"foldkit": "workspace:*"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
"test": "vitest run"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@effect/platform-browser": "4.
|
|
12
|
+
"@effect/platform-browser": "4.1.0",
|
|
13
13
|
"@foldkit/ui": "workspace:*",
|
|
14
14
|
"clsx": "^2.1.1",
|
|
15
|
-
"effect": "4.
|
|
15
|
+
"effect": "4.1.0",
|
|
16
16
|
"foldkit": "workspace:*"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"test": "vitest run"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@effect/platform-browser": "4.
|
|
12
|
+
"@effect/platform-browser": "4.1.0",
|
|
13
13
|
"@foldkit/ui": "workspace:*",
|
|
14
|
-
"effect": "4.
|
|
14
|
+
"effect": "4.1.0",
|
|
15
15
|
"foldkit": "workspace:*"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
"test": "vitest run"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@effect/platform-browser": "4.
|
|
12
|
+
"@effect/platform-browser": "4.1.0",
|
|
13
13
|
"@foldkit/ui": "workspace:*",
|
|
14
14
|
"@shoelace-style/shoelace": "^2.20.1",
|
|
15
15
|
"clsx": "^2.1.1",
|
|
16
|
-
"effect": "4.
|
|
16
|
+
"effect": "4.1.0",
|
|
17
17
|
"foldkit": "workspace:*",
|
|
18
18
|
"vanilla-colorful": "^0.7.2"
|
|
19
19
|
},
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"test": "vitest run"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@effect/platform-browser": "4.
|
|
12
|
+
"@effect/platform-browser": "4.1.0",
|
|
13
13
|
"@foldkit/ui": "workspace:*",
|
|
14
|
-
"effect": "4.
|
|
14
|
+
"effect": "4.1.0",
|
|
15
15
|
"foldkit": "workspace:*"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"channel": "
|
|
4
|
-
"sourceCommit": "
|
|
3
|
+
"channel": "canary",
|
|
4
|
+
"sourceCommit": "28664a17992ab5ef45788d282e8653d915bb4da1",
|
|
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/node": "0.
|
|
12
|
-
"@foldkit/oxlint-plugin": "0.15.
|
|
13
|
-
"@foldkit/ui": "0.
|
|
14
|
-
"@foldkit/vite-plugin": "0.
|
|
6
|
+
"create-foldkit-app": "0.41.0-canary.28664a17992a",
|
|
7
|
+
"@foldkit/devtools": "0.170.0-canary.28664a17992a",
|
|
8
|
+
"@foldkit/devtools-mcp": "0.26.0-canary.28664a17992a",
|
|
9
|
+
"foldkit": "0.170.0-canary.28664a17992a",
|
|
10
|
+
"@foldkit/markdown": "0.15.0-canary.28664a17992a",
|
|
11
|
+
"@foldkit/node": "0.2.0-canary.28664a17992a",
|
|
12
|
+
"@foldkit/oxlint-plugin": "0.15.4-canary.28664a17992a",
|
|
13
|
+
"@foldkit/ui": "0.170.0-canary.28664a17992a",
|
|
14
|
+
"@foldkit/vite-plugin": "0.29.0-canary.28664a17992a"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@effect/tsgo": "0.50.0",
|
|
18
|
-
"@foldkit/devtools": "0.
|
|
19
|
-
"@foldkit/vite-plugin": "0.
|
|
20
|
-
"@foldkit/devtools-mcp": "0.
|
|
21
|
-
"@foldkit/oxlint-plugin": "0.15.
|
|
18
|
+
"@foldkit/devtools": "0.170.0-canary.28664a17992a",
|
|
19
|
+
"@foldkit/vite-plugin": "0.29.0-canary.28664a17992a",
|
|
20
|
+
"@foldkit/devtools-mcp": "0.26.0-canary.28664a17992a",
|
|
21
|
+
"@foldkit/oxlint-plugin": "0.15.4-canary.28664a17992a",
|
|
22
22
|
"@types/node": "26.4.0",
|
|
23
23
|
"happy-dom": "^20.14.5",
|
|
24
24
|
"oxfmt": "^0.66.0",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-foldkit-app",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.41.0-canary.28664a17992a",
|
|
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.
|
|
15
|
-
"@effect/platform-node-shared": "4.
|
|
14
|
+
"@effect/platform-node": "~4.1.0",
|
|
15
|
+
"@effect/platform-node-shared": "~4.1.0",
|
|
16
16
|
"chalk": "^6.0.0",
|
|
17
|
-
"effect": "4.
|
|
17
|
+
"effect": "~4.1.0",
|
|
18
18
|
"rimraf": "^6.1.3",
|
|
19
19
|
"typescript": "^7.0.2"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@effect/vitest": "4.
|
|
22
|
+
"@effect/vitest": "4.1.0",
|
|
23
23
|
"@types/node": "26.4.0",
|
|
24
24
|
"vitest": "^5.0.2"
|
|
25
25
|
},
|