Skip to main content

@barocss/collaboration-yjs

Version in this checkout: 0.1.3. npm · Source

Yjs-backed adapter for Barocss document operations and presence.

Purpose​

Connect an existing Y.Doc and optional provider awareness to a DataStore through YjsAdapter.

Install​

npm install @barocss/collaboration-yjs @barocss/datastore yjs

The published package provides ES modules and TypeScript declarations. Use a bundler that supports package exports.

Public entry points​

ImportRole
@barocss/collaboration-yjsPublic JavaScript and TypeScript API

Import only these public paths. Source paths such as @barocss/collaboration-yjs/src/... are not part of the published API.

Usage​

import type { DataStore } from '@barocss/datastore';
import { YjsAdapter, type YjsAdapterOptions } from '@barocss/collaboration-yjs';

export async function connectSharedDocument(store: DataStore, options: YjsAdapterOptions) {
// options.ydoc comes from the host's Yjs document/provider setup.
const adapter = new YjsAdapter(options);
await adapter.connect(store);
return async () => { await adapter.disconnect(); };
}

Peer dependencies​

  • yjs: ^13.6.0.

Integration notes​

Supply the Yjs document, provider, room identity, and authentication in the host. connect receives the DataStore. Disconnect the adapter before destroying the provider and Y.Doc. This README does not claim a tested hosted provider configuration.

Documentation​

License​

MIT. The published archive includes the license in dist/LICENSE.