@floegence/floe-webapp-protocol 0.27.4 → 0.28.0
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 +54 -41
- package/package.json +2 -2
package/dist/index2.js
CHANGED
|
@@ -1,88 +1,101 @@
|
|
|
1
|
-
import { onCleanup as
|
|
1
|
+
import { onCleanup as P, createComponent as I, useContext as M, createContext as y } from "solid-js";
|
|
2
2
|
import { createStore as T } from "solid-js/store";
|
|
3
3
|
import { createReconnectManager as x } from "@floegence/flowersec-core/reconnect";
|
|
4
|
-
import { requestChannelGrant as
|
|
5
|
-
const
|
|
6
|
-
function
|
|
7
|
-
const n = x(), [c,
|
|
4
|
+
import { requestChannelGrant as k } from "./index4.js";
|
|
5
|
+
const d = y();
|
|
6
|
+
function S(o) {
|
|
7
|
+
const n = x(), [c, m] = T({
|
|
8
8
|
status: n.state().status,
|
|
9
9
|
error: n.state().error,
|
|
10
10
|
client: n.state().client
|
|
11
|
-
}),
|
|
12
|
-
|
|
11
|
+
}), f = o.contract, w = n.subscribe((t) => {
|
|
12
|
+
m({
|
|
13
13
|
status: t.status,
|
|
14
14
|
error: t.error,
|
|
15
15
|
client: t.client
|
|
16
16
|
});
|
|
17
17
|
});
|
|
18
|
-
let s = null,
|
|
19
|
-
const
|
|
20
|
-
|
|
18
|
+
let s = null, e = null;
|
|
19
|
+
const a = async (t, r) => {
|
|
20
|
+
const i = {
|
|
21
21
|
autoReconnect: t.autoReconnect,
|
|
22
22
|
observer: t.observer,
|
|
23
23
|
connectOnce: async ({
|
|
24
|
-
signal:
|
|
25
|
-
observer:
|
|
24
|
+
signal: p,
|
|
25
|
+
observer: v
|
|
26
26
|
}) => {
|
|
27
27
|
const {
|
|
28
|
-
connectTunnelBrowser:
|
|
29
|
-
connectDirectBrowser:
|
|
30
|
-
} = await import("@floegence/flowersec-core/browser"),
|
|
31
|
-
observer:
|
|
32
|
-
signal:
|
|
28
|
+
connectTunnelBrowser: b,
|
|
29
|
+
connectDirectBrowser: C
|
|
30
|
+
} = await import("@floegence/flowersec-core/browser"), l = {
|
|
31
|
+
observer: v,
|
|
32
|
+
signal: p,
|
|
33
33
|
keepaliveIntervalMs: t.keepaliveIntervalMs ?? 15e3,
|
|
34
34
|
connectTimeoutMs: t.connectTimeoutMs ?? 1e4,
|
|
35
35
|
handshakeTimeoutMs: t.handshakeTimeoutMs ?? 1e4
|
|
36
36
|
};
|
|
37
37
|
if ((t.mode ?? "tunnel") === "tunnel") {
|
|
38
|
-
const
|
|
39
|
-
if (!
|
|
38
|
+
const u = (t.getGrant ? await t.getGrant() : null) ?? t.grant ?? (t.controlplane ? await k(t.controlplane) : null);
|
|
39
|
+
if (!u)
|
|
40
40
|
throw new Error("Tunnel mode requires `getGrant`, `grant`, or `controlplane` config");
|
|
41
|
-
return
|
|
41
|
+
return b(u, l);
|
|
42
42
|
}
|
|
43
43
|
if (!t.directInfo)
|
|
44
44
|
throw new Error("Direct mode requires `directInfo`");
|
|
45
|
-
return
|
|
45
|
+
return C(t.directInfo, l);
|
|
46
46
|
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}), r);
|
|
55
|
-
}, f = {
|
|
47
|
+
};
|
|
48
|
+
if (r === "hard") {
|
|
49
|
+
await n.connect(i);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
await n.connectIfNeeded(i);
|
|
53
|
+
}, h = {
|
|
56
54
|
status: () => c.status,
|
|
57
55
|
error: () => c.error,
|
|
58
56
|
client: () => c.client,
|
|
59
|
-
contract: () =>
|
|
57
|
+
contract: () => f,
|
|
60
58
|
connect: async (t) => {
|
|
61
59
|
s = t;
|
|
62
|
-
const
|
|
63
|
-
|
|
60
|
+
const r = n.state();
|
|
61
|
+
if (!(r.status === "connected" && r.client) && !(r.status === "connecting" && !e)) {
|
|
62
|
+
if (e) {
|
|
63
|
+
await e;
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
e = a(t, "if_needed").finally(() => {
|
|
67
|
+
e = null;
|
|
68
|
+
}), await e;
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
reconnect: async (t) => {
|
|
72
|
+
const r = t ?? s;
|
|
73
|
+
if (!r)
|
|
74
|
+
throw new Error("reconnect() requires a config before the first connect() call");
|
|
75
|
+
return e || (s = r, e = a(r, "hard").finally(() => {
|
|
76
|
+
e = null;
|
|
77
|
+
}), e);
|
|
64
78
|
},
|
|
65
|
-
reconnect: a,
|
|
66
79
|
disconnect: () => {
|
|
67
80
|
n.disconnect();
|
|
68
81
|
}
|
|
69
82
|
};
|
|
70
|
-
return
|
|
83
|
+
return P(() => {
|
|
71
84
|
w(), n.disconnect();
|
|
72
|
-
}),
|
|
73
|
-
value:
|
|
85
|
+
}), I(d.Provider, {
|
|
86
|
+
value: h,
|
|
74
87
|
get children() {
|
|
75
88
|
return o.children;
|
|
76
89
|
}
|
|
77
90
|
});
|
|
78
91
|
}
|
|
79
|
-
function
|
|
80
|
-
const o = M(
|
|
92
|
+
function A() {
|
|
93
|
+
const o = M(d);
|
|
81
94
|
if (!o)
|
|
82
95
|
throw new Error("useProtocol must be used within a ProtocolProvider");
|
|
83
96
|
return o;
|
|
84
97
|
}
|
|
85
98
|
export {
|
|
86
|
-
|
|
87
|
-
|
|
99
|
+
S as ProtocolProvider,
|
|
100
|
+
A as useProtocol
|
|
88
101
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@floegence/floe-webapp-protocol",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"solid-js": "^1.8.0"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@floegence/flowersec-core": "^0.
|
|
33
|
+
"@floegence/flowersec-core": "^0.11.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"solid-js": "^1.9.11",
|