@floegence/floe-webapp-protocol 0.48.2 → 0.48.4

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.
@@ -1,10 +1,11 @@
1
- import type { JsonValue, RpcPeer } from '@floegence/flowersec-core';
1
+ import type { JsonValue, OperationOptions, RpcPeer } from '@floegence/flowersec-core';
2
2
  export interface RpcClientLike {
3
3
  rpc: Pick<RpcPeer, 'call' | 'notify' | 'onNotify'>;
4
4
  }
5
5
  export type RpcDecoder<T> = (payload: JsonValue) => T;
6
+ export type RpcOperationOptions = OperationOptions;
6
7
  export interface RpcHelpers {
7
- call: <Req extends JsonValue, Res>(typeId: number, payload: Req, decodeResponse: RpcDecoder<Res>) => Promise<Res>;
8
+ call: <Req extends JsonValue, Res>(typeId: number, payload: Req, decodeResponse: RpcDecoder<Res>, options?: RpcOperationOptions) => Promise<Res>;
8
9
  /** Strict notification: detached transports fail with ProtocolNotConnectedError. */
9
10
  notify: <Req extends JsonValue>(typeId: number, payload: Req) => Promise<void>;
10
11
  /** Best-effort notification: detached transports are treated as already dropped. */
package/dist/index3.js CHANGED
@@ -1,44 +1,44 @@
1
- import { useProtocol as y } from "./index2.js";
2
- class f extends Error {
1
+ import { useProtocol as h } from "./index2.js";
2
+ class u extends Error {
3
3
  constructor() {
4
4
  super("Not connected"), this.name = "ProtocolNotConnectedError";
5
5
  }
6
6
  }
7
- class p extends Error {
7
+ class d extends Error {
8
8
  typeId;
9
9
  code;
10
10
  constructor(o) {
11
11
  super(o.message ?? `RPC error: ${o.code}`, { cause: o.cause }), this.name = "RpcError", this.typeId = o.typeId, this.code = o.code;
12
12
  }
13
13
  }
14
- function h(n) {
15
- const o = async (r, t, s) => {
16
- const c = n.rpcTransport();
17
- if (!c) throw new f();
18
- let e;
14
+ function w(e) {
15
+ const o = async (r, t, s, c) => {
16
+ const i = e.rpcTransport();
17
+ if (!i) throw new u();
18
+ let n;
19
19
  try {
20
- e = await c.call(r, t, s);
21
- } catch (u) {
22
- throw new p({ typeId: r, code: -1, message: "RPC transport or response decode error", cause: u });
20
+ n = await i.call(r, t, s, c);
21
+ } catch (y) {
22
+ throw new d({ typeId: r, code: -1, message: "RPC transport or response decode error", cause: y });
23
23
  }
24
- if (!e.ok)
25
- throw new p({
24
+ if (!n.ok)
25
+ throw new d({
26
26
  typeId: r,
27
- code: e.error.code,
28
- message: e.error.message ?? `RPC error: ${e.error.code}`,
29
- cause: e.error
27
+ code: n.error.code,
28
+ message: n.error.message ?? `RPC error: ${n.error.code}`,
29
+ cause: n.error
30
30
  });
31
- return e.payload;
31
+ return n.payload;
32
32
  }, a = async (r, t, s) => {
33
- const c = n.rpcTransport();
33
+ const c = e.rpcTransport();
34
34
  if (!c) {
35
35
  if (s.detached === "ignore") return;
36
- throw new f();
36
+ throw new u();
37
37
  }
38
38
  try {
39
39
  await c.notify(r, t);
40
- } catch (e) {
41
- throw new p({ typeId: r, code: -1, message: "RPC notify transport error", cause: e });
40
+ } catch (i) {
41
+ throw new d({ typeId: r, code: -1, message: "RPC notify transport error", cause: i });
42
42
  }
43
43
  };
44
44
  return { call: o, notify: async (r, t) => {
@@ -46,17 +46,17 @@ function h(n) {
46
46
  }, notifyBestEffort: async (r, t) => {
47
47
  await a(r, t, { detached: "ignore" });
48
48
  }, onNotify: (r, t, s) => {
49
- const c = n.rpcTransport();
49
+ const c = e.rpcTransport();
50
50
  return c ? c.onNotify(r, t, s) : () => {
51
51
  };
52
52
  } };
53
53
  }
54
- function m(n) {
55
- const o = y(), a = n?.contract ?? o.contract(), i = h(o), d = a.createRpc(i);
56
- return Object.assign(d, i);
54
+ function E(e) {
55
+ const o = h(), a = e?.contract ?? o.contract(), p = w(o), f = a.createRpc(p);
56
+ return Object.assign(f, p);
57
57
  }
58
58
  export {
59
- f as ProtocolNotConnectedError,
60
- p as RpcError,
61
- m as useRpc
59
+ u as ProtocolNotConnectedError,
60
+ d as RpcError,
61
+ E as useRpc
62
62
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floegence/floe-webapp-protocol",
3
- "version": "0.48.2",
3
+ "version": "0.48.4",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",