@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.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.ttlMs ?? 1500);
1772
+ if (dedupeCfg !== false) {
1773
+ const ttlMs = Math.max(0, dedupeCfg?.ttlMs ?? 2500);
1759
1774
  const now = Date.now();
1760
- const dedupeKey = dedupeCfg.key?.(payload, meta) ?? (meta?.envelope ? `${event}|${String(meta.envelope.eventName)}|${String(meta.envelope.sentAt)}|${safeSerialize(payload)}` : `${event}|${safeSerialize(payload)}`);
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