@edryslabs/genericprovider 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/LICENSE +24 -0
  2. package/README.md +660 -0
  3. package/dist/index.d.ts +323 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +1001 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/lib.d.ts +36 -0
  8. package/dist/lib.d.ts.map +1 -0
  9. package/dist/lib.js +37 -0
  10. package/dist/lib.js.map +1 -0
  11. package/dist/providers/dummy/index.d.ts +226 -0
  12. package/dist/providers/dummy/index.d.ts.map +1 -0
  13. package/dist/providers/dummy/index.js +326 -0
  14. package/dist/providers/dummy/index.js.map +1 -0
  15. package/dist/providers/gun/index.d.ts +269 -0
  16. package/dist/providers/gun/index.d.ts.map +1 -0
  17. package/dist/providers/gun/index.js +683 -0
  18. package/dist/providers/gun/index.js.map +1 -0
  19. package/dist/providers/indexeddb/index.d.ts +161 -0
  20. package/dist/providers/indexeddb/index.d.ts.map +1 -0
  21. package/dist/providers/indexeddb/index.js +369 -0
  22. package/dist/providers/indexeddb/index.js.map +1 -0
  23. package/dist/providers/matrix/index.d.ts +109 -0
  24. package/dist/providers/matrix/index.d.ts.map +1 -0
  25. package/dist/providers/matrix/index.js +329 -0
  26. package/dist/providers/matrix/index.js.map +1 -0
  27. package/dist/providers/nostr/index.d.ts +172 -0
  28. package/dist/providers/nostr/index.d.ts.map +1 -0
  29. package/dist/providers/nostr/index.js +280 -0
  30. package/dist/providers/nostr/index.js.map +1 -0
  31. package/dist/providers/peerjs/index.d.ts +231 -0
  32. package/dist/providers/peerjs/index.d.ts.map +1 -0
  33. package/dist/providers/peerjs/index.js +1038 -0
  34. package/dist/providers/peerjs/index.js.map +1 -0
  35. package/dist/providers/pubnub/index.d.ts +106 -0
  36. package/dist/providers/pubnub/index.d.ts.map +1 -0
  37. package/dist/providers/pubnub/index.js +357 -0
  38. package/dist/providers/pubnub/index.js.map +1 -0
  39. package/dist/providers/simple-peer/index.d.ts +253 -0
  40. package/dist/providers/simple-peer/index.d.ts.map +1 -0
  41. package/dist/providers/simple-peer/index.js +783 -0
  42. package/dist/providers/simple-peer/index.js.map +1 -0
  43. package/dist/providers/supabase/index.d.ts +80 -0
  44. package/dist/providers/supabase/index.d.ts.map +1 -0
  45. package/dist/providers/supabase/index.js +202 -0
  46. package/dist/providers/supabase/index.js.map +1 -0
  47. package/dist/providers/trystero/index.d.ts +181 -0
  48. package/dist/providers/trystero/index.d.ts.map +1 -0
  49. package/dist/providers/trystero/index.js +187 -0
  50. package/dist/providers/trystero/index.js.map +1 -0
  51. package/dist/providers/websocket/index.d.ts +92 -0
  52. package/dist/providers/websocket/index.d.ts.map +1 -0
  53. package/dist/providers/websocket/index.js +272 -0
  54. package/dist/providers/websocket/index.js.map +1 -0
  55. package/dist/sync-monitor.d.ts +90 -0
  56. package/dist/sync-monitor.d.ts.map +1 -0
  57. package/dist/sync-monitor.js +149 -0
  58. package/dist/sync-monitor.js.map +1 -0
  59. package/dist/transport.d.ts +116 -0
  60. package/dist/transport.d.ts.map +1 -0
  61. package/dist/transport.js +2 -0
  62. package/dist/transport.js.map +1 -0
  63. package/package.json +137 -0
