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