@wordpress/sync

Sync data between multiple peers and persist in a local database.

Installation

Install the module

npm install @wordpress/sync --save

API

CRDT_DOC_META_PERSISTENCE_KEY

CRDT documents can hold meta information in a map. This map exists only in memory and is not synced or persisted. This key can be used to indicate that a (temporary) document has been loaded from persistence.

CRDT_RECORD_MAP_KEY

Root-level key for the CRDT document that holds the entity record data.

createSyncManager

The sync manager orchestrates the lifecycle of syncing entity records. It creates Yjs documents, connects to providers, creates awareness instances, and coordinates with the core-data store.

LOCAL_EDITOR_ORIGIN

Origin string for CRDT document changes originating from the local editor.

LOCAL_SYNC_MANAGER_ORIGIN

Origin string for CRDT document changes originating from the sync manager.

WORDPRESS_META_KEY_FOR_CRDT_DOC_PERSISTENCE

WordPress meta key used to persist the CRDT document for an entity.

Y

Exported copy of Yjs so that consumers of this package don’t need to install it.

Contributing to this package

This is an individual package that’s part of the Gutenberg project. The project is organized as a monorepo. It’s made up of multiple self-contained software packages, each with a specific purpose. The packages in this monorepo are published to npm and used by WordPress as well as other software projects.

To find out more about contributing to this package or Gutenberg as a whole, please read the project’s main contributor guide.