Documentation / @super-line/core / ResourceReplica
Interface: ResourceReplica
Defined in: packages/core/src/store.ts:53
A reactive handle over one opened CRDT document (mirrors super-store's StoreValue surface). Mutations are void: every local change leaves through ResourceReplica.onLocalChange, whoever produced it. applyRemote merges an inbound Change (own-origin merges are idempotent); seed hydrates the catch-up snapshot. Implemented by the client DocHandle replica.
Methods
applyDelete()
applyDelete():
void
Defined in: packages/core/src/store.ts:84
Mark this document deleted (server fan-out of a delete) + notify subscribers, so consumers re-read.
Returns
void
applyRemote()
applyRemote(
change):void
Defined in: packages/core/src/store.ts:75
Parameters
change
Returns
void
delete()
delete(
path):void
Defined in: packages/core/src/store.ts:59
Remove the value at path (a surgical key removal that merges, unlike a full-doc set).
Parameters
path
(string | number)[]
Returns
void
getSnapshot()
getSnapshot():
unknown
Defined in: packages/core/src/store.ts:54
Returns
unknown
native()?
optionalnative():unknown
Defined in: packages/core/src/store.ts:74
The engine's own document handle, for content the contract cannot describe — a native root, i.e. a CRDT type bound beside the described root in the same document. Typed unknown on purpose: it keeps every CRDT vocabulary out of @super-line/client, so the engine package that already owns that dependency is the one that hands back a typed handle (yDocOf for the Yjs engine). Undefined for engines with nothing to expose.
Returns
unknown
onLocalChange()
onLocalChange(
cb): () =>void
Defined in: packages/core/src/store.ts:67
Observe local changes so the client can write them through. Push, not pull, because set is no longer the only writer: a ResourceReplica.native handle is mutated directly by whatever binds to it (a rich-text editor, say), producing changes no set call will ever return. It must therefore survive ResourceReplica.reset, which swaps the underlying document — the implementation owns the subscriber set rather than delegating to a document that a resync will discard.
Parameters
cb
(change) => void
Returns
() => void
reset()?
optionalreset(snapshot):void
Defined in: packages/core/src/store.ts:82
Hard-resync to authoritative full state, discarding any local optimistic edits — unlike seed, which merges. Used by CRDT document collections after a server rejects a write (validate-before-commit, ADR-0007): the rejected edit was applied optimistically and must be thrown away.
Parameters
snapshot
unknown
Returns
void
seed()
seed(
snapshot):void
Defined in: packages/core/src/store.ts:76
Parameters
snapshot
unknown
Returns
void
set()
set(
data):void
Defined in: packages/core/src/store.ts:56
Parameters
data
unknown
Returns
void
subscribe()
subscribe(
cb): () =>void
Defined in: packages/core/src/store.ts:55
Parameters
cb
() => void
Returns
() => void
update()
update(
partial):void
Defined in: packages/core/src/store.ts:57
Parameters
partial
unknown
Returns
void