foldkit-bundle-surface 0.1.1 → 0.1.2

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.
Files changed (2) hide show
  1. package/README.md +18 -9
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -24,27 +24,34 @@ pnpm add foldkit-bundle-surface foldkit-bundle foldkit-surface effect foldkit
24
24
  ## Sixty seconds
25
25
 
26
26
  ```ts
27
- // Search and Row are bundles, Todo a Schema, and TodoSync the application's Sync contract.
28
27
  import { Schema } from 'effect'
29
28
  import { defineMessageUnion } from 'foldkit/message'
30
29
  import { Bundle } from 'foldkit-bundle'
31
30
  import { BundleSurface } from 'foldkit-bundle-surface'
32
31
  import { Module, Surface } from 'foldkit-surface'
33
32
 
33
+ const Search = Bundle.make('Search', {
34
+ Model: Schema.Struct({ query: Schema.String }),
35
+ Message: defineMessageUnion({ Typed: { query: Schema.String } }),
36
+ init: () => ({ model: { query: '' } }),
37
+ update: (_model, message) => ({ model: { query: message.query } }),
38
+ })
34
39
  const Searchbox = Bundle.declare(Search, 'search')
35
- const Rows = Bundle.declareEach(Row, 'rows')
36
-
37
- const Model = Schema.Struct({ ...Searchbox.fields, ...Rows.fields, todos: Schema.Array(Todo) })
38
- const Message = defineMessageUnion({ ...Searchbox.cases, ...Rows.cases })
40
+ const Model = Schema.Struct({ ...Searchbox.fields })
41
+ const Message = defineMessageUnion({ ...Searchbox.cases })
39
42
  const App = Surface.application({ Model, Message })
40
-
41
43
  const Page = BundleSurface.parent(App)
42
- const placements = Page.assemble(Page.at(Searchbox), Page.each(Rows))
44
+ const placements = Page.assemble(Page.at(Searchbox))
43
45
 
44
- const AppModule = Page.module(placements, [TodoSync])
46
+ const AppModule = Page.module(placements, [])
45
47
  Module.validate(AppModule) // []
46
48
  ```
47
49
 
50
+ The Module now records one owner for `search`. Nothing has mounted or run:
51
+ validation inspects declarations. Pass other contracts as the second argument
52
+ to `Page.module`, then check the findings before starting the application.
53
+ Rendering a Surface over `search` only observes that owner.
54
+
48
55
  - **`BundleSurface.parent(app)`** is `Bundle.parent` built from the application's
49
56
  own Model and Message, with `module` bound to that application.
50
57
  - **`Page.module(assembly, items)`** makes one `bundle` contract per placement,
@@ -77,7 +84,9 @@ A placement's state is part of the parent Model, so its fields are already in
77
84
  the application's ref tree. Observing one needs no bundle API:
78
85
  `App.fields.search.query`, `App.fields.search.select(projection)`.
79
86
 
80
- To mirror two placements of one bundle, give each mirror its own keys:
87
+ For an application with `search` and `filter` placements, the following
88
+ integration fragment gives each mirror its own keys. Import `Mirror` from
89
+ `foldkit-mirror`; the first example above defines only `search`:
81
90
 
82
91
  ```ts
83
92
  const SearchUrl = Mirror.url(App, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foldkit-bundle-surface",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "foldkit-bundle placements as foldkit-surface Module contracts: each placement owns its Model path, validated with every other owner.",
5
5
  "keywords": [
6
6
  "foldkit",
@@ -36,8 +36,8 @@
36
36
  "LICENSE"
37
37
  ],
38
38
  "dependencies": {
39
- "foldkit-surface": "0.3.0",
40
- "foldkit-bundle": "0.2.0"
39
+ "foldkit-bundle": "0.2.0",
40
+ "foldkit-surface": "0.4.0"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "effect": "^4.0.0-rc.112",
@@ -49,7 +49,7 @@
49
49
  "jsdom": "26.1.0",
50
50
  "tsdown": "^0.23.0",
51
51
  "typescript": "5.9.3",
52
- "foldkit-mirror": "0.2.1"
52
+ "foldkit-mirror": "0.2.2"
53
53
  },
54
54
  "scripts": {
55
55
  "build": "tsdown",