@m4l/realtime-runtime 1.1.0 → 1.2.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.
Files changed (39) hide show
  1. package/contracts/index.d.ts +1 -1
  2. package/contracts/index.d.ts.map +1 -1
  3. package/contracts/types.d.ts +88 -4
  4. package/contracts/types.d.ts.map +1 -1
  5. package/engine/runtimeCore.d.ts +3 -1
  6. package/engine/runtimeCore.d.ts.map +1 -1
  7. package/engine/runtimeCore.js +9 -7
  8. package/index.d.ts +2 -1
  9. package/index.d.ts.map +1 -1
  10. package/index.js +7 -6
  11. package/package.json +1 -1
  12. package/transport/atmosphere/SourceDataAtmosphere.d.ts +41 -9
  13. package/transport/atmosphere/SourceDataAtmosphere.d.ts.map +1 -1
  14. package/transport/atmosphere/SourceDataAtmosphere.js +240 -96
  15. package/transport/atmosphere/createAtmosphereSourceData.d.ts +7 -3
  16. package/transport/atmosphere/createAtmosphereSourceData.d.ts.map +1 -1
  17. package/transport/atmosphere/createAtmosphereSourceData.js +33 -4
  18. package/transport/atmosphere/index.d.ts +1 -1
  19. package/transport/atmosphere/index.d.ts.map +1 -1
  20. package/transport/atmosphere/types.d.ts +24 -3
  21. package/transport/atmosphere/types.d.ts.map +1 -1
  22. package/transport/index.d.ts +1 -1
  23. package/transport/index.d.ts.map +1 -1
  24. package/web/index.d.ts +1 -1
  25. package/web/index.d.ts.map +1 -1
  26. package/web/runtime.d.ts.map +1 -1
  27. package/web/runtime.js +55 -53
  28. package/web/store.d.ts +2 -2
  29. package/web/store.d.ts.map +1 -1
  30. package/web/store.helpers.d.ts +24 -4
  31. package/web/store.helpers.d.ts.map +1 -1
  32. package/web/store.helpers.js +126 -23
  33. package/web/store.js +261 -80
  34. package/web/tools.d.ts.map +1 -1
  35. package/web/tools.js +15 -4
  36. package/web/types.d.ts +32 -3
  37. package/web/types.d.ts.map +1 -1
  38. package/web.d.ts +1 -1
  39. package/web.d.ts.map +1 -1
package/web/runtime.js CHANGED
@@ -1,95 +1,97 @@
1
1
  import { cloneDeep as l } from "lodash-es";
2
2
  import { createRealTimeStore as m } from "./store.js";
3
- import { createGetOrCreateRuntime as R } from "../engine/runtimeRegistry.js";
3
+ import { createGetOrCreateRuntime as p } from "../engine/runtimeRegistry.js";
4
4
  import { disposeRealtimeRuntime as A } from "../engine/runtimeRegistry.js";
5
- import { createRealtimeRuntimeApi as p } from "../engine/runtimeCore.js";
5
+ import { createRealtimeRuntimeApi as R } from "../engine/runtimeCore.js";
6
6
  import { createRealTimeProducerTools as d } from "./tools.js";
