@mmstack/mesh 22.10.2 → 22.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.
package/README.md CHANGED
@@ -98,6 +98,22 @@ The default is last-writer-wins on a leaf, which drops one side of a true clash
98
98
  For a field where losing a write matters, set `preserve` on its path and resolve the `Conflicted`
99
99
  value in the UI.
100
100
 
101
+ A new container is a different case: by default an added record ships as one whole `set`, so two
102
+ clients that create the same missing container at once (say the first two suppressions under a
103
+ missing `lint`) race, and only one survives. Pass `emit: { added }` to choose per path. Use
104
+ `'leaves'` for a collection (an empty anchor plus its entries, so concurrent first writers merge)
105
+ and `'whole'` for an entry that must arrive as one atomic `set`:
106
+
107
+ ```ts
108
+ const leafy = new Set(['lint', 'lint.rules', 'lint.suppress']);
109
+ meshSync(doc, {
110
+ room,
111
+ writer,
112
+ transport,
113
+ emit: { added: (path) => (leafy.has(path.join('.')) ? 'leaves' : 'whole') },
114
+ });
115
+ ```
116
+
101
117
  ## Interop with other CRDTs
102
118
 
103
119
  A merge policy is a plain function, so one path can hold another CRDT and merge through that