@docx-editor.dev/core/collaboration/replication
@docx-editor.dev/core/collaboration/replication — the seam a replication implementation binds to, not the surface a host consumes.
Everything here exists for the layer BETWEEN a CRDT and the canonical tree: the document port an adapter writes through, the primitive journal it reads, and the descriptors that journal is made of. A host that renders presence and reads a status needs none of it, which is why it lives behind its own subpath — autocomplete on @docx-editor.dev/core/collaboration should not offer putXmlPart and spliceChildren to somebody wiring up an avatar stack.
Reach for this when you are writing a provider. @docx-editor.dev/pro is one.
Functions (1)
createCollaborationDocumentPortfunctionSource ↗
Create the narrow collaboration view over one canonical package store.
declare function createCollaborationDocumentPort(store: TreePackageStore, options: CreateCollaborationDocumentPortOptions): CollaborationDocumentPort;Interfaces (11)
CanonicalAttributeNameinterfaceSource ↗
Attribute name as the journal addresses it. Prefix is authored fidelity, not identity.
interface CanonicalAttributeName| Member | Type | Summary |
|---|---|---|
| localName | string | |
| namespaceUri | string | |
| prefix? | string |
CanonicalBinaryDescriptorinterfaceSource ↗
Content-addressed binary part reference. Bytes stay out of the journal.
interface CanonicalBinaryDescriptor| Member | Type | Summary |
|---|---|---|
| digest | string | |
| mediaType | string | |
| size | number | |
| storageKey | string |
CanonicalElementNodeDescriptorinterfaceSource ↗
OOXML element shell. Attributes, bindings, and children arrive as later effects.
interface CanonicalElementNodeDescriptor| Member | Type | Summary |
|---|---|---|
| kind | OoxmlElement['kind'] | |
| logicalId | string | |
| qname | CanonicalAttributeName |
CanonicalPrimitiveJournalinterfaceSource ↗
One immutable journal for one TreePackageStore transaction.
Empty only when a committed write used a path the journal does not yet intercept.
interface CanonicalPrimitiveJournal| Member | Type | Summary |
|---|---|---|
| effects | readonly CanonicalPrimitiveEffect[] |
CanonicalRelationshipRecordinterfaceSource ↗
One relationship as the journal records it.
interface CanonicalRelationshipRecord| Member | Type | Summary |
|---|---|---|
| id | string | |
| order | number | |
| ownerPart | string | |
| rawTarget | string | |
| targetMode | 'Internal' | 'External' | |
| type | string |
CanonicalTextNodeDescriptorinterfaceSource ↗
Text node shell. Value arrives later through spliceText.
interface CanonicalTextNodeDescriptor| Member | Type | Summary |
|---|---|---|
| kind | 'textValue' | |
| logicalId | string |
CollaborationDocumentPortinterfaceSource ↗
Narrow canonical document capability handed to a collaboration implementation.
It deliberately exposes no mutable package or tree store. Every write returns through the same validated transaction path as browser and automation edits.
interface CollaborationDocumentPort| Member | Type | Summary |
|---|---|---|
| applyParagraphText | | |
| applyParagraphTexts | | |
| applyRemotePackage | | Publish one remotely materialized canonical package as one revision. |
| binaryPart | | Bytes of one binary package part, or null when the part is absent. |
| documentId | string | |
| flushPendingJournals | | Freeze and deliver queued journals in production order. |
| hasPendingJournals | | True when a committed journal has not yet been frozen or delivered to observers. |
| observePrimitiveJournal | | Observe one settled primitive journal per committed canonical transaction. |
| paragraphByNodeId | | |
| paragraphByStableId | | Resolve a stable `w14:paraId` in any story this replica holds. |
| paragraphs | | |
| revision | | |
| save | | |
| subscribe | |
CollaborationMutationinterfaceSource ↗
Attribution for one collaboration-derived canonical publication.
interface CollaborationMutation| Member | Type | Summary |
|---|---|---|
| actorId | string | |
| operationId | string | |
| origin | string |
CollaborationParagraphinterfaceSource ↗
One existing body paragraph exposed to the replication adapter.
interface CollaborationParagraph| Member | Type | Summary |
|---|---|---|
| nodeId | string | Replica-local canonical node identity. Never sent as wire identity. |
| paragraphId | string | Uppercase `w14:paraId`, stable across save and reopen. |
| text | string | Current canonical UTF-16 text. |
CollaborationParagraphTextUpdateinterfaceSource ↗
One paragraph text value in an atomic collaboration publication.
interface CollaborationParagraphTextUpdate| Member | Type | Summary |
|---|---|---|
| paragraphId | string | |
| text | string |
CreateCollaborationDocumentPortOptionsinterfaceSource ↗
Options for a canonical collaboration document port.
interface CreateCollaborationDocumentPortOptions| Member | Type | Summary |
|---|---|---|
| documentId | string |
Type aliases (3)
CanonicalNodeDescriptortypeSource ↗
Immutable node record required to create a registry entry.
type CanonicalNodeDescriptor = CanonicalTextNodeDescriptor | CanonicalElementNodeDescriptor;CanonicalPrimitiveEffecttypeSource ↗
One compositional tree or package effect captured from a canonical write.
type CanonicalPrimitiveEffect = {
readonly kind: 'putNode';
readonly descriptor: CanonicalNodeDescriptor;
} | {
readonly kind: 'spliceText';
readonly logicalId: string;
readonly utf16Start: number;
readonly deleteCount: number;
readonly insert: string;
} | {
readonly kind: 'setAttribute';
readonly logicalId: string;
readonly qname: CanonicalAttributeName;
readonly value: string | null;
} | {
readonly kind: 'setNamespaceBinding';
readonly logicalId: string;
readonly prefix: string;
readonly uri: string | null;
} | {
readonly kind: 'spliceChildren';
readonly parentLogicalId: string;
readonly start: number;
readonly deleteCount: number;
readonly childLogicalIds: readonly string[];
} | {
readonly kind: 'moveNode';
readonly logicalId: string;
readonly destinationParentLogicalId: string;
readonly destinationIndex: number;
} | {
readonly kind: 'putXmlPart';
readonly name: string;
readonly rootLogicalId: string;
} | {
readonly kind: 'deleteXmlPart';
readonly name: string;
} | {
readonly kind: 'putRelationship';
readonly owner: string;
readonly record: CanonicalRelationshipRecord;
} | {
readonly kind: 'deleteRelationship';
readonly owner: string;
readonly relationshipId: string;
} | {
readonly kind: 'putContentTypeOverride';
readonly partName: string;
readonly mediaType: string;
} | {
readonly kind: 'deleteContentTypeOverride';
readonly partName: string;
} | {
readonly kind: 'putBinary';
readonly descriptor: CanonicalBinaryDescriptor;
} | {
readonly kind: 'deleteBinary';
readonly storageKey: string;
};CollaborationApplyResulttypeSource ↗
Result of replacing one supported paragraph's canonical text.
type CollaborationApplyResult = {
readonly ok: true;
readonly changed: boolean;
} | {
readonly ok: false;
readonly reason: string;
};