@fileverse-dev/ddoc 2.4.12 → 2.4.13

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.
@@ -1,4 +1,4 @@
1
- import { B as p, g as m, s as w, d as k, i as b, l as L, a as O, c as E, b as x, e as R, H as y, f as M } from "./index-yZbcVTPq.mjs";
1
+ import { B as p, g as m, s as w, d as k, i as b, l as L, a as O, c as E, b as x, e as R, H as y, f as M } from "./index-DSCO381A.mjs";
2
2
  class S extends p {
3
3
  constructor({ callbackSelector: r, cause: a, data: n, extraData: i, sender: f, urls: t }) {
4
4
  var o;
@@ -89868,7 +89868,7 @@ async function Sk(e, t) {
89868
89868
  });
89869
89869
  return V === "0x" ? { data: void 0 } : { data: V };
89870
89870
  } catch (B) {
89871
- const L = BWt(B), { offchainLookup: j, offchainLookupSignature: N } = await import("./ccip-BAm9EVjo.mjs");
89871
+ const L = BWt(B), { offchainLookup: j, offchainLookupSignature: N } = await import("./ccip-CJNLvfE1.mjs");
89872
89872
  if (e.ccipRead !== !1 && (L == null ? void 0 : L.slice(0, 10)) === N && b)
89873
89873
  return { data: await j(e, { data: L, to: b }) };
89874
89874
  throw S && (L == null ? void 0 : L.slice(0, 10)) === "0x101bb98d" ? new HVt({ factory: c }) : cpe(B, {
@@ -254918,6 +254918,7 @@ class iNn {
254918
254918
  ct(this, "_machineEventHandler", null);
254919
254919
  ct(this, "_onConnect", null);
254920
254920
  ct(this, "_onDisconnection", null);
254921
+ ct(this, "_onHandShakeError", null);
254921
254922
  ct(this, "_sequenceCallbackMap", {});
254922
254923
  ct(this, "_webSocketStatus", No.CLOSED);
254923
254924
  ct(this, "_webSocket", null);
@@ -254967,7 +254968,7 @@ class iNn {
254967
254968
  return xs(n);
254968
254969
  });
254969
254970
  ct(this, "_handleHandShake", async (t) => {
254970
- var s, l, u;
254971
+ var s, l, u, c;
254971
254972
  if (this._websocketServiceDid = t.data.server_did, this._webSocketStatus !== No.CONNECTED || !this.roomId)
254972
254973
  throw new Error(
254973
254974
  "Cannot establish handshake. WebSocket not connected or roomId not defined"
@@ -254992,11 +254993,15 @@ class iNn {
254992
254993
  if ((l = this._onCollaborationConnectCallback) == null || l.call(this, {
254993
254994
  data: a,
254994
254995
  roomKey: this.roomKey
254995
- }), !a.is_handshake_response) {
254996
+ }), a.statusCode !== 200) {
254997
+ (u = this._onHandShakeError) == null || u.call(this, a.error);
254998
+ return;
254999
+ }
255000
+ if (!a.is_handshake_response) {
254996
255001
  this.disconnect();
254997
255002
  return;
254998
255003
  }
254999
- (u = this._onConnect) == null || u.call(this);
255004
+ (c = this._onConnect) == null || c.call(this);
255000
255005
  });
255001
255006
  ct(this, "_executeRequestCallback", (t) => {
255002
255007
  const n = this._getSequenceIdCallback(t.seqId);
@@ -255199,7 +255204,7 @@ class iNn {
255199
255204
  });
255200
255205
  }
255201
255206
  async init(t) {
255202
- this._onConnect = t.onConnect, this._onDisconnection = t.onDisconnect, this._machineEventHandler = t.onWsEvent, this._onError = t.onError, this.roomId = t.roomId, await this.connectSocket();
255207
+ this._onConnect = t.onConnect, this._onDisconnection = t.onDisconnect, this._machineEventHandler = t.onWsEvent, this._onError = t.onError, this._onHandShakeError = t.onHandShakeError, this.roomId = t.roomId, await this.connectSocket();
255203
255208
  }
255204
255209
  }
255205
255210
  const aNn = (e) => {
@@ -255336,10 +255341,25 @@ const aNn = (e) => {
255336
255341
  _awarenessUpdateHandler: null,
255337
255342
  uncommittedUpdatesIdList: [],
255338
255343
  updateQueue: []
255339
- }), LNn = (e, t) => t.data.error ? {
255340
- errorCount: e.errorCount + 1,
255341
- errorMessage: t.data.error
255342
- } : {}, NNn = (e) => {
255344
+ }), LNn = (e, t) => ({
255345
+ socketClient: null,
255346
+ roomId: "",
255347
+ roomMembers: [],
255348
+ isConnected: !1,
255349
+ awareness: null,
255350
+ _awarenessUpdateHandler: null,
255351
+ roomKey: "",
255352
+ wsUrl: "",
255353
+ uncommittedUpdatesIdList: [],
255354
+ updateQueue: [],
255355
+ isOwner: !1,
255356
+ isReady: !1,
255357
+ isNewDoc: !1,
255358
+ contentTobeAppliedQueue: [],
255359
+ initialUpdate: null,
255360
+ errorCount: 0,
255361
+ errorMessage: ""
255362
+ }), NNn = (e) => {
255343
255363
  var t, n;
255344
255364
  return T9(
255345
255365
  e.awareness,
@@ -255414,6 +255434,9 @@ const aNn = (e) => {
255414
255434
  t({ type: "SYNC_LATEST_COMMIT", data: null });
255415
255435
  },
255416
255436
  onDisconnect: () => t({ type: "DISCONNECTED", data: null }),
255437
+ onHandShakeError: (i) => {
255438
+ t({ type: "DISCONNECT", data: { error: "Network error" } }), o == null || o(i);
255439
+ },
255417
255440
  onWsEvent: (i) => {
255418
255441
  if (!(i != null && i.event_type))
255419
255442
  throw new Error("Message is not an event");
package/dist/index.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import { D as d, E as r, P as s, R as a, h as t, u as i } from "./index-yZbcVTPq.mjs";
1
+ import { D as d, E as r, P as s, R as a, h as t, u as i } from "./index-DSCO381A.mjs";
2
2
  export {
3
3
  d as DdocEditor,
4
4
  r as Editor,
@@ -114,12 +114,24 @@ export declare const disconnectedStateHandler: () => {
114
114
  uncommittedUpdatesIdList: never[];
115
115
  updateQueue: never[];
116
116
  };
117
- export declare const handleDisconnectionDueToError: (context: SyncMachineContext, event: SyncMachinEvent) => {
117
+ export declare const handleDisconnectionDueToError: (_context: SyncMachineContext, _event: SyncMachinEvent) => {
118
+ socketClient: null;
119
+ roomId: string;
120
+ roomMembers: never[];
121
+ isConnected: boolean;
122
+ awareness: null;
123
+ _awarenessUpdateHandler: null;
124
+ roomKey: string;
125
+ wsUrl: string;
126
+ uncommittedUpdatesIdList: never[];
127
+ updateQueue: never[];
128
+ isOwner: boolean;
129
+ isReady: boolean;
130
+ isNewDoc: boolean;
131
+ contentTobeAppliedQueue: never[];
132
+ initialUpdate: null;
118
133
  errorCount: number;
119
- errorMessage: any;
120
- } | {
121
- errorCount?: undefined;
122
- errorMessage?: undefined;
134
+ errorMessage: string;
123
135
  };
124
136
  export declare const terminateSessionHandler: (context: SyncMachineContext) => {
125
137
  socketClient: null;
@@ -20,6 +20,7 @@ export declare class SocketClient {
20
20
  private _machineEventHandler;
21
21
  private _onConnect;
22
22
  private _onDisconnection;
23
+ private _onHandShakeError;
23
24
  private _sequenceCallbackMap;
24
25
  _webSocketStatus: SocketStatusEnum;
25
26
  private _webSocket;
@@ -123,6 +123,7 @@ export interface ISocketInitConfig {
123
123
  onDisconnect: DisconnectHandler;
124
124
  onError: (err: string) => void;
125
125
  onWsEvent: EventHandler;
126
+ onHandShakeError: (err: string) => void;
126
127
  roomId: string;
127
128
  }
128
129
  export declare enum SocketStatusEnum {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@fileverse-dev/ddoc",
3
3
  "private": false,
4
4
  "description": "DDoc",
5
- "version": "2.4.12",
5
+ "version": "2.4.13",
6
6
  "main": "dist/index.es.js",
7
7
  "module": "dist/index.es.js",
8
8
  "exports": {