7
- function f(r, s) {
8
- return s.reduce((n, t) => {
9
- const e = t.staleResourceTtlMs;
10
- if (e === void 0 || e <= 0)
7
+ function f(s, r) {
8
+ return r.reduce((n, e) => {
9
+ const t = e.staleResourceTtlMs;
10
+ if (t === void 0 || t <= 0)
11
11
  return n;
12
- const o = t.staleResourceCleanupIntervalMs ?? Math.max(5e3, Math.min(e, 3e4)), u = globalThis.setInterval(() => {
13
- r.getState().realTimeProducerActions.cleanupStaleResources(
14
- t.resourceTypeId
12
+ const o = e.staleResourceCleanupIntervalMs ?? Math.max(5e3, Math.min(t, 3e4)), u = globalThis.setInterval(() => {
13
+ s.getState().realTimeProducerActions.cleanupStaleResources(
14
+ e.resourceTypeId
15
15
  );
16
16
  }, o);
17
17
  return n.push(u), n;
18
18
  }, []);
19
19
  }
20
- function T(r) {
21
- Object.values(r.getState().hasResourcesTypes).forEach((s) => {
22
- s.sourceDataClass.stop();
20
+ function T(s) {
21
+ Object.values(s.getState().hasResourcesTypes).forEach((r) => {
22
+ r.sourceDataClass.stop();
23
23
  });
24
24
  }
25
- function b(r, s) {
25
+ function b(s, r) {
26
26
  let n = !1;
27
27
  return function() {
28
- n || (n = !0, s.forEach((e) => {
29
- globalThis.clearInterval(e);
30
- }), T(r));
28
+ n || (n = !0, r.forEach((t) => {
29
+ globalThis.clearInterval(t);
30
+ }), T(s));
31
31
  };
32
32
  }
33
- function h(r, s, n) {
34
- return p({
33
+ function h(s, r, n) {
34
+ return R({
35
35
  dispose: n,
36
- getSnapshot: (t) => l(
37
- r.getState().hasResourcesTypes[t]?.hasResources ?? {}
36
+ getResourceTypeSnapshot: (e) => r.getResourceTypeSnapshot(e),
37
+ getSnapshot: (e) => l(
38
+ r.getResourceTypeSnapshot(e)
38
39
  ),
39
- getStatus: (t) => r.getState().hasResourcesTypes[t]?.status,
40
- subscribe: (t, e) => {
41
- s.subscribe(t, e);
40
+ getStatus: (e) => s.getState().hasResourcesTypes[e]?.status,
41
+ subscribe: (e, t) => {
42
+ r.subscribe(e, t);
42
43
  },
43
- unsubscribe: (t, e) => {
44
- s.unsubscribe(t, e);
44
+ subscribeResourceType: (e, t) => r.subscribeResourceType(e, t),
45
+ unsubscribe: (e, t) => {
46
+ r.unsubscribe(e, t);
45
47
  }
46
48
  });
47
49
  }
48
- function i(r, s) {
49
- const { storeDevtoolsEnabled: n = !1, ...t } = r, e = m(
50
- t,
50
+ function a(s, r) {
51
+ const { storeDevtoolsEnabled: n = !1, ...e } = s, t = m(
52
+ e,
51
53
  n,
52
- s
54
+ r
53
55
  ), o = f(
54
- e,
55
- t.resourceTypesConfig
56
- ), u = b(e, o), a = d(e), c = h(e, a, u);
57
- return e.getState().realTimeProducerActions.init(), {
56
+ t,
57
+ e.resourceTypesConfig
58
+ ), u = b(t, o), i = d(t), c = h(t, i, u);
59
+ return t.getState().realTimeProducerActions.init(), {
58
60
  runtime: c,
59
- store: e,
60
- tools: a
61
+ store: t,
62
+ tools: i
61
63
  };
62
64
  }
63
- function C(r, s) {
64
- return i(
65
- r,
66
- s
65
+ function P(s, r) {
66
+ return a(
67
+ s,
68
+ r
67
69
  ).runtime;
68
70
  }
69
- function M(r, s) {
70
- const { runtime: n, store: t, tools: e } = i(r, s);
71
+ function C(s, r) {
72
+ const { runtime: n, store: e, tools: t } = a(s, r);
71
73
  return {
72
74
  ...n,
73
- store: t,
74
- tools: e
75
+ store: e,
76
+ tools: t
75
77
  };
76
78
  }
77
- function D(r) {
78
- const s = R(r);
79
- return function(t) {
80
- const { runtimeKey: e, ...o } = t;
81
- return s({
79
+ function M(s) {
80
+ const r = p(s);
81
+ return function(e) {
82
+ const { runtimeKey: t, ...o } = e;
83
+ return r({
82
84
  createProps: {
83
85
  ...o,
84
- storeId: o.storeId ?? e
86
+ storeId: o.storeId ?? t
85
87
  },
86
- runtimeKey: e
88
+ runtimeKey: t
87
89
  });
88
90
  };
89
91
  }
90
92
  export {
91
- D as createGetOrCreateRealtimeRuntime,
92
- C as createRealtimeRuntime,
93
- M as createRealtimeRuntimeBundle,
93
+ M as createGetOrCreateRealtimeRuntime,
94
+ P as createRealtimeRuntime,
95
+ C as createRealtimeRuntimeBundle,
94
96
  A as disposeRealtimeRuntime
95
97
  };
package/web/store.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import { OnMessagesStoreCallback } from '../contracts';
1
+ import { OnMessagesStoreCallback, OnRealTimeProducerMetricCallback } from '../contracts';
2
2
  import { SourceDataBase } from '../transport/SourceDataBase';
3
3
  import { CreateRealTimeStoreProps, CreateRealtimeRuntimeProps, InitialRealTimeProducerStoreProps, RealTimeProducerStoreStateWithActions } from './types';
4
4
  /**
5
5
  * Factory contract used to create one source mechanism without forcing one global implementation.
6
6
  */
7
- export type CreateRealTimeSourceData = (config: InitialRealTimeProducerStoreProps['resourceTypesConfig'][number], onMessages: OnMessagesStoreCallback) => SourceDataBase;
7
+ export type CreateRealTimeSourceData = (config: InitialRealTimeProducerStoreProps['resourceTypesConfig'][number], onMessages: OnMessagesStoreCallback, onPerformanceMetric?: OnRealTimeProducerMetricCallback) => SourceDataBase;
8
8
  /**
9
9
  * Create the producer-side realtime store.
10
10
  */
@@ -1 +1 @@
1
- {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../../../packages/realtime-runtime/src/web/store.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,uBAAuB,EAIxB,MAAM,cAAc,CAAC;AAKtB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAQlE,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC1B,iCAAiC,EAGjC,qCAAqC,EACtC,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,CACrC,MAAM,EAAE,iCAAiC,CAAC,qBAAqB,CAAC,CAAC,MAAM,CAAC,EACxE,UAAU,EAAE,uBAAuB,KAChC,cAAc,CAAC;AAqBpB;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,wBAAwB,EACnC,oBAAoB,qBAAQ,EAC5B,gBAAgB,EAAE,wBAAwB;;EAgM3C;AACD,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC;AACvE,YAAY,EACV,wBAAwB,EACxB,0BAA0B,EAC1B,iCAAiC,GAClC,CAAC"}
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../../../packages/realtime-runtime/src/web/store.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,uBAAuB,EACvB,gCAAgC,EAOjC,MAAM,cAAc,CAAC;AAKtB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAYlE,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC1B,iCAAiC,EAIjC,qCAAqC,EACtC,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,CACrC,MAAM,EAAE,iCAAiC,CAAC,qBAAqB,CAAC,CAAC,MAAM,CAAC,EACxE,UAAU,EAAE,uBAAuB,EACnC,mBAAmB,CAAC,EAAE,gCAAgC,KACnD,cAAc,CAAC;AAoEpB;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,wBAAwB,EACnC,oBAAoB,qBAAQ,EAC5B,gBAAgB,EAAE,wBAAwB;;EA8b3C;AACD,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC;AACvE,YAAY,EACV,wBAAwB,EACxB,0BAA0B,EAC1B,iCAAiC,GAClC,CAAC"}
@@ -1,14 +1,34 @@
1
1
  import { DevtoolsOptions } from 'zustand/middleware';
2
2
  import { StateCreator } from 'zustand';
3
3
  import { ObjectQueue } from '../engine/ObjectQueue';
4
- import { RealTimeMessage, RealTimeResourceHash, RealTimeResourceSerialId, RealTimeResourceTypeId, Subscriber } from '../contracts';
5
- import { RealTimeProducerStoreStateWithActions } from './types';
4
+ import { RealTimeMessage, RealTimeMessageIngressReason, RealTimeMessagePayload, RealTimeResourceHash, RealTimeResourceSourceMechanismConfig, RealTimeResourceSerialId, RealTimeResourceTypeId, Subscriber } from '../contracts';
5
+ import { QueuedRealTimeMessage, RealTimeProducerStoreStateWithActions } from './types';
6
+ /**
7
+ * Apply one realtime patch into a mutable target using the runtime patch contract.
8
+ */
9
+ export declare function mergeRealtimePatch(target: RealTimeMessagePayload, patch: RealTimeMessagePayload): RealTimeMessagePayload;
10
+ /**
11
+ * Build a read-only working snapshot by copying only the root and patched branches.
12
+ */
13
+ export declare function createRealtimePatchedResourceSnapshot(currentResource: RealTimeMessagePayload | undefined, patch: RealTimeMessagePayload, resourceSerialId: RealTimeResourceSerialId): RealTimeMessagePayload;
6
14
  /**
7
15
  * Drain all queued realtime messages while preserving arrival order.
8
16
  */
9
- export declare function drainQueuedMessages(messagesQueue: ObjectQueue<RealTimeMessage>): RealTimeMessage[];
17
+ export declare function drainQueuedMessages(messagesQueue: ObjectQueue<QueuedRealTimeMessage>): QueuedRealTimeMessage[];
18
+ /**
19
+ * Group one incoming batch by its canonical per-message resource type before enqueueing it into producer queues.
20
+ */
21
+ export declare function groupMessagesByResourceTypeId(routingContextResourceTypeId: RealTimeResourceTypeId, messages: RealTimeMessage[], reason: RealTimeMessageIngressReason): Map<string, QueuedRealTimeMessage[]>;
22
+ /**
23
+ * Resolve the message that should be queued after resource-specific normalization.
24
+ */
25
+ export declare function normalizeProducerMessage(message: RealTimeMessage, resourceTypeConfig: RealTimeResourceSourceMechanismConfig, reason: RealTimeMessageIngressReason): RealTimeMessage;
26
+ /**
27
+ * Resolve the message that should be applied and emitted after resource-specific sanitization.
28
+ */
29
+ export declare function sanitizeProducerMessage(currentResource: RealTimeMessagePayload | undefined, message: RealTimeMessage, resourceTypeConfig: RealTimeResourceSourceMechanismConfig, reason: RealTimeMessageIngressReason): RealTimeMessage;
10
30
  /**
11
- * Apply one realtime message to the producer-side resource hash.
31
+ * Apply one already-sanitized realtime message to the producer-side resource hash.
12
32
  */
13
33
  export declare function applyProducerMessage(hasResources: RealTimeResourceHash, lastSeenByResource: Map<RealTimeResourceSerialId, number>, message: RealTimeMessage, receivedAtMs: number): void;
14
34
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"store.helpers.d.ts","sourceRoot":"","sources":["../../../../../packages/realtime-runtime/src/web/store.helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACpB,wBAAwB,EACxB,sBAAsB,EACtB,UAAU,EACX,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,SAAS,CAAC;AAErE;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,WAAW,CAAC,eAAe,CAAC,qBAY9E;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,oBAAoB,EAClC,kBAAkB,EAAE,GAAG,CAAC,wBAAwB,EAAE,MAAM,CAAC,EACzD,OAAO,EAAE,eAAe,EACxB,YAAY,EAAE,MAAM,QAiBrB;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,cAAc,EAAE,sBAAsB,EACtC,iBAAiB,EAAE,MAAM,CAAC,wBAAwB,EAAE,UAAU,CAAC,EAC/D,eAAe,EAAE,eAAe,EAAE,QAOnC;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,eAAe,EAAE,YAAY,CAAC,qCAAqC,EAAE,EAAE,EAAE,CAAC,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC,CAAC,EACpG,MAAM,EAAE,eAAe,GACtB,YAAY,CAAC,qCAAqC,EAAE,EAAE,EAAE,CAAC,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC,CAAC,CAYrF"}
1
+ {"version":3,"file":"store.helpers.d.ts","sourceRoot":"","sources":["../../../../../packages/realtime-runtime/src/web/store.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EACV,eAAe,EACf,4BAA4B,EAC5B,sBAAsB,EACtB,oBAAoB,EACpB,qCAAqC,EACrC,wBAAwB,EACxB,sBAAsB,EACtB,UAAU,EACX,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EACV,qBAAqB,EACrB,qCAAqC,EACtC,MAAM,SAAS,CAAC;AAgEjB;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,sBAAsB,EAC9B,KAAK,EAAE,sBAAsB,0BAmB9B;AAED;;GAEG;AACH,wBAAgB,qCAAqC,CACnD,eAAe,EAAE,sBAAsB,GAAG,SAAS,EACnD,KAAK,EAAE,sBAAsB,EAC7B,gBAAgB,EAAE,wBAAwB,0BAO3C;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,WAAW,CAAC,qBAAqB,CAAC,2BAYpF;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAC3C,4BAA4B,EAAE,sBAAsB,EACpD,QAAQ,EAAE,eAAe,EAAE,EAC3B,MAAM,EAAE,4BAA4B,wCAgCrC;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,eAAe,EACxB,kBAAkB,EAAE,qCAAqC,EACzD,MAAM,EAAE,4BAA4B,mBASrC;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,eAAe,EAAE,sBAAsB,GAAG,SAAS,EACnD,OAAO,EAAE,eAAe,EACxB,kBAAkB,EAAE,qCAAqC,EACzD,MAAM,EAAE,4BAA4B,mBA0BrC;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,oBAAoB,EAClC,kBAAkB,EAAE,GAAG,CAAC,wBAAwB,EAAE,MAAM,CAAC,EACzD,OAAO,EAAE,eAAe,EACxB,YAAY,EAAE,MAAM,QAoBrB;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,cAAc,EAAE,sBAAsB,EACtC,iBAAiB,EAAE,MAAM,CAAC,wBAAwB,EAAE,UAAU,CAAC,EAC/D,eAAe,EAAE,eAAe,EAAE,QAOnC;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,eAAe,EAAE,YAAY,CAAC,qCAAqC,EAAE,EAAE,EAAE,CAAC,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC,CAAC,EACpG,MAAM,EAAE,eAAe,GACtB,YAAY,CAAC,qCAAqC,EAAE,EAAE,EAAE,CAAC,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC,CAAC,CAYrF"}
@@ -1,35 +1,138 @@
1
- import { cloneDeep as c, merge as i } from "lodash-es";
2
- import { devtools as l } from "zustand/middleware";
3
- function p(e) {
4
- const t = [];
1
+ import { devtools as f } from "zustand/middleware";
2
+ function u(e) {
3
+ if (typeof e != "object" || e === null || Array.isArray(e))
4
+ return !1;
5
+ const r = Object.getPrototypeOf(e);
6
+ return r === Object.prototype || r === null;
7
+ }
8
+ function a(e) {
9
+ return Array.isArray(e) ? e.map(a) : u(e) ? d({}, e) : e;
10
+ }
11
+ function p(e, r) {
12
+ const t = u(e) ? { ...e } : {};
13
+ return Object.entries(r).forEach(([o, n]) => {
14
+ if (n === void 0) {
15
+ delete t[o];
16
+ return;
17
+ }
18
+ const c = t[o];
19
+ if (u(c) && u(n)) {
20
+ t[o] = p(c, n);
21
+ return;
22
+ }
23
+ t[o] = a(n);
24
+ }), t;
25
+ }
26
+ function d(e, r) {
27
+ return Object.entries(r).forEach(([t, o]) => {
28
+ if (o === void 0) {
29
+ delete e[t];
30
+ return;
31
+ }
32
+ const n = e[t];
33
+ if (u(n) && u(o)) {
34
+ d(n, o);
35
+ return;
36
+ }
37
+ e[t] = a(o);
38
+ }), e;
39
+ }
40
+ function y(e, r, t) {
41
+ const o = p(e, r);
42
+ return o.resourceSerialId = t, o;
43
+ }
44
+ function b(e) {
45
+ const r = [];
5
46
  for (; !e.isEmpty(); ) {
6
- const o = e.dequeue();
7
- o && t.push(o);
47
+ const t = e.dequeue();
48
+ t && r.push(t);
8
49
  }
9
- return t;
50
+ return r;
10
51
  }
11
- function u(e, t, o, s) {
12
- const { payload: n, resourceSerialId: r, type: a } = o;
13
- if (a === "delete") {
14
- delete e[r], t.delete(r);
52
+ function I(e, r, t) {
53
+ const o = /* @__PURE__ */ new Map();
54
+ return r.forEach((n) => {
55
+ if (!n.resourceTypeId) {
56
+ console.error(
57
+ "Realtime producer received one message without resourceTypeId; dropping it because every message must carry its own resourceTypeId.",
58
+ {
59
+ routingContextResourceTypeId: e,
60
+ message: n
61
+ }
62
+ );
63
+ return;
64
+ }
65
+ const c = {
66
+ message: n,
67
+ reason: t
68
+ }, i = o.get(n.resourceTypeId);
69
+ if (i) {
70
+ i.push(c);
71
+ return;
72
+ }
73
+ o.set(n.resourceTypeId, [c]);
74
+ }), o;
75
+ }
76
+ function h(e, r, t) {
77
+ return r.normalizeMessageStrategy?.(
78
+ e,
79
+ {
80
+ reason: t,
81
+ resourceTypeId: e.resourceTypeId
82
+ }
83
+ ) ?? e;
84
+ }
85
+ function P(e, r, t, o) {
86
+ const { payload: n, resourceSerialId: c, type: i } = r;
87
+ if (i === "delete")
88
+ return r;
89
+ const s = t.mergePayloadStrategy?.(
90
+ e,
91
+ n,
92
+ {
93
+ reason: o,
94
+ resourceSerialId: c,
95
+ resourceTypeId: r.resourceTypeId
96
+ }
97
+ ) ?? n;
98
+ return s === n ? r : {
99
+ ...r,
100
+ payload: s
101
+ };
102
+ }
103
+ function m(e, r, t, o) {
104
+ const { payload: n, resourceSerialId: c, type: i } = t;
105
+ if (i === "delete") {
106
+ delete e[c], r.delete(c);
15
107
  return;
16
108
  }
17
- e[r] ? i(e[r], n) : e[r] = { ...c(n), resourceSerialId: r }, t.set(r, s);
109
+ if (e[c])
110
+ d(e[c], n);
111
+ else {
112
+ const s = {};
113
+ e[c] = d(s, n);
114
+ }
115
+ e[c].resourceSerialId = c, r.set(c, o);
18
116
  }
19
- function b(e, t, o) {
20
- Object.values(t).forEach((s) => {
21
- s.onMessageCallbacks.forEach((n) => {
22
- n(e, o);
117
+ function M(e, r, t) {
118
+ Object.values(r).forEach((o) => {
119
+ o.onMessageCallbacks.forEach((n) => {
120
+ n(e, t);
23
121
  });
24
122
  });
25
123
  }
26
- function m(e, t) {
27
- const { enabled: o = !1 } = t;
28
- return o && process.env.NODE_ENV === "development" ? l(e, t) : e;
124
+ function O(e, r) {
125
+ const { enabled: t = !1 } = r;
126
+ return t && process.env.NODE_ENV === "development" ? f(e, r) : e;
29
127
  }
30
128
  export {
31
- u as applyProducerMessage,
32
- m as createProducerDevtools,
33
- p as drainQueuedMessages,
34
- b as notifySubscribersWithBatch
129
+ m as applyProducerMessage,
130
+ O as createProducerDevtools,
131
+ y as createRealtimePatchedResourceSnapshot,
132
+ b as drainQueuedMessages,
133
+ I as groupMessagesByResourceTypeId,
134
+ d as mergeRealtimePatch,
135
+ h as normalizeProducerMessage,
136
+ M as notifySubscribersWithBatch,
137
+ P as sanitizeProducerMessage
35
138
  };