@floegence/floe-webapp-protocol 0.36.77 → 0.37.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 +39 -40
- package/package.json +2 -2
package/dist/index2.js
CHANGED
|
@@ -1,61 +1,60 @@
|
|
|
1
|
-
import { createContext as
|
|
2
|
-
import { createStore as
|
|
3
|
-
import { createBrowserReconnectConfig as
|
|
4
|
-
import { RpcProxy as
|
|
5
|
-
import { createReconnectManager as
|
|
6
|
-
const
|
|
7
|
-
function
|
|
8
|
-
const r =
|
|
9
|
-
status:
|
|
10
|
-
error:
|
|
11
|
-
client:
|
|
12
|
-
}),
|
|
1
|
+
import { createContext as P, onCleanup as C, createComponent as x, useContext as b } from "solid-js";
|
|
2
|
+
import { createStore as v } from "solid-js/store";
|
|
3
|
+
import { createBrowserReconnectConfig as A } from "@floegence/flowersec-core/browser";
|
|
4
|
+
import { RpcProxy as N } from "@floegence/flowersec-core/rpc";
|
|
5
|
+
import { createReconnectManager as R } from "@floegence/flowersec-core/reconnect";
|
|
6
|
+
const h = P();
|
|
7
|
+
function W(o) {
|
|
8
|
+
const r = R(), s = r.state(), [a, p] = v({
|
|
9
|
+
status: s.status,
|
|
10
|
+
error: s.error,
|
|
11
|
+
client: s.client
|
|
12
|
+
}), m = o.contract, c = new N(), w = {
|
|
13
13
|
rpc: {
|
|
14
14
|
call: (t, n) => c.call(t, n),
|
|
15
15
|
notify: (t, n) => c.notify(t, n),
|
|
16
16
|
onNotify: (t, n) => c.onNotify(t, n)
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
t.client ? c.attach(t.client.rpc) : c.detach(),
|
|
19
|
+
s.client && c.attach(s.client.rpc);
|
|
20
|
+
const y = r.subscribe((t) => {
|
|
21
|
+
t.client ? c.attach(t.client.rpc) : c.detach(), p({
|
|
22
22
|
status: t.status,
|
|
23
23
|
error: t.error,
|
|
24
24
|
client: t.client
|
|
25
25
|
});
|
|
26
26
|
});
|
|
27
|
-
let
|
|
28
|
-
const l = async (t, n) => {
|
|
29
|
-
const u = b(t);
|
|
27
|
+
let l = null, u = null, e = null;
|
|
28
|
+
const f = (t) => ((l !== t || u === null) && (l = t, u = A(t)), u), d = async (t, n) => {
|
|
30
29
|
if (n === "hard") {
|
|
31
|
-
await r.connect(
|
|
30
|
+
await r.connect(t);
|
|
32
31
|
return;
|
|
33
32
|
}
|
|
34
|
-
await r.connectIfNeeded(
|
|
35
|
-
},
|
|
36
|
-
status: () =>
|
|
37
|
-
error: () =>
|
|
38
|
-
client: () =>
|
|
39
|
-
rpcTransport: () =>
|
|
40
|
-
contract: () =>
|
|
33
|
+
await r.connectIfNeeded(t);
|
|
34
|
+
}, g = {
|
|
35
|
+
status: () => a.status,
|
|
36
|
+
error: () => a.error,
|
|
37
|
+
client: () => a.client,
|
|
38
|
+
rpcTransport: () => w,
|
|
39
|
+
contract: () => m,
|
|
41
40
|
connect: async (t) => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (!(n.status === "connected" && n.client) && !(n.status === "connecting" && !e)) {
|
|
41
|
+
const n = f(t), i = r.state();
|
|
42
|
+
if (!(i.status === "connected" && i.client) && !(i.status === "connecting" && !e)) {
|
|
45
43
|
if (e) {
|
|
46
44
|
await e;
|
|
47
45
|
return;
|
|
48
46
|
}
|
|
49
|
-
e =
|
|
47
|
+
e = d(n, "if_needed").finally(() => {
|
|
50
48
|
e = null;
|
|
51
49
|
}), await e;
|
|
52
50
|
}
|
|
53
51
|
},
|
|
54
52
|
reconnect: async (t) => {
|
|
55
|
-
const n = t ??
|
|
53
|
+
const n = t ?? l;
|
|
56
54
|
if (!n)
|
|
57
55
|
throw new Error("reconnect() requires a config before the first connect() call");
|
|
58
|
-
|
|
56
|
+
const i = f(n);
|
|
57
|
+
return e || (e = d(i, "hard").finally(() => {
|
|
59
58
|
e = null;
|
|
60
59
|
}), e);
|
|
61
60
|
},
|
|
@@ -63,22 +62,22 @@ function F(o) {
|
|
|
63
62
|
c.detach(), r.disconnect();
|
|
64
63
|
}
|
|
65
64
|
};
|
|
66
|
-
return
|
|
67
|
-
|
|
68
|
-
}),
|
|
69
|
-
value:
|
|
65
|
+
return C(() => {
|
|
66
|
+
y(), c.detach(), r.disconnect();
|
|
67
|
+
}), x(h.Provider, {
|
|
68
|
+
value: g,
|
|
70
69
|
get children() {
|
|
71
70
|
return o.children;
|
|
72
71
|
}
|
|
73
72
|
});
|
|
74
73
|
}
|
|
75
|
-
function
|
|
76
|
-
const o =
|
|
74
|
+
function _() {
|
|
75
|
+
const o = b(h);
|
|
77
76
|
if (!o)
|
|
78
77
|
throw new Error("useProtocol must be used within a ProtocolProvider");
|
|
79
78
|
return o;
|
|
80
79
|
}
|
|
81
80
|
export {
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
W as ProtocolProvider,
|
|
82
|
+
_ as useProtocol
|
|
84
83
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@floegence/floe-webapp-protocol",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"solid-js": "^1.8.0"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@floegence/flowersec-core": "^0.
|
|
36
|
+
"@floegence/flowersec-core": "^0.20.2"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"solid-js": "^1.9.11",
|