@q9labsai/chalk-client 4.1.16 → 5.0.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 +99 -40
- package/dist/access/grant.d.ts +0 -10
- package/dist/access/grant.d.ts.map +1 -1
- package/dist/access/manager.d.ts.map +1 -1
- package/dist/{chunk-M3S7HNQF.js → chunk-2HJIJVE2.js} +601 -3628
- package/dist/{chunk-OKIL2ELF.js → chunk-AVXJ4HQU.js} +154 -50
- package/dist/{chunk-E4OK5K6N.js → chunk-CMVO7USN.js} +2 -8
- package/dist/{chunk-BD7FRQ67.js → chunk-IPAN4LUZ.js} +1089 -2457
- package/dist/{chunk-O7WTAXAY.js → chunk-O2NOZKJP.js} +170 -639
- package/dist/client.d.ts +2500 -5206
- package/dist/client.d.ts.map +1 -1
- package/dist/collaboration/types.d.ts +21 -1
- package/dist/collaboration/types.d.ts.map +1 -1
- package/dist/collaboration/wire.d.ts +8 -1
- package/dist/collaboration/wire.d.ts.map +1 -1
- package/dist/connection/dependencies.d.ts +8 -13
- package/dist/connection/dependencies.d.ts.map +1 -1
- package/dist/connection/diagnostics.d.ts +1 -1
- package/dist/connection/diagnostics.d.ts.map +1 -1
- package/dist/connection/index.d.ts +2 -6
- package/dist/connection/index.d.ts.map +1 -1
- package/dist/connection/lifecycle.d.ts +4 -1
- package/dist/connection/lifecycle.d.ts.map +1 -1
- package/dist/connection/media-devices.d.ts +11 -0
- package/dist/connection/media-devices.d.ts.map +1 -1
- package/dist/connection/production.d.ts +1 -1
- package/dist/connection/production.d.ts.map +1 -1
- package/dist/connection/types.d.ts +4 -4
- package/dist/connection/types.d.ts.map +1 -1
- package/dist/effect.d.ts +0 -4
- package/dist/effect.d.ts.map +1 -1
- package/dist/effect.js +65 -776
- package/dist/foreground-deadline.d.ts +9 -0
- package/dist/foreground-deadline.d.ts.map +1 -0
- package/dist/generated/http-api.d.ts +2561 -5213
- package/dist/generated/http-api.d.ts.map +1 -1
- package/dist/generated/schemas.d.ts +1919 -6814
- package/dist/generated/schemas.d.ts.map +1 -1
- package/dist/generated/sync.d.ts +191 -28
- package/dist/generated/sync.d.ts.map +1 -1
- package/dist/generated/whiteboard-v1.d.ts +0 -7
- package/dist/generated/whiteboard-v1.d.ts.map +1 -1
- package/dist/index.d.ts +0 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -128
- package/dist/media/client.d.ts +6 -5
- package/dist/media/client.d.ts.map +1 -1
- package/dist/media/index.d.ts +1 -2
- package/dist/media/index.d.ts.map +1 -1
- package/dist/media/index.js +1 -7
- package/dist/media/plane.d.ts +12 -1
- package/dist/media/plane.d.ts.map +1 -1
- package/dist/media/target.d.ts +4 -2
- package/dist/media/target.d.ts.map +1 -1
- package/dist/media/tracks.d.ts +2 -2
- package/dist/media/tracks.d.ts.map +1 -1
- package/dist/media/transport.d.ts.map +1 -1
- package/dist/media/types.d.ts +4 -11
- package/dist/media/types.d.ts.map +1 -1
- package/dist/public-invites/client.d.ts.map +1 -1
- package/dist/public-invites/index.d.ts +2 -2
- package/dist/public-invites/index.d.ts.map +1 -1
- package/dist/public-invites/index.js +2 -5
- package/dist/public-invites/types.d.ts +2 -6
- package/dist/public-invites/types.d.ts.map +1 -1
- package/dist/server/access-refresh.d.cts +5 -0
- package/dist/server/access-refresh.d.ts +5 -0
- package/dist/server/access-refresh.d.ts.map +1 -1
- package/dist/server/client.d.ts.map +1 -1
- package/dist/server/index.cjs +22 -117
- package/dist/server/index.d.cts +2 -2
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +19 -114
- package/dist/server/types.d.cts +2 -8
- package/dist/server/types.d.ts +2 -8
- package/dist/server/types.d.ts.map +1 -1
- package/dist/space-client/chat-controller-helpers.d.ts.map +1 -1
- package/dist/space-client/chat-controller.d.ts +2 -3
- package/dist/space-client/chat-controller.d.ts.map +1 -1
- package/dist/space-client/controller-effects.d.ts +0 -3
- package/dist/space-client/controller-effects.d.ts.map +1 -1
- package/dist/space-client/core.d.ts +3 -18
- package/dist/space-client/core.d.ts.map +1 -1
- package/dist/space-client/core.test.helpers.d.ts +1 -1
- package/dist/space-client/core.test.helpers.d.ts.map +1 -1
- package/dist/space-client/effect.d.ts +0 -2
- package/dist/space-client/effect.d.ts.map +1 -1
- package/dist/space-client/index.d.ts +1 -2
- package/dist/space-client/index.d.ts.map +1 -1
- package/dist/space-client/media-controller.d.ts +4 -4
- package/dist/space-client/media-controller.d.ts.map +1 -1
- package/dist/space-client/offline-actions-storage.d.ts +18 -3
- package/dist/space-client/offline-actions-storage.d.ts.map +1 -1
- package/dist/space-client/offline-actions.d.ts +1 -0
- package/dist/space-client/offline-actions.d.ts.map +1 -1
- package/dist/space-client/participants-controller.d.ts +2 -3
- package/dist/space-client/participants-controller.d.ts.map +1 -1
- package/dist/space-client/reactions-controller.d.ts +2 -3
- package/dist/space-client/reactions-controller.d.ts.map +1 -1
- package/dist/space-client/recording-controller.d.ts +2 -3
- package/dist/space-client/recording-controller.d.ts.map +1 -1
- package/dist/space-client/space-client.d.ts.map +1 -1
- package/dist/space-client/store.d.ts.map +1 -1
- package/dist/space-client/terminal.test.helpers.d.ts +136 -0
- package/dist/space-client/terminal.test.helpers.d.ts.map +1 -0
- package/dist/space-client/types.d.ts +17 -8
- package/dist/space-client/types.d.ts.map +1 -1
- package/dist/sync/index.d.ts +1 -1
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +1 -3
- package/dist/sync/v1-client.d.ts +5 -3
- package/dist/sync/v1-client.d.ts.map +1 -1
- package/dist/sync/v1-collaboration-state.d.ts +10 -3
- package/dist/sync/v1-collaboration-state.d.ts.map +1 -1
- package/dist/sync/v1-types.d.ts +10 -9
- package/dist/sync/v1-types.d.ts.map +1 -1
- package/dist/webhooks/generated/event-v1.d.cts +10 -2
- package/dist/webhooks/generated/event-v1.d.ts +10 -2
- package/dist/webhooks/generated/event-v1.d.ts.map +1 -1
- package/dist/webhooks/generated/fixtures-v1.d.cts +2 -2
- package/dist/webhooks/generated/fixtures-v1.d.ts +2 -2
- package/dist/webhooks/index.cjs +10 -2
- package/dist/webhooks/index.js +10 -2
- package/dist/webhooks/test.cjs +2 -2
- package/dist/webhooks/test.js +2 -2
- package/dist/whiteboard/file-download-transport.d.ts +8 -0
- package/dist/whiteboard/file-download-transport.d.ts.map +1 -0
- package/dist/whiteboard/index.d.ts +1 -1
- package/dist/whiteboard/index.d.ts.map +1 -1
- package/dist/whiteboard/types.d.ts +12 -15
- package/dist/whiteboard/types.d.ts.map +1 -1
- package/dist/whiteboard/v1-client.d.ts.map +1 -1
- package/package.json +4 -16
- package/dist/access/episode-diagnostic-credential.d.ts +0 -11
- package/dist/access/episode-diagnostic-credential.d.ts.map +0 -1
- package/dist/chunk-EWTITNJ3.js +0 -1163
- package/dist/chunk-HW5TTZL2.js +0 -99
- package/dist/chunk-PBSYXPNJ.js +0 -23
- package/dist/chunk-RCDXIDCN.js +0 -33
- package/dist/connection/snapshot.d.ts +0 -23
- package/dist/connection/snapshot.d.ts.map +0 -1
- package/dist/feedback/collector.d.ts +0 -14
- package/dist/feedback/collector.d.ts.map +0 -1
- package/dist/feedback/context.d.ts +0 -38
- package/dist/feedback/context.d.ts.map +0 -1
- package/dist/feedback/controller.d.ts +0 -4
- package/dist/feedback/controller.d.ts.map +0 -1
- package/dist/feedback/index.d.ts +0 -7
- package/dist/feedback/index.d.ts.map +0 -1
- package/dist/feedback/transport.d.ts +0 -29
- package/dist/feedback/transport.d.ts.map +0 -1
- package/dist/feedback/types.d.ts +0 -202
- package/dist/feedback/types.d.ts.map +0 -1
- package/dist/feedback/validation.d.ts +0 -30
- package/dist/feedback/validation.d.ts.map +0 -1
- package/dist/media/rtk.d.ts +0 -101
- package/dist/media/rtk.d.ts.map +0 -1
- package/dist/space-client/episode-diagnostic-registry.d.ts +0 -13
- package/dist/space-client/episode-diagnostic-registry.d.ts.map +0 -1
- package/dist/space-client/episode-diagnostic-render-registry.d.ts +0 -4
- package/dist/space-client/episode-diagnostic-render-registry.d.ts.map +0 -1
- package/dist/space-client/episode-diagnostic-runtime.d.ts +0 -105
- package/dist/space-client/episode-diagnostic-runtime.d.ts.map +0 -1
- package/dist/telemetry/attributes.d.ts +0 -7
- package/dist/telemetry/attributes.d.ts.map +0 -1
- package/dist/telemetry/client.d.ts +0 -44
- package/dist/telemetry/client.d.ts.map +0 -1
- package/dist/telemetry/delivery.d.ts +0 -107
- package/dist/telemetry/delivery.d.ts.map +0 -1
- package/dist/telemetry/exporter.d.ts +0 -38
- package/dist/telemetry/exporter.d.ts.map +0 -1
- package/dist/telemetry/index.d.ts +0 -7
- package/dist/telemetry/index.d.ts.map +0 -1
- package/dist/telemetry/index.js +0 -50
- package/dist/telemetry/journey.d.ts +0 -52
- package/dist/telemetry/journey.d.ts.map +0 -1
- package/dist/telemetry/random.d.ts +0 -18
- package/dist/telemetry/random.d.ts.map +0 -1
- package/dist/telemetry/reconnect.d.ts +0 -7
- package/dist/telemetry/reconnect.d.ts.map +0 -1
- package/dist/telemetry/rtc.d.ts +0 -41
- package/dist/telemetry/rtc.d.ts.map +0 -1
- package/dist/telemetry/storage.d.ts +0 -22
- package/dist/telemetry/storage.d.ts.map +0 -1
- package/dist/telemetry/sync.d.ts +0 -10
- package/dist/telemetry/sync.d.ts.map +0 -1
- package/dist/telemetry/test-support.d.ts +0 -51
- package/dist/telemetry/test-support.d.ts.map +0 -1
- package/dist/telemetry/trace.d.ts +0 -18
- package/dist/telemetry/trace.d.ts.map +0 -1
- package/dist/telemetry/types.d.ts +0 -109
- package/dist/telemetry/types.d.ts.map +0 -1
- package/dist/whiteboard/file-http-transport.d.ts +0 -9
- package/dist/whiteboard/file-http-transport.d.ts.map +0 -1
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
recordReconnect
|
|
3
|
-
} from "./chunk-RCDXIDCN.js";
|
|
4
|
-
import {
|
|
5
|
-
syncTelemetryCorrelation
|
|
6
|
-
} from "./chunk-PBSYXPNJ.js";
|
|
7
|
-
|
|
8
1
|
// src/sync/canonical.ts
|
|
9
2
|
var encoder = new TextEncoder();
|
|
10
3
|
function canonicalJson(value) {
|
|
@@ -256,7 +249,7 @@ var SyncProtocolMetadata = {
|
|
|
256
249
|
},
|
|
257
250
|
{
|
|
258
251
|
id: "live",
|
|
259
|
-
accepts: ["command", "live_target", "directed_request", "delivery_ack", "request_ack", "reaction_send", "chat_send", "chat_page_request", "chat_read_set", "ping"],
|
|
252
|
+
accepts: ["command", "live_target", "directed_request", "delivery_ack", "request_ack", "reaction_send", "chat_send", "chat_page_request", "chat_read_set", "chat_reaction_set", "ping"],
|
|
260
253
|
heartbeat: {
|
|
261
254
|
intervalMs: 2e4,
|
|
262
255
|
missedDeadlinesBeforeClose: 2
|
|
@@ -378,6 +371,7 @@ var SyncProtocolMetadata = {
|
|
|
378
371
|
chatAttachmentFileNameUtf8Bytes: 255,
|
|
379
372
|
chatAttachmentMaxBytes: 26214400,
|
|
380
373
|
chatPageMaxMessages: 100,
|
|
374
|
+
chatReactionMaxMemberships: 128,
|
|
381
375
|
chatPageEncodedBytes: 131072,
|
|
382
376
|
reactionTtlMs: 5e3,
|
|
383
377
|
reactionRateWindowMs: 1e4,
|
|
@@ -386,8 +380,9 @@ var SyncProtocolMetadata = {
|
|
|
386
380
|
},
|
|
387
381
|
collaboration: {
|
|
388
382
|
extension: "collaboration_v1",
|
|
383
|
+
messageReactionsExtension: "collaboration_v2",
|
|
389
384
|
capabilities: ["sendReaction", "sendChat"],
|
|
390
|
-
reactions: ["\u{1F44D}", "\u2764\uFE0F", "\u{1F602}", "\u{1F62E}", "\u{1F622}", "\u{
|
|
385
|
+
reactions: ["\u{1F44D}", "\u2764\uFE0F", "\u{1F602}", "\u{1F62E}", "\u{1F389}", "\u{1F44F}", "\u{1F600}", "\u{1F605}", "\u{1F64F}", "\u{1F525}", "\u2705", "\u{1F440}", "\u{1F4AF}", "\u{1F914}", "\u{1F622}", "\u{1F64C}", "\u{1F680}", "\u{1F44C}", "\u{1F60D}", "\u{1F91D}", "\u{1F4A1}", "\u2B50", "\u{1F60E}", "\u{1F973}"],
|
|
391
386
|
attachmentMimeTypes: [
|
|
392
387
|
"image/png",
|
|
393
388
|
"image/jpeg",
|
|
@@ -417,6 +412,10 @@ var SyncProtocolMetadata = {
|
|
|
417
412
|
exactFields: ["name", "capabilities", "participant_capabilities", "chat_head_sequence", "retained_floor_sequence", "read_receipts"]
|
|
418
413
|
},
|
|
419
414
|
clientFrames: {
|
|
415
|
+
setChatReaction: {
|
|
416
|
+
type: "chat_reaction_set",
|
|
417
|
+
exactFields: ["type", "request_id", "message_id", "emoji", "on"]
|
|
418
|
+
},
|
|
420
419
|
sendReaction: {
|
|
421
420
|
type: "reaction_send",
|
|
422
421
|
exactFields: ["type", "operation_id", "reaction"]
|
|
@@ -436,6 +435,16 @@ var SyncProtocolMetadata = {
|
|
|
436
435
|
}
|
|
437
436
|
},
|
|
438
437
|
serverFrames: {
|
|
438
|
+
chatReactions: {
|
|
439
|
+
type: "chat_reactions",
|
|
440
|
+
exactFields: ["type", "message_id", "revision", "reactions"]
|
|
441
|
+
},
|
|
442
|
+
chatReactionResult: {
|
|
443
|
+
type: "chat_reaction_result",
|
|
444
|
+
acceptedFields: ["type", "request_id", "outcome", "state"],
|
|
445
|
+
rejectedFields: ["type", "request_id", "outcome", "error_code"],
|
|
446
|
+
outcomes: ["accepted", "rejected"]
|
|
447
|
+
},
|
|
439
448
|
reaction: {
|
|
440
449
|
type: "reaction",
|
|
441
450
|
exactFields: ["type", "event_id", "participant_id", "display_name", "reaction", "occurred_at", "expires_at"]
|
|
@@ -448,7 +457,8 @@ var SyncProtocolMetadata = {
|
|
|
448
457
|
},
|
|
449
458
|
chatMessage: {
|
|
450
459
|
type: "chat_message",
|
|
451
|
-
exactFields: ["type", "message_id", "client_message_id", "sequence", "participant_id", "display_name", "text", "attachments", "created_at"]
|
|
460
|
+
exactFields: ["type", "message_id", "client_message_id", "sequence", "participant_id", "display_name", "text", "attachments", "created_at"],
|
|
461
|
+
optionalFields: ["reactions", "reaction_revision"]
|
|
452
462
|
},
|
|
453
463
|
chatSendResult: {
|
|
454
464
|
type: "chat_send_result",
|
|
@@ -613,7 +623,7 @@ function strictCommand(value) {
|
|
|
613
623
|
}
|
|
614
624
|
}
|
|
615
625
|
function strictCollaborationsHelloExtension(value) {
|
|
616
|
-
return exactObject(value, ["name", "chat_cursor"]) && value.name
|
|
626
|
+
return exactObject(value, ["name", "chat_cursor"]) && ["collaboration_v1", "collaboration_v2"].includes(String(value.name)) && exactObject(value.chat_cursor, ["after_sequence", "retained_floor_sequence"]);
|
|
617
627
|
}
|
|
618
628
|
function strictHello(value) {
|
|
619
629
|
const base = exactObjectWithCorrelation(value, ["type", "protocol", "token", "streams"]);
|
|
@@ -623,7 +633,7 @@ function strictHello(value) {
|
|
|
623
633
|
return exactObject(streams.control, ["cursor"]) && (streams.control.cursor === null || strictCursor(streams.control.cursor)) && exactObject(streams.media, ["cursor"]) && streams.media.cursor === null && exactObject(streams.presence, ["cursor"]) && streams.presence.cursor === null && exactObject(streams.requests, ["cursor"]) && streams.requests.cursor === null;
|
|
624
634
|
}
|
|
625
635
|
function strictChatMessage(value) {
|
|
626
|
-
return exactObjectWithCorrelation(value, ["type", "message_id", "client_message_id", "sequence", "participant_id", "display_name", "text", "attachments", "created_at"]) && Array.isArray(value.attachments) && value.attachments.every(strictChatAttachment);
|
|
636
|
+
return isObject(value) && exactObjectWithCorrelation(value, ["type", "message_id", "client_message_id", "sequence", "participant_id", "display_name", "text", "attachments", "created_at"].concat(["reactions", "reaction_revision"].filter((key) => key in value))) && Array.isArray(value.attachments) && value.attachments.every(strictChatAttachment);
|
|
627
637
|
}
|
|
628
638
|
function strictChatAttachment(value) {
|
|
629
639
|
return exactObject(value, ["attachment_id", "file_name", "mime_type", "byte_length"]);
|
|
@@ -683,6 +693,8 @@ function strictClientFrame(value) {
|
|
|
683
693
|
return exactObject(value, ["type", "client_message_id", "text", "attachment_ids"]);
|
|
684
694
|
case "chat_page_request":
|
|
685
695
|
return exactObject(value, ["type", "request_id", "direction", "cursor_sequence", "limit"]);
|
|
696
|
+
case "chat_reaction_set":
|
|
697
|
+
return exactObject(value, ["type", "request_id", "message_id", "emoji", "on"]);
|
|
686
698
|
case "chat_read_set":
|
|
687
699
|
return exactObject(value, ["type", "request_id", "sequence"]);
|
|
688
700
|
case "delivery_ack":
|
|
@@ -770,7 +782,7 @@ function strictProjection(value) {
|
|
|
770
782
|
function strictWelcome(value) {
|
|
771
783
|
const base = ["type", "protocol", "participant_id", "participant_generation", "recovery_id", "head", "mode"];
|
|
772
784
|
const extension = Array.isArray(value.extensions) && value.extensions.length === 1 ? value.extensions[0] : void 0;
|
|
773
|
-
const extensionValid = isObject(extension) && extension.name
|
|
785
|
+
const extensionValid = isObject(extension) && ["collaboration_v1", "collaboration_v2"].includes(String(extension.name)) && exactObject(extension, ["name", "capabilities", "participant_capabilities", "chat_head_sequence", "retained_floor_sequence", "read_receipts"]) && Array.isArray(extension.read_receipts);
|
|
774
786
|
const fields = extensionValid ? [...base, "extensions"] : base;
|
|
775
787
|
if (!strictCursor(value.head)) return false;
|
|
776
788
|
if (value.mode === "snapshot") return exactObjectWithCorrelation(value, [...fields, "snapshot"]) && strictSnapshot(value.snapshot);
|
|
@@ -810,6 +822,10 @@ function strictServerFrame(value) {
|
|
|
810
822
|
return strictReaction(value);
|
|
811
823
|
case "reaction_result":
|
|
812
824
|
return value.outcome === "accepted" ? exactObjectWithCorrelation(value, ["type", "operation_id", "outcome", "reaction"]) && strictReaction(value.reaction) : value.outcome === "rejected" && exactObjectWithCorrelation(value, ["type", "operation_id", "outcome", "error_code"]);
|
|
825
|
+
case "chat_reactions":
|
|
826
|
+
return exactObjectWithCorrelation(value, ["type", "message_id", "revision", "reactions"]);
|
|
827
|
+
case "chat_reaction_result":
|
|
828
|
+
return value.outcome === "accepted" ? exactObjectWithCorrelation(value, ["type", "request_id", "outcome", "state"]) && strictServerFrame(value.state) : exactObjectWithCorrelation(value, ["type", "request_id", "outcome", "error_code"]);
|
|
813
829
|
case "chat_message":
|
|
814
830
|
return strictChatMessage(value);
|
|
815
831
|
case "chat_send_result":
|
|
@@ -935,7 +951,7 @@ var NullCursorStreamSchema = Schema.Struct({ cursor: Schema.Null }).check(exactK
|
|
|
935
951
|
var StreamsSchema = Schema.Struct({ control: Schema.Struct({ cursor: Schema.NullOr(ControlCursorSchema) }).check(exactKeys(["cursor"])), media: NullCursorStreamSchema, presence: NullCursorStreamSchema, requests: NullCursorStreamSchema });
|
|
936
952
|
var HelloFrameSchema = Schema.Struct({ type: Schema.Literal("hello"), protocol: Schema.Literal(1), token: boundedUtf8String(8192), streams: StreamsSchema, ...HelloCorrelationFields }).check(boundedFrame(65536));
|
|
937
953
|
var ChatCursorSchema = Schema.Struct({ after_sequence: Schema.NullOr(UnsignedDecimalSchema), retained_floor_sequence: Schema.NullOr(UnsignedDecimalSchema) }).check(exactKeys(["after_sequence", "retained_floor_sequence"]));
|
|
938
|
-
var CollaborationHelloExtensionSchema = Schema.Struct({ name: Schema.
|
|
954
|
+
var CollaborationHelloExtensionSchema = Schema.Struct({ name: Schema.Literals(["collaboration_v1", "collaboration_v2"]), chat_cursor: ChatCursorSchema }).check(exactKeys(["name", "chat_cursor"]));
|
|
939
955
|
var ExtendedHelloFrameSchema = Schema.Struct({ type: Schema.Literal("hello"), protocol: Schema.Literal(1), token: boundedUtf8String(8192), streams: StreamsSchema, extensions: Schema.Tuple([CollaborationHelloExtensionSchema]), ...HelloCorrelationFields }).check(boundedFrame(65536));
|
|
940
956
|
var DeliveryAckFrameSchema = Schema.Struct({ type: Schema.Literal("delivery_ack"), stream: Schema.Literal("control"), revision: PositiveIntegerSchema, state_digest: StateDigestSchema });
|
|
941
957
|
var RecoveryAckFrameSchema = Schema.Struct({ type: Schema.Literal("recovery_ack"), recovery_id: UuidSchema, revision: NonNegativeIntegerSchema, state_digest: StateDigestSchema });
|
|
@@ -946,12 +962,9 @@ var SetDisplayNameCommandFrameSchema = Schema.Struct({
|
|
|
946
962
|
name: Schema.Literal("set_display_name"),
|
|
947
963
|
payload: Schema.Struct({ display_name: boundedUtf8String(256, 1).check(Schema.makeFilter((value) => value.length > 0 && value === value.trim() ? void 0 : { path: [], issue: "must be non-empty without surrounding whitespace" })) })
|
|
948
964
|
}).check(boundedFrame(65536));
|
|
949
|
-
var SetAdmissionPolicyCommandFrameSchema = Schema.Struct({
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
name: Schema.Literal("set_admission_policy"),
|
|
953
|
-
payload: Schema.Struct({ policy: Schema.Union([Schema.Literal("open"), Schema.Literal("knock"), Schema.Literal("members_only")]) })
|
|
954
|
-
}).check(boundedFrame(65536));
|
|
965
|
+
var SetAdmissionPolicyCommandFrameSchema = Schema.Struct({ type: Schema.Literal("command"), command_id: CommandIdSchema, name: Schema.Literal("set_admission_policy"), payload: Schema.Struct({ policy: Schema.Union([Schema.Literal("open"), Schema.Literal("knock")]) }) }).check(
|
|
966
|
+
boundedFrame(65536)
|
|
967
|
+
);
|
|
955
968
|
var AssignRolesCommandFrameSchema = Schema.Struct({
|
|
956
969
|
type: Schema.Literal("command"),
|
|
957
970
|
command_id: CommandIdSchema,
|
|
@@ -975,7 +988,33 @@ var LiveTargetFrameSchema = Schema.Struct({ type: Schema.Literal("live_target"),
|
|
|
975
988
|
var DirectedRequestNameSchema = Schema.Union([Schema.Literal("request_unmute"), Schema.Literal("request_start_camera")]);
|
|
976
989
|
var DirectedRequestSendFrameSchema = Schema.Struct({ type: Schema.Literal("directed_request"), request_id: RequestIdSchema, name: DirectedRequestNameSchema, target_participant_id: UuidSchema });
|
|
977
990
|
var RequestAckFrameSchema = Schema.Struct({ type: Schema.Literal("request_ack"), request_id: RequestIdSchema });
|
|
978
|
-
var
|
|
991
|
+
var ReactionValues = ["\u{1F44D}", "\u2764\uFE0F", "\u{1F602}", "\u{1F62E}", "\u{1F389}", "\u{1F44F}", "\u{1F600}", "\u{1F605}", "\u{1F64F}", "\u{1F525}", "\u2705", "\u{1F440}", "\u{1F4AF}", "\u{1F914}", "\u{1F622}", "\u{1F64C}", "\u{1F680}", "\u{1F44C}", "\u{1F60D}", "\u{1F91D}", "\u{1F4A1}", "\u2B50", "\u{1F60E}", "\u{1F973}"];
|
|
992
|
+
var ReactionSchema = Schema.Union([
|
|
993
|
+
Schema.Literal("\u{1F44D}"),
|
|
994
|
+
Schema.Literal("\u2764\uFE0F"),
|
|
995
|
+
Schema.Literal("\u{1F602}"),
|
|
996
|
+
Schema.Literal("\u{1F62E}"),
|
|
997
|
+
Schema.Literal("\u{1F389}"),
|
|
998
|
+
Schema.Literal("\u{1F44F}"),
|
|
999
|
+
Schema.Literal("\u{1F600}"),
|
|
1000
|
+
Schema.Literal("\u{1F605}"),
|
|
1001
|
+
Schema.Literal("\u{1F64F}"),
|
|
1002
|
+
Schema.Literal("\u{1F525}"),
|
|
1003
|
+
Schema.Literal("\u2705"),
|
|
1004
|
+
Schema.Literal("\u{1F440}"),
|
|
1005
|
+
Schema.Literal("\u{1F4AF}"),
|
|
1006
|
+
Schema.Literal("\u{1F914}"),
|
|
1007
|
+
Schema.Literal("\u{1F622}"),
|
|
1008
|
+
Schema.Literal("\u{1F64C}"),
|
|
1009
|
+
Schema.Literal("\u{1F680}"),
|
|
1010
|
+
Schema.Literal("\u{1F44C}"),
|
|
1011
|
+
Schema.Literal("\u{1F60D}"),
|
|
1012
|
+
Schema.Literal("\u{1F91D}"),
|
|
1013
|
+
Schema.Literal("\u{1F4A1}"),
|
|
1014
|
+
Schema.Literal("\u2B50"),
|
|
1015
|
+
Schema.Literal("\u{1F60E}"),
|
|
1016
|
+
Schema.Literal("\u{1F973}")
|
|
1017
|
+
]);
|
|
979
1018
|
var ReactionSendFrameSchema = Schema.Struct({ type: Schema.Literal("reaction_send"), operation_id: RequestIdSchema, reaction: ReactionSchema }).check(boundedFrame(SyncProtocolLimits.collaborationFrameBytes));
|
|
980
1019
|
var ChatTextSchema = boundedUtf8String(16384).check(Schema.makeFilter((value) => Array.from(value).length <= 4e3 ? void 0 : { path: ["text"], issue: "must fit the Unicode scalar limit" }));
|
|
981
1020
|
var ChatAttachmentMimeTypeSchema = Schema.Union([
|
|
@@ -1003,6 +1042,7 @@ var ChatSendFrameSchema = Schema.Struct({ type: Schema.Literal("chat_send"), cli
|
|
|
1003
1042
|
Schema.makeFilter((frame) => frame.text.length > 0 || frame.attachment_ids.length > 0 ? void 0 : { path: [], issue: "must contain text or at least one attachment" }),
|
|
1004
1043
|
boundedFrame(SyncProtocolLimits.collaborationFrameBytes)
|
|
1005
1044
|
);
|
|
1045
|
+
var ChatReactionSetFrameSchema = Schema.Struct({ type: Schema.Literal("chat_reaction_set"), request_id: RequestIdSchema, message_id: UuidSchema, emoji: ReactionSchema, on: Schema.Boolean }).check(boundedFrame(SyncProtocolLimits.collaborationFrameBytes));
|
|
1006
1046
|
var ChatReadSetFrameSchema = Schema.Struct({ type: Schema.Literal("chat_read_set"), request_id: RequestIdSchema, sequence: UnsignedDecimalSchema }).check(boundedFrame(SyncProtocolLimits.collaborationFrameBytes));
|
|
1007
1047
|
var ChatPageDirectionSchema = Schema.Union([Schema.Literal("older"), Schema.Literal("newer")]);
|
|
1008
1048
|
var ChatPageRequestFrameSchema = Schema.Struct({ type: Schema.Literal("chat_page_request"), request_id: RequestIdSchema, direction: ChatPageDirectionSchema, cursor_sequence: Schema.NullOr(UnsignedDecimalSchema), limit: PositiveIntegerSchema }).check(
|
|
@@ -1335,7 +1375,7 @@ var CollaborationCapabilitiesSchema = Schema.Array(CollaborationCapabilitySchema
|
|
|
1335
1375
|
);
|
|
1336
1376
|
var ChatReadReceiptSchema = Schema.Struct({ participant_id: UuidSchema, participant_generation: PositiveIntegerSchema, sequence: UnsignedDecimalSchema, read_at: boundedUtf8String(64, 1) }).check(exactKeys(["participant_id", "participant_generation", "sequence", "read_at"]));
|
|
1337
1377
|
var CollaborationWelcomeExtensionSchema = Schema.Struct({
|
|
1338
|
-
name: Schema.
|
|
1378
|
+
name: Schema.Literals(["collaboration_v1", "collaboration_v2"]),
|
|
1339
1379
|
capabilities: CollaborationCapabilitiesSchema,
|
|
1340
1380
|
participant_capabilities: Schema.Record(UuidSchema, CollaborationCapabilitiesSchema),
|
|
1341
1381
|
chat_head_sequence: Schema.NullOr(UnsignedDecimalSchema),
|
|
@@ -1455,6 +1495,18 @@ var ChatAttachmentSchema = Schema.Struct({ attachment_id: UuidSchema, file_name:
|
|
|
1455
1495
|
Schema.makeFilter((attachment) => attachment.byte_length <= SyncProtocolLimits.chatAttachmentMaxBytes ? void 0 : { path: ["byte_length"], issue: "must fit the attachment byte limit" }),
|
|
1456
1496
|
exactKeys(["attachment_id", "file_name", "mime_type", "byte_length"])
|
|
1457
1497
|
);
|
|
1498
|
+
var ChatReactionSchema = Schema.Struct({ emoji: ReactionSchema, participant_ids: Schema.Array(UuidSchema).check(Schema.isMinLength(1), Schema.isMaxLength(SyncProtocolLimits.chatReactionMaxMemberships)) }).check(exactKeys(["emoji", "participant_ids"]));
|
|
1499
|
+
var ChatReactionsSchema = Schema.Array(ChatReactionSchema).check(
|
|
1500
|
+
Schema.isMaxLength(24),
|
|
1501
|
+
Schema.makeFilter(
|
|
1502
|
+
(groups) => new Set(groups.map((group) => group.emoji)).size === groups.length && groups.reduce((count, group) => count + group.participant_ids.length, 0) <= SyncProtocolLimits.chatReactionMaxMemberships && groups.every((group) => new Set(group.participant_ids).size === group.participant_ids.length) ? void 0 : { path: [], issue: "must contain unique bounded reaction memberships" }
|
|
1503
|
+
)
|
|
1504
|
+
);
|
|
1505
|
+
var ChatReactionsFrameSchema = Schema.Struct({ type: Schema.Literal("chat_reactions"), message_id: UuidSchema, revision: UnsignedDecimalSchema, reactions: ChatReactionsSchema, ...ServerCorrelationFields }).check(boundedFrame(SyncProtocolLimits.collaborationFrameBytes));
|
|
1506
|
+
var ChatReactionResultFrameSchema = Schema.Union([
|
|
1507
|
+
Schema.Struct({ type: Schema.Literal("chat_reaction_result"), request_id: RequestIdSchema, outcome: Schema.Literal("accepted"), state: ChatReactionsFrameSchema, ...ServerCorrelationFields }),
|
|
1508
|
+
Schema.Struct({ type: Schema.Literal("chat_reaction_result"), request_id: RequestIdSchema, outcome: Schema.Literal("rejected"), error_code: CollaborationErrorCodeSchema, ...ServerCorrelationFields })
|
|
1509
|
+
]);
|
|
1458
1510
|
var ChatMessageFrameSchema = Schema.Struct({
|
|
1459
1511
|
type: Schema.Literal("chat_message"),
|
|
1460
1512
|
message_id: UuidSchema,
|
|
@@ -1463,6 +1515,8 @@ var ChatMessageFrameSchema = Schema.Struct({
|
|
|
1463
1515
|
participant_id: UuidSchema,
|
|
1464
1516
|
display_name: boundedUtf8String(256, 1),
|
|
1465
1517
|
text: ChatTextSchema,
|
|
1518
|
+
reactions: Schema.optional(ChatReactionsSchema),
|
|
1519
|
+
reaction_revision: Schema.optional(UnsignedDecimalSchema),
|
|
1466
1520
|
attachments: Schema.Array(ChatAttachmentSchema).check(Schema.isMaxLength(SyncProtocolLimits.chatAttachmentMaxItems)),
|
|
1467
1521
|
created_at: boundedUtf8String(64, 1),
|
|
1468
1522
|
...ServerCorrelationFields
|
|
@@ -1534,6 +1588,7 @@ var SyncV1ClientFrameSchema = Schema.Unknown.check(Schema.makeFilter((frame) =>
|
|
|
1534
1588
|
ChatSendFrameSchema,
|
|
1535
1589
|
ChatPageRequestFrameSchema,
|
|
1536
1590
|
ChatReadSetFrameSchema,
|
|
1591
|
+
ChatReactionSetFrameSchema,
|
|
1537
1592
|
DeliveryAckFrameSchema,
|
|
1538
1593
|
RecoveryAckFrameSchema,
|
|
1539
1594
|
PingFrameSchema
|
|
@@ -1563,6 +1618,8 @@ var SyncV1ServerFrameSchema = Schema.Unknown.check(Schema.makeFilter((frame) =>
|
|
|
1563
1618
|
ChatHeadFrameSchema,
|
|
1564
1619
|
ChatReadReceiptFrameSchema,
|
|
1565
1620
|
ChatReadResultFrameSchema,
|
|
1621
|
+
ChatReactionsFrameSchema,
|
|
1622
|
+
ChatReactionResultFrameSchema,
|
|
1566
1623
|
RetryableErrorFrameSchema,
|
|
1567
1624
|
ErrorFrameSchema,
|
|
1568
1625
|
PongFrameSchema
|
|
@@ -1598,6 +1655,8 @@ function reactionFromFrame(frame) {
|
|
|
1598
1655
|
}
|
|
1599
1656
|
function chatMessageFromFrame(frame) {
|
|
1600
1657
|
return {
|
|
1658
|
+
reactions: chatReactionsFromWire(frame.reactions ?? []),
|
|
1659
|
+
reactionRevision: frame.reaction_revision ?? "0",
|
|
1601
1660
|
messageId: frame.message_id,
|
|
1602
1661
|
clientMessageId: frame.client_message_id,
|
|
1603
1662
|
sequence: frame.sequence,
|
|
@@ -1621,6 +1680,12 @@ function chatReadReceiptFromFrame(frame) {
|
|
|
1621
1680
|
readAt: frame.read_at
|
|
1622
1681
|
};
|
|
1623
1682
|
}
|
|
1683
|
+
function chatReactionsFromWire(groups) {
|
|
1684
|
+
return groups.map((group) => ({ emoji: group.emoji, count: group.participant_ids.length, participantIds: [...group.participant_ids] }));
|
|
1685
|
+
}
|
|
1686
|
+
function chatReactionsFromFrame(frame) {
|
|
1687
|
+
return { messageId: frame.message_id, revision: frame.revision, reactions: chatReactionsFromWire(frame.reactions) };
|
|
1688
|
+
}
|
|
1624
1689
|
|
|
1625
1690
|
// src/sync/v1-deferred.ts
|
|
1626
1691
|
function resolveV1Deferred(deferred, value) {
|
|
@@ -1912,6 +1977,7 @@ var V1CollaborationState = class {
|
|
|
1912
1977
|
#reactions = /* @__PURE__ */ new Map();
|
|
1913
1978
|
#chatSends = /* @__PURE__ */ new Map();
|
|
1914
1979
|
#chatPages = /* @__PURE__ */ new Map();
|
|
1980
|
+
#chatReactions = /* @__PURE__ */ new Map();
|
|
1915
1981
|
#chatReads = /* @__PURE__ */ new Map();
|
|
1916
1982
|
#state;
|
|
1917
1983
|
#participantCapabilities = {};
|
|
@@ -1921,7 +1987,7 @@ var V1CollaborationState = class {
|
|
|
1921
1987
|
this.#options = options;
|
|
1922
1988
|
const cursor = options.request === false ? { afterSequence: null, retainedFloorSequence: null } : options.request?.chatCursor ?? { afterSequence: null, retainedFloorSequence: null };
|
|
1923
1989
|
this.#chatAfterSequence = cursor.afterSequence;
|
|
1924
|
-
this.#requestedVersion = options.request === false ? 0 : 1;
|
|
1990
|
+
this.#requestedVersion = options.request === false ? 0 : options.request?.name === "collaboration_v2" ? 2 : 1;
|
|
1925
1991
|
this.#state = {
|
|
1926
1992
|
negotiated: false,
|
|
1927
1993
|
version: null,
|
|
@@ -1936,7 +2002,7 @@ var V1CollaborationState = class {
|
|
|
1936
2002
|
}
|
|
1937
2003
|
get helloExtension() {
|
|
1938
2004
|
if (this.#requestedVersion === 0) return null;
|
|
1939
|
-
return { name: "collaboration_v1", chat_cursor: { after_sequence: this.#chatAfterSequence, retained_floor_sequence: this.#state.retainedFloorSequence } };
|
|
2005
|
+
return { name: this.#requestedVersion === 2 ? "collaboration_v2" : "collaboration_v1", chat_cursor: { after_sequence: this.#chatAfterSequence, retained_floor_sequence: this.#state.retainedFloorSequence } };
|
|
1940
2006
|
}
|
|
1941
2007
|
getState() {
|
|
1942
2008
|
return { ...this.#state, capabilities: [...this.#state.capabilities], readReceipts: this.#state.readReceipts.map((receipt) => ({ ...receipt })) };
|
|
@@ -1951,7 +2017,7 @@ var V1CollaborationState = class {
|
|
|
1951
2017
|
acceptWelcome(frame) {
|
|
1952
2018
|
if ("extensions" in frame) {
|
|
1953
2019
|
const extension = frame.extensions[0];
|
|
1954
|
-
const version = 1;
|
|
2020
|
+
const version = extension.name === "collaboration_v2" ? 2 : 1;
|
|
1955
2021
|
if (this.#requestedVersion !== version) throw new V1ReplicaError("collaboration welcome version does not match the requested extension");
|
|
1956
2022
|
this.#state = {
|
|
1957
2023
|
negotiated: true,
|
|
@@ -1989,9 +2055,30 @@ var V1CollaborationState = class {
|
|
|
1989
2055
|
const frame = { type: "chat_send", client_message_id: clientMessageId, text: input.text, attachment_ids: attachments.map((attachment) => attachment.attachmentId) };
|
|
1990
2056
|
return this.#sendTrackedRequest(clientMessageId, frame, this.#chatSends);
|
|
1991
2057
|
}
|
|
2058
|
+
reactToChatMessage(input) {
|
|
2059
|
+
this.#assertReady("sendChat");
|
|
2060
|
+
if (this.#state.version !== 2) throw new V1SyncError("message reactions require collaboration_v2", "collaboration_unavailable");
|
|
2061
|
+
this.#assertCapacity();
|
|
2062
|
+
const requestId = this.#nextRequestId();
|
|
2063
|
+
return this.#sendTrackedRequest(requestId, { type: "chat_reaction_set", request_id: requestId, message_id: input.messageId, emoji: input.emoji, on: input.on }, this.#chatReactions);
|
|
2064
|
+
}
|
|
2065
|
+
chatReactions(frame) {
|
|
2066
|
+
this.#requireNegotiated();
|
|
2067
|
+
this.#emit({ type: "chat_reactions", state: chatReactionsFromFrame(frame) });
|
|
2068
|
+
}
|
|
2069
|
+
chatReactionResult(frame) {
|
|
2070
|
+
this.#requireLive();
|
|
2071
|
+
this.#requireNegotiated();
|
|
2072
|
+
const deferred = this.#chatReactions.get(frame.request_id);
|
|
2073
|
+
if (!deferred) return;
|
|
2074
|
+
this.#chatReactions.delete(frame.request_id);
|
|
2075
|
+
if (frame.outcome === "accepted") {
|
|
2076
|
+
this.chatReactions(frame.state);
|
|
2077
|
+
resolveV1Deferred(deferred, chatReactionsFromFrame(frame.state));
|
|
2078
|
+
} else rejectV1Deferred(deferred, new V1SyncError(frame.error_code, frame.error_code));
|
|
2079
|
+
}
|
|
1992
2080
|
markChatRead(sequence) {
|
|
1993
2081
|
this.#assertReady();
|
|
1994
|
-
if (this.#state.version !== 1) throw new V1SyncError("durable chat read receipts require collaboration_v1", "collaboration_unavailable");
|
|
1995
2082
|
this.#assertCapacity();
|
|
1996
2083
|
const requestId = this.#nextRequestId();
|
|
1997
2084
|
const frame = { type: "chat_read_set", request_id: requestId, sequence };
|
|
@@ -2067,14 +2154,14 @@ var V1CollaborationState = class {
|
|
|
2067
2154
|
}
|
|
2068
2155
|
chatReadReceipt(frame) {
|
|
2069
2156
|
this.#requireLive();
|
|
2070
|
-
this.#
|
|
2157
|
+
this.#requireNegotiated();
|
|
2071
2158
|
const receipt = chatReadReceiptFromFrame(frame);
|
|
2072
2159
|
this.#rememberChatReadReceipt(receipt);
|
|
2073
2160
|
this.#emit({ type: "chat_read_receipt", receipt });
|
|
2074
2161
|
}
|
|
2075
2162
|
chatReadResult(frame) {
|
|
2076
2163
|
this.#requireLive();
|
|
2077
|
-
this.#
|
|
2164
|
+
this.#requireNegotiated();
|
|
2078
2165
|
const deferred = this.#chatReads.get(frame.request_id);
|
|
2079
2166
|
if (!deferred) return;
|
|
2080
2167
|
this.#chatReads.delete(frame.request_id);
|
|
@@ -2094,6 +2181,8 @@ var V1CollaborationState = class {
|
|
|
2094
2181
|
this.#reactions.clear();
|
|
2095
2182
|
this.#chatSends.clear();
|
|
2096
2183
|
this.#chatPages.clear();
|
|
2184
|
+
for (const deferred of this.#chatReactions.values()) rejectV1Deferred(deferred, new V1SyncError(code, code));
|
|
2185
|
+
this.#chatReactions.clear();
|
|
2097
2186
|
this.#chatReads.clear();
|
|
2098
2187
|
}
|
|
2099
2188
|
#sendTrackedRequest(requestId, frame, pending) {
|
|
@@ -2130,10 +2219,10 @@ var V1CollaborationState = class {
|
|
|
2130
2219
|
}
|
|
2131
2220
|
#assertCapacity() {
|
|
2132
2221
|
const maximum = Math.min(this.#options.maxPendingRequests ?? MAX_COLLABORATION_REQUESTS_IN_FLIGHT, MAX_COLLABORATION_REQUESTS_IN_FLIGHT);
|
|
2133
|
-
if (this.#reactions.size + this.#chatSends.size + this.#chatPages.size + this.#chatReads.size >= maximum) throw new V1SyncError("collaboration in-flight capacity exceeded", "capacity");
|
|
2222
|
+
if (this.#reactions.size + this.#chatSends.size + this.#chatPages.size + this.#chatReads.size + this.#chatReactions.size >= maximum) throw new V1SyncError("collaboration in-flight capacity exceeded", "capacity");
|
|
2134
2223
|
}
|
|
2135
2224
|
#assertRequestIdAvailable(id) {
|
|
2136
|
-
if (this.#reactions.has(id) || this.#chatSends.has(id) || this.#chatPages.has(id) || this.#chatReads.has(id)) throw new V1SyncError("collaboration request ID is already pending", "request_id_conflict");
|
|
2225
|
+
if (this.#reactions.has(id) || this.#chatSends.has(id) || this.#chatPages.has(id) || this.#chatReads.has(id) || this.#chatReactions.has(id)) throw new V1SyncError("collaboration request ID is already pending", "request_id_conflict");
|
|
2137
2226
|
}
|
|
2138
2227
|
#nextRequestId() {
|
|
2139
2228
|
const id = this.#options.requestIds?.next() ?? crypto.randomUUID();
|
|
@@ -2146,10 +2235,6 @@ var V1CollaborationState = class {
|
|
|
2146
2235
|
#requireNegotiated() {
|
|
2147
2236
|
if (!this.#state.negotiated) throw new V1ReplicaError("collaboration frame arrived without a negotiated extension");
|
|
2148
2237
|
}
|
|
2149
|
-
#requireVersion(version) {
|
|
2150
|
-
this.#requireNegotiated();
|
|
2151
|
-
if (this.#state.version !== version) throw new V1ReplicaError("collaboration_v1 frame arrived on a different extension version");
|
|
2152
|
-
}
|
|
2153
2238
|
#emit(event) {
|
|
2154
2239
|
for (const listener of this.#listeners) listener(event);
|
|
2155
2240
|
}
|
|
@@ -2858,6 +2943,9 @@ var V1SyncClient = class {
|
|
|
2858
2943
|
stateChanged: () => this.#emit()
|
|
2859
2944
|
});
|
|
2860
2945
|
}
|
|
2946
|
+
restartTransport() {
|
|
2947
|
+
this.#recover("lifecycle transport deadline");
|
|
2948
|
+
}
|
|
2861
2949
|
async start() {
|
|
2862
2950
|
if (this.#started) return;
|
|
2863
2951
|
this.#started = true;
|
|
@@ -2937,6 +3025,9 @@ var V1SyncClient = class {
|
|
|
2937
3025
|
sendChatMessage(input) {
|
|
2938
3026
|
return this.#collaborationState.sendChatMessage(input);
|
|
2939
3027
|
}
|
|
3028
|
+
reactToChatMessage(input) {
|
|
3029
|
+
return this.#collaborationState.reactToChatMessage(input);
|
|
3030
|
+
}
|
|
2940
3031
|
markChatRead(sequence) {
|
|
2941
3032
|
return this.#collaborationState.markChatRead(sequence);
|
|
2942
3033
|
}
|
|
@@ -3029,12 +3120,10 @@ var V1SyncClient = class {
|
|
|
3029
3120
|
if (!this.#started || !this.#transportAvailable || this.#socket) return;
|
|
3030
3121
|
this.#phase = { phase: "connecting" };
|
|
3031
3122
|
this.#emit();
|
|
3032
|
-
recordReconnect(this.#options.recordReconnect, "sync_attempt", { attempt: this.#reconnectAttempt });
|
|
3033
3123
|
const socket = this.#options.webSocket.connect(this.#options.url);
|
|
3034
3124
|
const connectionGeneration = ++this.#connectionGeneration;
|
|
3035
3125
|
this.#socket = socket;
|
|
3036
3126
|
socket.onopen = () => {
|
|
3037
|
-
recordReconnect(this.#options.recordReconnect, "sync_socket_open");
|
|
3038
3127
|
void this.#authenticate(socket);
|
|
3039
3128
|
};
|
|
3040
3129
|
socket.onmessage = (event) => {
|
|
@@ -3062,8 +3151,7 @@ var V1SyncClient = class {
|
|
|
3062
3151
|
media: { cursor: null },
|
|
3063
3152
|
presence: { cursor: null },
|
|
3064
3153
|
requests: { cursor: null }
|
|
3065
|
-
}
|
|
3066
|
-
...this.#options.telemetry ? syncTelemetryCorrelation(this.#options.telemetry) : {}
|
|
3154
|
+
}
|
|
3067
3155
|
};
|
|
3068
3156
|
const collaborationExtension = this.#collaborationState.helloExtension;
|
|
3069
3157
|
if (!collaborationExtension) {
|
|
@@ -3126,6 +3214,10 @@ var V1SyncClient = class {
|
|
|
3126
3214
|
const control = this.#requireControl();
|
|
3127
3215
|
this.#send({ type: "delivery_ack", stream: "control", revision: control.revision, state_digest: control.stateDigest });
|
|
3128
3216
|
}
|
|
3217
|
+
if (frame.name === "participant_left" && frame.payload.participant_id === this.#participantId) {
|
|
3218
|
+
this.#phase = { phase: "terminal", terminalReason: frame.payload.reason === "removed" ? "participant_removed" : "participant_inactive" };
|
|
3219
|
+
this.#socket?.close(1e3, "participant inactive");
|
|
3220
|
+
}
|
|
3129
3221
|
this.#emit();
|
|
3130
3222
|
return;
|
|
3131
3223
|
case "ack":
|
|
@@ -3163,6 +3255,12 @@ var V1SyncClient = class {
|
|
|
3163
3255
|
case "chat_head":
|
|
3164
3256
|
this.#collaborationState.chatHead(frame);
|
|
3165
3257
|
return;
|
|
3258
|
+
case "chat_reactions":
|
|
3259
|
+
this.#collaborationState.chatReactions(frame);
|
|
3260
|
+
break;
|
|
3261
|
+
case "chat_reaction_result":
|
|
3262
|
+
this.#collaborationState.chatReactionResult(frame);
|
|
3263
|
+
break;
|
|
3166
3264
|
case "chat_read_receipt":
|
|
3167
3265
|
this.#collaborationState.chatReadReceipt(frame);
|
|
3168
3266
|
return;
|
|
@@ -3199,7 +3297,6 @@ var V1SyncClient = class {
|
|
|
3199
3297
|
if (frame.mode === "replay" && (!this.#control || this.#control.revision >= frame.head.revision)) throw new V1ReplicaError("invalid replay welcome");
|
|
3200
3298
|
if (frame.mode === "up_to_date" && !sameHead(this.#control, frame.head)) throw new V1ReplicaError("up-to-date head mismatch");
|
|
3201
3299
|
if (frame.mode === "snapshot" && !sameHead(this.#control, frame.head)) throw new V1ReplicaError("snapshot head mismatch");
|
|
3202
|
-
recordReconnect(this.#options.recordReconnect, "sync_reconnected");
|
|
3203
3300
|
this.#recovery = { id: frame.recovery_id, head: frame.head, replayEvents: 0, replayBytes: 0, controlComplete: false };
|
|
3204
3301
|
if (frame.mode === "snapshot") this.#ackRecovery();
|
|
3205
3302
|
this.#emit();
|
|
@@ -3235,10 +3332,11 @@ var V1SyncClient = class {
|
|
|
3235
3332
|
previous.find((candidate) => mediaKey(candidate) === mediaKey(item)),
|
|
3236
3333
|
item
|
|
3237
3334
|
);
|
|
3238
|
-
this.#options.mediaPlane?.remotePublicationsChanged?.();
|
|
3335
|
+
if (!this.#mediaEnded()) this.#options.mediaPlane?.remotePublicationsChanged?.();
|
|
3239
3336
|
} else {
|
|
3240
3337
|
this.#presence = { projectionId: frame.projection_id, sequence: 0, items: frame.items.map(presenceItem) };
|
|
3241
3338
|
this.#presenceEventEvidence.clear();
|
|
3339
|
+
this.#notifyRemoteParticipantsChanged();
|
|
3242
3340
|
}
|
|
3243
3341
|
this.#enterLiveIfReady();
|
|
3244
3342
|
this.#emit();
|
|
@@ -3252,18 +3350,26 @@ var V1SyncClient = class {
|
|
|
3252
3350
|
this.#media = updateProjection(this.#media, frame.projection_id, frame.sequence, item, mediaKey);
|
|
3253
3351
|
rememberBoundedEvidence(this.#mediaEventEvidence, frame.sequence, frameSignature(frame), MAX_PROJECTION_EVENT_EVIDENCE);
|
|
3254
3352
|
this.#notifyRemotePublicationResumed(previous, item);
|
|
3255
|
-
if (item.participantId !== this.#participantId && (previous?.enabled !== item.enabled || previous?.publicationId !== item.publicationId)) {
|
|
3353
|
+
if (!this.#mediaEnded() && item.participantId !== this.#participantId && (previous?.enabled !== item.enabled || previous?.publicationId !== item.publicationId)) {
|
|
3256
3354
|
this.#options.mediaPlane?.remotePublicationsChanged?.();
|
|
3257
3355
|
}
|
|
3258
3356
|
} else {
|
|
3259
3357
|
if (this.#acceptProjectionDuplicate(this.#presence, this.#presenceEventEvidence, frame)) return;
|
|
3260
3358
|
this.#presence = updateProjection(this.#presence, frame.projection_id, frame.sequence, presenceItem(frame.item), (item) => item.participantId);
|
|
3261
3359
|
rememberBoundedEvidence(this.#presenceEventEvidence, frame.sequence, frameSignature(frame), MAX_PROJECTION_EVENT_EVIDENCE);
|
|
3360
|
+
this.#notifyRemoteParticipantsChanged();
|
|
3262
3361
|
}
|
|
3263
3362
|
this.#emit();
|
|
3264
3363
|
}
|
|
3364
|
+
#notifyRemoteParticipantsChanged() {
|
|
3365
|
+
if (this.#presence && !this.#mediaEnded()) this.#options.mediaPlane?.remoteParticipantsChanged?.(this.#presence.items.filter((item) => item.state === "connected").map((item) => item.participantId));
|
|
3366
|
+
}
|
|
3367
|
+
#mediaEnded() {
|
|
3368
|
+
return this.#control?.status === "ended" || this.#phase.phase === "terminal";
|
|
3369
|
+
}
|
|
3265
3370
|
#notifyRemotePublicationResumed(previous, current) {
|
|
3266
|
-
if (
|
|
3371
|
+
if (this.#mediaEnded()) return;
|
|
3372
|
+
if (previous?.enabled === false && current.enabled && current.publicationId && current.participantId !== this.#participantId) {
|
|
3267
3373
|
this.#options.mediaPlane?.remotePublicationResumed?.(current.publicationId);
|
|
3268
3374
|
}
|
|
3269
3375
|
}
|
|
@@ -3282,7 +3388,6 @@ var V1SyncClient = class {
|
|
|
3282
3388
|
}
|
|
3283
3389
|
#enterLiveIfReady() {
|
|
3284
3390
|
if (!this.#recovery?.controlComplete || !this.#media || !this.#presence) return;
|
|
3285
|
-
recordReconnect(this.#options.recordReconnect, "state_resynced");
|
|
3286
3391
|
this.#recovery = null;
|
|
3287
3392
|
this.#phase = { phase: "live" };
|
|
3288
3393
|
this.#reconnectAttempt = 0;
|
|
@@ -3317,7 +3422,6 @@ var V1SyncClient = class {
|
|
|
3317
3422
|
}
|
|
3318
3423
|
#disconnected(socket) {
|
|
3319
3424
|
if (socket !== this.#socket) return;
|
|
3320
|
-
recordReconnect(this.#options.recordReconnect, "sync_loss");
|
|
3321
3425
|
this.#socket = null;
|
|
3322
3426
|
this.#recovery = null;
|
|
3323
3427
|
this.#clearHeartbeat();
|
|
@@ -3336,12 +3440,9 @@ var V1SyncClient = class {
|
|
|
3336
3440
|
const exponentialAttempt = configuredDelay === void 0 ? Math.max(0, this.#reconnectAttempt - FAST_RECONNECT_ATTEMPTS + 1) : this.#reconnectAttempt;
|
|
3337
3441
|
const baseDelay = configuredDelay === 0 ? 0 : Math.min(MAX_RECONNECT_DELAY_MS, (configuredDelay ?? DEFAULT_RECONNECT_DELAY_MS) * 2 ** Math.min(exponentialAttempt, 5));
|
|
3338
3442
|
const delay = configuredDelay === void 0 ? Math.round(baseDelay * (0.8 + 0.4 * Math.random())) : baseDelay;
|
|
3339
|
-
recordReconnect(this.#options.recordReconnect, "sync_backoff", { boundary: "start", delay_ms: delay, attempt: this.#reconnectAttempt });
|
|
3340
3443
|
this.#reconnectAttempt += 1;
|
|
3341
|
-
const backoffStartedAt = this.#now();
|
|
3342
3444
|
this.#reconnectTimer = this.#clock().setTimeout(() => {
|
|
3343
3445
|
this.#reconnectTimer = void 0;
|
|
3344
|
-
recordReconnect(this.#options.recordReconnect, "sync_backoff", { boundary: "end", duration_ms: Math.max(0, this.#now() - backoffStartedAt) });
|
|
3345
3446
|
this.#connect();
|
|
3346
3447
|
}, delay);
|
|
3347
3448
|
}
|
|
@@ -3352,7 +3453,6 @@ var V1SyncClient = class {
|
|
|
3352
3453
|
this.#disconnected(socket);
|
|
3353
3454
|
}
|
|
3354
3455
|
#handleLifecycle(event) {
|
|
3355
|
-
recordReconnect(this.#options.recordReconnect, "network_change", { lifecycle: event });
|
|
3356
3456
|
if (event === "online" || event === "offline") this.#online = event === "online";
|
|
3357
3457
|
else this.#active = event === "active";
|
|
3358
3458
|
this.#transportAvailable = this.#online && this.#active;
|
|
@@ -3524,7 +3624,7 @@ function copyPublication(publication) {
|
|
|
3524
3624
|
return { ...publication };
|
|
3525
3625
|
}
|
|
3526
3626
|
function validMediaPublication(publication) {
|
|
3527
|
-
return typeof publication.participantId === "string" && publication.participantId.length > 0 && (publication.source === "microphone" || publication.source === "camera" || publication.source === "screen") && typeof publication.enabled === "boolean" && (publication.publicationId === null || typeof publication.publicationId === "string") && (!publication.enabled || publication.publicationId !== null);
|
|
3627
|
+
return typeof publication.participantId === "string" && publication.participantId.length > 0 && (publication.source === "microphone" || publication.source === "camera" || publication.source === "screen" || publication.source === "screen_audio") && typeof publication.enabled === "boolean" && (publication.publicationId === null || typeof publication.publicationId === "string") && (!publication.enabled || publication.publicationId !== null);
|
|
3528
3628
|
}
|
|
3529
3629
|
function assertV1Url(value) {
|
|
3530
3630
|
const url = new URL(value);
|
|
@@ -3673,6 +3773,11 @@ function createV1SyncClient(options) {
|
|
|
3673
3773
|
}
|
|
3674
3774
|
|
|
3675
3775
|
export {
|
|
3776
|
+
UuidSchema,
|
|
3777
|
+
ReactionValues,
|
|
3778
|
+
ReactionSchema,
|
|
3779
|
+
ChatAttachmentMimeTypeSchema,
|
|
3780
|
+
ChatReactionSetFrameSchema,
|
|
3676
3781
|
canonicalJson,
|
|
3677
3782
|
canonicalJsonBytes,
|
|
3678
3783
|
SyncBrowserCapabilityError,
|
|
@@ -3681,7 +3786,6 @@ export {
|
|
|
3681
3786
|
createBrowserSyncLifecycle,
|
|
3682
3787
|
createReactNativeWebSocketFactory,
|
|
3683
3788
|
createReactNativeSyncLifecycle,
|
|
3684
|
-
ChatAttachmentMimeTypeSchema,
|
|
3685
3789
|
encodeV1ClientFrame,
|
|
3686
3790
|
decodeV1ServerFrame,
|
|
3687
3791
|
decodeV1ClientFrame,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createChalkEffectClient,
|
|
3
3
|
parseAccessGrant
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-2HJIJVE2.js";
|
|
5
5
|
|
|
6
6
|
// src/public-invites/client.ts
|
|
7
7
|
import { Effect } from "effect";
|
|
@@ -9,8 +9,7 @@ function createChalkPublicClient(options) {
|
|
|
9
9
|
const baseClientOptions = {
|
|
10
10
|
baseUrl: options.baseUrl,
|
|
11
11
|
credentials: options.credentials ?? (options.runtime === "react-native" ? void 0 : "include"),
|
|
12
|
-
fetch: options.fetch
|
|
13
|
-
telemetry: options.telemetry
|
|
12
|
+
fetch: options.fetch
|
|
14
13
|
};
|
|
15
14
|
const createClient = (guestCredential, requestInit) => createChalkEffectClient({
|
|
16
15
|
...baseClientOptions,
|
|
@@ -73,10 +72,6 @@ function createChalkPublicClient(options) {
|
|
|
73
72
|
})
|
|
74
73
|
);
|
|
75
74
|
};
|
|
76
|
-
const getPublicStatus = async () => {
|
|
77
|
-
const client = await Effect.runPromise(createClient(void 0));
|
|
78
|
-
return Effect.runPromise(client.default.getPublicStatus({}));
|
|
79
|
-
};
|
|
80
75
|
return {
|
|
81
76
|
prepareSpaceEntrance: async (spaceInviteToken) => {
|
|
82
77
|
const client = await Effect.runPromise(createClient(void 0));
|
|
@@ -86,7 +81,6 @@ function createChalkPublicClient(options) {
|
|
|
86
81
|
arriveBySpacePublicInvite,
|
|
87
82
|
create: createPublicSpace,
|
|
88
83
|
createPublicSpace,
|
|
89
|
-
getPublicStatus,
|
|
90
84
|
getSpacePublicInviteArrival,
|
|
91
85
|
leave: leaveSpacePublicInviteArrival,
|
|
92
86
|
leaveSpacePublicInviteArrival,
|