@floegence/floe-webapp-protocol 0.40.9 → 0.40.11
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 +1 -1
- package/dist/index2.js +43 -38
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type JSX } from 'solid-js';
|
|
2
|
-
import {
|
|
2
|
+
import type { ArtifactSource, ConnectionControllerOptions, ConnectionState, Session } from '@floegence/flowersec-core';
|
|
3
3
|
import type { ProtocolContract } from './contract';
|
|
4
4
|
interface ProtocolContextValue {
|
|
5
5
|
status: () => ConnectionState;
|
package/dist/index2.js
CHANGED
|
@@ -1,67 +1,72 @@
|
|
|
1
|
-
import { createContext as
|
|
2
|
-
import { createStore as
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
function T(o) {
|
|
7
|
-
const [s, i] = h({
|
|
1
|
+
import { createContext as b, onCleanup as y, createComponent as h, useContext as x } from "solid-js";
|
|
2
|
+
import { createStore as S } from "solid-js/store";
|
|
3
|
+
const E = () => import("@floegence/flowersec-core/browser"), w = b();
|
|
4
|
+
function F(r) {
|
|
5
|
+
const [s, u] = S({
|
|
8
6
|
status: "idle",
|
|
9
7
|
error: null,
|
|
10
8
|
session: null
|
|
11
|
-
}),
|
|
12
|
-
let
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
|
|
9
|
+
}), C = r.contract;
|
|
10
|
+
let o = null, c = null, a = null, n = null, l = 0;
|
|
11
|
+
const m = (t) => {
|
|
12
|
+
const e = t.failure;
|
|
13
|
+
u({
|
|
16
14
|
status: t.state,
|
|
17
15
|
session: t.currentSession ?? null,
|
|
18
|
-
error:
|
|
16
|
+
error: e === void 0 ? null : new Error(`${e.phase}:${e.code}`)
|
|
19
17
|
});
|
|
20
|
-
},
|
|
18
|
+
}, f = async () => {
|
|
21
19
|
c?.(), c = null;
|
|
22
|
-
const t =
|
|
23
|
-
|
|
20
|
+
const t = o;
|
|
21
|
+
o = null, t && await t.close(), u({
|
|
24
22
|
status: "idle",
|
|
25
23
|
session: null,
|
|
26
24
|
error: null
|
|
27
25
|
});
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
}, p = async (t) => {
|
|
27
|
+
const e = ++l;
|
|
28
|
+
await f(), a = t;
|
|
29
|
+
const {
|
|
30
|
+
createConnectionController: P
|
|
31
|
+
} = await E();
|
|
32
|
+
if (e !== l) return;
|
|
33
|
+
const i = P(t.source, t.controller);
|
|
34
|
+
o = i, c = i.subscribe(m), i.start(), await i.waitForSession();
|
|
35
|
+
}, d = async (t) => n || (n = (async () => {
|
|
36
|
+
o && a?.source === t.source && o.state === "connected" || await p(t);
|
|
32
37
|
})().finally(() => {
|
|
33
38
|
n = null;
|
|
34
|
-
}), n),
|
|
39
|
+
}), n), v = {
|
|
35
40
|
status: () => s.status,
|
|
36
41
|
error: () => s.error,
|
|
37
42
|
session: () => s.session,
|
|
38
43
|
rpcTransport: () => s.session?.rpc ?? null,
|
|
39
|
-
contract: () =>
|
|
40
|
-
connect:
|
|
44
|
+
contract: () => C,
|
|
45
|
+
connect: d,
|
|
41
46
|
reconnect: async (t) => {
|
|
42
|
-
const
|
|
43
|
-
if (!
|
|
44
|
-
await
|
|
47
|
+
const e = t ?? a;
|
|
48
|
+
if (!e) throw new Error("reconnect() requires a config before the first connect() call");
|
|
49
|
+
await d(e);
|
|
45
50
|
},
|
|
46
51
|
disconnect: () => {
|
|
47
|
-
|
|
52
|
+
l += 1, f();
|
|
48
53
|
}
|
|
49
54
|
};
|
|
50
|
-
return
|
|
51
|
-
c?.(),
|
|
52
|
-
}),
|
|
53
|
-
value:
|
|
55
|
+
return y(() => {
|
|
56
|
+
l += 1, c?.(), o?.close();
|
|
57
|
+
}), h(w.Provider, {
|
|
58
|
+
value: v,
|
|
54
59
|
get children() {
|
|
55
|
-
return
|
|
60
|
+
return r.children;
|
|
56
61
|
}
|
|
57
62
|
});
|
|
58
63
|
}
|
|
59
|
-
function
|
|
60
|
-
const
|
|
61
|
-
if (!
|
|
62
|
-
return
|
|
64
|
+
function G() {
|
|
65
|
+
const r = x(w);
|
|
66
|
+
if (!r) throw new Error("useProtocol must be used within a ProtocolProvider");
|
|
67
|
+
return r;
|
|
63
68
|
}
|
|
64
69
|
export {
|
|
65
|
-
|
|
66
|
-
|
|
70
|
+
F as ProtocolProvider,
|
|
71
|
+
G as useProtocol
|
|
67
72
|
};
|