@floegence/floe-webapp-protocol 0.44.0 → 0.44.2

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 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
- export type ConnectConfig = Readonly<{
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,39 @@
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";
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";
4
3
  const j = () => import("@floegence/flowersec-core/browser");
5
- class F extends Error {
4
+ class N extends Error {
6
5
  constructor() {
7
6
  super("Connection source or options changed; call replaceConnection() explicitly"), this.name = "ConnectionReplacementRequiredError";
8
7
  }
9
8
  }
10
- const v = D(), y = Object.freeze({
9
+ const S = z(), v = Object.freeze({
11
10
  state: "idle",
12
11
  attempt: 0
13
- }), b = C(y);
14
- function H(t) {
15
- const [o, d] = R({
16
- snapshot: y,
17
- diagnostic: b,
12
+ }), h = Object.freeze({
13
+ state: "idle",
14
+ attempt: 0
15
+ });
16
+ function G(t) {
17
+ const [o, u] = k({
18
+ snapshot: v,
19
+ diagnostic: h,
18
20
  error: null
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
+ }), f = t.contract;
22
+ let c = null, C = null, a = null, i = null, l = 0;
23
+ const y = (e, n, r) => c === e && a === n && l === r, P = (e, n, r, s, d) => {
24
+ if (y(n, r, s))
23
25
  try {
24
- if (c.lifecycle?.synchronize(e), !p(n, c, s)) return;
25
- const u = C(e);
26
- d({
26
+ if (r.lifecycle?.synchronize(e), !y(n, r, s)) return;
27
+ const p = d.connectionDiagnostic(e);
28
+ u({
27
29
  snapshot: e,
28
- diagnostic: u,
29
- error: _(e, u)
30
+ diagnostic: p,
31
+ error: F(e, p, d)
30
32
  });
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({
33
+ } catch (p) {
34
+ const x = p instanceof Error ? p : new Error("Floe connection binding failed");
35
+ if (r.lifecycle?.dispose(), y(n, r, s)) {
36
+ const b = Object.freeze({
35
37
  state: "failed",
36
38
  attempt: e.attempt,
37
39
  failure: Object.freeze({
@@ -42,89 +44,87 @@ function H(t) {
42
44
  kind: "terminal"
43
45
  })
44
46
  });
45
- d({
46
- snapshot: h,
47
- diagnostic: C(h),
47
+ u({
48
+ snapshot: b,
49
+ diagnostic: d.connectionDiagnostic(b),
48
50
  error: x
49
51
  });
50
52
  }
51
53
  n.close();
52
54
  }
53
55
  }, 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,
56
+ const e = l;
57
+ C?.(), C = null;
58
+ const n = c, r = a;
59
+ c = null, a = null, r?.lifecycle?.dispose(), n !== null && await n.close(), e === l && c === null && a === null && u({
60
+ snapshot: v,
61
+ diagnostic: h,
60
62
  error: null
61
63
  });
62
64
  }, m = async (e) => {
63
- const n = i, {
64
- createConnectionController: c
65
- } = await j();
66
- if (n !== i) return;
67
- const s = await c(e.source, e.controller);
68
- if (n !== i) {
65
+ const n = l, r = await j();
66
+ if (n !== l) return;
67
+ const s = e.privateLoopback === void 0 ? await r.createConnectionController(e.source, e.controller) : await r.createPrivateLoopbackConnectionControllerV1(e.source, e.privateLoopback);
68
+ if (n !== l) {
69
69
  await s.close();
70
70
  return;
71
71
  }
72
- a = e, r = s, f = s.subscribe((u) => E(u, s, e, n)), s.start(), await s.waitForSession();
73
- }, P = {
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: () => S,
80
+ contract: () => f,
81
81
  connect: async (e) => {
82
- if (r !== null && a !== null && !I(a, e))
83
- throw new F();
84
- return l !== null || (l = (async () => {
85
- if (r === null) {
82
+ if (c !== null && a !== null && !R(a, e))
83
+ throw new N();
84
+ return i !== null || (i = (async () => {
85
+ if (c === null) {
86
86
  await m(e);
87
87
  return;
88
88
  }
89
- r.start(), await r.waitForSession();
89
+ c.start(), await c.waitForSession();
90
90
  })().finally(() => {
91
- l = null;
92
- })), l;
91
+ i = null;
92
+ })), i;
93
93
  },
94
- replaceConnection: async (e) => (l !== null && await l.catch(() => {
95
- }), l = (async () => {
96
- i += 1, await w(), i += 1, await m(e);
94
+ replaceConnection: async (e) => (i !== null && await i.catch(() => {
95
+ }), i = (async () => {
96
+ l += 1, await w(), l += 1, await m(e);
97
97
  })().finally(() => {
98
- l = null;
99
- }), l),
100
- retryNow: () => r?.retryNow() ?? !1,
98
+ i = null;
99
+ }), i),
100
+ retryNow: () => c?.retryNow() ?? !1,
101
101
  disconnect: () => {
102
- i += 1, w();
102
+ l += 1, w();
103
103
  }
104
104
  };
105
- return O(() => {
106
- i += 1, f?.(), a?.lifecycle?.dispose(), r?.close();
107
- }), g(v.Provider, {
108
- value: P,
105
+ return D(() => {
106
+ l += 1, C?.(), a?.lifecycle?.dispose(), c?.close();
107
+ }), L(S.Provider, {
108
+ value: E,
109
109
  get children() {
110
110
  return t.children;
111
111
  }
112
112
  });
113
113
  }
114
- function J() {
115
- const t = N(v);
114
+ function B() {
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 I(t, o) {
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 _(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);
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
- F as ConnectionReplacementRequiredError,
128
- H as ProtocolProvider,
129
- J as useProtocol
127
+ N as ConnectionReplacementRequiredError,
128
+ G as ProtocolProvider,
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.44.0",
3
+ "version": "0.44.2",
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.1.1"
37
+ "@floegence/flowersec-core": "3.2.0"
38
38
  },
39
39
  "devDependencies": {
40
40
  "solid-js": "^1.9.11",