From fc11c7045548a2bac3317751d7290f4fae629c6b Mon Sep 17 00:00:00 2001 From: Youngteac Hong Date: Wed, 23 Oct 2024 17:10:17 +0900 Subject: [PATCH] Bump up Yorkie to v0.5.3 (#293) * Bump up Yorkie to v0.5.2 * Bump up Yorkie to v0.5.3 --- package-lock.json | 115 +++++++++--------- package.json | 2 +- src/components/Editor/index.tsx | 18 +-- .../Editor/mime/text/md/CodeEditor/index.tsx | 4 +- src/features/peerSlices.ts | 1 + 5 files changed, 66 insertions(+), 74 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4c74471..b967227 100644 --- a/package-lock.json +++ b/package-lock.json @@ -66,7 +66,7 @@ "remark-toc": "^8.0.1", "tss-react": "^4.8.2", "unique-names-generator": "^4.7.1", - "yorkie-js-sdk": "^0.4.13" + "yorkie-js-sdk": "^0.5.3" }, "devDependencies": { "@esbuild-plugins/node-globals-polyfill": "^0.2.3", @@ -1901,6 +1901,28 @@ "resolved": "https://registry.npmjs.org/@braintree/sanitize-url/-/sanitize-url-6.0.2.tgz", "integrity": "sha512-Tbsj02wXCbqGmzdnXNk0SOF19ChhRU70BsroIi4Pm6Ehp56in6vch94mfbdQ17DozxkL3BAVjbZ4Qc1a0HFRAg==" }, + "node_modules/@bufbuild/protobuf": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@bufbuild/protobuf/-/protobuf-1.10.0.tgz", + "integrity": "sha512-QDdVFLoN93Zjg36NoQPZfsVH9tZew7wKDKyV5qRdj8ntT4wQCOradQjRaTdwMhWUYsgKsvCINKKm87FdEk96Ag==" + }, + "node_modules/@connectrpc/connect": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/@connectrpc/connect/-/connect-1.6.1.tgz", + "integrity": "sha512-KchMDNtU4CDTdkyf0qG7ugJ6qHTOR/aI7XebYn3OTCNagaDYWiZUVKgRgwH79yeMkpNgvEUaXSK7wKjaBK9b/Q==", + "peerDependencies": { + "@bufbuild/protobuf": "^1.10.0" + } + }, + "node_modules/@connectrpc/connect-web": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/@connectrpc/connect-web/-/connect-web-1.6.1.tgz", + "integrity": "sha512-GVfxQOmt3TtgTaKeXLS/EA2IHa3nHxwe2BCHT7X0Q/0hohM+nP5DDnIItGEjGrGdt3LTTqWqE4s70N4h+qIMlQ==", + "peerDependencies": { + "@bufbuild/protobuf": "^1.10.0", + "@connectrpc/connect": "1.6.1" + } + }, "node_modules/@date-io/core": { "version": "2.16.0", "resolved": "https://registry.npmjs.org/@date-io/core/-/core-2.16.0.tgz", @@ -5018,11 +5040,6 @@ "resolved": "https://registry.npmjs.org/@types/extend/-/extend-3.0.1.tgz", "integrity": "sha512-R1g/VyKFFI2HLC1QGAeTtCBWCo6n75l41OnsVYNbmKG+kempOESaodf6BeJyUM3Q0rKa/NQcTHbB2+66lNnxLw==" }, - "node_modules/@types/google-protobuf": { - "version": "3.15.12", - "resolved": "https://registry.npmjs.org/@types/google-protobuf/-/google-protobuf-3.15.12.tgz", - "integrity": "sha512-40um9QqwHjRS92qnOaDpL7RmDK15NuZYo9HihiJRbYkMQZlWnuH8AdvbMy8/o6lgLmKbDUKa+OALCltHdbOTpQ==" - }, "node_modules/@types/hast": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/@types/hast/-/hast-2.3.4.tgz", @@ -5103,11 +5120,6 @@ "@types/lodash": "*" } }, - "node_modules/@types/long": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.2.tgz", - "integrity": "sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA==" - }, "node_modules/@types/marked": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/@types/marked/-/marked-4.0.8.tgz", @@ -10005,11 +10017,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/google-protobuf": { - "version": "3.21.2", - "resolved": "https://registry.npmjs.org/google-protobuf/-/google-protobuf-3.21.2.tgz", - "integrity": "sha512-3MSOYFO5U9mPGikIYCzK0SaThypfGgS6bHqrUGXG3DPHCrb+txNqeEcns1W0lkGfk0rCyNXm7xB9rMxnCiZOoA==" - }, "node_modules/gopd": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", @@ -10041,11 +10048,6 @@ "lodash": "^4.17.15" } }, - "node_modules/grpc-web": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/grpc-web/-/grpc-web-1.5.0.tgz", - "integrity": "sha512-y1tS3BBIoiVSzKTDF3Hm7E8hV2n7YY7pO0Uo7depfWJqKzWE+SKr0jvHNIJsJJYILQlpYShpi/DRJJMbosgDMQ==" - }, "node_modules/has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", @@ -19744,15 +19746,18 @@ } }, "node_modules/yorkie-js-sdk": { - "version": "0.4.13", - "resolved": "https://registry.npmjs.org/yorkie-js-sdk/-/yorkie-js-sdk-0.4.13.tgz", - "integrity": "sha512-6Im/SRxJoGcUOf5nHIQDDZnKbLBDUgD66xZxcrAXvZS4KblQnRU54/MdloIF9BzNJlJGwWSk9KjgYwLY73nntg==", - "dependencies": { - "@types/google-protobuf": "^3.15.5", - "@types/long": "^4.0.1", - "google-protobuf": "^3.19.4", - "grpc-web": "^1.3.1", + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/yorkie-js-sdk/-/yorkie-js-sdk-0.5.3.tgz", + "integrity": "sha512-psMg/cICvgFeH2FxZ0wKxJpciaKlNq2DhU4eJpdxhn0mv3kuXdDtKev1qJkTk/KXPVW91QMpyLlR9un4akLlGw==", + "dependencies": { + "@bufbuild/protobuf": "^1.6.0", + "@connectrpc/connect": "^1.4.0", + "@connectrpc/connect-web": "^1.4.0", "long": "^5.2.0" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=7.1.0" } }, "node_modules/zustand": { @@ -20998,6 +21003,23 @@ "resolved": "https://registry.npmjs.org/@braintree/sanitize-url/-/sanitize-url-6.0.2.tgz", "integrity": "sha512-Tbsj02wXCbqGmzdnXNk0SOF19ChhRU70BsroIi4Pm6Ehp56in6vch94mfbdQ17DozxkL3BAVjbZ4Qc1a0HFRAg==" }, + "@bufbuild/protobuf": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@bufbuild/protobuf/-/protobuf-1.10.0.tgz", + "integrity": "sha512-QDdVFLoN93Zjg36NoQPZfsVH9tZew7wKDKyV5qRdj8ntT4wQCOradQjRaTdwMhWUYsgKsvCINKKm87FdEk96Ag==" + }, + "@connectrpc/connect": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/@connectrpc/connect/-/connect-1.6.1.tgz", + "integrity": "sha512-KchMDNtU4CDTdkyf0qG7ugJ6qHTOR/aI7XebYn3OTCNagaDYWiZUVKgRgwH79yeMkpNgvEUaXSK7wKjaBK9b/Q==", + "requires": {} + }, + "@connectrpc/connect-web": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/@connectrpc/connect-web/-/connect-web-1.6.1.tgz", + "integrity": "sha512-GVfxQOmt3TtgTaKeXLS/EA2IHa3nHxwe2BCHT7X0Q/0hohM+nP5DDnIItGEjGrGdt3LTTqWqE4s70N4h+qIMlQ==", + "requires": {} + }, "@date-io/core": { "version": "2.16.0", "resolved": "https://registry.npmjs.org/@date-io/core/-/core-2.16.0.tgz", @@ -23212,11 +23234,6 @@ "resolved": "https://registry.npmjs.org/@types/extend/-/extend-3.0.1.tgz", "integrity": "sha512-R1g/VyKFFI2HLC1QGAeTtCBWCo6n75l41OnsVYNbmKG+kempOESaodf6BeJyUM3Q0rKa/NQcTHbB2+66lNnxLw==" }, - "@types/google-protobuf": { - "version": "3.15.12", - "resolved": "https://registry.npmjs.org/@types/google-protobuf/-/google-protobuf-3.15.12.tgz", - "integrity": "sha512-40um9QqwHjRS92qnOaDpL7RmDK15NuZYo9HihiJRbYkMQZlWnuH8AdvbMy8/o6lgLmKbDUKa+OALCltHdbOTpQ==" - }, "@types/hast": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/@types/hast/-/hast-2.3.4.tgz", @@ -23297,11 +23314,6 @@ "@types/lodash": "*" } }, - "@types/long": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.2.tgz", - "integrity": "sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA==" - }, "@types/marked": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/@types/marked/-/marked-4.0.8.tgz", @@ -27070,11 +27082,6 @@ "slash": "^3.0.0" } }, - "google-protobuf": { - "version": "3.21.2", - "resolved": "https://registry.npmjs.org/google-protobuf/-/google-protobuf-3.21.2.tgz", - "integrity": "sha512-3MSOYFO5U9mPGikIYCzK0SaThypfGgS6bHqrUGXG3DPHCrb+txNqeEcns1W0lkGfk0rCyNXm7xB9rMxnCiZOoA==" - }, "gopd": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", @@ -27103,11 +27110,6 @@ "lodash": "^4.17.15" } }, - "grpc-web": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/grpc-web/-/grpc-web-1.5.0.tgz", - "integrity": "sha512-y1tS3BBIoiVSzKTDF3Hm7E8hV2n7YY7pO0Uo7depfWJqKzWE+SKr0jvHNIJsJJYILQlpYShpi/DRJJMbosgDMQ==" - }, "has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", @@ -34008,14 +34010,13 @@ "dev": true }, "yorkie-js-sdk": { - "version": "0.4.13", - "resolved": "https://registry.npmjs.org/yorkie-js-sdk/-/yorkie-js-sdk-0.4.13.tgz", - "integrity": "sha512-6Im/SRxJoGcUOf5nHIQDDZnKbLBDUgD66xZxcrAXvZS4KblQnRU54/MdloIF9BzNJlJGwWSk9KjgYwLY73nntg==", - "requires": { - "@types/google-protobuf": "^3.15.5", - "@types/long": "^4.0.1", - "google-protobuf": "^3.19.4", - "grpc-web": "^1.3.1", + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/yorkie-js-sdk/-/yorkie-js-sdk-0.5.3.tgz", + "integrity": "sha512-psMg/cICvgFeH2FxZ0wKxJpciaKlNq2DhU4eJpdxhn0mv3kuXdDtKev1qJkTk/KXPVW91QMpyLlR9un4akLlGw==", + "requires": { + "@bufbuild/protobuf": "^1.6.0", + "@connectrpc/connect": "^1.4.0", + "@connectrpc/connect-web": "^1.4.0", "long": "^5.2.0" } }, diff --git a/package.json b/package.json index aef1103..18d8c86 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,7 @@ "remark-toc": "^8.0.1", "tss-react": "^4.8.2", "unique-names-generator": "^4.7.1", - "yorkie-js-sdk": "^0.4.13" + "yorkie-js-sdk": "^0.5.3" }, "devDependencies": { "@esbuild-plugins/node-globals-polyfill": "^0.2.3", diff --git a/src/components/Editor/index.tsx b/src/components/Editor/index.tsx index c1671f9..5744a2c 100644 --- a/src/components/Editor/index.tsx +++ b/src/components/Editor/index.tsx @@ -21,6 +21,7 @@ import { import { makeStyles } from 'styles/common'; import { Presence, syncPeer } from 'features/peerSlices'; import { Alert, Box, CircularProgress, Snackbar } from '@mui/material'; +import { StreamConnectionStatus } from 'yorkie-js-sdk'; import WhiteBoardEditor from './mime/application/whiteboard/Editor'; import Editor from './mime/text/md/Editor'; @@ -84,21 +85,10 @@ export default function BaseEditor(props: { docKey: string }) { return; } - const unsubscribeClient = client.subscribe((event) => { - if ( - status === DocStatus.Connect && - ((event.type === 'status-changed' && event.value === 'deactivated') || - (event.type === 'stream-connection-status-changed' && event.value === 'disconnected') || - (event.type === 'document-synced' && event.value === 'sync-failed')) - ) { + const unsubscribeClient = doc.subscribe('connection', (event) => { + if (status === DocStatus.Connect && event.value === StreamConnectionStatus.Disconnected) { dispatch(setStatus(DocStatus.Disconnect)); - } else if ( - status === DocStatus.Disconnect && - (event.type === 'document-changed' || - (event.type === 'status-changed' && event.value === 'activated') || - (event.type === 'stream-connection-status-changed' && event.value === 'connected') || - (event.type === 'document-synced' && event.value === 'synced')) - ) { + } else if (status === DocStatus.Disconnect && event.value === StreamConnectionStatus.Connected) { dispatch(setStatus(DocStatus.Connect)); } }); diff --git a/src/components/Editor/mime/text/md/CodeEditor/index.tsx b/src/components/Editor/mime/text/md/CodeEditor/index.tsx index 42bb94e..9ad55c0 100644 --- a/src/components/Editor/mime/text/md/CodeEditor/index.tsx +++ b/src/components/Editor/mime/text/md/CodeEditor/index.tsx @@ -5,7 +5,7 @@ import React, { useEffect, useMemo, useRef, useCallback, useState, MouseEvent } from 'react'; import { createRoot } from 'react-dom/client'; import { useDispatch, useSelector } from 'react-redux'; -import { ActorID, DocEvent, OperationInfo } from 'yorkie-js-sdk'; +import { ActorID, OperationInfo } from 'yorkie-js-sdk'; import CodeMirror from 'codemirror'; import SimpleMDE from 'easymde'; import SimpleMDEReact from 'react-simplemde-editor'; @@ -690,7 +690,7 @@ export default function CodeEditor() { } }; - doc.subscribe((event: DocEvent) => { + doc.subscribe((event) => { if (event.type === 'snapshot') { // re-sync for the new text from the snapshot setText(); diff --git a/src/features/peerSlices.ts b/src/features/peerSlices.ts index 4d03f25..fec43c0 100644 --- a/src/features/peerSlices.ts +++ b/src/features/peerSlices.ts @@ -10,6 +10,7 @@ export interface Presence { board: string; whiteboardUser?: TDUser; selection: any; // TODO(chacha912): Import type from yorkie-js-sdk + [key: string]: any; // NOTE(hackerwins): Quick fix for Indexable. } export enum ConnectionStatus {