@q9labsai/chalk-client 4.1.8 → 4.1.9

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.
@@ -3,16 +3,16 @@ import {
3
3
  CloudflareSFUClient,
4
4
  createCloudflareSFUHTTPTransport
5
5
  } from "./chunk-C4BIONCP.js";
6
- import {
7
- AccessGrantError,
8
- requireParsedAccessGrant,
9
- validEpisodeDiagnosticCredential
10
- } from "./chunk-JPNE4K2L.js";
11
6
  import {
12
7
  createBrowserSyncLifecycle,
13
8
  createBrowserWebSocketFactory,
14
9
  createV1SyncClient
15
10
  } from "./chunk-5VXGLI3T.js";
11
+ import {
12
+ AccessGrantError,
13
+ requireParsedAccessGrant,
14
+ validEpisodeDiagnosticCredential
15
+ } from "./chunk-JPNE4K2L.js";
16
16
  import {
17
17
  createTraceContext,
18
18
  parseTraceparent
@@ -887,6 +887,7 @@ var ChalkWhiteboardV1Client = class {
887
887
  #listeners = /* @__PURE__ */ new Set();
888
888
  #operations = /* @__PURE__ */ new Map();
889
889
  #reservedOperationIds = /* @__PURE__ */ new Set();
890
+ #awaitingOperationIds = /* @__PURE__ */ new Set();
890
891
  #pendingStoreWrites = /* @__PURE__ */ new Set();
891
892
  #operationRetryTimers = /* @__PURE__ */ new Map();
892
893
  #snapshots = /* @__PURE__ */ new Map();
@@ -910,6 +911,7 @@ var ChalkWhiteboardV1Client = class {
910
911
  #initialSnapshot = null;
911
912
  #startPromise = null;
912
913
  #stopPromise = null;
914
+ #waitingForOperations = false;
913
915
  #reconnectTimer;
914
916
  #heartbeatTimer;
915
917
  #missedHeartbeats = 0;
@@ -962,6 +964,8 @@ var ChalkWhiteboardV1Client = class {
962
964
  this.#clearHeartbeat();
963
965
  this.#clearOperationRetryTimers();
964
966
  this.#clearUpdateAssemblies();
967
+ this.#awaitingOperationIds.clear();
968
+ this.#waitingForOperations = false;
965
969
  this.#socket?.close(1e3, "whiteboard subscription stopped");
966
970
  this.#socket = null;
967
971
  this.#phase = "stopped";
@@ -1226,12 +1230,21 @@ var ChalkWhiteboardV1Client = class {
1226
1230
  this.#presenting = "presenting" in frame ? frame.presenting : false;
1227
1231
  this.#publishSummary("loading", null);
1228
1232
  this.#missedHeartbeats = 0;
1229
- for (const entry of [...this.#operations.values()].sort((left, right) => compareChalkWhiteboardV1PendingOperations(left.pending, right.pending))) {
1233
+ const pendingOperations = [...this.#operations.values()].sort((left, right) => compareChalkWhiteboardV1PendingOperations(left.pending, right.pending));
1234
+ this.#awaitingOperationIds.clear();
1235
+ this.#waitingForOperations = true;
1236
+ for (const entry of pendingOperations) this.#awaitingOperationIds.add(entry.pending.operationId);
1237
+ for (const entry of pendingOperations) {
1230
1238
  this.#sendOperation(entry.pending.frame);
1231
1239
  }
1232
- void this.#requestSnapshot().catch(() => void 0);
1240
+ this.#requestSnapshotAfterOperations();
1233
1241
  this.#startHeartbeat();
1234
1242
  }
1243
+ #requestSnapshotAfterOperations() {
1244
+ if (this.#phase !== "live" || !this.#waitingForOperations || this.#awaitingOperationIds.size > 0) return;
1245
+ this.#waitingForOperations = false;
1246
+ void this.#requestSnapshot().catch(() => void 0);
1247
+ }
1235
1248
  #requestSnapshot() {
1236
1249
  const requestId = this.#nextId();
1237
1250
  const frame = { type: "request_snapshot", request_id: requestId };
@@ -1330,6 +1343,7 @@ var ChalkWhiteboardV1Client = class {
1330
1343
  this.#clearOperationRetryTimer(frame.operation_id);
1331
1344
  this.#sceneId = frame.scene_id;
1332
1345
  this.#revision = frame.revision;
1346
+ this.#awaitingOperationIds.delete(frame.operation_id);
1333
1347
  this.#publishSummary("ready", null);
1334
1348
  entry.deferred && resolveDeferred(entry.deferred, {
1335
1349
  operationId: frame.operation_id,
@@ -1337,6 +1351,7 @@ var ChalkWhiteboardV1Client = class {
1337
1351
  revision: frame.revision
1338
1352
  });
1339
1353
  void this.#store.remove(frame.operation_id).catch(() => void 0);
1354
+ this.#requestSnapshotAfterOperations();
1340
1355
  }
1341
1356
  #operationError(frame) {
1342
1357
  this.#requireLive();
@@ -1348,9 +1363,11 @@ var ChalkWhiteboardV1Client = class {
1348
1363
  }
1349
1364
  this.#operations.delete(frame.correlation_id);
1350
1365
  this.#clearOperationRetryTimer(frame.correlation_id);
1366
+ this.#awaitingOperationIds.delete(frame.correlation_id);
1351
1367
  entry.deferred && rejectDeferred(entry.deferred, error(failure(operationName(entry.pending.frame), mapErrorCode(frame.code), frame.recoverable, frame.message)));
1352
1368
  this.#publishSummary("ready", failure(operationName(entry.pending.frame), mapErrorCode(frame.code), frame.recoverable, frame.message));
1353
1369
  void this.#store.remove(frame.correlation_id).catch(() => void 0);
1370
+ this.#requestSnapshotAfterOperations();
1354
1371
  return;
1355
1372
  }
1356
1373
  const snapshot = this.#snapshots.get(frame.correlation_id);
@@ -1400,6 +1417,7 @@ var ChalkWhiteboardV1Client = class {
1400
1417
  this.#clearHeartbeat();
1401
1418
  this.#clearUpdateAssemblies();
1402
1419
  this.#phase = "connecting";
1420
+ this.#waitingForOperations = false;
1403
1421
  this.#participantId = null;
1404
1422
  this.#capabilities = [];
1405
1423
  this.#canDraw = false;
@@ -4775,7 +4793,7 @@ var makeSpaceClientCoreLayer = (options, platform = {}) => {
4775
4793
  now: baseDependencies.clock.now,
4776
4794
  setTimeout: baseDependencies.clock.setTimeout,
4777
4795
  clearTimeout: baseDependencies.clock.clearTimeout,
4778
- release: { id: "chalk-client@4.1.8" }
4796
+ release: { id: "chalk-client@4.1.9" }
4779
4797
  });
4780
4798
  const diagnosticSyncClients = /* @__PURE__ */ new Set();
4781
4799
  const dependencies = {
package/dist/effect.js CHANGED
@@ -17,8 +17,9 @@ import {
17
17
  makeSpaceClientCoreLayer,
18
18
  makeSpaceClientCoreLayerFromServices,
19
19
  makeSpaceStoreLayer
20
- } from "./chunk-V6P6EHYO.js";
20
+ } from "./chunk-TQQAPRVW.js";
21
21
  import "./chunk-C4BIONCP.js";
22
+ import "./chunk-5VXGLI3T.js";
22
23
  import {
23
24
  AIProviderConfigSchema,
24
25
  APIKeyListSchema,
@@ -988,7 +989,6 @@ import {
988
989
  WhiteboardUploadNotReadyErrorWireSchema,
989
990
  createChalkEffectClient
990
991
  } from "./chunk-JPNE4K2L.js";
991
- import "./chunk-5VXGLI3T.js";
992
992
  import {
993
993
  TelemetryDeliveryService,
994
994
  TelemetryEventSourceService,
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  createSpaceClient,
13
13
  decodeWhiteboardV1ServerFrame,
14
14
  encodeWhiteboardV1ClientFrame
15
- } from "./chunk-V6P6EHYO.js";
15
+ } from "./chunk-TQQAPRVW.js";
16
16
  import {
17
17
  CloudflareRTKClient,
18
18
  CloudflareRTKError,
@@ -27,15 +27,6 @@ import {
27
27
  validatePublicationSnapshot,
28
28
  waitFor
29
29
  } from "./chunk-C4BIONCP.js";
30
- import {
31
- createChalkPublicClient,
32
- createChalkPublicInviteClient
33
- } from "./chunk-DFLTEYWX.js";
34
- import {
35
- ArrivalInvalidHandleError,
36
- ArrivalUnavailableError,
37
- SpacePublicInviteUnavailableError
38
- } from "./chunk-JPNE4K2L.js";
39
30
  import {
40
31
  AsyncStorageV1PendingTargetStore,
41
32
  InMemoryV1PendingTargetStore,
@@ -64,6 +55,15 @@ import {
64
55
  reactionFromFrame,
65
56
  restoreV1Snapshot
66
57
  } from "./chunk-5VXGLI3T.js";
58
+ import {
59
+ createChalkPublicClient,
60
+ createChalkPublicInviteClient
61
+ } from "./chunk-DFLTEYWX.js";
62
+ import {
63
+ ArrivalInvalidHandleError,
64
+ ArrivalUnavailableError,
65
+ SpacePublicInviteUnavailableError
66
+ } from "./chunk-JPNE4K2L.js";
67
67
  import {
68
68
  CHALK_JOURNEY_ID_HEADER,
69
69
  TELEMETRY_EVENT_VERSION,
@@ -1 +1 @@
1
- {"version":3,"file":"v1-client.d.ts","sourceRoot":"","sources":["../../src/whiteboard/v1-client.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,8BAA8B,EACnC,KAAK,uBAAu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lD;IAED,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC,CAatC;IAED,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC,CAYrC;IA4BD,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,IAAI,GAAG,MAAM,IAAI,CAIvE;IAED,YAAY,CAAC,KAAK,EAAE,4BAA4B,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAalF;IAED,UAAU,CAAC,KAAK,EAAE;QAAE,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAQlE;IAED,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC,CAG/B;IAED,KAAK,IAAI,OAAO,CAAC,uBAAuB,CAAC,CAOxC;IAEK,iBAAiB,CAAC,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAa9E;IAEK,eAAe,CAAC,UAAU,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAcxD;CA6iBF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@q9labsai/chalk-client",
3
- "version": "4.1.8",
3
+ "version": "4.1.9",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",