@floegence/floe-webapp-protocol 0.40.8 → 0.40.10

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 JSX } from 'solid-js';
2
- import { type ArtifactSource, type ConnectionControllerOptions, type ConnectionState, type Session } from '@floegence/flowersec-core';
2
+ import type { ArtifactSource, ConnectionControllerOptions, ConnectionState, Session } from '@floegence/flowersec-core';
3
3
  import type { ProtocolContract } from './contract';
4
4
  interface ProtocolContextValue {
5
5
  status: () => ConnectionState;
package/dist/index2.js CHANGED
@@ -1,67 +1,72 @@
1
- import { createContext as C, onCleanup as v, createComponent as P, useContext as b } from "solid-js";
2
- import { createStore as h } from "solid-js/store";
3
- import "@floegence/flowersec-core";
4
- import { createConnectionController as y } from "@floegence/flowersec-core/browser";
5
- const f = C();
6
- function T(o) {
7
- const [s, i] = h({
1
+ import { createContext as b, onCleanup as y, createComponent as h, useContext as x } from "solid-js";
2
+ import { createStore as S } from "solid-js/store";
3
+ const E = () => import("@floegence/flowersec-core/browser"), w = b();
4
+ function F(r) {
5
+ const [s, u] = S({
8
6
  status: "idle",
9
7
  error: null,
10
8
  session: null
11
- }), d = o.contract;
12
- let e = null, c = null, l = null, n = null;
13
- const w = (t) => {
14
- const r = t.failure;
15
- i({
9
+ }), C = r.contract;
10
+ let o = null, c = null, a = null, n = null, l = 0;
11
+ const m = (t) => {
12
+ const e = t.failure;
13
+ u({
16
14
  status: t.state,
17
15
  session: t.currentSession ?? null,
18
- error: r === void 0 ? null : new Error(`${r.phase}:${r.code}`)
16
+ error: e === void 0 ? null : new Error(`${e.phase}:${e.code}`)
19
17
  });
20
- }, u = async () => {
18
+ }, f = async () => {
21
19
  c?.(), c = null;
22
- const t = e;
23
- e = null, t && await t.close(), i({
20
+ const t = o;
21
+ o = null, t && await t.close(), u({
24
22
  status: "idle",
25
23
  session: null,
26
24
  error: null
27
25
  });
28
- }, m = async (t) => {
29
- await u(), l = t, e = y(t.source, t.controller), c = e.subscribe(w), e.start(), await e.waitForSession();
30
- }, a = async (t) => n || (n = (async () => {
31
- e && l?.source === t.source && e.state === "connected" || await m(t);
26
+ }, p = async (t) => {
27
+ const e = ++l;
28
+ await f(), a = t;
29
+ const {
30
+ createConnectionController: P
31
+ } = await E();
32
+ if (e !== l) return;
33
+ const i = P(t.source, t.controller);
34
+ o = i, c = i.subscribe(m), i.start(), await i.waitForSession();
35
+ }, d = async (t) => n || (n = (async () => {
36
+ o && a?.source === t.source && o.state === "connected" || await p(t);
32
37
  })().finally(() => {
33
38
  n = null;
34
- }), n), p = {
39
+ }), n), v = {
35
40
  status: () => s.status,
36
41
  error: () => s.error,
37
42
  session: () => s.session,
38
43
  rpcTransport: () => s.session?.rpc ?? null,
39
- contract: () => d,
40
- connect: a,
44
+ contract: () => C,
45
+ connect: d,
41
46
  reconnect: async (t) => {
42
- const r = t ?? l;
43
- if (!r) throw new Error("reconnect() requires a config before the first connect() call");
44
- await a(r);
47
+ const e = t ?? a;
48
+ if (!e) throw new Error("reconnect() requires a config before the first connect() call");
49
+ await d(e);
45
50
  },
46
51
  disconnect: () => {
47
- u();
52
+ l += 1, f();
48
53
  }
49
54
  };
50
- return v(() => {
51
- c?.(), e?.close();
52
- }), P(f.Provider, {
53
- value: p,
55
+ return y(() => {
56
+ l += 1, c?.(), o?.close();
57
+ }), h(w.Provider, {
58
+ value: v,
54
59
  get children() {
55
- return o.children;
60
+ return r.children;
56
61
  }
57
62
  });
58
63
  }
59
- function g() {
60
- const o = b(f);
61
- if (!o) throw new Error("useProtocol must be used within a ProtocolProvider");
62
- return o;
64
+ function G() {
65
+ const r = x(w);
66
+ if (!r) throw new Error("useProtocol must be used within a ProtocolProvider");
67
+ return r;
63
68
  }
64
69
  export {
65
- T as ProtocolProvider,
66
- g as useProtocol
70
+ F as ProtocolProvider,
71
+ G as useProtocol
67
72
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floegence/floe-webapp-protocol",
3
- "version": "0.40.8",
3
+ "version": "0.40.10",
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": "2.2.0"
36
+ "@floegence/flowersec-core": "2.3.0"
37
37
  },
38
38
  "devDependencies": {
39
39
  "solid-js": "^1.9.11",