@@ -0,0 +1,149 @@
1
+ /**
2
+ * Optional sync monitoring utilities using hash-based detection.
3
+ *
4
+ * ⚠️ NOTE: For most use cases, use the BUILT-IN verification instead:
5
+ * GenericProvider with verifyUpdates: true (default)
6
+ *
7
+ * When to use SyncHealthMonitor:
8
+ * - You need to monitor sync health across ALL peers simultaneously
9
+ * - You want periodic pub/sub-based hash broadcasting for diagnostics
10
+ * - You need alerting/monitoring separate from the core sync mechanism
11
+ *
12
+ * When to use built-in verification (recommended):
13
+ * - Fast desync detection on every update (no waiting)
14
+ * - Exponential backoff and rate limiting
15
+ * - Sequence numbers for duplicate detection
16
+ * - Zero configuration (enabled by default)
17
+ *
18
+ * This utility is complementary to Yjs's built-in state vector sync.
19
+ * Use for monitoring/alerting, not as primary sync mechanism.
20
+ */
21
+ import * as Y from 'yjs';
22
+ /**
23
+ * Compute a simple hash of the document content.
24
+ * For production, use a proper hash function (e.g., crypto.subtle.digest).
25
+ */
26
+ function simpleHash(data) {
27
+ let hash = 0;
28
+ for (let i = 0; i < data.length; i++) {
29
+ hash = ((hash << 5) - hash + data[i]) | 0;
30
+ }
31
+ return hash.toString(36);
32
+ }
33
+ /**
34
+ * Compute hash of entire Yjs document state.
35
+ */
36
+ export function computeDocumentHash(doc) {
37
+ const state = Y.encodeStateAsUpdate(doc);
38
+ return simpleHash(state);
39
+ }
40
+ /**
41
+ * Sync health monitor that detects divergence using periodic hashing.
42
+ */
43
+ export class SyncHealthMonitor {
44
+ constructor(provider, options = {}) {
45
+ this.options = options;
46
+ this.localHash = '';
47
+ this.peerHashes = new Map();
48
+ this.provider = provider;
49
+ this.options.checkInterval = options.checkInterval ?? 10000; // 10 seconds default
50
+ }
51
+ /**
52
+ * Start monitoring sync health.
53
+ */
54
+ start() {
55
+ if (this.intervalId)
56
+ return;
57
+ console.log('[SyncMonitor] Starting health checks...');
58
+ this.intervalId = setInterval(() => {
59
+ this.checkHealth();
60
+ }, this.options.checkInterval);
61
+ // Subscribe to peer hashes via pub/sub
62
+ this.provider.pubsub.subscribe('sync-health', (msg) => {
63
+ if (msg.type === 'hash-broadcast') {
64
+ this.handlePeerHash(msg.clientId, msg.hash);
65
+ }
66
+ });
67
+ }
68
+ /**
69
+ * Stop monitoring.
70
+ */
71
+ stop() {
72
+ if (this.intervalId) {
73
+ clearInterval(this.intervalId);
74
+ this.intervalId = undefined;
75
+ }
76
+ }
77
+ /**
78
+ * Perform a health check.
79
+ */
80
+ checkHealth() {
81
+ if (!this.provider.connected)
82
+ return;
83
+ // Compute local hash
84
+ this.localHash = computeDocumentHash(this.provider.doc);
85
+ // Broadcast to peers
86
+ this.provider.pubsub.publish('sync-health', {
87
+ type: 'hash-broadcast',
88
+ clientId: this.provider.doc.clientID,
89
+ hash: this.localHash,
90
+ });
91
+ // Check for divergence
92
+ this.detectDivergence();
93
+ }
94
+ /**
95
+ * Handle hash from peer.
96
+ */
97
+ handlePeerHash(clientId, hash) {
98
+ this.peerHashes.set(clientId, hash);
99
+ }
100
+ /**
101
+ * Detect if any peer has different hash.
102
+ */
103
+ detectDivergence() {
104
+ const divergent = [];
105
+ this.peerHashes.forEach((peerHash, clientId) => {
106
+ if (peerHash !== this.localHash) {
107
+ divergent.push(clientId);
108
+ }
109
+ });
110
+ if (divergent.length > 0) {
111
+ console.warn('[SyncMonitor] ⚠️ Desync detected with clients:', divergent);
112
+ console.warn('[SyncMonitor] Local hash:', this.localHash, 'Peer hashes:', Array.from(this.peerHashes.entries()));
113
+ // Trigger automatic re-sync
114
+ console.log('[SyncMonitor] 🔄 Triggering automatic re-sync...');
115
+ this.provider.syncNow();
116
+ // Notify callback
117
+ if (this.options.onDesync) {
118
+ this.options.onDesync({
119
+ localHash: this.localHash,
120
+ peerHashes: new Map(this.peerHashes),
121
+ divergentClients: divergent,
122
+ timestamp: Date.now(),
123
+ });
124
+ }
125
+ }
126
+ }
127
+ }
128
+ /**
129
+ * Example usage:
130
+ *
131
+ * ```typescript
132
+ * const provider = new GenericProvider(doc, transport)
133
+ * await provider.connect({ room: 'my-room' })
134
+ *
135
+ * // Start monitoring
136
+ * const monitor = new SyncHealthMonitor(provider, {
137
+ * checkInterval: 5000, // Check every 5 seconds
138
+ * onDesync: (details) => {
139
+ * console.error('Documents out of sync!', details)
140
+ * // Send to error tracking, show warning to user, etc.
141
+ * }
142
+ * })
143
+ * monitor.start()
144
+ *
145
+ * // Stop when done
146
+ * monitor.stop()
147
+ * ```
148
+ */
149
+ //# sourceMappingURL=sync-monitor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync-monitor.js","sourceRoot":"","sources":["../src/sync-monitor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,CAAC,MAAM,KAA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SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;YAC1B,CAAC;QACH,CAAC,CAAC,CAAA;QAEF,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzB,OAAO,CAAC,IAAI,CAAC,gDAAgD,EAAE,SAAS,CAAC,CAAA;YACzE,OAAO,CAAC,IAAI,CACV,2BAA2B,EAC3B,IAAI,CAAC,SAAS,EACd,cAAc,EACd,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CACtC,CAAA;YAED,4BAA4B;YAC5B,OAAO,CAAC,GAAG,CAAC,kDAAkD,CAAC,CAAA;YAC/D,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAA;YAEvB,kBAAkB;YAClB,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;gBAC1B,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;oBACpB,SAAS,EAAE,IAAI,CAAC,SAAS;oBACzB,UAAU,EAAE,IAAI,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC;oBACpC,gBAAgB,EAAE,SAAS;oBAC3B,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;iBACtB,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;IACH,CAAC;CACF;AASD;;;;;;;;;;;;;;;;;;;;GAoBG"}
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Minimal transport interface that any backend must implement.
3
+ * The transport is responsible ONLY for sending/receiving binary data.
4
+ * How it does this (WebSocket, WebRTC, PubNub, IndexedDB, etc.) is up to the implementation.
5
+ */
6
+ export interface Transport {
7
+ /**
8
+ * Connect to the backend with the given configuration.
9
+ * The config object can contain any backend-specific parameters.
10
+ *
11
+ * @param config - Backend-specific connection configuration
12
+ * @returns Promise that resolves when connected
13
+ */
14
+ connect(config: ConnectionConfig): Promise<void>;
15
+ /**
16
+ * Disconnect from the backend.
17
+ * Should clean up connections but allow reconnection.
18
+ */
19
+ disconnect(): void;
20
+ /**
21
+ * Send binary data to the backend.
22
+ * Can be sync or async depending on the transport.
23
+ *
24
+ * @param data - Binary data to send (Yjs updates or awareness)
25
+ */
26
+ send(data: Uint8Array): void | Promise<void>;
27
+ /**
28
+ * Optional: send binary data to a single peer instead of broadcasting.
29
+ * Only transports with a peer concept (e.g. WebRTC) can implement this.
30
+ * When absent, the provider falls back to broadcast-and-filter.
31
+ *
32
+ * @param peerId - Target peer's ID
33
+ * @param data - Binary data to send
34
+ */
35
+ sendTo?(peerId: string, data: Uint8Array): void | Promise<void>;
36
+ /**
37
+ * Register a callback for incoming binary data.
38
+ * The transport calls this callback whenever data is received.
39
+ *
40
+ * @param callback - Function to call with received data
41
+ * @returns Cleanup function to unregister the callback
42
+ */
43
+ onMessage(callback: (data: Uint8Array) => void): () => void;
44
+ /**
45
+ * Optional: register a callback that fires whenever a new peer data channel
46
+ * opens. The provider uses this to push its local state to the new peer
47
+ * immediately (syncNow), which is required for correct P2P reconnect sync.
48
+ *
49
+ * @param callback - Function to call with the new peer's ID
50
+ * @returns Cleanup function to unregister the callback
51
+ */
52
+ onPeerConnect?(callback: (peerId: string) => void): () => void;
53
+ /**
54
+ * Optional: register a callback that fires when a connected peer disconnects
55
+ * (channel close or error). Consumers use this for presence/leave tracking.
56
+ *
57
+ * @param callback - Function to call with the departed peer's ID
58
+ * @returns Cleanup function to unregister the callback
59
+ */
60
+ onPeerDisconnect?(callback: (peerId: string) => void): () => void;
61
+ /**
62
+ * Optional: per-peer control side-channel that bypasses the provider pipe.
63
+ * For consumer-defined out-of-band exchanges (identity/auth handshakes) that
64
+ * must not be CRC-verified or decoded as Yjs/pubsub data. Only transports
65
+ * with a peer concept implement these.
66
+ *
67
+ * @param peerId - Target peer's ID
68
+ * @param payload - Small binary payload (not chunked/encrypted by the transport)
69
+ */
70
+ sendControl?(peerId: string, payload: Uint8Array): void;
71
+ /**
72
+ * Optional: tear down a single peer connection (e.g. reject a peer that
73
+ * failed an out-of-band handshake). Only transports with a peer concept
74
+ * implement this.
75
+ *
76
+ * @param peerId - Peer to disconnect
77
+ */
78
+ disconnectPeer?(peerId: string): void;
79
+ /**
80
+ * Optional: register a callback for incoming control frames.
81
+ *
82
+ * @param callback - Function called with (senderPeerId, payload)
83
+ * @returns Cleanup function to unregister the callback
84
+ */
85
+ onControlFrame?(callback: (peerId: string, payload: Uint8Array) => void): () => void;
86
+ /**
87
+ * Check if the transport is currently connected.
88
+ */
89
+ readonly isConnected: boolean;
90
+ }
91
+ /**
92
+ * Connection configuration passed to transport.connect()
93
+ * Can be extended with any backend-specific properties.
94
+ */
95
+ export interface ConnectionConfig {
96
+ /** Room/channel identifier for grouping clients */
97
+ room: string;
98
+ /** Optional password for encrypted communication */
99
+ password?: string;
100
+ /** Any other backend-specific configuration */
101
+ [key: string]: any;
102
+ }
103
+ /**
104
+ * Connection status emitted by the provider
105
+ */
106
+ export type ConnectionStatus = {
107
+ state: 'disconnected';
108
+ } | {
109
+ state: 'connecting';
110
+ } | {
111
+ state: 'connected';
112
+ } | {
113
+ state: 'error';
114
+ error: Error;
115
+ };
116
+ //# sourceMappingURL=transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEhD;;;OAGG;IACH,UAAU,IAAI,IAAI,CAAA;IAElB;;;;;OAKG;IACH,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE5C;;;;;;;OAOG;IACH,MAAM,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE/D;;;;;;OAMG;IACH,SAAS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":3,"file":"transport.js","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,137 @@
1
+ {
2
+ "name": "@edryslabs/genericprovider",
3
+ "version": "1.0.1",
4
+ "description": "A clean, minimal, backend-agnostic provider for Yjs that lets you implement any transport mechanism.",
5
+ "license": "ISC",
6
+ "author": "André Dietrich",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/andre-dietrich/y-generic.git"
10
+ },
11
+ "main": "./dist/lib.js",
12
+ "types": "./dist/lib.d.ts",
13
+ "targets": {
14
+ "main": false,
15
+ "types": false
16
+ },
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/lib.d.ts",
20
+ "default": "./dist/lib.js"
21
+ },
22
+ "./providers/dummy": {
23
+ "types": "./dist/providers/dummy/index.d.ts",
24
+ "default": "./dist/providers/dummy/index.js"
25
+ },
26
+ "./providers/simple-peer": {
27
+ "types": "./dist/providers/simple-peer/index.d.ts",
28
+ "default": "./dist/providers/simple-peer/index.js"
29
+ },
30
+ "./providers/peerjs": {
31
+ "types": "./dist/providers/peerjs/index.d.ts",
32
+ "default": "./dist/providers/peerjs/index.js"
33
+ },
34
+ "./providers/indexeddb": {
35
+ "types": "./dist/providers/indexeddb/index.d.ts",
36
+ "default": "./dist/providers/indexeddb/index.js"
37
+ },
38
+ "./providers/gun": {
39
+ "types": "./dist/providers/gun/index.d.ts",
40
+ "default": "./dist/providers/gun/index.js"
41
+ },
42
+ "./providers/trystero": {
43
+ "types": "./dist/providers/trystero/index.d.ts",
44
+ "default": "./dist/providers/trystero/index.js"
45
+ },
46
+ "./providers/pubnub": {
47
+ "types": "./dist/providers/pubnub/index.d.ts",
48
+ "default": "./dist/providers/pubnub/index.js"
49
+ },
50
+ "./providers/websocket": {
51
+ "types": "./dist/providers/websocket/index.d.ts",
52
+ "default": "./dist/providers/websocket/index.js"
53
+ },
54
+ "./providers/matrix": {
55
+ "types": "./dist/providers/matrix/index.d.ts",
56
+ "default": "./dist/providers/matrix/index.js"
57
+ },
58
+ "./providers/supabase": {
59
+ "types": "./dist/providers/supabase/index.d.ts",
60
+ "default": "./dist/providers/supabase/index.js"
61
+ },
62
+ "./providers/nostr": {
63
+ "types": "./dist/providers/nostr/index.d.ts",
64
+ "default": "./dist/providers/nostr/index.js"
65
+ }
66
+ },
67
+ "files": [
68
+ "dist"
69
+ ],
70
+ "scripts": {
71
+ "dev:dummy": "npx parcel serve test/dummy/index.html --open --port 3011",
72
+ "dev:edge-cases": "npx parcel serve test/dummy/edge-cases.html --open --port 3012",
73
+ "dev:simple-peer": "npx parcel serve test/simple-peer/index.html --open --port 3002",
74
+ "dev:peerjs": "npx parcel serve test/peerjs/index.html --open --port 3003",
75
+ "dev:indexeddb": "npx parcel serve test/indexeddb/index.html --open --port 3004",
76
+ "dev:gun": "npx parcel serve test/gun/index.html --open --port 3005",
77
+ "dev:trystero": "npx parcel serve test/trystero/index.html --open --port 3006",
78
+ "dev:pubnub": "npx parcel serve test/pubnub/index.html --open --port 3007",
79
+ "dev:websocket": "npx parcel serve test/websocket/index.html --open --port 3008",
80
+ "dev:matrix": "npx parcel serve test/matrix/index.html --open --port 3009",
81
+ "dev:supabase": "npx parcel serve test/supabase/index.html --open --port 3010",
82
+ "dev:nostr": "npx parcel serve test/nostr/index.html --open --port 3013",
83
+ "test": "parcel test.html --open",
84
+ "build": "rm -rf dist && tsc",
85
+ "build:demo:index": "npx parcel build test/index.html --dist-dir demos --public-url ./ --no-source-maps",
86
+ "build:demo:dummy": "npx parcel build test/dummy/index.html --dist-dir demos/dummy --public-url ./ --no-source-maps",
87
+ "build:demo:simple-peer": "npx parcel build test/simple-peer/index.html --dist-dir demos/simple-peer --public-url ./ --no-source-maps",
88
+ "build:demo:peerjs": "npx parcel build test/peerjs/index.html --dist-dir demos/peerjs --public-url ./ --no-source-maps",
89
+ "build:demo:indexeddb": "npx parcel build test/indexeddb/index.html --dist-dir demos/indexeddb --public-url ./ --no-source-maps",
90
+ "build:demo:gun": "npx parcel build test/gun/index.html --dist-dir demos/gun --public-url ./ --no-source-maps",
91
+ "build:demo:trystero": "npx parcel build test/trystero/index.html --dist-dir demos/trystero --public-url ./ --no-source-maps",
92
+ "build:demo:pubnub": "npx parcel build test/pubnub/index.html --dist-dir demos/pubnub --public-url ./ --no-source-maps",
93
+ "build:demo:websocket": "npx parcel build test/websocket/index.html --dist-dir demos/websocket --public-url ./ --no-source-maps",
94
+ "build:demo:supabase": "npx parcel build test/supabase/index.html --dist-dir demos/supabase --public-url ./ --no-source-maps",
95
+ "build:demo:nostr": "npx parcel build test/nostr/index.html --dist-dir demos/nostr --public-url ./ --no-source-maps",
96
+ "build:demos": "rm -rf demos && npm run build:demo:index && npm run build:demo:dummy && npm run build:demo:simple-peer && npm run build:demo:peerjs && npm run build:demo:indexeddb && npm run build:demo:gun && npm run build:demo:trystero && npm run build:demo:pubnub && npm run build:demo:websocket && npm run build:demo:matrix && npm run build:demo:supabase && npm run build:demo:nostr"
97
+ },
98
+ "dependencies": {
99
+ "y-provider": "^0.10.3-canary.2"
100
+ },
101
+ "peerDependencies": {
102
+ "gun": "^0.2020.1240",
103
+ "lib0": "^0.2.98",
104
+ "peerjs": "^1.5.0",
105
+ "simple-peer": "^9.11.0",
106
+ "y-protocols": "^1.0.6",
107
+ "yjs": "^13.6.29"
108
+ },
109
+ "peerDependenciesMeta": {
110
+ "gun": {
111
+ "optional": true
112
+ },
113
+ "simple-peer": {
114
+ "optional": true
115
+ },
116
+ "peerjs": {
117
+ "optional": true
118
+ }
119
+ },
120
+ "devDependencies": {
121
+ "@parcel/transformer-typescript-types": "^2.16.4",
122
+ "@types/node": "^20.0.0",
123
+ "buffer": "^6.0.3",
124
+ "events": "^3.3.0",
125
+ "lib0": "^0.2.98",
126
+ "parcel": "^2.16.4",
127
+ "process": "^0.11.10",
128
+ "quill-cursors": "^4.0.4",
129
+ "quill": "^2.0.3",
130
+ "typescript": "^5.0.0",
131
+ "y-protocols": "^1.0.6",
132
+ "y-quill": "^1.0.0",
133
+ "y-webrtc": "^10.3.0",
134
+ "y-websocket": "^3.0.0",
135
+ "yjs": "^13.6.29"
136
+ }
137
+ }