|
@@ -8,7 +8,7 @@ import { Server } from 'socket.io';
|
|
|
import type { Plugin } from 'vite';
|
|
import type { Plugin } from 'vite';
|
|
|
import { defineConfig } from 'vite';
|
|
import { defineConfig } from 'vite';
|
|
|
import dts from 'vite-plugin-dts';
|
|
import dts from 'vite-plugin-dts';
|
|
|
-
|
|
|
|
|
|
|
+import { YSocketIO } from 'y-socket.io/dist/server';
|
|
|
|
|
|
|
|
const excludeFiles = [
|
|
const excludeFiles = [
|
|
|
'**/components/playground/*',
|
|
'**/components/playground/*',
|
|
@@ -22,8 +22,8 @@ const devSocketIOPlugin = (): Plugin => ({
|
|
|
configureServer(server) {
|
|
configureServer(server) {
|
|
|
if (!server.httpServer) return;
|
|
if (!server.httpServer) return;
|
|
|
|
|
|
|
|
|
|
+ // setup socket.io
|
|
|
const io = new Server(server.httpServer);
|
|
const io = new Server(server.httpServer);
|
|
|
-
|
|
|
|
|
io.on('connection', (socket) => {
|
|
io.on('connection', (socket) => {
|
|
|
// eslint-disable-next-line no-console
|
|
// eslint-disable-next-line no-console
|
|
|
console.log('Client connected');
|
|
console.log('Client connected');
|
|
@@ -33,6 +33,10 @@ const devSocketIOPlugin = (): Plugin => ({
|
|
|
console.log('Client disconnected');
|
|
console.log('Client disconnected');
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
|
|
+
|
|
|
|
|
+ // setup y-socket.io
|
|
|
|
|
+ const ysocketio = new YSocketIO(io);
|
|
|
|
|
+ ysocketio.initialize();
|
|
|
},
|
|
},
|
|
|
});
|
|
});
|
|
|
|
|
|