You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(core): reject root-level primitives in initialState (#83)
* fix(core): reject root-level primitives in initialState
LoroDoc only stores container types (Map/List/MovableList/Text/Tree)
at the document root, but Mirror previously accepted root-level
primitives (e.g. `{ version: 0 }`) in initialState and silently kept
them in memory while never writing them to the doc. This caused
`mirror.getState()` to drift from `doc.toJSON()`.
Now reject primitives both at compile time (via a `RootInitialValue`
constraint on `initialState`) and at runtime (clear error pointing
users to wrap the value in a root LoroMap). `null`/`undefined` are
still accepted as "absent".
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(jotai,react): apply root primitive constraint to wrapper configs
The jotai LoroMirrorAtomConfig and react UseLoroStoreOptions
redeclare initialState with a looser type than MirrorOptions, which
broke the build after the core constraint was tightened. Mirror the
RootInitialValue intersection in both wrappers and re-export the
type from loro-mirror so consumers can reuse it.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* chore: ignore .claude/ local agent state
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Zixuan Chen <me@zxch3n.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`initialState["${key}"] is a primitive (${detail}), but LoroDoc only supports container types (Map, List, MovableList, Text, Tree) at the root. Wrap it under a root LoroMap (e.g. a "meta" map).`,
0 commit comments