refactor: place y-websocket in data-service

This commit is contained in:
alt0
2022-12-22 22:09:12 +08:00
parent 825851c7d6
commit 1cf6cc03c0
7 changed files with 11 additions and 29 deletions
+1 -3
View File
@@ -28,7 +28,6 @@
"css-spring": "^4.1.0",
"dayjs": "^1.11.7",
"i18next": "^21.9.1",
"lib0": "^0.2.58",
"lit": "^2.3.1",
"next": "13.0.1",
"prettier": "^2.7.1",
@@ -36,8 +35,7 @@
"quill-cursors": "^4.0.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-i18next": "^11.18.4",
"y-protocols": "^1.0.5"
"react-i18next": "^11.18.4"
},
"devDependencies": {
"@types/node": "18.7.18",
@@ -13,27 +13,7 @@ import type {
LoadWorkspaceHandler,
CreateEditorHandler,
} from './context';
import { token } from '@pathfinder/data-services';
import { WebsocketProvider } from './y-websocket';
const getEditorParams = (workspaceId: string) => {
const providers = [];
const params = new URLSearchParams(location.search);
// const room = params.get('room') ?? 'AFFINE-pathfinder';
// if (params.get('syncMode') === 'websocket') {
// const WebsocketDocProvider = createWebsocketDocProvider(
// `ws://${window.location.host}/collaboration/`
// );
// providers.push(WebsocketDocProvider);
// }
providers.push(IndexedDBDocProvider);
return {
room: workspaceId,
providers,
};
};
import { token, WebsocketProvider } from '@pathfinder/data-services';
interface Props {
setLoadWorkspaceHandler: (handler: LoadWorkspaceHandler) => void;
+3 -1
View File
@@ -26,6 +26,8 @@
"encoding": "^0.1.13",
"firebase": "^9.13.0",
"ky": "^0.33.0",
"swr": "^2.0.0"
"swr": "^2.0.0",
"lib0": "^0.2.58",
"y-protocols": "^1.0.5"
}
}
+1
View File
@@ -1,3 +1,4 @@
export { signInWithGoogle, onAuthStateChanged } from './auth';
export * from './request';
export * from './sdks';
export * from './websocket';
@@ -0,0 +1 @@
export { WebsocketProvider } from './y-websocket';