@emeryld/rrroutes-client 2.7.13 → 2.8.1
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/README.md +15 -0
- 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.batch.d.ts +1 -1
- package/dist/routesV3.client.d.ts +2 -2
- package/dist/routesV3.client.get.d.ts +1 -1
- package/dist/routesV3.client.infiniteGet.d.ts +1 -1
- package/dist/routesV3.client.mutation.d.ts +1 -1
- package/dist/routesV3.client.types.d.ts +44 -38
- 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.mjs
CHANGED
|
@@ -1448,6 +1448,12 @@ function createRouteClient(opts) {
|
|
|
1448
1448
|
configurable: false,
|
|
1449
1449
|
writable: false
|
|
1450
1450
|
});
|
|
1451
|
+
Object.defineProperty(built, "metadata", {
|
|
1452
|
+
value: { leaf },
|
|
1453
|
+
enumerable: true,
|
|
1454
|
+
configurable: false,
|
|
1455
|
+
writable: false
|
|
1456
|
+
});
|
|
1451
1457
|
return built;
|
|
1452
1458
|
}
|
|
1453
1459
|
const fetchRaw = async (input) => {
|
|
@@ -1569,6 +1575,15 @@ function safeSerialize(value) {
|
|
|
1569
1575
|
return "[unserializable]";
|
|
1570
1576
|
}
|
|
1571
1577
|
}
|
|
1578
|
+
function derivePayloadIdentity(payload) {
|
|
1579
|
+
if (!payload || typeof payload !== "object") return void 0;
|
|
1580
|
+
const record = payload;
|
|
1581
|
+
const idCandidate = record.id ?? record._id ?? record.notificationId ?? record.uuid ?? record.key;
|
|
1582
|
+
if (typeof idCandidate === "string" || typeof idCandidate === "number" || typeof idCandidate === "bigint") {
|
|
1583
|
+
return String(idCandidate);
|
|
1584
|
+
}
|
|
1585
|
+
return void 0;
|
|
1586
|
+
}
|
|
1572
1587
|
function useLatestRef(value) {
|
|
1573
1588
|
const ref = React2.useRef(value);
|
|
1574
1589
|
React2.useEffect(() => {
|
|
@@ -1754,10 +1769,11 @@ function useSocketEvent(args) {
|
|
|
1754
1769
|
emitDebug({ type: "subscription", phase: "register", event });
|
|
1755
1770
|
const unsubscribe = client.on(event, (payload, meta) => {
|
|
1756
1771
|
const dedupeCfg = messageDeduplicationRef.current;
|
|
1757
|
-
if (dedupeCfg) {
|
|
1758
|
-
const ttlMs = Math.max(0, dedupeCfg
|
|
1772
|
+
if (dedupeCfg !== false) {
|
|
1773
|
+
const ttlMs = Math.max(0, dedupeCfg?.ttlMs ?? 2500);
|
|
1759
1774
|
const now = Date.now();
|
|
1760
|
-
const
|
|
1775
|
+
const payloadId = derivePayloadIdentity(payload);
|
|
1776
|
+
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)}`);
|
|
1761
1777
|
const prev = seenMessageKeysRef.current.get(dedupeKey);
|
|
1762
1778
|
if (typeof prev === "number" && now - prev <= ttlMs) {
|
|
1763
1779
|
emitDebug({
|
|
@@ -3308,9 +3324,6 @@ export {
|
|
|
3308
3324
|
buildSocketedRoute,
|
|
3309
3325
|
createRouteClient,
|
|
3310
3326
|
defaultFetcher,
|
|
3311
|
-
useSocketClient
|
|
3312
|
-
useSocketConnection,
|
|
3313
|
-
useSocketEvent,
|
|
3314
|
-
useSocketRooms
|
|
3327
|
+
useSocketClient
|
|
3315
3328
|
};
|
|
3316
3329
|
//# sourceMappingURL=index.mjs.map
|