create-foldkit-app 0.22.2 → 0.23.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/README.md +1 -1
- package/dist/examples.js +3 -3
- package/package.json +1 -1
- package/templates/base/AGENTS.md +4 -2
package/README.md
CHANGED
|
@@ -39,7 +39,7 @@ The CLI prompts you for a project name, starter example, and package manager. Pa
|
|
|
39
39
|
| `generative-art` | Perlin-noise flow field with evolving particle trails, mouse vortex, and high-frequency Messages |
|
|
40
40
|
| `auth` | Authentication with Submodels, OutMessage, and protected routes |
|
|
41
41
|
| `shopping-cart` | Complex state management with nested Models and routing |
|
|
42
|
-
| `
|
|
42
|
+
| `state-machine` | Experimental state machine checkout with guarded branches and edge Commands |
|
|
43
43
|
| `pixel-art` | Pixel editor with undo/redo, UI components, and localStorage persistence |
|
|
44
44
|
| `websocket-chat` | Managed resources with WebSocket integration |
|
|
45
45
|
| `managed-resource-layer` | Layer-backed ManagedResource lifecycle with an Effect service |
|
package/dist/examples.js
CHANGED
|
@@ -19,7 +19,7 @@ export const EXAMPLE_VALUES = [
|
|
|
19
19
|
'generative-art',
|
|
20
20
|
'auth',
|
|
21
21
|
'shopping-cart',
|
|
22
|
-
'
|
|
22
|
+
'state-machine',
|
|
23
23
|
'pixel-art',
|
|
24
24
|
'websocket-chat',
|
|
25
25
|
'managed-resource-layer',
|
|
@@ -131,8 +131,8 @@ export const examples = [
|
|
|
131
131
|
description: 'Complex state management with nested models and routing',
|
|
132
132
|
},
|
|
133
133
|
{
|
|
134
|
-
value: '
|
|
135
|
-
title: '
|
|
134
|
+
value: 'state-machine',
|
|
135
|
+
title: 'state-machine',
|
|
136
136
|
description: 'Checkout workflow powered by the experimental state machine module with guarded branches and edge Commands',
|
|
137
137
|
},
|
|
138
138
|
{
|
package/package.json
CHANGED
package/templates/base/AGENTS.md
CHANGED
|
@@ -52,7 +52,7 @@ Use `evo()` from `foldkit/struct` for immutable model updates. Never spread or `
|
|
|
52
52
|
|
|
53
53
|
### View
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
Every view receives `h`, the typed Html builder, as its last parameter (`view: (model, h) => ...`; `Submodel.defineView` passes the child's own). Never construct a builder; reach for `h.div`, `h.OnClick`, etc. off the parameter, and give extracted view helpers an `h: HtmlBuilder<Message>` last parameter that callers thread through. Only where no builder is in scope, typically module scope, use `inertHtml` from `foldkit/html`, aliased `ih` so the two builders stay distinguishable. Use `h.empty` (not `null`) for conditional rendering, `M.value().pipe(M.tagsExhaustive({...}))` for discriminated unions, and `Array.match` for lists that may be empty.
|
|
56
56
|
|
|
57
57
|
Keys are for mapped list items only: key each row by a stable Model identifier (`h.keyed('li')(item.id, [], [...])`), never by array position, and never derive a key from displayed data. Never key branches; the build gives each view function's output its own identity, so branch switches replace DOM automatically. When switching an inline same-tag ternary must reset DOM state, extract each arm into its own named view function.
|
|
58
58
|
|
|
@@ -74,7 +74,9 @@ Use uppercase section headers (`// MODEL`, `// MESSAGE`, `// INIT`, `// UPDATE`,
|
|
|
74
74
|
|
|
75
75
|
### Testing
|
|
76
76
|
|
|
77
|
-
Test update functions with `foldkit/test`. Since update is pure, tests run without a runtime, DOM, or side effects. Use `
|
|
77
|
+
Test update functions with `foldkit/test`. Since update is pure, tests run without a runtime, DOM, or side effects. Use `story` for update-level tests (send Messages, assert on Model and Commands) and `scene` for feature-level testing through the view with accessible locators.
|
|
78
|
+
|
|
79
|
+
Import the steps as named imports from `foldkit/story` or `foldkit/scene`: `import { Command, given, message, model, story } from 'foldkit/story'`. A test file needs only one of the two modules. If a single file ever tests both, import the namespaces instead (`import { Scene, Story } from 'foldkit'`) so `Story.given` and `Scene.given` stay distinguishable.
|
|
78
80
|
|
|
79
81
|
Name each test file for its test style, beside the code under test: `story.test.ts` for the Story tests (which drive `update`) and `scene.test.ts` for the Scene tests (which drive the rendered view). The name describes how the test works, not a source file, so it stays correct whether `update` and `view` live in `main.ts` or in their own files. When one folder holds more than one test of a kind (sibling pages, component variants), prefix with the subject: `login.story.test.ts`. Scene tests always run from the root `update`/`view`, so a single root-level `scene.test.ts` is the right home even in a multi-page app. If the `repos/foldkit` subtree is available, study the `story.test.ts` and `scene.test.ts` files in `repos/foldkit/examples/`.
|
|
80
82
|
|