@floegence/floe-webapp-protocol 0.44.0 → 0.44.1
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/index2.js +67 -67
- package/package.json +1 -1
package/dist/index2.js
CHANGED
|
@@ -1,37 +1,39 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class F extends Error {
|
|
1
|
+
import { createContext as z, onCleanup as D, createComponent as O, useContext as g } from "solid-js";
|
|
2
|
+
import { createStore as j } from "solid-js/store";
|
|
3
|
+
const N = () => import("@floegence/flowersec-core/browser");
|
|
4
|
+
class R extends Error {
|
|
6
5
|
constructor() {
|
|
7
6
|
super("Connection source or options changed; call replaceConnection() explicitly"), this.name = "ConnectionReplacementRequiredError";
|
|
8
7
|
}
|
|
9
8
|
}
|
|
10
|
-
const
|
|
9
|
+
const S = z(), h = Object.freeze({
|
|
11
10
|
state: "idle",
|
|
12
11
|
attempt: 0
|
|
13
|
-
}),
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
}), v = Object.freeze({
|
|
13
|
+
state: "idle",
|
|
14
|
+
attempt: 0
|
|
15
|
+
});
|
|
16
|
+
function k(t) {
|
|
17
|
+
const [o, u] = j({
|
|
18
|
+
snapshot: h,
|
|
19
|
+
diagnostic: v,
|
|
18
20
|
error: null
|
|
19
|
-
}),
|
|
20
|
-
let
|
|
21
|
-
const
|
|
22
|
-
if (
|
|
21
|
+
}), p = t.contract;
|
|
22
|
+
let c = null, C = null, a = null, i = null, l = 0;
|
|
23
|
+
const y = (e, n, r) => c === e && a === n && l === r, E = (e, n, r, s, d) => {
|
|
24
|
+
if (y(n, r, s))
|
|
23
25
|
try {
|
|
24
|
-
if (
|
|
25
|
-
const
|
|
26
|
-
|
|
26
|
+
if (r.lifecycle?.synchronize(e), !y(n, r, s)) return;
|
|
27
|
+
const f = d.connectionDiagnostic(e);
|
|
28
|
+
u({
|
|
27
29
|
snapshot: e,
|
|
28
|
-
diagnostic:
|
|
29
|
-
error:
|
|
30
|
+
diagnostic: f,
|
|
31
|
+
error: I(e, f, d)
|
|
30
32
|
});
|
|
31
|
-
} catch (
|
|
32
|
-
const x =
|
|
33
|
-
if (
|
|
34
|
-
const
|
|
33
|
+
} catch (f) {
|
|
34
|
+
const x = f instanceof Error ? f : new Error("Floe connection binding failed");
|
|
35
|
+
if (r.lifecycle?.dispose(), y(n, r, s)) {
|
|
36
|
+
const b = Object.freeze({
|
|
35
37
|
state: "failed",
|
|
36
38
|
attempt: e.attempt,
|
|
37
39
|
failure: Object.freeze({
|
|
@@ -42,34 +44,32 @@ function H(t) {
|
|
|
42
44
|
kind: "terminal"
|
|
43
45
|
})
|
|
44
46
|
});
|
|
45
|
-
|
|
46
|
-
snapshot:
|
|
47
|
-
diagnostic:
|
|
47
|
+
u({
|
|
48
|
+
snapshot: b,
|
|
49
|
+
diagnostic: d.connectionDiagnostic(b),
|
|
48
50
|
error: x
|
|
49
51
|
});
|
|
50
52
|
}
|
|
51
53
|
n.close();
|
|
52
54
|
}
|
|
53
55
|
}, w = async () => {
|
|
54
|
-
const e =
|
|
55
|
-
|
|
56
|
-
const n =
|
|
57
|
-
|
|
58
|
-
snapshot:
|
|
59
|
-
diagnostic:
|
|
56
|
+
const e = l;
|
|
57
|
+
C?.(), C = null;
|
|
58
|
+
const n = c, r = a;
|
|
59
|
+
c = null, a = null, r?.lifecycle?.dispose(), n !== null && await n.close(), e === l && c === null && a === null && u({
|
|
60
|
+
snapshot: h,
|
|
61
|
+
diagnostic: v,
|
|
60
62
|
error: null
|
|
61
63
|
});
|
|
62
64
|
}, m = async (e) => {
|
|
63
|
-
const n =
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if (n !==
|
|
67
|
-
const s = await c(e.source, e.controller);
|
|
68
|
-
if (n !== i) {
|
|
65
|
+
const n = l, r = await N();
|
|
66
|
+
if (n !== l) return;
|
|
67
|
+
const s = await r.createConnectionController(e.source, e.controller);
|
|
68
|
+
if (n !== l) {
|
|
69
69
|
await s.close();
|
|
70
70
|
return;
|
|
71
71
|
}
|
|
72
|
-
a = e,
|
|
72
|
+
a = e, c = s, C = s.subscribe((d) => E(d, s, e, n, r)), s.start(), await s.waitForSession();
|
|
73
73
|
}, P = {
|
|
74
74
|
status: () => o.snapshot.state,
|
|
75
75
|
snapshot: () => o.snapshot,
|
|
@@ -77,54 +77,54 @@ function H(t) {
|
|
|
77
77
|
error: () => o.error,
|
|
78
78
|
session: () => o.snapshot.currentSession ?? null,
|
|
79
79
|
rpcTransport: () => o.snapshot.currentSession?.rpc ?? null,
|
|
80
|
-
contract: () =>
|
|
80
|
+
contract: () => p,
|
|
81
81
|
connect: async (e) => {
|
|
82
|
-
if (
|
|
83
|
-
throw new
|
|
84
|
-
return
|
|
85
|
-
if (
|
|
82
|
+
if (c !== null && a !== null && !F(a, e))
|
|
83
|
+
throw new R();
|
|
84
|
+
return i !== null || (i = (async () => {
|
|
85
|
+
if (c === null) {
|
|
86
86
|
await m(e);
|
|
87
87
|
return;
|
|
88
88
|
}
|
|
89
|
-
|
|
89
|
+
c.start(), await c.waitForSession();
|
|
90
90
|
})().finally(() => {
|
|
91
|
-
|
|
92
|
-
})),
|
|
91
|
+
i = null;
|
|
92
|
+
})), i;
|
|
93
93
|
},
|
|
94
|
-
replaceConnection: async (e) => (
|
|
95
|
-
}),
|
|
96
|
-
|
|
94
|
+
replaceConnection: async (e) => (i !== null && await i.catch(() => {
|
|
95
|
+
}), i = (async () => {
|
|
96
|
+
l += 1, await w(), l += 1, await m(e);
|
|
97
97
|
})().finally(() => {
|
|
98
|
-
|
|
99
|
-
}),
|
|
100
|
-
retryNow: () =>
|
|
98
|
+
i = null;
|
|
99
|
+
}), i),
|
|
100
|
+
retryNow: () => c?.retryNow() ?? !1,
|
|
101
101
|
disconnect: () => {
|
|
102
|
-
|
|
102
|
+
l += 1, w();
|
|
103
103
|
}
|
|
104
104
|
};
|
|
105
|
-
return
|
|
106
|
-
|
|
107
|
-
}),
|
|
105
|
+
return D(() => {
|
|
106
|
+
l += 1, C?.(), a?.lifecycle?.dispose(), c?.close();
|
|
107
|
+
}), O(S.Provider, {
|
|
108
108
|
value: P,
|
|
109
109
|
get children() {
|
|
110
110
|
return t.children;
|
|
111
111
|
}
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
|
-
function
|
|
115
|
-
const t =
|
|
114
|
+
function B() {
|
|
115
|
+
const t = g(S);
|
|
116
116
|
if (!t) throw new Error("useProtocol must be used within a ProtocolProvider");
|
|
117
117
|
return t;
|
|
118
118
|
}
|
|
119
|
-
function
|
|
119
|
+
function F(t, o) {
|
|
120
120
|
return t.source === o.source && t.controller === o.controller && t.lifecycle === o.lifecycle;
|
|
121
121
|
}
|
|
122
|
-
function
|
|
123
|
-
const
|
|
124
|
-
return
|
|
122
|
+
function I(t, o, u) {
|
|
123
|
+
const p = t.failure;
|
|
124
|
+
return p === void 0 || t.state !== "failed" && t.state !== "closed" ? null : new u.ConnectionControllerError(t.state === "closed" ? "closed" : "failed", p, t.retryDisposition, o);
|
|
125
125
|
}
|
|
126
126
|
export {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
R as ConnectionReplacementRequiredError,
|
|
128
|
+
k as ProtocolProvider,
|
|
129
|
+
B as useProtocol
|
|
130
130
|
};
|