@mml-io/mml-web-client 0.0.0-experimental-79daa47-20250916 → 0.0.0-experimental-7763fa3-20250916
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/build/index.js +59 -9
- package/build/index.js.map +3 -3
- package/package.json +5 -5
package/build/index.js
CHANGED
|
@@ -78,13 +78,44 @@
|
|
|
78
78
|
}
|
|
79
79
|
return node;
|
|
80
80
|
}
|
|
81
|
-
function
|
|
81
|
+
function getNetworkedDOMProtocolSubProtocol_v0_2Subversion(protocol) {
|
|
82
|
+
return protocolSubVersionMap[protocol] ?? null;
|
|
83
|
+
}
|
|
84
|
+
function getNetworkedDOMProtocolSubProtocol_v0_2SubversionOrThrow(protocol) {
|
|
85
|
+
const subversion = getNetworkedDOMProtocolSubProtocol_v0_2Subversion(protocol);
|
|
86
|
+
if (subversion === null) {
|
|
87
|
+
throw new Error(`Unrecognized networked-dom-v0.2 protocol subversion: ${protocol}`);
|
|
88
|
+
}
|
|
89
|
+
return subversion;
|
|
90
|
+
}
|
|
91
|
+
function isNetworkedDOMProtocolSubProtocol_v0_2(protocol) {
|
|
92
|
+
return networkedDOMProtocolSubProtocol_v0_2_SubVersionsList.includes(protocol);
|
|
93
|
+
}
|
|
94
|
+
function protocolSubversionHasConnectionTokens(protocolSubversion) {
|
|
95
|
+
return protocolSubversion >= 1;
|
|
96
|
+
}
|
|
97
|
+
function encodeConnectUsers(connectUsersMessage, writer, protocolSubversion) {
|
|
82
98
|
const connectionIdsLength = connectUsersMessage.connectionIds.length;
|
|
83
99
|
writer.writeUint8(ConnectUsersMessageType);
|
|
84
100
|
writer.writeUVarint(connectionIdsLength);
|
|
85
101
|
for (let i = 0; i < connectionIdsLength; i++) {
|
|
86
102
|
writer.writeUVarint(connectUsersMessage.connectionIds[i]);
|
|
87
103
|
}
|
|
104
|
+
if (protocolSubversionHasConnectionTokens(protocolSubversion)) {
|
|
105
|
+
if (connectUsersMessage.connectionTokens.length !== connectionIdsLength) {
|
|
106
|
+
throw new Error(
|
|
107
|
+
`connectionTokens length (${connectUsersMessage.connectionTokens.length}) does not match connectionIds length (${connectionIdsLength})`
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
for (let i = 0; i < connectionIdsLength; i++) {
|
|
111
|
+
const token = connectUsersMessage.connectionTokens[i];
|
|
112
|
+
if (token === null || token === void 0) {
|
|
113
|
+
writer.writeUVarint(0);
|
|
114
|
+
} else {
|
|
115
|
+
writer.writeLengthPrefixedString(token);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
88
119
|
}
|
|
89
120
|
function encodeDisconnectUsers(disconnectUsersMessage, writer) {
|
|
90
121
|
const connectionIdsLength = disconnectUsersMessage.connectionIds.length;
|
|
@@ -276,11 +307,11 @@
|
|
|
276
307
|
}
|
|
277
308
|
return messages;
|
|
278
309
|
}
|
|
279
|
-
function encodeClientMessage(message, writer) {
|
|
310
|
+
function encodeClientMessage(message, writer, protocolSubversion) {
|
|
280
311
|
const type2 = message.type;
|
|
281
312
|
switch (type2) {
|
|
282
313
|
case "connectUsers":
|
|
283
|
-
return encodeConnectUsers(message, writer);
|
|
314
|
+
return encodeConnectUsers(message, writer, protocolSubversion);
|
|
284
315
|
case "disconnectUsers":
|
|
285
316
|
return encodeDisconnectUsers(message, writer);
|
|
286
317
|
case "event":
|
|
@@ -291,7 +322,7 @@
|
|
|
291
322
|
throw new Error(`Unknown message type: ${type2}`);
|
|
292
323
|
}
|
|
293
324
|
}
|
|
294
|
-
var networkedDOMProtocolSubProtocol_v0_1, textDecoder, BufferReader, textEncoder, BufferWriter, networkedDOMProtocolSubProtocol_v0_2, SnapshotMessageType, BatchStartMessageType, DocumentTimeMessageType, ChildrenAddedMessageType, ChildrenRemovedMessageType, AttributesChangedMessageType, ChangeVisibleToMessageType, ChangeHiddenFromMessageType, TextChangedMessageType, BatchEndMessageType, PingMessageType, WarningMessageType, ErrorMessageType, ConnectUsersMessageType, DisconnectUsersMessageType, EventMessageType, PongMessageType, batchEndMessage, batchStartMessage;
|
|
325
|
+
var networkedDOMProtocolSubProtocol_v0_1, textDecoder, BufferReader, textEncoder, BufferWriter, networkedDOMProtocolSubProtocol_v0_2, networkedDOMProtocolSubProtocol_v0_2_1, networkedDOMProtocolSubProtocol_v0_2_SubVersionsList, protocolSubVersionMap, SnapshotMessageType, BatchStartMessageType, DocumentTimeMessageType, ChildrenAddedMessageType, ChildrenRemovedMessageType, AttributesChangedMessageType, ChangeVisibleToMessageType, ChangeHiddenFromMessageType, TextChangedMessageType, BatchEndMessageType, PingMessageType, WarningMessageType, ErrorMessageType, ConnectUsersMessageType, DisconnectUsersMessageType, EventMessageType, PongMessageType, batchEndMessage, batchStartMessage;
|
|
295
326
|
var init_build = __esm({
|
|
296
327
|
"../networked-dom-protocol/build/index.js"() {
|
|
297
328
|
networkedDOMProtocolSubProtocol_v0_1 = "networked-dom-v0.1";
|
|
@@ -519,6 +550,15 @@
|
|
|
519
550
|
}
|
|
520
551
|
};
|
|
521
552
|
networkedDOMProtocolSubProtocol_v0_2 = "networked-dom-v0.2";
|
|
553
|
+
networkedDOMProtocolSubProtocol_v0_2_1 = "networked-dom-v0.2.1";
|
|
554
|
+
networkedDOMProtocolSubProtocol_v0_2_SubVersionsList = [
|
|
555
|
+
networkedDOMProtocolSubProtocol_v0_2_1,
|
|
556
|
+
networkedDOMProtocolSubProtocol_v0_2
|
|
557
|
+
];
|
|
558
|
+
protocolSubVersionMap = {
|
|
559
|
+
[networkedDOMProtocolSubProtocol_v0_2]: 0,
|
|
560
|
+
[networkedDOMProtocolSubProtocol_v0_2_1]: 1
|
|
561
|
+
};
|
|
522
562
|
SnapshotMessageType = 1;
|
|
523
563
|
BatchStartMessageType = 2;
|
|
524
564
|
DocumentTimeMessageType = 3;
|
|
@@ -1120,7 +1160,14 @@
|
|
|
1120
1160
|
this.batchMode = false;
|
|
1121
1161
|
this.batchMessages = [];
|
|
1122
1162
|
this.websocket.binaryType = "arraybuffer";
|
|
1123
|
-
this.
|
|
1163
|
+
this.protocolSubversion = getNetworkedDOMProtocolSubProtocol_v0_2SubversionOrThrow(
|
|
1164
|
+
websocket.protocol
|
|
1165
|
+
);
|
|
1166
|
+
this.send({
|
|
1167
|
+
type: "connectUsers",
|
|
1168
|
+
connectionIds: [connectionId],
|
|
1169
|
+
connectionTokens: [this.options.connectionToken ?? null]
|
|
1170
|
+
});
|
|
1124
1171
|
}
|
|
1125
1172
|
handleEvent(element, event) {
|
|
1126
1173
|
const nodeId = this.elementToId.get(element);
|
|
@@ -1144,7 +1191,7 @@
|
|
|
1144
1191
|
}
|
|
1145
1192
|
send(message) {
|
|
1146
1193
|
const writer = new BufferWriter(256);
|
|
1147
|
-
encodeClientMessage(message, writer);
|
|
1194
|
+
encodeClientMessage(message, writer, this.protocolSubversion);
|
|
1148
1195
|
this.websocket.send(writer.getBuffer());
|
|
1149
1196
|
}
|
|
1150
1197
|
clearContents() {
|
|
@@ -1513,7 +1560,7 @@
|
|
|
1513
1560
|
}
|
|
1514
1561
|
static createWebSocket(url) {
|
|
1515
1562
|
return new WebSocket(url, [
|
|
1516
|
-
|
|
1563
|
+
...networkedDOMProtocolSubProtocol_v0_2_SubVersionsList,
|
|
1517
1564
|
networkedDOMProtocolSubProtocol_v0_1
|
|
1518
1565
|
]);
|
|
1519
1566
|
}
|
|
@@ -1536,7 +1583,7 @@
|
|
|
1536
1583
|
websocket.addEventListener("open", () => {
|
|
1537
1584
|
clearTimeout(timeoutId);
|
|
1538
1585
|
this.websocket = websocket;
|
|
1539
|
-
const isV02 = websocket.protocol
|
|
1586
|
+
const isV02 = isNetworkedDOMProtocolSubProtocol_v0_2(websocket.protocol);
|
|
1540
1587
|
let websocketAdapter;
|
|
1541
1588
|
if (isV02) {
|
|
1542
1589
|
websocketAdapter = new NetworkedDOMWebsocketV02Adapter(
|
|
@@ -9361,7 +9408,8 @@
|
|
|
9361
9408
|
{
|
|
9362
9409
|
tagPrefix: "m-",
|
|
9363
9410
|
// If overlays are allowed, allow SVG elements to populate them
|
|
9364
|
-
allowSVGElements: this.options.allowOverlay
|
|
9411
|
+
allowSVGElements: this.options.allowOverlay,
|
|
9412
|
+
connectionToken: this.options.connectionToken ?? null
|
|
9365
9413
|
}
|
|
9366
9414
|
);
|
|
9367
9415
|
this.websocket = websocket;
|
|
@@ -114255,6 +114303,7 @@ void main() {
|
|
|
114255
114303
|
const urlSearchParams = new URLSearchParams(window.location.search);
|
|
114256
114304
|
const useIframe = scriptUrl.searchParams.get("iframe") === "true" || urlSearchParams.get("iframe") === "true";
|
|
114257
114305
|
const allowOverlay = scriptUrl.searchParams.get("allowOverlay") === "true" || urlSearchParams.get("allowOverlay") === "true";
|
|
114306
|
+
const connectionToken = urlSearchParams.get("token") ?? null;
|
|
114258
114307
|
const fullScreenMMLSceneOptions = {
|
|
114259
114308
|
allowOverlay
|
|
114260
114309
|
};
|
|
@@ -114282,6 +114331,7 @@ void main() {
|
|
|
114282
114331
|
const statusUI = new StatusUI();
|
|
114283
114332
|
const mmlNetworkSource = MMLNetworkSource.create({
|
|
114284
114333
|
url,
|
|
114334
|
+
connectionToken,
|
|
114285
114335
|
mmlScene: fullScreenMMLScene,
|
|
114286
114336
|
statusUpdated: (status) => {
|
|
114287
114337
|
if (status === NetworkedDOMWebsocketStatus.Connected) {
|