From aeedc27b0053c5c0e3a93953504f2eb631ada218 Mon Sep 17 00:00:00 2001 From: Nulo Date: Sun, 5 Mar 2023 22:15:59 +0000 Subject: [PATCH] persistir fixes #5 --- package.json | 1 + pnpm-lock.yaml | 11 +++++++++++ src/lib/doc.ts | 2 ++ 3 files changed, 14 insertions(+) diff --git a/package.json b/package.json index 0a60b48..217c6ad 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "nanoid": "^4.0.1", "navaid": "^1.2.0", "regexparam": "^2.0.1", + "y-indexeddb": "^9.0.9", "y-prosemirror": "^1.2.0", "y-protocols": "^1.0.5", "y-webrtc": "^10.2.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ee751f9..0f85ad8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -24,6 +24,7 @@ specifiers: tslib: ^2.5.0 typescript: ^4.9.3 vite: ^4.1.0 + y-indexeddb: ^9.0.9 y-prosemirror: ^1.2.0 y-protocols: ^1.0.5 y-webrtc: ^10.2.4 @@ -34,6 +35,7 @@ dependencies: nanoid: 4.0.1 navaid: 1.2.0 regexparam: 2.0.1 + y-indexeddb: 9.0.9_yjs@13.5.48 y-prosemirror: 1.2.0_vhy2hiocjqydif5dwvxgfnpihi y-protocols: 1.0.5 y-webrtc: 10.2.4 @@ -1195,6 +1197,15 @@ packages: dev: false optional: true + /y-indexeddb/9.0.9_yjs@13.5.48: + resolution: {integrity: sha512-GcJbiJa2eD5hankj46Hea9z4hbDnDjvh1fT62E5SpZRsv8GcEemw34l1hwI2eknGcv5Ih9JfusT37JLx9q3LFg==} + peerDependencies: + yjs: ^13.0.0 + dependencies: + lib0: 0.2.63 + yjs: 13.5.48 + dev: false + /y-prosemirror/1.2.0_vhy2hiocjqydif5dwvxgfnpihi: resolution: {integrity: sha512-t3uxuX4HIkb1GNt8jV+dplRbNH2OmQD/BNeCCbjLD3Mq0o6JEXxHedv58ZIPFDE6ma24jljlL+u8pGvN6B37XQ==} peerDependencies: diff --git a/src/lib/doc.ts b/src/lib/doc.ts index 5cf3612..3d5b844 100644 --- a/src/lib/doc.ts +++ b/src/lib/doc.ts @@ -1,5 +1,6 @@ import * as Y from "yjs"; import { WebrtcProvider } from "y-webrtc"; +import { IndexeddbPersistence } from "y-indexeddb"; import { nanoid } from "nanoid"; export type WorldIdentifier = { @@ -34,6 +35,7 @@ export function getWorldY(world: WorldIdentifier): WorldY { "wss://y-webrtc-signaling-us.herokuapp.com", ], }); + const idbProvider = new IndexeddbPersistence(world.room, ydoc); const worldY = { ydoc, webrtcProvider: provider }; worldYCache[world.room] = worldY; return worldY;