y-openrtc 2.9.3 → 2.9.5
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 +7 -0
- package/dist/provider.js +5 -3
- package/dist/roomRuntime.js +45 -12
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -71,6 +71,10 @@ files or long-lived secrets.
|
|
|
71
71
|
- OpenRTC remains the source of truth for room membership and peer transport.
|
|
72
72
|
- Runtime connection events and room-membership changes drive peer attachment;
|
|
73
73
|
the provider does not poll or own base-connection retries.
|
|
74
|
+
- A supplied room owns discovery and dialing. Its ID determines membership;
|
|
75
|
+
the provider's document label can be different. Provider frames use the
|
|
76
|
+
room's scoped public connections, with a JSON envelope preserving Yjs bytes.
|
|
77
|
+
Diagnostic transport connections are never used for document delivery.
|
|
74
78
|
- Same-tab sync still prefers `BroadcastChannel` when available.
|
|
75
79
|
- `password` encrypts provider payloads end-to-end on top of OpenRTC.
|
|
76
80
|
|
|
@@ -91,3 +95,6 @@ pnpm --dir openrtc/packages/y-openrtc test:live
|
|
|
91
95
|
```
|
|
92
96
|
|
|
93
97
|
The live test only uses the public OpenRTC API key. Server secrets are not needed for this package-local live test and should stay server-side.
|
|
98
|
+
It checks document and awareness convergence between isolated browser contexts,
|
|
99
|
+
so BroadcastChannel cannot hide a broken network path. The separate static Hub
|
|
100
|
+
configuration check runs only when `OPENRTC_HUB_API_KEY` is supplied.
|
package/dist/provider.js
CHANGED
|
@@ -273,7 +273,7 @@ export class YProvider {
|
|
|
273
273
|
}
|
|
274
274
|
this.runtime = runtime;
|
|
275
275
|
this.localNodeId = await runtime.getNodeId();
|
|
276
|
-
const preferredRoomId = normalizeOpenrtcRoomId(this.options.roomIdOverride ?? await roomIdFromName(this.roomName));
|
|
276
|
+
const preferredRoomId = normalizeOpenrtcRoomId(this.options.roomIdOverride ?? this.options.room?.id ?? await roomIdFromName(this.roomName));
|
|
277
277
|
const roomCandidates = this.resolveRoomCandidates(preferredRoomId);
|
|
278
278
|
this.attachLocalObservers();
|
|
279
279
|
this.stopRuntimeConnections = runtime.onConnection((connection) => {
|
|
@@ -467,7 +467,7 @@ export class YProvider {
|
|
|
467
467
|
const localNodeId = this.localNodeId;
|
|
468
468
|
const candidates = Array.from(this.roomMembers.values())
|
|
469
469
|
.filter((member) => member.nodeId !== this.localNodeId)
|
|
470
|
-
.filter((member) => !!member.ticket)
|
|
470
|
+
.filter((member) => Boolean(this.options.room) || !!member.ticket)
|
|
471
471
|
.filter((member) => !this.filterBcConns || !this.hasBcNodeId(member.nodeId))
|
|
472
472
|
.sort((left, right) => stableScore(`${this.providerId}:${right.nodeId}`) -
|
|
473
473
|
stableScore(`${this.providerId}:${left.nodeId}`));
|
|
@@ -488,7 +488,9 @@ export class YProvider {
|
|
|
488
488
|
}
|
|
489
489
|
}
|
|
490
490
|
}
|
|
491
|
-
|
|
491
|
+
// An activated room already owns discovery and dialing. The provider
|
|
492
|
+
// only attaches its document protocol to the room owner's connections.
|
|
493
|
+
const connectableMembers = this.options.room ? [] : candidates.filter((member) => desiredNodeIds.has(member.nodeId) &&
|
|
492
494
|
shouldInitiate(localNodeId, member.nodeId) &&
|
|
493
495
|
!this.openrtcConnections.has(member.nodeId) &&
|
|
494
496
|
!this.pendingNodeIds.has(member.nodeId));
|
package/dist/roomRuntime.js
CHANGED
|
@@ -8,7 +8,32 @@ function assertRoom(room, requested) {
|
|
|
8
8
|
}
|
|
9
9
|
/** One-handle adapter; cast is isolated here so provider code cannot see legacy construction. */
|
|
10
10
|
export function runtimeFromRoom(room) {
|
|
11
|
-
|
|
11
|
+
// Observe capability-scoped logical connections. Diagnostic connections
|
|
12
|
+
// are raw transport views and must never carry a product protocol.
|
|
13
|
+
const observed = new Map();
|
|
14
|
+
function adaptConnection(connection) {
|
|
15
|
+
let closed = false;
|
|
16
|
+
return {
|
|
17
|
+
id: connection.id,
|
|
18
|
+
remoteNodeId: connection.peerId,
|
|
19
|
+
get isClosed() { return closed; },
|
|
20
|
+
// Public capability messages are JSON values. Preserve Yjs bytes
|
|
21
|
+
// in an explicit protocol envelope rather than serializing a typed
|
|
22
|
+
// array into numeric object keys that the receiver cannot decode.
|
|
23
|
+
send: (payload) => connection.send({ yOpenrtc: 1, bytes: Array.from(payload) }),
|
|
24
|
+
onMessage: (callback) => connection.onMessage((message) => {
|
|
25
|
+
const frame = message;
|
|
26
|
+
if (frame?.yOpenrtc !== 1 || !Array.isArray(frame.bytes)
|
|
27
|
+
|| !frame.bytes.every(byte => Number.isInteger(byte) && byte >= 0 && byte <= 255))
|
|
28
|
+
return;
|
|
29
|
+
callback(Uint8Array.from(frame.bytes));
|
|
30
|
+
}),
|
|
31
|
+
onDisconnect: connection.onClose,
|
|
32
|
+
disconnect: async () => undefined, // The borrowed room owns lifecycle.
|
|
33
|
+
markClosed: () => { closed = true; },
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
const connections = () => [...observed.values()];
|
|
12
37
|
const adapter = {
|
|
13
38
|
initialize: async () => undefined,
|
|
14
39
|
start: async () => undefined,
|
|
@@ -42,18 +67,26 @@ export function runtimeFromRoom(room) {
|
|
|
42
67
|
}))));
|
|
43
68
|
},
|
|
44
69
|
onConnection: (callback) => {
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
70
|
+
const closeObservers = new Set();
|
|
71
|
+
const stop = room.onConnection((connection) => {
|
|
72
|
+
const view = adaptConnection(connection);
|
|
73
|
+
observed.set(connection.id, view);
|
|
74
|
+
const stopClose = connection.onClose(() => {
|
|
75
|
+
view.markClosed();
|
|
76
|
+
if (observed.get(connection.id) === view)
|
|
77
|
+
observed.delete(connection.id);
|
|
78
|
+
closeObservers.delete(stopClose);
|
|
79
|
+
stopClose();
|
|
80
|
+
});
|
|
81
|
+
closeObservers.add(stopClose);
|
|
82
|
+
callback(view);
|
|
83
|
+
});
|
|
84
|
+
return () => {
|
|
85
|
+
stop();
|
|
86
|
+
closeObservers.forEach(unsubscribe => unsubscribe());
|
|
87
|
+
closeObservers.clear();
|
|
88
|
+
observed.clear();
|
|
54
89
|
};
|
|
55
|
-
publish();
|
|
56
|
-
return room.peers.watch(publish);
|
|
57
90
|
},
|
|
58
91
|
onStateChange: room.diagnostics.onStateChange,
|
|
59
92
|
getConnections: connections,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "y-openrtc",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"lib0": "^0.2.114",
|
|
46
|
-
"openrtc": "^2.9.
|
|
46
|
+
"openrtc": "^2.9.5",
|
|
47
47
|
"y-protocols": "^1.0.6"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/node": "^24.10.1",
|
|
54
54
|
"happy-dom": "^20.5.0",
|
|
55
|
+
"playwright": "^1.59.1",
|
|
55
56
|
"typescript": "^5.8.3",
|
|
56
57
|
"vitest": "^4.0.18",
|
|
57
58
|
"yjs": "^13.6.27"
|