foldkit-mirror 0.10.0 → 0.12.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.
Files changed (2) hide show
  1. package/README.md +20 -74
  2. package/package.json +5 -5
package/README.md CHANGED
@@ -9,19 +9,8 @@ sidebar can be remembered. In every case the Model remains authoritative and
9
9
 
10
10
  The mental model is:
11
11
 
12
- ```text
13
- Model slice
14
- |
15
- | encode when it changes
16
- v
17
- URL / KeyValueStore / cookie
18
-
19
- URL / KeyValueStore / cookie
20
- |
21
- | decode on navigation / cold load
22
- v
23
- Model slice
24
- ```
12
+ A Model slice is encoded out to the URL, a `KeyValueStore` or a cookie whenever
13
+ it changes, and decoded back in on navigation or a cold load.
25
14
 
26
15
  A mirror is therefore a **secondary representation**, not a second store of
27
16
  truth.
@@ -33,20 +22,12 @@ with no durable log or ordering.
33
22
 
34
23
  That is the boundary between the three nearby packages:
35
24
 
36
- ```text
37
- Mirror
38
- Model owns the value
39
- URL / store represents it
40
- losing the representation is acceptable
41
-
42
- Sync
43
- client-authored state must survive offline
44
- durable operations replay and converge
45
-
46
- Remote
47
- server owns the fact
48
- client Model caches a disposable copy
49
- ```
25
+ - **Mirror:** the Model owns the value, the URL or a store represents it, and
26
+ losing the representation is acceptable.
27
+ - **Sync:** client-authored state must survive offline, and durable operations
28
+ replay and converge.
29
+ - **Remote:** the server owns the fact, and the client Model caches a disposable
30
+ copy.
50
31
 
51
32
  ## Which state belongs here?
52
33
 
@@ -68,62 +49,27 @@ back into the application at different times.
68
49
 
69
50
  ### URL mirror
70
51
 
71
- ```text
72
- Model changes filter
73
- |
74
- v
75
- Filters.subscriptions
76
- |
77
- v
78
- history.pushState / replaceState
79
- |
80
- user navigates
81
- v
82
- UrlChanged
83
- |
84
- v
85
- Filters.urlChanged(model, url)
86
- |
87
- v
88
- Model
89
- ```
52
+ 1. The Model changes the filter.
53
+ 2. `Filters.subscriptions` writes it out with `history.pushState` or
54
+ `replaceState`.
55
+ 3. When the user navigates, the runtime sends `UrlChanged`.
56
+ 4. `Filters.urlChanged(model, url)` reduces the URL back into the Model.
90
57
 
91
58
  The URL participates in navigation, so the runtime hands navigation back to the
92
59
  application and the mirror reduces the URL into its slice.
93
60
 
94
61
  ### Key-value mirror
95
62
 
96
- ```text
97
- cold load
98
- |
99
- v
100
- Prefs.restore Command
101
- |
102
- v
103
- MirrorRestored Message
104
- |
105
- v
106
- Prefs.reduce(model, message)
107
- |
108
- v
109
- Model
110
-
111
- later Model changes
112
- |
113
- v
114
- Prefs.subscriptions
115
- |
116
- v
117
- KeyValueStore
118
- ```
63
+ On a cold load, the `Prefs.restore` Command reads the store and sends a
64
+ `MirrorRestored` Message, and `Prefs.reduce(model, message)` reduces it into the
65
+ Model. After that, each Model change goes out through `Prefs.subscriptions` to
66
+ the `KeyValueStore`.
119
67
 
120
68
  That is why the full integration has three seams:
121
69
 
122
- ```text
123
- reduce read an external representation back into Model
124
- restore ask a store for its cold-load value
125
- subscriptions write Model changes outward
126
- ```
70
+ - `reduce` reads an external representation back into the Model.
71
+ - `restore` asks a store for its cold-load value.
72
+ - `subscriptions` writes Model changes outward.
127
73
 
128
74
  A URL mirror does not need a restore Command because the initial URL is already
129
75
  available to application startup. A store mirror does — unless the store's keys
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foldkit-mirror",
3
- "version": "0.10.0",
3
+ "version": "0.12.0",
4
4
  "description": "A Foldkit Model slice kept in the URL or a key-value store: written when the slice changes, read back on navigation or cold load.",
5
5
  "keywords": [
6
6
  "foldkit",
@@ -39,20 +39,20 @@
39
39
  "LICENSE"
40
40
  ],
41
41
  "dependencies": {
42
- "foldkit-surface": "0.14.0"
42
+ "foldkit-surface": "0.16.0"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "effect": "^4.1.0",
46
46
  "foldkit": "^0.170.0"
47
47
  },
48
48
  "devDependencies": {
49
- "@effect/platform-browser": "^4.1.1",
50
- "effect": "^4.1.1",
49
+ "@effect/platform-browser": "4.1.4",
50
+ "effect": "4.1.4",
51
51
  "foldkit": "0.170.0",
52
52
  "jsdom": "30.1.3",
53
53
  "tsdown": "^0.23.1",
54
54
  "typescript": "7.0.2",
55
- "foldkit-bundle": "0.12.0"
55
+ "foldkit-bundle": "0.14.0"
56
56
  },
57
57
  "scripts": {
58
58
  "build": "node ../../scripts/declarations.mjs . && tsdown && node ../../scripts/declared-any.mjs .",