Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use PartySocket for y-partykit #37

Open
threepointone opened this issue Jan 29, 2023 · 0 comments
Open

use PartySocket for y-partykit #37

threepointone opened this issue Jan 29, 2023 · 0 comments

Comments

@threepointone
Copy link
Contributor

y-partykit provider, via y-websocket, has its own logic for resilience etc. We could consolidate it with PartySocket which does much of the same (and better).

Maybe we won't do this because the original need was for y-partykit's onCommand, which might go away with #36

diff --git a/packages/y-partykit/src/provider.ts b/packages/y-partykit/src/provider.ts
index 334929c..de0cb6f 100644
--- a/packages/y-partykit/src/provider.ts
+++ b/packages/y-partykit/src/provider.ts
@@ -1,5 +1,8 @@
 import { WebsocketProvider } from "y-websocket";
-import type * as Y from "yjs";
+import PartySocket from "partysocket";
+import * as Y from "yjs";
+
+console.log(Y);
 
 export default class YPartyKitProvider extends WebsocketProvider {
   constructor(
@@ -20,6 +23,11 @@ export default class YPartyKitProvider extends WebsocketProvider {
     } else {
       options.params._pk = crypto.randomUUID();
     }
-    super(serverUrl, room, doc, options);
+    super(serverUrl, room, doc, {
+      // TODO: fix this
+      // @ts-expect-error We know that this is a valid polyfill
+      WebSocketPolyfill: PartySocket,
+      ...options,
+    });
   }
 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant