@floegence/floe-webapp-protocol 0.44.1 → 0.45.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 +11 -4
- package/dist/index2.js +36 -36
- package/package.json +2 -2
package/dist/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ArtifactSource, ConnectionDiagnostic, ConnectionSnapshot, ConnectionState, Session } from '@floegence/flowersec-core';
|
|
2
|
-
import type { ConnectionControllerOptions } from '@floegence/flowersec-core/browser';
|
|
2
|
+
import type { ConnectionControllerOptions, PrivateLoopbackArtifactSourceV1, PrivateLoopbackConnectionControllerOptionsV1 } from '@floegence/flowersec-core/browser';
|
|
3
3
|
import { type JSX } from 'solid-js';
|
|
4
4
|
import type { ProtocolContract } from './contract';
|
|
5
5
|
interface ProtocolContextValue {
|
|
@@ -19,11 +19,18 @@ export interface ConnectionLifecycle {
|
|
|
19
19
|
synchronize(snapshot: ConnectionSnapshot): void;
|
|
20
20
|
dispose(): void;
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
source: ArtifactSource;
|
|
24
|
-
controller?: ConnectionControllerOptions;
|
|
22
|
+
type SharedConnectConfig = Readonly<{
|
|
25
23
|
lifecycle?: ConnectionLifecycle;
|
|
26
24
|
}>;
|
|
25
|
+
export type ConnectConfig = SharedConnectConfig & (Readonly<{
|
|
26
|
+
source: ArtifactSource;
|
|
27
|
+
controller?: ConnectionControllerOptions;
|
|
28
|
+
privateLoopback?: never;
|
|
29
|
+
}> | Readonly<{
|
|
30
|
+
source: PrivateLoopbackArtifactSourceV1;
|
|
31
|
+
privateLoopback: PrivateLoopbackConnectionControllerOptionsV1;
|
|
32
|
+
controller?: never;
|
|
33
|
+
}>);
|
|
27
34
|
export declare class ConnectionReplacementRequiredError extends Error {
|
|
28
35
|
constructor();
|
|
29
36
|
}
|
package/dist/index2.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import { createContext as z, onCleanup as D, createComponent as
|
|
2
|
-
import { createStore as
|
|
3
|
-
const
|
|
4
|
-
class
|
|
1
|
+
import { createContext as z, onCleanup as D, createComponent as L, useContext as O } from "solid-js";
|
|
2
|
+
import { createStore as k } from "solid-js/store";
|
|
3
|
+
const j = () => import("@floegence/flowersec-core/browser");
|
|
4
|
+
class N extends Error {
|
|
5
5
|
constructor() {
|
|
6
6
|
super("Connection source or options changed; call replaceConnection() explicitly"), this.name = "ConnectionReplacementRequiredError";
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
-
const S = z(),
|
|
9
|
+
const S = z(), v = Object.freeze({
|
|
10
10
|
state: "idle",
|
|
11
11
|
attempt: 0
|
|
12
|
-
}),
|
|
12
|
+
}), h = Object.freeze({
|
|
13
13
|
state: "idle",
|
|
14
14
|
attempt: 0
|
|
15
15
|
});
|
|
16
|
-
function
|
|
17
|
-
const [o, u] =
|
|
18
|
-
snapshot:
|
|
19
|
-
diagnostic:
|
|
16
|
+
function G(t) {
|
|
17
|
+
const [o, u] = k({
|
|
18
|
+
snapshot: v,
|
|
19
|
+
diagnostic: h,
|
|
20
20
|
error: null
|
|
21
|
-
}),
|
|
21
|
+
}), f = t.contract;
|
|
22
22
|
let c = null, C = null, a = null, i = null, l = 0;
|
|
23
|
-
const y = (e, n, r) => c === e && a === n && l === r,
|
|
23
|
+
const y = (e, n, r) => c === e && a === n && l === r, P = (e, n, r, s, d) => {
|
|
24
24
|
if (y(n, r, s))
|
|
25
25
|
try {
|
|
26
26
|
if (r.lifecycle?.synchronize(e), !y(n, r, s)) return;
|
|
27
|
-
const
|
|
27
|
+
const p = d.connectionDiagnostic(e);
|
|
28
28
|
u({
|
|
29
29
|
snapshot: e,
|
|
30
|
-
diagnostic:
|
|
31
|
-
error:
|
|
30
|
+
diagnostic: p,
|
|
31
|
+
error: F(e, p, d)
|
|
32
32
|
});
|
|
33
|
-
} catch (
|
|
34
|
-
const x =
|
|
33
|
+
} catch (p) {
|
|
34
|
+
const x = p instanceof Error ? p : new Error("Floe connection binding failed");
|
|
35
35
|
if (r.lifecycle?.dispose(), y(n, r, s)) {
|
|
36
36
|
const b = Object.freeze({
|
|
37
37
|
state: "failed",
|
|
@@ -57,30 +57,30 @@ function k(t) {
|
|
|
57
57
|
C?.(), C = null;
|
|
58
58
|
const n = c, r = a;
|
|
59
59
|
c = null, a = null, r?.lifecycle?.dispose(), n !== null && await n.close(), e === l && c === null && a === null && u({
|
|
60
|
-
snapshot:
|
|
61
|
-
diagnostic:
|
|
60
|
+
snapshot: v,
|
|
61
|
+
diagnostic: h,
|
|
62
62
|
error: null
|
|
63
63
|
});
|
|
64
64
|
}, m = async (e) => {
|
|
65
|
-
const n = l, r = await
|
|
65
|
+
const n = l, r = await j();
|
|
66
66
|
if (n !== l) return;
|
|
67
|
-
const s = await r.createConnectionController(e.source, e.controller);
|
|
67
|
+
const s = e.privateLoopback === void 0 ? await r.createConnectionController(e.source, e.controller) : await r.createPrivateLoopbackConnectionControllerV1(e.source, e.privateLoopback);
|
|
68
68
|
if (n !== l) {
|
|
69
69
|
await s.close();
|
|
70
70
|
return;
|
|
71
71
|
}
|
|
72
|
-
a = e, c = s, C = s.subscribe((d) =>
|
|
73
|
-
},
|
|
72
|
+
a = e, c = s, C = s.subscribe((d) => P(d, s, e, n, r)), s.start(), await s.waitForSession();
|
|
73
|
+
}, E = {
|
|
74
74
|
status: () => o.snapshot.state,
|
|
75
75
|
snapshot: () => o.snapshot,
|
|
76
76
|
diagnostic: () => o.diagnostic,
|
|
77
77
|
error: () => o.error,
|
|
78
78
|
session: () => o.snapshot.currentSession ?? null,
|
|
79
79
|
rpcTransport: () => o.snapshot.currentSession?.rpc ?? null,
|
|
80
|
-
contract: () =>
|
|
80
|
+
contract: () => f,
|
|
81
81
|
connect: async (e) => {
|
|
82
|
-
if (c !== null && a !== null && !
|
|
83
|
-
throw new
|
|
82
|
+
if (c !== null && a !== null && !R(a, e))
|
|
83
|
+
throw new N();
|
|
84
84
|
return i !== null || (i = (async () => {
|
|
85
85
|
if (c === null) {
|
|
86
86
|
await m(e);
|
|
@@ -104,27 +104,27 @@ function k(t) {
|
|
|
104
104
|
};
|
|
105
105
|
return D(() => {
|
|
106
106
|
l += 1, C?.(), a?.lifecycle?.dispose(), c?.close();
|
|
107
|
-
}),
|
|
108
|
-
value:
|
|
107
|
+
}), L(S.Provider, {
|
|
108
|
+
value: E,
|
|
109
109
|
get children() {
|
|
110
110
|
return t.children;
|
|
111
111
|
}
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
114
|
function B() {
|
|
115
|
-
const t =
|
|
115
|
+
const t = O(S);
|
|
116
116
|
if (!t) throw new Error("useProtocol must be used within a ProtocolProvider");
|
|
117
117
|
return t;
|
|
118
118
|
}
|
|
119
|
-
function
|
|
120
|
-
return t.source === o.source && t.controller === o.controller && t.lifecycle === o.lifecycle;
|
|
119
|
+
function R(t, o) {
|
|
120
|
+
return t.source === o.source && t.controller === o.controller && t.privateLoopback === o.privateLoopback && t.lifecycle === o.lifecycle;
|
|
121
121
|
}
|
|
122
|
-
function
|
|
123
|
-
const
|
|
124
|
-
return
|
|
122
|
+
function F(t, o, u) {
|
|
123
|
+
const f = t.failure;
|
|
124
|
+
return f === void 0 || t.state !== "failed" && t.state !== "closed" ? null : new u.ConnectionControllerError(t.state === "closed" ? "closed" : "failed", f, t.retryDisposition, o);
|
|
125
125
|
}
|
|
126
126
|
export {
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
N as ConnectionReplacementRequiredError,
|
|
128
|
+
G as ProtocolProvider,
|
|
129
129
|
B as useProtocol
|
|
130
130
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@floegence/floe-webapp-protocol",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.45.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": "3.
|
|
37
|
+
"@floegence/flowersec-core": "3.2.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"solid-js": "^1.9.11",
|