@fileverse-dev/ddoc 3.0.77 → 3.0.78

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/dist/index.es.js CHANGED
@@ -179267,7 +179267,7 @@ class a$e {
179267
179267
  return (s = (i = this.callbacksRef) == null ? void 0 : i.onStateChange) == null || s.call(i, o), this.onCollabStateChange(o), !0;
179268
179268
  }
179269
179269
  runExitActions(t, n) {
179270
- t === "ready" && n === "reconnecting" && this.cleanupAwareness(), n === "idle" && this.cleanupAwareness();
179270
+ n === "idle" && this.cleanupAwareness();
179271
179271
  }
179272
179272
  runEntryActions(t, n) {
179273
179273
  var r, o;
@@ -179764,48 +179764,48 @@ const l$e = { status: "idle" }, u$e = (e) => {
179764
179764
  r.current || (r.current = new a$e(e, n));
179765
179765
  const o = r.current;
179766
179766
  o.updateRefs(e.services, e.callbacks, e.onLocalUpdate);
179767
- const i = o.isReady, s = o.awareness;
179768
- Re(() => {
179769
- if (!i || !e.ydoc) return;
179770
- const d = (p, h) => {
179771
- h === "self" || !o.isReady || o.enqueueLocalUpdate(p);
179767
+ const i = o.isReady, s = o.isConnected, a = o.awareness, l = Ve(!1);
179768
+ i && a && (l.current = !0), Re(() => {
179769
+ if (!s || !e.ydoc) return;
179770
+ const f = (g, m) => {
179771
+ m === "self" || !o.isConnected || o.enqueueLocalUpdate(g);
179772
179772
  };
179773
- return e.ydoc.on("update", d), () => {
179774
- e.ydoc.off("update", d);
179773
+ return e.ydoc.on("update", f), () => {
179774
+ e.ydoc.off("update", f);
179775
179775
  };
179776
- }, [e.ydoc, i]), Re(() => {
179777
- if (!s) return;
179778
- const d = () => {
179779
- Wc(s, [e.ydoc.clientID], "window unload");
179776
+ }, [e.ydoc, s]), Re(() => {
179777
+ if (!a) return;
179778
+ const f = () => {
179779
+ Wc(a, [e.ydoc.clientID], "window unload");
179780
179780
  };
179781
- return typeof window < "u" && typeof window.addEventListener == "function" && window.addEventListener("beforeunload", d), () => {
179782
- Wc(s, [e.ydoc.clientID], "hook unmount"), typeof window < "u" && typeof window.removeEventListener == "function" && window.removeEventListener("beforeunload", d);
179781
+ return typeof window < "u" && typeof window.addEventListener == "function" && window.addEventListener("beforeunload", f), () => {
179782
+ Wc(a, [e.ydoc.clientID], "hook unmount"), typeof window < "u" && typeof window.removeEventListener == "function" && window.removeEventListener("beforeunload", f);
179783
179783
  };
179784
- }, [s !== void 0]), Re(() => () => {
179785
- var d;
179786
- (d = r.current) == null || d.forceCleanup();
179784
+ }, [a !== void 0]), Re(() => () => {
179785
+ var f;
179786
+ (f = r.current) == null || f.forceCleanup();
179787
179787
  }, []);
179788
- const a = Se(
179789
- (d) => {
179790
- o.connect(d).catch((p) => {
179791
- console.error("useSyncManager: connect failed", p);
179788
+ const u = Se(
179789
+ (f) => {
179790
+ o.connect(f).catch((g) => {
179791
+ console.error("useSyncManager: connect failed", g);
179792
179792
  });
179793
179793
  },
179794
179794
  // eslint-disable-next-line react-hooks/exhaustive-deps
179795
179795
  [e.ydoc]
179796
- ), l = Se(() => {
179796
+ ), c = Se(() => {
179797
179797
  o.disconnect();
179798
- }, [o]), u = Se(() => {
179798
+ }, [o]), d = Se(() => {
179799
179799
  o.terminateSession();
179800
- }, [o]), c = t.status === "ready" || t.status === "reconnecting";
179800
+ }, [o]), p = l.current || t.status === "ready" || t.status === "reconnecting", h = l.current && !!a || t.status === "ready" && !!a;
179801
179801
  return {
179802
179802
  state: t,
179803
- connect: a,
179804
- disconnect: l,
179805
- terminateSession: u,
179806
- isReady: t.status === "ready" && !!s,
179807
- awareness: s,
179808
- hasCollabContentInitialised: c
179803
+ connect: u,
179804
+ disconnect: c,
179805
+ terminateSession: d,
179806
+ isReady: h,
179807
+ awareness: a,
179808
+ hasCollabContentInitialised: p
179809
179809
  };
179810
179810
  }, c$e = ({
179811
179811
  onChange: e,