@floegence/floe-webapp-protocol 0.56.11 → 0.56.12
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 +2 -1
- package/dist/index2.js +38 -35
- package/package.json +1 -1
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
|
-
|
|
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(
|
|
16
|
+
function H(e) {
|
|
17
17
|
const [o, u] = k({
|
|
18
18
|
snapshot: b,
|
|
19
19
|
diagnostic: h,
|
|
20
20
|
error: null
|
|
21
|
-
}), f =
|
|
22
|
-
let c = null, C = null,
|
|
23
|
-
const w = (
|
|
24
|
-
if (w(r, n,
|
|
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(
|
|
27
|
-
const p = d.connectionDiagnostic(
|
|
26
|
+
if (n.lifecycle?.synchronize(t), !w(r, n, a)) return;
|
|
27
|
+
const p = d.connectionDiagnostic(t);
|
|
28
28
|
u({
|
|
29
|
-
snapshot:
|
|
29
|
+
snapshot: t,
|
|
30
30
|
diagnostic: p,
|
|
31
|
-
error: T(
|
|
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,
|
|
35
|
+
if (n.lifecycle?.dispose(), w(r, n, a)) {
|
|
36
36
|
const v = Object.freeze({
|
|
37
37
|
state: "failed",
|
|
38
|
-
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
|
|
56
|
+
const t = l;
|
|
57
57
|
C?.(), C = null;
|
|
58
|
-
const r = c, n =
|
|
59
|
-
c = null,
|
|
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 (
|
|
64
|
+
}, m = async (t) => {
|
|
65
65
|
const r = l, n = await j();
|
|
66
66
|
if (r !== l) return;
|
|
67
|
-
const
|
|
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
|
|
69
|
+
await a.close();
|
|
70
70
|
return;
|
|
71
71
|
}
|
|
72
|
-
|
|
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 (
|
|
82
|
-
if (c !== null &&
|
|
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(
|
|
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 (
|
|
94
|
+
replaceConnection: async (t) => (i !== null && await i.catch(() => {
|
|
95
95
|
}), i = (async () => {
|
|
96
|
-
l += 1, await y(), l += 1, await m(
|
|
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
|
|
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?.(),
|
|
109
|
+
l += 1, C?.(), s?.lifecycle?.dispose(), c?.close();
|
|
107
110
|
}), L(D.Provider, {
|
|
108
111
|
value: S,
|
|
109
112
|
get children() {
|
|
110
|
-
return
|
|
113
|
+
return e.children;
|
|
111
114
|
}
|
|
112
115
|
});
|
|
113
116
|
}
|
|
114
117
|
function V() {
|
|
115
|
-
const
|
|
116
|
-
if (!
|
|
117
|
-
return
|
|
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(
|
|
120
|
-
return
|
|
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(
|
|
123
|
-
const f =
|
|
124
|
-
return f === void 0 ||
|
|
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,
|