@floegence/floe-webapp-protocol 0.36.66 → 0.36.67
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/contract.d.ts +3 -0
- package/dist/index3.js +40 -32
- package/package.json +5 -2
package/dist/contract.d.ts
CHANGED
|
@@ -16,7 +16,10 @@ export interface RpcClientLike {
|
|
|
16
16
|
}
|
|
17
17
|
export interface RpcHelpers {
|
|
18
18
|
call: <Req, Res>(typeId: number, payload: Req) => Promise<Res>;
|
|
19
|
+
/** Strict notification: detached transports fail with ProtocolNotConnectedError. */
|
|
19
20
|
notify: <Req>(typeId: number, payload: Req) => Promise<void>;
|
|
21
|
+
/** Best-effort notification: detached transports are treated as already dropped. */
|
|
22
|
+
notifyBestEffort: <Req>(typeId: number, payload: Req) => Promise<void>;
|
|
20
23
|
onNotify: <Payload>(typeId: number, handler: (payload: Payload) => void) => () => void;
|
|
21
24
|
}
|
|
22
25
|
export interface ProtocolContract<TApi = unknown> {
|
package/dist/index3.js
CHANGED
|
@@ -1,52 +1,60 @@
|
|
|
1
|
-
import { useProtocol as
|
|
2
|
-
import { RpcProxyDetachedError as
|
|
3
|
-
class
|
|
1
|
+
import { useProtocol as y } from "./index2.js";
|
|
2
|
+
import { RpcProxyDetachedError as d } from "@floegence/flowersec-core/rpc";
|
|
3
|
+
class u extends Error {
|
|
4
4
|
constructor() {
|
|
5
5
|
super("Not connected"), this.name = "ProtocolNotConnectedError";
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
|
-
class
|
|
8
|
+
class p extends Error {
|
|
9
9
|
typeId;
|
|
10
10
|
code;
|
|
11
11
|
constructor(t) {
|
|
12
12
|
super(t.message ?? `RPC error: ${t.code}`, { cause: t.cause }), this.name = "RpcError", this.typeId = t.typeId, this.code = t.code;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
let
|
|
15
|
+
function h(c) {
|
|
16
|
+
const t = async (r, e) => {
|
|
17
|
+
const a = c.rpcTransport();
|
|
18
|
+
let o;
|
|
19
19
|
try {
|
|
20
|
-
|
|
21
|
-
} catch (
|
|
22
|
-
throw
|
|
20
|
+
o = await a.rpc.call(r, e);
|
|
21
|
+
} catch (n) {
|
|
22
|
+
throw n instanceof d ? new u() : new p({ typeId: r, code: -1, message: "RPC transport error", cause: n });
|
|
23
23
|
}
|
|
24
|
-
if (
|
|
25
|
-
throw new
|
|
26
|
-
typeId:
|
|
27
|
-
code:
|
|
28
|
-
message:
|
|
29
|
-
cause:
|
|
24
|
+
if (o.error)
|
|
25
|
+
throw new p({
|
|
26
|
+
typeId: r,
|
|
27
|
+
code: o.error.code,
|
|
28
|
+
message: o.error.message ?? `RPC error: ${o.error.code}`,
|
|
29
|
+
cause: o.error
|
|
30
30
|
});
|
|
31
|
-
return
|
|
32
|
-
},
|
|
33
|
-
const
|
|
31
|
+
return o.payload;
|
|
32
|
+
}, s = async (r, e, a) => {
|
|
33
|
+
const o = c.rpcTransport();
|
|
34
34
|
try {
|
|
35
|
-
await
|
|
36
|
-
} catch (
|
|
37
|
-
if (
|
|
38
|
-
|
|
35
|
+
await o.rpc.notify(r, e);
|
|
36
|
+
} catch (n) {
|
|
37
|
+
if (n instanceof d) {
|
|
38
|
+
if (a.detached === "ignore") return;
|
|
39
|
+
throw new u();
|
|
40
|
+
}
|
|
41
|
+
throw new p({ typeId: r, code: -1, message: "RPC notify transport error", cause: n });
|
|
39
42
|
}
|
|
40
|
-
}
|
|
41
|
-
|
|
43
|
+
};
|
|
44
|
+
return { call: t, notify: async (r, e) => {
|
|
45
|
+
await s(r, e, { detached: "throw" });
|
|
46
|
+
}, notifyBestEffort: async (r, e) => {
|
|
47
|
+
await s(r, e, { detached: "ignore" });
|
|
48
|
+
}, onNotify: (r, e) => c.rpcTransport().rpc.onNotify(r, (o) => {
|
|
49
|
+
e(o);
|
|
42
50
|
}) };
|
|
43
51
|
}
|
|
44
|
-
function
|
|
45
|
-
const t =
|
|
46
|
-
return Object.assign(
|
|
52
|
+
function E(c) {
|
|
53
|
+
const t = y(), s = c?.contract ?? t.contract(), i = h(t), f = s.createRpc(i);
|
|
54
|
+
return Object.assign(f, i);
|
|
47
55
|
}
|
|
48
56
|
export {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
57
|
+
u as ProtocolNotConnectedError,
|
|
58
|
+
p as RpcError,
|
|
59
|
+
E as useRpc
|
|
52
60
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@floegence/floe-webapp-protocol",
|
|
3
|
-
"version": "0.36.
|
|
3
|
+
"version": "0.36.67",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -20,6 +20,9 @@
|
|
|
20
20
|
"files": [
|
|
21
21
|
"dist"
|
|
22
22
|
],
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=24.0.0"
|
|
25
|
+
},
|
|
23
26
|
"scripts": {
|
|
24
27
|
"dev": "vite build --watch",
|
|
25
28
|
"build": "pnpm clean && vite build && tsc -p tsconfig.build.json",
|
|
@@ -30,7 +33,7 @@
|
|
|
30
33
|
"solid-js": "^1.8.0"
|
|
31
34
|
},
|
|
32
35
|
"dependencies": {
|
|
33
|
-
"@floegence/flowersec-core": "^0.19.
|
|
36
|
+
"@floegence/flowersec-core": "^0.19.9"
|
|
34
37
|
},
|
|
35
38
|
"devDependencies": {
|
|
36
39
|
"solid-js": "^1.9.11",
|