@floegence/floe-webapp-protocol 0.44.0 → 0.44.1

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.
Files changed (2) hide show
  1. package/dist/index2.js +67 -67
  2. package/package.json +1 -1
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";
4
- const j = () => import("@floegence/flowersec-core/browser");
5
- class F extends Error {
1
+ import { createContext as z, onCleanup as D, createComponent as O, useContext as g } from "solid-js";
2
+ import { createStore as j } from "solid-js/store";
3
+ const N = () => import("@floegence/flowersec-core/browser");
4
+ class R 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(), h = 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
+ }), v = Object.freeze({
13
+ state: "idle",
14
+ attempt: 0
15
+ });
16
+ function k(t) {
17
+ const [o, u] = j({
18
+ snapshot: h,
19
+ diagnostic: v,
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
+ }), p = 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, E = (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 f = d.connectionDiagnostic(e);
28
+ u({
27
29
  snapshot: e,
28
- diagnostic: u,
29
- error: _(e, u)
30
+ diagnostic: f,
31
+ error: I(e, f, 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 (f) {
34
+ const x = f instanceof Error ? f : 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,34 +44,32 @@ 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: h,
61
+ diagnostic: v,
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 N();
66
+ if (n !== l) return;
67
+ const s = await r.createConnectionController(e.source, e.controller);
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();
72
+ a = e, c = s, C = s.subscribe((d) => E(d, s, e, n, r)), s.start(), await s.waitForSession();
73
73
  }, P = {
74
74
  status: () => o.snapshot.state,
75
75
  snapshot: () => o.snapshot,
@@ -77,54 +77,54 @@ function H(t) {
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: () => p,
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 && !F(a, e))
83
+ throw new R();
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, {
105
+ return D(() => {
106
+ l += 1, C?.(), a?.lifecycle?.dispose(), c?.close();
107
+ }), O(S.Provider, {
108
108
  value: P,
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 = g(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) {
119
+ function F(t, o) {
120
120
  return t.source === o.source && t.controller === o.controller && 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 I(t, o, u) {
123
+ const p = t.failure;
124
+ return p === void 0 || t.state !== "failed" && t.state !== "closed" ? null : new u.ConnectionControllerError(t.state === "closed" ? "closed" : "failed", p, t.retryDisposition, o);
125
125
  }
126
126
  export {
127
- F as ConnectionReplacementRequiredError,
128
- H as ProtocolProvider,
129
- J as useProtocol
127
+ R as ConnectionReplacementRequiredError,
128
+ k 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.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",