feat: seperate createDoc and createStore (#11182)

This commit is contained in:
Saul-Mirone
2025-03-26 11:03:47 +00:00
parent d6093e1d66
commit 0a8d8e0a6b
70 changed files with 337 additions and 312 deletions
@@ -1127,8 +1127,9 @@ export class Store {
schema: this.schema,
blobCRUD: this.workspace.blobSync,
docCRUD: {
create: (id: string) => this.workspace.createDoc({ id }),
get: (id: string) => this.workspace.getDoc(id),
create: (id: string) => this.workspace.createDoc(id).getStore({ id }),
get: (id: string) =>
this.workspace.getDoc(id)?.getStore({ id }) ?? null,
delete: (id: string) => this.workspace.removeDoc(id),
},
middlewares,
@@ -4,8 +4,7 @@ import type { Awareness } from 'y-protocols/awareness.js';
import type * as Y from 'yjs';
import type { IdGenerator } from '../utils/id-generator.js';
import type { CreateBlocksOptions, Doc, GetBlocksOptions } from './doc.js';
import type { Store } from './store/store.js';
import type { Doc } from './doc.js';
import type { WorkspaceMeta } from './workspace-meta.js';
export interface Workspace {
@@ -25,8 +24,8 @@ export interface Workspace {
docRemoved: Subject<string>;
};
createDoc(options?: CreateBlocksOptions): Store;
getDoc(docId: string, options?: GetBlocksOptions): Store | null;
createDoc(docId?: string): Doc;
getDoc(docId: string): Doc | null;
removeDoc(docId: string): void;
dispose(): void;