@floegence/floe-webapp-protocol 0.56.11 → 0.56.14

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/client.d.ts CHANGED
@@ -13,7 +13,8 @@ interface ProtocolContextValue {
13
13
  connect: (config: ConnectConfig) => Promise<void>;
14
14
  replaceConnection: (config: ConnectConfig) => Promise<void>;
15
15
  retryNow: () => boolean;
16
- disconnect: () => void;
16
+ /** Resolves after the canceled controller and its pending connection settle. */
17
+ disconnect: () => Promise<void>;
17
18
  }
18
19
  export interface ConnectionLifecycle {
19
20
  synchronize(snapshot: ConnectionSnapshot): void;
package/dist/index2.js CHANGED
@@ -13,29 +13,29 @@ const D = x(), b = Object.freeze({
13
13
  state: "idle",
14
14
  attempt: 0
15
15
  });
16
- function H(t) {
16
+ function H(e) {
17
17
  const [o, u] = k({
18
18
  snapshot: b,
19
19
  diagnostic: h,
20
20
  error: null
21
- }), f = t.contract;
22
- let c = null, C = null, a = null, i = null, l = 0;
23
- const w = (e, r, n) => c === e && a === r && l === n, P = (e, r, n, s, d) => {
24
- if (w(r, n, s))
21
+ }), f = e.contract;
22
+ let c = null, C = null, s = null, i = null, l = 0;
23
+ const w = (t, r, n) => c === t && s === r && l === n, P = (t, r, n, a, d) => {
24
+ if (w(r, n, a))
25
25
  try {
26
- if (n.lifecycle?.synchronize(e), !w(r, n, s)) return;
27
- const p = d.connectionDiagnostic(e);
26
+ if (n.lifecycle?.synchronize(t), !w(r, n, a)) return;
27
+ const p = d.connectionDiagnostic(t);
28
28
  u({
29
- snapshot: e,
29
+ snapshot: t,
30
30
  diagnostic: p,
31
- error: T(e, p, d)
31
+ error: T(t, p, d)
32
32
  });
33
33
  } catch (p) {
34
34
  const E = p instanceof Error ? p : new Error("Floe connection binding failed");
35
- if (n.lifecycle?.dispose(), w(r, n, s)) {
35
+ if (n.lifecycle?.dispose(), w(r, n, a)) {
36
36
  const v = Object.freeze({
37
37
  state: "failed",
38
- attempt: e.attempt,
38
+ attempt: t.attempt,
39
39
  failure: Object.freeze({
40
40
  phase: "artifact",
41
41
  code: "connected_acquisition_failed"
@@ -53,23 +53,23 @@ function H(t) {
53
53
  r.close();
54
54
  }
55
55
  }, y = async () => {
56
- const e = l;
56
+ const t = l;
57
57
  C?.(), C = null;
58
- const r = c, n = a;
59
- c = null, a = null, n?.lifecycle?.dispose(), r !== null && await r.close(), e === l && c === null && a === null && u({
58
+ const r = c, n = s;
59
+ c = null, s = null, n?.lifecycle?.dispose(), r !== null && await r.close(), t === l && c === null && s === null && u({
60
60
  snapshot: b,
61
61
  diagnostic: h,
62
62
  error: null
63
63
  });
64
- }, m = async (e) => {
64
+ }, m = async (t) => {
65
65
  const r = l, n = await j();
66
66
  if (r !== l) return;
67
- const s = e.httpDirect !== void 0 ? await n.createHTTPDirectConnectionControllerV1(e.source, e.httpDirect) : e.privateLoopback !== void 0 ? await n.createPrivateLoopbackConnectionControllerV1(e.source, e.privateLoopback) : await n.createConnectionController(e.source, e.controller);
67
+ const a = t.httpDirect !== void 0 ? await n.createHTTPDirectConnectionControllerV1(t.source, t.httpDirect) : t.privateLoopback !== void 0 ? await n.createPrivateLoopbackConnectionControllerV1(t.source, t.privateLoopback) : await n.createConnectionController(t.source, t.controller);
68
68
  if (r !== l) {
69
- await s.close();
69
+ await a.close();
70
70
  return;
71
71
  }
72
- a = e, c = s, C = s.subscribe((d) => P(d, s, e, r, n)), s.start(), await s.waitForSession();
72
+ s = t, c = a, C = a.subscribe((d) => P(d, a, t, r, n)), a.start(), await a.waitForSession();
73
73
  }, S = {
74
74
  status: () => o.snapshot.state,
75
75
  snapshot: () => o.snapshot,
@@ -78,12 +78,12 @@ function H(t) {
78
78
  session: () => o.snapshot.currentSession ?? null,
79
79
  rpcTransport: () => o.snapshot.currentSession?.rpc ?? null,
80
80
  contract: () => f,
81
- connect: async (e) => {
82
- if (c !== null && a !== null && !R(a, e))
81
+ connect: async (t) => {
82
+ if (c !== null && s !== null && !R(s, t))
83
83
  throw new N();
84
84
  return i !== null || (i = (async () => {
85
85
  if (c === null) {
86
- await m(e);
86
+ await m(t);
87
87
  return;
88
88
  }
89
89
  c.start(), await c.waitForSession();
@@ -91,37 +91,40 @@ function H(t) {
91
91
  i = null;
92
92
  })), i;
93
93
  },
94
- replaceConnection: async (e) => (i !== null && await i.catch(() => {
94
+ replaceConnection: async (t) => (i !== null && await i.catch(() => {
95
95
  }), i = (async () => {
96
- l += 1, await y(), l += 1, await m(e);
96
+ l += 1, await y(), l += 1, await m(t);
97
97
  })().finally(() => {
98
98
  i = null;
99
99
  }), i),
100
100
  retryNow: () => c?.retryNow() ?? !1,
101
- disconnect: () => {
102
- l += 1, y();
101
+ disconnect: async () => {
102
+ l += 1;
103
+ const t = i;
104
+ await y(), await t?.catch(() => {
105
+ });
103
106
  }
104
107
  };
105
108
  return z(() => {
106
- l += 1, C?.(), a?.lifecycle?.dispose(), c?.close();
109
+ l += 1, C?.(), s?.lifecycle?.dispose(), c?.close();
107
110
  }), L(D.Provider, {
108
111
  value: S,
109
112
  get children() {
110
- return t.children;
113
+ return e.children;
111
114
  }
112
115
  });
113
116
  }
114
117
  function V() {
115
- const t = O(D);
116
- if (!t) throw new Error("useProtocol must be used within a ProtocolProvider");
117
- return t;
118
+ const e = O(D);
119
+ if (!e) throw new Error("useProtocol must be used within a ProtocolProvider");
120
+ return e;
118
121
  }
119
- function R(t, o) {
120
- return t.source === o.source && t.controller === o.controller && t.privateLoopback === o.privateLoopback && t.httpDirect === o.httpDirect && t.lifecycle === o.lifecycle;
122
+ function R(e, o) {
123
+ return e.source === o.source && e.controller === o.controller && e.privateLoopback === o.privateLoopback && e.httpDirect === o.httpDirect && e.lifecycle === o.lifecycle;
121
124
  }
122
- function T(t, o, u) {
123
- const f = t.failure;
124
- return f === void 0 || t.state !== "failed" && t.state !== "closed" ? null : new u.ConnectionControllerError(t.state === "closed" ? "closed" : "failed", f, t.retryDisposition, o);
125
+ function T(e, o, u) {
126
+ const f = e.failure;
127
+ return f === void 0 || e.state !== "failed" && e.state !== "closed" ? null : new u.ConnectionControllerError(e.state === "closed" ? "closed" : "failed", f, e.retryDisposition, o);
125
128
  }
126
129
  export {
127
130
  N as ConnectionReplacementRequiredError,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floegence/floe-webapp-protocol",
3
- "version": "0.56.11",
3
+ "version": "0.56.14",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",