yrby-client 0.5.0 → 0.6.0
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.
- package/README.md +236 -36
- package/dist/actioncable_provider.d.ts +18 -11
- package/dist/actioncable_provider.d.ts.map +1 -1
- package/dist/actioncable_provider.js +286 -178
- package/dist/actioncable_provider.js.map +1 -1
- package/dist/cjs/actioncable_provider.d.ts +18 -11
- package/dist/cjs/actioncable_provider.js +287 -179
- package/dist/cjs/document_element.d.ts +24 -0
- package/dist/cjs/document_element.js +260 -0
- package/dist/cjs/document_session.d.ts +62 -0
- package/dist/cjs/document_session.js +335 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js +4 -1
- package/dist/cjs/reliable_sync.d.ts +18 -31
- package/dist/cjs/reliable_sync.js +128 -98
- package/dist/cjs/turbo_adapter.d.ts +9 -0
- package/dist/cjs/turbo_adapter.js +81 -0
- package/dist/cjs/y_protocol_session.d.ts +6 -6
- package/dist/cjs/y_protocol_session.js +96 -81
- package/dist/document_element.d.ts +25 -0
- package/dist/document_element.d.ts.map +1 -0
- package/dist/document_element.js +225 -0
- package/dist/document_element.js.map +1 -0
- package/dist/document_session.d.ts +63 -0
- package/dist/document_session.d.ts.map +1 -0
- package/dist/document_session.js +296 -0
- package/dist/document_session.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/reliable_sync.d.ts +18 -31
- package/dist/reliable_sync.d.ts.map +1 -1
- package/dist/reliable_sync.js +128 -98
- package/dist/reliable_sync.js.map +1 -1
- package/dist/turbo_adapter.d.ts +10 -0
- package/dist/turbo_adapter.d.ts.map +1 -0
- package/dist/turbo_adapter.js +78 -0
- package/dist/turbo_adapter.js.map +1 -0
- package/dist/y_protocol_session.d.ts +6 -6
- package/dist/y_protocol_session.d.ts.map +1 -1
- package/dist/y_protocol_session.js +96 -81
- package/dist/y_protocol_session.js.map +1 -1
- package/package.json +29 -6
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
// Awareness); it works in raw Uint8Array frames and leaves the transport to the
|
|
5
5
|
// caller: base64, the { update, id } / { ack } envelope, and a socket.
|
|
6
6
|
//
|
|
7
|
-
// Call
|
|
8
|
-
//
|
|
9
|
-
// returns a reply to send, or null).
|
|
10
|
-
//
|
|
11
|
-
import {
|
|
7
|
+
// Call resume() when the transport connects, pause() when it drops,
|
|
8
|
+
// acknowledge(id) on an { ack } envelope, and receive(frame) for an inbound
|
|
9
|
+
// frame (it returns a reply to send, or null). The session sends local doc and
|
|
10
|
+
// awareness edits from their "update" events.
|
|
11
|
+
import { mergeUpdates, applyUpdate } from "yjs";
|
|
12
12
|
import * as encoding from "lib0/encoding";
|
|
13
13
|
import * as decoding from "lib0/decoding";
|
|
14
14
|
import { readSyncMessage, writeSyncStep1, writeUpdate, messageYjsSyncStep2 } from "y-protocols/sync";
|
|
@@ -22,12 +22,12 @@ export class YProtocolSession {
|
|
|
22
22
|
awareness;
|
|
23
23
|
#send;
|
|
24
24
|
#onError;
|
|
25
|
-
#
|
|
25
|
+
#state = { phase: "unsynced", cycle: {} };
|
|
26
26
|
#delivery;
|
|
27
27
|
#onDocUpdate;
|
|
28
28
|
#onAwarenessUpdate;
|
|
29
29
|
constructor(doc, opts) {
|
|
30
|
-
const { send, awareness = null, resendInterval, onError, setInterval:
|
|
30
|
+
const { send, awareness = null, resendInterval, onError, setInterval: setTimer, clearInterval: clearTimer } = opts ?? {};
|
|
31
31
|
if (!doc)
|
|
32
32
|
throw new TypeError("YProtocolSession requires a Y.Doc");
|
|
33
33
|
if (typeof send !== "function")
|
|
@@ -40,8 +40,8 @@ export class YProtocolSession {
|
|
|
40
40
|
merge: mergeUpdates,
|
|
41
41
|
send: (update, id) => this.#send(this.#frameUpdate(update), id),
|
|
42
42
|
resendInterval,
|
|
43
|
-
setInterval:
|
|
44
|
-
clearInterval:
|
|
43
|
+
setInterval: setTimer,
|
|
44
|
+
clearInterval: clearTimer,
|
|
45
45
|
});
|
|
46
46
|
this.#onDocUpdate = (update, origin) => {
|
|
47
47
|
if (origin === this)
|
|
@@ -52,10 +52,10 @@ export class YProtocolSession {
|
|
|
52
52
|
if (this.awareness) {
|
|
53
53
|
this.#onAwarenessUpdate = ({ added, updated, removed }, origin) => {
|
|
54
54
|
// Only broadcast our own presence changes. Updates applied from a peer,
|
|
55
|
-
// and our own remote-cleanup in
|
|
55
|
+
// and our own remote-cleanup in pause(), carry origin === this;
|
|
56
56
|
// re-sending those would echo presence and broadcast tombstones for
|
|
57
57
|
// other clients' cursors.
|
|
58
|
-
if (origin === this)
|
|
58
|
+
if (origin === this || this.#state.phase === "destroyed")
|
|
59
59
|
return;
|
|
60
60
|
const changed = added.concat(updated, removed);
|
|
61
61
|
this.#send(this.#frameAwareness(changed), undefined); // fire-and-forget
|
|
@@ -65,26 +65,35 @@ export class YProtocolSession {
|
|
|
65
65
|
}
|
|
66
66
|
/** True once we've received the server's SyncStep2 (the document is caught up). */
|
|
67
67
|
get synced() {
|
|
68
|
-
return this.#synced;
|
|
68
|
+
return this.#state.phase === "synced";
|
|
69
69
|
}
|
|
70
70
|
/** True while there are unacknowledged local document updates in flight. */
|
|
71
71
|
get hasPending() {
|
|
72
72
|
return this.#delivery.hasPending;
|
|
73
73
|
}
|
|
74
|
-
/**
|
|
75
|
-
|
|
74
|
+
/** Call when the transport is up. Sends the opening handshake, re-announces presence, and replays the unacked tail. */
|
|
75
|
+
resume() {
|
|
76
|
+
if (this.#state.phase === "destroyed")
|
|
77
|
+
return;
|
|
78
|
+
const cycle = {};
|
|
79
|
+
this.#state = { phase: "unsynced", cycle };
|
|
76
80
|
this.#send(this.#frameSyncStep1(), undefined);
|
|
81
|
+
if (!this.#current(cycle))
|
|
82
|
+
return;
|
|
77
83
|
if (this.awareness && this.awareness.getLocalState() !== null) {
|
|
78
84
|
this.#send(this.#frameAwareness([this.doc.clientID]), undefined);
|
|
79
85
|
}
|
|
80
|
-
this.#
|
|
86
|
+
if (this.#current(cycle))
|
|
87
|
+
this.#delivery.resume();
|
|
81
88
|
}
|
|
82
|
-
/**
|
|
83
|
-
|
|
84
|
-
this.#
|
|
85
|
-
|
|
89
|
+
/** Call when the transport is down. Keeps the queue, stops retransmits, and clears peers' presence. */
|
|
90
|
+
pause() {
|
|
91
|
+
if (this.#state.phase === "destroyed")
|
|
92
|
+
return;
|
|
93
|
+
this.#state = { phase: "unsynced", cycle: {} };
|
|
94
|
+
this.#delivery.pause();
|
|
86
95
|
if (this.awareness) {
|
|
87
|
-
const remote = [...this.awareness.getStates().keys()].filter(
|
|
96
|
+
const remote = [...this.awareness.getStates().keys()].filter(c => c !== this.doc.clientID);
|
|
88
97
|
if (remote.length)
|
|
89
98
|
removeAwarenessStates(this.awareness, remote, this);
|
|
90
99
|
}
|
|
@@ -96,13 +105,13 @@ export class YProtocolSession {
|
|
|
96
105
|
* waiting for the awareness timeout. A no-op when there's no local state.
|
|
97
106
|
*/
|
|
98
107
|
removeLocalAwareness() {
|
|
99
|
-
if (this.awareness && this.awareness.getLocalState() !== null) {
|
|
108
|
+
if (this.#state.phase !== "destroyed" && this.awareness && this.awareness.getLocalState() !== null) {
|
|
100
109
|
this.awareness.setLocalState(null); // fires "update" -> sends the removal frame
|
|
101
110
|
}
|
|
102
111
|
}
|
|
103
112
|
/** A reliable-delivery `{ ack: id }` envelope arrived. */
|
|
104
|
-
|
|
105
|
-
this.#delivery.
|
|
113
|
+
acknowledge(id) {
|
|
114
|
+
this.#delivery.acknowledge(id);
|
|
106
115
|
}
|
|
107
116
|
/**
|
|
108
117
|
* Apply an update without treating it as a local edit, so it isn't queued for
|
|
@@ -114,11 +123,12 @@ export class YProtocolSession {
|
|
|
114
123
|
* keystroke becomes an outbound frame), so a bare `Y.applyUpdate(doc, update)`
|
|
115
124
|
* would look like a local edit and get echoed back on the next connect. Going
|
|
116
125
|
* through here applies under the session's own origin, which the outbound
|
|
117
|
-
* filter skips. Safe to call before `
|
|
126
|
+
* filter skips. Safe to call before `resume()`: the state folds into the
|
|
118
127
|
* SyncStep1 handshake instead of being re-sent.
|
|
119
128
|
*/
|
|
120
129
|
applyRemoteUpdate(update) {
|
|
121
|
-
|
|
130
|
+
if (this.#state.phase !== "destroyed")
|
|
131
|
+
applyUpdate(this.doc, update, this);
|
|
122
132
|
}
|
|
123
133
|
/**
|
|
124
134
|
* Decode and apply one incoming binary protocol frame (document sync or
|
|
@@ -126,21 +136,27 @@ export class YProtocolSession {
|
|
|
126
136
|
* SyncStep1), or null if there's nothing to send.
|
|
127
137
|
*/
|
|
128
138
|
receive(frame) {
|
|
139
|
+
if (this.#state.phase === "destroyed")
|
|
140
|
+
return null;
|
|
141
|
+
const { cycle } = this.#state;
|
|
129
142
|
// A malformed/truncated frame must never take down the transport callback:
|
|
130
143
|
// decode + apply defensively, drop the frame on error, keep the session live.
|
|
131
144
|
try {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
return null;
|
|
145
|
+
if (!validateFrame(frame))
|
|
146
|
+
return null; // a y-protocols type yrby doesn't use
|
|
135
147
|
const decoder = decoding.createDecoder(frame);
|
|
136
148
|
const encoder = encoding.createEncoder();
|
|
137
149
|
const type = decoding.readVarUint(decoder);
|
|
138
150
|
switch (type) {
|
|
139
151
|
case MessageType.Sync: {
|
|
140
152
|
encoding.writeVarUint(encoder, MessageType.Sync);
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
this.#
|
|
153
|
+
// y-protocols catches a failing update itself and reports it through this handler.
|
|
154
|
+
const report = (error) => { if (this.#current(cycle))
|
|
155
|
+
this.#onError(error, "receive"); };
|
|
156
|
+
const syncType = readSyncMessage(decoder, encoder, this.doc, this, report);
|
|
157
|
+
if (syncType === messageYjsSyncStep2 && this.#current(cycle)) {
|
|
158
|
+
this.#state = { phase: "synced", cycle };
|
|
159
|
+
}
|
|
144
160
|
break;
|
|
145
161
|
}
|
|
146
162
|
case MessageType.Awareness:
|
|
@@ -148,22 +164,29 @@ export class YProtocolSession {
|
|
|
148
164
|
applyAwarenessUpdate(this.awareness, decoding.readVarUint8Array(decoder), this);
|
|
149
165
|
break;
|
|
150
166
|
default:
|
|
151
|
-
return null; //
|
|
167
|
+
return null; // unreachable, since validateFrame accepts only the two types above
|
|
152
168
|
}
|
|
153
|
-
return encoding.length(encoder) > 1 ? encoding.toUint8Array(encoder) : null;
|
|
169
|
+
return this.#current(cycle) && encoding.length(encoder) > 1 ? encoding.toUint8Array(encoder) : null;
|
|
154
170
|
}
|
|
155
171
|
catch (error) {
|
|
156
|
-
this.#
|
|
172
|
+
if (this.#current(cycle))
|
|
173
|
+
this.#onError(error, "receive");
|
|
157
174
|
return null;
|
|
158
175
|
}
|
|
159
176
|
}
|
|
160
177
|
/** Detach doc/awareness listeners and stop retransmits. */
|
|
161
178
|
destroy() {
|
|
179
|
+
if (this.#state.phase === "destroyed")
|
|
180
|
+
return;
|
|
181
|
+
this.#state = { phase: "destroyed" };
|
|
162
182
|
this.doc.off("update", this.#onDocUpdate);
|
|
163
183
|
if (this.awareness && this.#onAwarenessUpdate)
|
|
164
184
|
this.awareness.off("update", this.#onAwarenessUpdate);
|
|
165
185
|
this.#delivery.destroy();
|
|
166
186
|
}
|
|
187
|
+
#current(cycle) {
|
|
188
|
+
return this.#state.phase !== "destroyed" && this.#state.cycle === cycle;
|
|
189
|
+
}
|
|
167
190
|
#frameSyncStep1() {
|
|
168
191
|
const e = encoding.createEncoder();
|
|
169
192
|
encoding.writeVarUint(e, MessageType.Sync);
|
|
@@ -182,53 +205,45 @@ export class YProtocolSession {
|
|
|
182
205
|
encoding.writeVarUint8Array(e, encodeAwarenessUpdate(this.awareness, clients));
|
|
183
206
|
return encoding.toUint8Array(e);
|
|
184
207
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
default:
|
|
223
|
-
return null; // a y-protocols type yrby doesn't speak: ignore
|
|
224
|
-
}
|
|
225
|
-
// This protocol is one message per frame. Anything left after a complete
|
|
226
|
-
// message is malformed (trailing garbage, or low-level packed messages whose
|
|
227
|
-
// tail we'd silently drop), so reject it before mutating local state.
|
|
228
|
-
if (decoding.hasContent(decoder)) {
|
|
229
|
-
throw new Error("frame has trailing bytes after a complete message");
|
|
230
|
-
}
|
|
231
|
-
return type;
|
|
208
|
+
}
|
|
209
|
+
// Checks a frame's structure before anything is applied, so a truncated or
|
|
210
|
+
// padded frame changes nothing. Returns false for a frame type yrby ignores
|
|
211
|
+
// (auth, query-awareness) and throws for a malformed one. Yjs checks the
|
|
212
|
+
// contents of an update itself when applying it.
|
|
213
|
+
function validateFrame(frame) {
|
|
214
|
+
const decoder = decoding.createDecoder(frame);
|
|
215
|
+
const type = decoding.readVarUint(decoder);
|
|
216
|
+
if (type === MessageType.Sync) {
|
|
217
|
+
// Every sync message is a subtype followed by one length-prefixed payload.
|
|
218
|
+
decoding.readVarUint(decoder);
|
|
219
|
+
decoding.readVarUint8Array(decoder);
|
|
220
|
+
}
|
|
221
|
+
else if (type === MessageType.Awareness) {
|
|
222
|
+
validateAwareness(decoding.readVarUint8Array(decoder));
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
227
|
+
// This protocol is one message per frame. Anything left after a complete
|
|
228
|
+
// message is malformed (trailing garbage, or low-level packed messages whose
|
|
229
|
+
// tail we'd silently drop).
|
|
230
|
+
if (decoding.hasContent(decoder))
|
|
231
|
+
throw new Error("frame has trailing bytes after a complete message");
|
|
232
|
+
return true;
|
|
233
|
+
}
|
|
234
|
+
// applyAwarenessUpdate mutates state entry by entry and notifies listeners
|
|
235
|
+
// only at the end, so a bad entry mid-payload would leave earlier entries
|
|
236
|
+
// applied with no event fired. Reading every entry first makes the real apply
|
|
237
|
+
// infallible and catches trailing bytes inside the payload.
|
|
238
|
+
function validateAwareness(payload) {
|
|
239
|
+
const decoder = decoding.createDecoder(payload);
|
|
240
|
+
const count = decoding.readVarUint(decoder);
|
|
241
|
+
for (let i = 0; i < count; i++) {
|
|
242
|
+
decoding.readVarUint(decoder); // clientID
|
|
243
|
+
decoding.readVarUint(decoder); // clock
|
|
244
|
+
JSON.parse(decoding.readVarString(decoder)); // state (null on removal)
|
|
232
245
|
}
|
|
246
|
+
if (decoding.hasContent(decoder))
|
|
247
|
+
throw new Error("awareness payload has trailing bytes");
|
|
233
248
|
}
|
|
234
249
|
//# sourceMappingURL=y_protocol_session.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"y_protocol_session.js","sourceRoot":"","sources":["../src/y_protocol_session.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,kFAAkF;AAClF,2EAA2E;AAC3E,gFAAgF;AAChF,uEAAuE;AACvE,EAAE;AACF,
|
|
1
|
+
{"version":3,"file":"y_protocol_session.js","sourceRoot":"","sources":["../src/y_protocol_session.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,kFAAkF;AAClF,2EAA2E;AAC3E,gFAAgF;AAChF,uEAAuE;AACvE,EAAE;AACF,oEAAoE;AACpE,4EAA4E;AAC5E,+EAA+E;AAC/E,8CAA8C;AAC9C,OAAO,EAAO,YAAY,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,QAAQ,MA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AA8E;AAC9E,4DAA4D;AAC5D,SAAS,iBAAiB,CAAC,OAAmB;IAC5C,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAChD,MAAM,KAAK,GAAG,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC5C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;QAC/B,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW;QAC1C,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ;QACvC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,0BAA0B;IACzE,CAAC;IACD,IAAI,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;AAC5F,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yrby-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "JavaScript client for the yrby y-websocket protocol: a ready-made ActionCable/AnyCable provider, a transport-agnostic protocol session (sync steps, encode/decode, awareness), and a reliable-delivery core (ack-tracked queue, sync-since-last-ack, retransmit + reconnect replay). Written in TypeScript with bundled types; ESM + CommonJS, usable from plain JS.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
@@ -36,6 +36,16 @@
|
|
|
36
36
|
"types": "./dist/cjs/base64.d.ts",
|
|
37
37
|
"default": "./dist/cjs/base64.js"
|
|
38
38
|
}
|
|
39
|
+
},
|
|
40
|
+
"./element": {
|
|
41
|
+
"import": {
|
|
42
|
+
"types": "./dist/document_element.d.ts",
|
|
43
|
+
"default": "./dist/document_element.js"
|
|
44
|
+
},
|
|
45
|
+
"require": {
|
|
46
|
+
"types": "./dist/cjs/document_element.d.ts",
|
|
47
|
+
"default": "./dist/cjs/document_element.js"
|
|
48
|
+
}
|
|
39
49
|
}
|
|
40
50
|
},
|
|
41
51
|
"files": [
|
|
@@ -47,7 +57,10 @@
|
|
|
47
57
|
"build": "npm run clean && tsc && tsc -p tsconfig.cjs.json && node -e \"require('fs').writeFileSync('dist/cjs/package.json', JSON.stringify({ type: 'commonjs' }) + '\\n')\"",
|
|
48
58
|
"typecheck": "tsc --noEmit",
|
|
49
59
|
"prepack": "npm run build",
|
|
50
|
-
"test": "npm run build && node --test"
|
|
60
|
+
"test": "npm run build && node --test --test-timeout=30000",
|
|
61
|
+
"test:browser": "node browser/run.mjs",
|
|
62
|
+
"test:browser:turbolinks": "node browser/run_turbolinks.mjs",
|
|
63
|
+
"test:browser:collaboration": "node browser/run_collaboration.mjs"
|
|
51
64
|
},
|
|
52
65
|
"license": "MIT",
|
|
53
66
|
"author": "JP Camara <jp@jpcamara.com>",
|
|
@@ -73,8 +86,9 @@
|
|
|
73
86
|
"access": "public"
|
|
74
87
|
},
|
|
75
88
|
"peerDependencies": {
|
|
76
|
-
"
|
|
77
|
-
"y-protocols": "^1.0.5"
|
|
89
|
+
"@rails/actioncable": ">= 7.1",
|
|
90
|
+
"y-protocols": "^1.0.5",
|
|
91
|
+
"yjs": "^13.6.0"
|
|
78
92
|
},
|
|
79
93
|
"peerDependenciesMeta": {
|
|
80
94
|
"yjs": {
|
|
@@ -82,14 +96,23 @@
|
|
|
82
96
|
},
|
|
83
97
|
"y-protocols": {
|
|
84
98
|
"optional": true
|
|
99
|
+
},
|
|
100
|
+
"@rails/actioncable": {
|
|
101
|
+
"optional": true
|
|
85
102
|
}
|
|
86
103
|
},
|
|
87
104
|
"dependencies": {
|
|
88
105
|
"lib0": "^0.2.117"
|
|
89
106
|
},
|
|
90
107
|
"devDependencies": {
|
|
91
|
-
"
|
|
108
|
+
"@anycable/web": "^1.1.1",
|
|
109
|
+
"@hotwired/turbo": "^8.0.23",
|
|
110
|
+
"@rails/actioncable": "^8.1.301",
|
|
111
|
+
"agent-browser": "^0.28.0",
|
|
112
|
+
"esbuild": "^0.25.12",
|
|
113
|
+
"turbolinks": "^5.2.0",
|
|
114
|
+
"typescript": "^5.6.0",
|
|
92
115
|
"y-protocols": "^1.0.5",
|
|
93
|
-
"
|
|
116
|
+
"yjs": "^13.6.0"
|
|
94
117
|
}
|
|
95
118
|
}
|