@floegence/floe-webapp-protocol 0.36.77 → 0.37.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.
Files changed (2) hide show
  1. package/dist/index2.js +39 -40
  2. package/package.json +2 -2
package/dist/index2.js CHANGED
@@ -1,61 +1,60 @@
1
- import { createContext as y, onCleanup as P, createComponent as g, useContext as C } from "solid-js";
2
- import { createStore as x } from "solid-js/store";
3
- import { createBrowserReconnectConfig as b } from "@floegence/flowersec-core/browser";
4
- import { RpcProxy as v } from "@floegence/flowersec-core/rpc";
5
- import { createReconnectManager as N } from "@floegence/flowersec-core/reconnect";
6
- const f = y();
7
- function F(o) {
8
- const r = N(), i = r.state(), [s, d] = x({
9
- status: i.status,
10
- error: i.error,
11
- client: i.client
12
- }), h = o.contract, c = new v(), p = {
1
+ import { createContext as P, onCleanup as C, createComponent as x, useContext as b } from "solid-js";
2
+ import { createStore as v } from "solid-js/store";
3
+ import { createBrowserReconnectConfig as A } from "@floegence/flowersec-core/browser";
4
+ import { RpcProxy as N } from "@floegence/flowersec-core/rpc";
5
+ import { createReconnectManager as R } from "@floegence/flowersec-core/reconnect";
6
+ const h = P();
7
+ function W(o) {
8
+ const r = R(), s = r.state(), [a, p] = v({
9
+ status: s.status,
10
+ error: s.error,
11
+ client: s.client
12
+ }), m = o.contract, c = new N(), w = {
13
13
  rpc: {
14
14
  call: (t, n) => c.call(t, n),
15
15
  notify: (t, n) => c.notify(t, n),
16
16
  onNotify: (t, n) => c.onNotify(t, n)
17
17
  }
18
18
  };
19
- i.client && c.attach(i.client.rpc);
20
- const m = r.subscribe((t) => {
21
- t.client ? c.attach(t.client.rpc) : c.detach(), d({
19
+ s.client && c.attach(s.client.rpc);
20
+ const y = r.subscribe((t) => {
21
+ t.client ? c.attach(t.client.rpc) : c.detach(), p({
22
22
  status: t.status,
23
23
  error: t.error,
24
24
  client: t.client
25
25
  });
26
26
  });
27
- let a = null, e = null;
28
- const l = async (t, n) => {
29
- const u = b(t);
27
+ let l = null, u = null, e = null;
28
+ const f = (t) => ((l !== t || u === null) && (l = t, u = A(t)), u), d = async (t, n) => {
30
29
  if (n === "hard") {
31
- await r.connect(u);
30
+ await r.connect(t);
32
31
  return;
33
32
  }
34
- await r.connectIfNeeded(u);
35
- }, w = {
36
- status: () => s.status,
37
- error: () => s.error,
38
- client: () => s.client,
39
- rpcTransport: () => p,
40
- contract: () => h,
33
+ await r.connectIfNeeded(t);
34
+ }, g = {
35
+ status: () => a.status,
36
+ error: () => a.error,
37
+ client: () => a.client,
38
+ rpcTransport: () => w,
39
+ contract: () => m,
41
40
  connect: async (t) => {
42
- a = t;
43
- const n = r.state();
44
- if (!(n.status === "connected" && n.client) && !(n.status === "connecting" && !e)) {
41
+ const n = f(t), i = r.state();
42
+ if (!(i.status === "connected" && i.client) && !(i.status === "connecting" && !e)) {
45
43
  if (e) {
46
44
  await e;
47
45
  return;
48
46
  }
49
- e = l(t, "if_needed").finally(() => {
47
+ e = d(n, "if_needed").finally(() => {
50
48
  e = null;
51
49
  }), await e;
52
50
  }
53
51
  },
54
52
  reconnect: async (t) => {
55
- const n = t ?? a;
53
+ const n = t ?? l;
56
54
  if (!n)
57
55
  throw new Error("reconnect() requires a config before the first connect() call");
58
- return e || (a = n, e = l(n, "hard").finally(() => {
56
+ const i = f(n);
57
+ return e || (e = d(i, "hard").finally(() => {
59
58
  e = null;
60
59
  }), e);
61
60
  },
@@ -63,22 +62,22 @@ function F(o) {
63
62
  c.detach(), r.disconnect();
64
63
  }
65
64
  };
66
- return P(() => {
67
- m(), c.detach(), r.disconnect();
68
- }), g(f.Provider, {
69
- value: w,
65
+ return C(() => {
66
+ y(), c.detach(), r.disconnect();
67
+ }), x(h.Provider, {
68
+ value: g,
70
69
  get children() {
71
70
  return o.children;
72
71
  }
73
72
  });
74
73
  }
75
- function M() {
76
- const o = C(f);
74
+ function _() {
75
+ const o = b(h);
77
76
  if (!o)
78
77
  throw new Error("useProtocol must be used within a ProtocolProvider");
79
78
  return o;
80
79
  }
81
80
  export {
82
- F as ProtocolProvider,
83
- M as useProtocol
81
+ W as ProtocolProvider,
82
+ _ as useProtocol
84
83
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floegence/floe-webapp-protocol",
3
- "version": "0.36.77",
3
+ "version": "0.37.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -33,7 +33,7 @@
33
33
  "solid-js": "^1.8.0"
34
34
  },
35
35
  "dependencies": {
36
- "@floegence/flowersec-core": "^0.19.11"
36
+ "@floegence/flowersec-core": "^0.20.0"
37
37
  },
38
38
  "devDependencies": {
39
39
  "solid-js": "^1.9.11",