@emeryld/rrroutes-client 2.7.13 → 2.8.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.
- package/dist/index.cjs +21 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +20 -7
- package/dist/index.mjs.map +1 -1
- package/dist/routesV3.client.types.d.ts +7 -1
- package/dist/sockets/socket.client.context.connection.d.ts +1 -1
- package/dist/sockets/socket.client.context.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -39,10 +39,7 @@ __export(index_exports, {
|
|
|
39
39
|
buildSocketedRoute: () => buildSocketedRoute,
|
|
40
40
|
createRouteClient: () => createRouteClient,
|
|
41
41
|
defaultFetcher: () => defaultFetcher,
|
|
42
|
-
useSocketClient: () => useSocketClient
|
|
43
|
-
useSocketConnection: () => useSocketConnection,
|
|
44
|
-
useSocketEvent: () => useSocketEvent,
|
|
45
|
-
useSocketRooms: () => useSocketRooms
|
|
42
|
+
useSocketClient: () => useSocketClient
|
|
46
43
|
});
|
|
47
44
|
module.exports = __toCommonJS(index_exports);
|
|
48
45
|
|
|
@@ -1481,6 +1478,12 @@ function createRouteClient(opts) {
|
|
|
1481
1478
|
configurable: false,
|
|
1482
1479
|
writable: false
|
|
1483
1480
|
});
|
|
1481
|
+
Object.defineProperty(built, "metadata", {
|
|
1482
|
+
value: { leaf },
|
|
1483
|
+
enumerable: true,
|
|
1484
|
+
configurable: false,
|
|
1485
|
+
writable: false
|
|
1486
|
+
});
|
|
1484
1487
|
return built;
|
|
1485
1488
|
}
|
|
1486
1489
|
const fetchRaw = async (input) => {
|
|
@@ -1602,6 +1605,15 @@ function safeSerialize(value) {
|
|
|
1602
1605
|
return "[unserializable]";
|
|
1603
1606
|
}
|
|
1604
1607
|
}
|
|
1608
|
+
function derivePayloadIdentity(payload) {
|
|
1609
|
+
if (!payload || typeof payload !== "object") return void 0;
|
|
1610
|
+
const record = payload;
|
|
1611
|
+
const idCandidate = record.id ?? record._id ?? record.notificationId ?? record.uuid ?? record.key;
|
|
1612
|
+
if (typeof idCandidate === "string" || typeof idCandidate === "number" || typeof idCandidate === "bigint") {
|
|
1613
|
+
return String(idCandidate);
|
|
1614
|
+
}
|
|
1615
|
+
return void 0;
|
|
1616
|
+
}
|
|
1605
1617
|
function useLatestRef(value) {
|
|
1606
1618
|
const ref = React2.useRef(value);
|
|
1607
1619
|
React2.useEffect(() => {
|
|
@@ -1787,10 +1799,11 @@ function useSocketEvent(args) {
|
|
|
1787
1799
|
emitDebug({ type: "subscription", phase: "register", event });
|
|
1788
1800
|
const unsubscribe = client.on(event, (payload, meta) => {
|
|
1789
1801
|
const dedupeCfg = messageDeduplicationRef.current;
|
|
1790
|
-
if (dedupeCfg) {
|
|
1791
|
-
const ttlMs = Math.max(0, dedupeCfg
|
|
1802
|
+
if (dedupeCfg !== false) {
|
|
1803
|
+
const ttlMs = Math.max(0, dedupeCfg?.ttlMs ?? 2500);
|
|
1792
1804
|
const now = Date.now();
|
|
1793
|
-
const
|
|
1805
|
+
const payloadId = derivePayloadIdentity(payload);
|
|
1806
|
+
const dedupeKey = dedupeCfg?.key?.(payload, meta) ?? (payloadId ? `${event}|payload:${payloadId}` : void 0) ?? (meta?.envelope ? `${event}|${String(meta.envelope.eventName)}|${String(meta.envelope.sentAt)}|${safeSerialize(payload)}` : `${event}|${safeSerialize(payload)}`);
|
|
1794
1807
|
const prev = seenMessageKeysRef.current.get(dedupeKey);
|
|
1795
1808
|
if (typeof prev === "number" && now - prev <= ttlMs) {
|
|
1796
1809
|
emitDebug({
|
|
@@ -3342,9 +3355,6 @@ function buildSocketedRoute(options) {
|
|
|
3342
3355
|
buildSocketedRoute,
|
|
3343
3356
|
createRouteClient,
|
|
3344
3357
|
defaultFetcher,
|
|
3345
|
-
useSocketClient
|
|
3346
|
-
useSocketConnection,
|
|
3347
|
-
useSocketEvent,
|
|
3348
|
-
useSocketRooms
|
|
3358
|
+
useSocketClient
|
|
3349
3359
|
});
|
|
3350
3360
|
//# sourceMappingURL=index.cjs.map
|