@graphrefly/graphrefly 0.22.0 → 0.23.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 (78) hide show
  1. package/dist/{chunk-RHI3GHZW.js → chunk-263BEJJO.js} +3 -3
  2. package/dist/{chunk-44HD4BTA.js → chunk-2GQLMQVJ.js} +3 -3
  3. package/dist/chunk-32N5A454.js +36 -0
  4. package/dist/chunk-32N5A454.js.map +1 -0
  5. package/dist/{chunk-IR3KMOLX.js → chunk-CWYPA63G.js} +3 -383
  6. package/dist/chunk-CWYPA63G.js.map +1 -0
  7. package/dist/{chunk-TH6COGOP.js → chunk-HVBX5KIW.js} +2 -2
  8. package/dist/chunk-JFONSPNF.js +391 -0
  9. package/dist/chunk-JFONSPNF.js.map +1 -0
  10. package/dist/{chunk-QA3RP5NH.js → chunk-NZMBRXQV.js} +101 -5
  11. package/dist/chunk-NZMBRXQV.js.map +1 -0
  12. package/dist/{chunk-MQBQOFDS.js → chunk-PNUZM7PC.js} +12 -31
  13. package/dist/chunk-PNUZM7PC.js.map +1 -0
  14. package/dist/{chunk-EQUZ5NLD.js → chunk-PX6PDUJ5.js} +11 -16
  15. package/dist/chunk-PX6PDUJ5.js.map +1 -0
  16. package/dist/{chunk-NXC35KC5.js → chunk-XRFJJ2IU.js} +3 -3
  17. package/dist/{chunk-BLD3IFYF.js → chunk-XTLYW4FR.js} +9 -7
  18. package/dist/{chunk-BLD3IFYF.js.map → chunk-XTLYW4FR.js.map} +1 -1
  19. package/dist/compat/nestjs/index.cjs +100 -4
  20. package/dist/compat/nestjs/index.cjs.map +1 -1
  21. package/dist/compat/nestjs/index.d.cts +6 -6
  22. package/dist/compat/nestjs/index.d.ts +6 -6
  23. package/dist/compat/nestjs/index.js +9 -7
  24. package/dist/core/index.cjs +100 -4
  25. package/dist/core/index.cjs.map +1 -1
  26. package/dist/core/index.d.cts +3 -3
  27. package/dist/core/index.d.ts +3 -3
  28. package/dist/core/index.js +3 -3
  29. package/dist/extra/index.cjs +100 -4
  30. package/dist/extra/index.cjs.map +1 -1
  31. package/dist/extra/index.d.cts +4 -4
  32. package/dist/extra/index.d.ts +4 -4
  33. package/dist/extra/index.js +9 -7
  34. package/dist/graph/index.cjs +100 -4
  35. package/dist/graph/index.cjs.map +1 -1
  36. package/dist/graph/index.d.cts +5 -5
  37. package/dist/graph/index.d.ts +5 -5
  38. package/dist/graph/index.js +4 -4
  39. package/dist/{graph-ab1yPwIB.d.cts → graph-BtdSRHUc.d.cts} +3 -3
  40. package/dist/{graph-DFr0diXB.d.ts → graph-CEO2FkLY.d.ts} +3 -3
  41. package/dist/{index-BvWfZCTt.d.cts → index-B0tfuXwV.d.cts} +3 -3
  42. package/dist/{index-Dy04P4W3.d.cts → index-BFGjXbiP.d.cts} +2 -2
  43. package/dist/{index-DrJq9B1T.d.cts → index-BPlWVAKY.d.cts} +3 -3
  44. package/dist/{index-C9z6rU9P.d.cts → index-BUj3ASVe.d.cts} +25 -7
  45. package/dist/{index-DLE1Sp-L.d.cts → index-C59uSJAH.d.cts} +2 -2
  46. package/dist/{index-DsGxLfwL.d.ts → index-CkElcUY6.d.ts} +2 -2
  47. package/dist/{index-HdJx_BjO.d.ts → index-DSPc5rkv.d.ts} +25 -7
  48. package/dist/{index-D36MAQ3f.d.ts → index-DgscL7v0.d.ts} +3 -3
  49. package/dist/{index-BbYZma8G.d.ts → index-RXN94sHK.d.ts} +3 -3
  50. package/dist/{index-BHm3Ba5q.d.ts → index-jEtF4N7L.d.ts} +2 -2
  51. package/dist/index.cjs +109 -14
  52. package/dist/index.cjs.map +1 -1
  53. package/dist/index.d.cts +15 -15
  54. package/dist/index.d.ts +15 -15
  55. package/dist/index.js +26 -22
  56. package/dist/index.js.map +1 -1
  57. package/dist/{meta-n3FoVWML.d.ts → meta-3QjzotRv.d.ts} +1 -1
  58. package/dist/{meta--fr9sxRM.d.cts → meta-B-Lbs4-O.d.cts} +1 -1
  59. package/dist/{node-C5UD5MGq.d.cts → node-C7PD3sn9.d.cts} +42 -0
  60. package/dist/{node-C5UD5MGq.d.ts → node-C7PD3sn9.d.ts} +42 -0
  61. package/dist/{observable-CQRBtEbq.d.ts → observable-EyO-moQY.d.ts} +1 -1
  62. package/dist/{observable-DWydVy5b.d.cts → observable-axpzv1K2.d.cts} +1 -1
  63. package/dist/patterns/reactive-layout/index.cjs +214 -117
  64. package/dist/patterns/reactive-layout/index.cjs.map +1 -1
  65. package/dist/patterns/reactive-layout/index.d.cts +5 -5
  66. package/dist/patterns/reactive-layout/index.d.ts +5 -5
  67. package/dist/patterns/reactive-layout/index.js +6 -4
  68. package/dist/{storage-C9fZfMfM.d.ts → storage-CHT5WE9m.d.ts} +1 -1
  69. package/dist/{storage-Bew05Xy6.d.cts → storage-DIgAr7M_.d.cts} +1 -1
  70. package/package.json +2 -1
  71. package/dist/chunk-EQUZ5NLD.js.map +0 -1
  72. package/dist/chunk-IR3KMOLX.js.map +0 -1
  73. package/dist/chunk-MQBQOFDS.js.map +0 -1
  74. package/dist/chunk-QA3RP5NH.js.map +0 -1
  75. /package/dist/{chunk-RHI3GHZW.js.map → chunk-263BEJJO.js.map} +0 -0
  76. /package/dist/{chunk-44HD4BTA.js.map → chunk-2GQLMQVJ.js.map} +0 -0
  77. /package/dist/{chunk-TH6COGOP.js.map → chunk-HVBX5KIW.js.map} +0 -0
  78. /package/dist/{chunk-NXC35KC5.js.map → chunk-XRFJJ2IU.js.map} +0 -0
@@ -1,9 +1,9 @@
1
- export { T as ToObservableOptions, t as toObservable } from '../../observable-DWydVy5b.cjs';
2
- export { A as ACTOR_KEY, a as ActorExtractor, C as COMMAND_HANDLERS, b as CQRS_EVENT_HANDLERS, d as CRON_HANDLERS, e as CommandHandler, f as CommandHandlerMeta, E as EVENT_HANDLERS, g as EventHandler, h as EventHandlerMeta, G as GRAPHREFLY_REQUEST_GRAPH, j as GRAPHREFLY_ROOT_GRAPH, k as GraphCron, l as GraphCronMeta, m as GraphInterval, n as GraphIntervalMeta, o as GraphReflyCqrsOptions, p as GraphReflyEventExplorer, q as GraphReflyFeatureOptions, r as GraphReflyGuard, s as GraphReflyGuardImpl, t as GraphReflyModule, u as GraphReflyRootOptions, I as INTERVAL_HANDLERS, v as InjectCqrsGraph, w as InjectGraph, x as InjectNode, O as ObserveGateway, y as ObserveGatewayOptions, z as ObserveSSEOptions, B as ObserveSubscriptionOptions, D as ObserveWsCommand, F as ObserveWsMessage, H as OnGraphEvent, J as OnGraphEventMeta, Q as QUERY_HANDLERS, K as QueryHandler, L as QueryHandlerMeta, S as SAGA_HANDLERS, M as SagaHandler, N as SagaHandlerMeta, P as fromHeader, R as fromJwtPayload, T as getActor, U as getGraphToken, V as getNodeToken, W as observeSSE, X as observeSubscription } from '../../index-DrJq9B1T.cjs';
1
+ export { T as ToObservableOptions, t as toObservable } from '../../observable-axpzv1K2.cjs';
2
+ export { A as ACTOR_KEY, a as ActorExtractor, C as COMMAND_HANDLERS, b as CQRS_EVENT_HANDLERS, d as CRON_HANDLERS, e as CommandHandler, f as CommandHandlerMeta, E as EVENT_HANDLERS, g as EventHandler, h as EventHandlerMeta, G as GRAPHREFLY_REQUEST_GRAPH, j as GRAPHREFLY_ROOT_GRAPH, k as GraphCron, l as GraphCronMeta, m as GraphInterval, n as GraphIntervalMeta, o as GraphReflyCqrsOptions, p as GraphReflyEventExplorer, q as GraphReflyFeatureOptions, r as GraphReflyGuard, s as GraphReflyGuardImpl, t as GraphReflyModule, u as GraphReflyRootOptions, I as INTERVAL_HANDLERS, v as InjectCqrsGraph, w as InjectGraph, x as InjectNode, O as ObserveGateway, y as ObserveGatewayOptions, z as ObserveSSEOptions, B as ObserveSubscriptionOptions, D as ObserveWsCommand, F as ObserveWsMessage, H as OnGraphEvent, J as OnGraphEventMeta, Q as QUERY_HANDLERS, K as QueryHandler, L as QueryHandlerMeta, S as SAGA_HANDLERS, M as SagaHandler, N as SagaHandlerMeta, P as fromHeader, R as fromJwtPayload, T as getActor, U as getGraphToken, V as getNodeToken, W as observeSSE, X as observeSubscription } from '../../index-BPlWVAKY.cjs';
3
3
  import 'rxjs';
4
- import '../../node-C5UD5MGq.cjs';
4
+ import '../../node-C7PD3sn9.cjs';
5
5
  import '@nestjs/common';
6
6
  import '@nestjs/core';
7
- import '../../graph-ab1yPwIB.cjs';
8
- import '../../meta--fr9sxRM.cjs';
9
- import '../../storage-Bew05Xy6.cjs';
7
+ import '../../graph-BtdSRHUc.cjs';
8
+ import '../../meta-B-Lbs4-O.cjs';
9
+ import '../../storage-DIgAr7M_.cjs';
@@ -1,9 +1,9 @@
1
- export { T as ToObservableOptions, t as toObservable } from '../../observable-CQRBtEbq.js';
2
- export { A as ACTOR_KEY, a as ActorExtractor, C as COMMAND_HANDLERS, b as CQRS_EVENT_HANDLERS, d as CRON_HANDLERS, e as CommandHandler, f as CommandHandlerMeta, E as EVENT_HANDLERS, g as EventHandler, h as EventHandlerMeta, G as GRAPHREFLY_REQUEST_GRAPH, j as GRAPHREFLY_ROOT_GRAPH, k as GraphCron, l as GraphCronMeta, m as GraphInterval, n as GraphIntervalMeta, o as GraphReflyCqrsOptions, p as GraphReflyEventExplorer, q as GraphReflyFeatureOptions, r as GraphReflyGuard, s as GraphReflyGuardImpl, t as GraphReflyModule, u as GraphReflyRootOptions, I as INTERVAL_HANDLERS, v as InjectCqrsGraph, w as InjectGraph, x as InjectNode, O as ObserveGateway, y as ObserveGatewayOptions, z as ObserveSSEOptions, B as ObserveSubscriptionOptions, D as ObserveWsCommand, F as ObserveWsMessage, H as OnGraphEvent, J as OnGraphEventMeta, Q as QUERY_HANDLERS, K as QueryHandler, L as QueryHandlerMeta, S as SAGA_HANDLERS, M as SagaHandler, N as SagaHandlerMeta, P as fromHeader, R as fromJwtPayload, T as getActor, U as getGraphToken, V as getNodeToken, W as observeSSE, X as observeSubscription } from '../../index-D36MAQ3f.js';
1
+ export { T as ToObservableOptions, t as toObservable } from '../../observable-EyO-moQY.js';
2
+ export { A as ACTOR_KEY, a as ActorExtractor, C as COMMAND_HANDLERS, b as CQRS_EVENT_HANDLERS, d as CRON_HANDLERS, e as CommandHandler, f as CommandHandlerMeta, E as EVENT_HANDLERS, g as EventHandler, h as EventHandlerMeta, G as GRAPHREFLY_REQUEST_GRAPH, j as GRAPHREFLY_ROOT_GRAPH, k as GraphCron, l as GraphCronMeta, m as GraphInterval, n as GraphIntervalMeta, o as GraphReflyCqrsOptions, p as GraphReflyEventExplorer, q as GraphReflyFeatureOptions, r as GraphReflyGuard, s as GraphReflyGuardImpl, t as GraphReflyModule, u as GraphReflyRootOptions, I as INTERVAL_HANDLERS, v as InjectCqrsGraph, w as InjectGraph, x as InjectNode, O as ObserveGateway, y as ObserveGatewayOptions, z as ObserveSSEOptions, B as ObserveSubscriptionOptions, D as ObserveWsCommand, F as ObserveWsMessage, H as OnGraphEvent, J as OnGraphEventMeta, Q as QUERY_HANDLERS, K as QueryHandler, L as QueryHandlerMeta, S as SAGA_HANDLERS, M as SagaHandler, N as SagaHandlerMeta, P as fromHeader, R as fromJwtPayload, T as getActor, U as getGraphToken, V as getNodeToken, W as observeSSE, X as observeSubscription } from '../../index-DgscL7v0.js';
3
3
  import 'rxjs';
4
- import '../../node-C5UD5MGq.js';
4
+ import '../../node-C7PD3sn9.js';
5
5
  import '@nestjs/common';
6
6
  import '@nestjs/core';
7
- import '../../graph-DFr0diXB.js';
8
- import '../../meta-n3FoVWML.js';
9
- import '../../storage-C9fZfMfM.js';
7
+ import '../../graph-CEO2FkLY.js';
8
+ import '../../meta-3QjzotRv.js';
9
+ import '../../storage-CHT5WE9m.js';
@@ -31,16 +31,18 @@ import {
31
31
  getNodeToken,
32
32
  observeSSE,
33
33
  observeSubscription
34
- } from "../../chunk-MQBQOFDS.js";
35
- import "../../chunk-RHI3GHZW.js";
36
- import "../../chunk-44HD4BTA.js";
34
+ } from "../../chunk-PNUZM7PC.js";
35
+ import "../../chunk-263BEJJO.js";
37
36
  import {
38
37
  toObservable
39
- } from "../../chunk-IR3KMOLX.js";
40
- import "../../chunk-NXC35KC5.js";
41
- import "../../chunk-TH6COGOP.js";
38
+ } from "../../chunk-JFONSPNF.js";
39
+ import "../../chunk-2GQLMQVJ.js";
40
+ import "../../chunk-32N5A454.js";
41
+ import "../../chunk-CWYPA63G.js";
42
+ import "../../chunk-XRFJJ2IU.js";
43
+ import "../../chunk-HVBX5KIW.js";
42
44
  import "../../chunk-7TAQJHQV.js";
43
- import "../../chunk-QA3RP5NH.js";
45
+ import "../../chunk-NZMBRXQV.js";
44
46
  export {
45
47
  ACTOR_KEY,
46
48
  COMMAND_HANDLERS,
@@ -92,9 +92,20 @@ var flushInProgress = false;
92
92
  var drainPhase2 = [];
93
93
  var drainPhase3 = [];
94
94
  var drainPhase4 = [];
95
+ var flushHooks = [];
95
96
  function isBatching() {
96
97
  return batchDepth > 0 || flushInProgress;
97
98
  }
99
+ function isExplicitlyBatching() {
100
+ return batchDepth > 0;
101
+ }
102
+ function registerBatchFlushHook(hook) {
103
+ if (batchDepth > 0) {
104
+ flushHooks.push(hook);
105
+ } else {
106
+ hook();
107
+ }
108
+ }
98
109
  function batch(fn) {
99
110
  batchDepth += 1;
100
111
  let threw = false;
@@ -108,6 +119,13 @@ function batch(fn) {
108
119
  if (batchDepth === 0) {
109
120
  if (threw) {
110
121
  if (!flushInProgress) {
122
+ const hooks = flushHooks.splice(0);
123
+ for (const h of hooks) {
124
+ try {
125
+ h();
126
+ } catch {
127
+ }
128
+ }
111
129
  drainPhase2.length = 0;
112
130
  drainPhase3.length = 0;
113
131
  drainPhase4.length = 0;
@@ -124,7 +142,18 @@ function drainPending() {
124
142
  const errors = [];
125
143
  let iterations = 0;
126
144
  try {
127
- while (drainPhase2.length > 0 || drainPhase3.length > 0 || drainPhase4.length > 0) {
145
+ while (drainPhase2.length > 0 || drainPhase3.length > 0 || drainPhase4.length > 0 || ownsFlush && flushHooks.length > 0) {
146
+ if (ownsFlush && flushHooks.length > 0) {
147
+ const hooks = flushHooks.splice(0);
148
+ for (const h of hooks) {
149
+ try {
150
+ h();
151
+ } catch (e) {
152
+ errors.push(e);
153
+ }
154
+ }
155
+ continue;
156
+ }
128
157
  iterations += 1;
129
158
  if (iterations > MAX_DRAIN_ITERATIONS) {
130
159
  drainPhase2.length = 0;
@@ -855,6 +884,22 @@ var NodeImpl = class _NodeImpl {
855
884
  * treats `0` as "wave settled" — O(1) check for full dep settlement.
856
885
  */
857
886
  _dirtyDepCount = 0;
887
+ // --- Per-batch emit accumulator (Bug 2: K+1 fan-in fix) ---
888
+ /**
889
+ * Inside an explicit `batch(() => ...)` scope, every `_emit` accumulates
890
+ * its already-framed messages here instead of dispatching synchronously.
891
+ * At batch end, `_flushBatchPending` runs (registered via
892
+ * `registerBatchFlushHook`) and delivers the whole accumulated batch as
893
+ * one `downWithBatch` call — collapsing what would otherwise be K
894
+ * separate sink invocations into one. This is the fix for the diamond
895
+ * fan-in K+1 over-fire.
896
+ *
897
+ * `null` outside batch (or after flush). Only ever appended to within
898
+ * a single explicit batch lifetime; reset to `null` on flush. State
899
+ * updates (cache, version, status) still happen per-emit via
900
+ * `_updateState` — only the downstream delivery is coalesced.
901
+ */
902
+ _batchPendingMessages = null;
858
903
  // --- PAUSE/RESUME lock tracking (C0) ---
859
904
  /**
860
905
  * Set of active pause locks held against this node. Every `[PAUSE, lockId]`
@@ -1232,7 +1277,10 @@ var NodeImpl = class _NodeImpl {
1232
1277
  dep.unsub = noopUnsub;
1233
1278
  dep.unsub = dep.node.subscribe((msgs) => {
1234
1279
  if (dep.unsub === null) return;
1280
+ const tierOf = this._config.tierOf;
1281
+ let sawSettlement = false;
1235
1282
  for (const m of msgs) {
1283
+ if (tierOf(m[0]) >= 3) sawSettlement = true;
1236
1284
  this._config.onMessage(
1237
1285
  this,
1238
1286
  m,
@@ -1240,6 +1288,7 @@ var NodeImpl = class _NodeImpl {
1240
1288
  this._actions
1241
1289
  );
1242
1290
  }
1291
+ if (sawSettlement) this._maybeRunFnOnSettlement();
1243
1292
  });
1244
1293
  subscribedCount++;
1245
1294
  }
@@ -1294,7 +1343,10 @@ var NodeImpl = class _NodeImpl {
1294
1343
  try {
1295
1344
  record.unsub = depNode.subscribe((msgs) => {
1296
1345
  if (record.unsub === null) return;
1346
+ const tierOf = this._config.tierOf;
1347
+ let sawSettlement = false;
1297
1348
  for (const m of msgs) {
1349
+ if (tierOf(m[0]) >= 3) sawSettlement = true;
1298
1350
  this._config.onMessage(
1299
1351
  this,
1300
1352
  m,
@@ -1302,6 +1354,7 @@ var NodeImpl = class _NodeImpl {
1302
1354
  this._actions
1303
1355
  );
1304
1356
  }
1357
+ if (sawSettlement) this._maybeRunFnOnSettlement();
1305
1358
  });
1306
1359
  } catch (err) {
1307
1360
  record.unsub = null;
@@ -1423,7 +1476,6 @@ var NodeImpl = class _NodeImpl {
1423
1476
  }
1424
1477
  return;
1425
1478
  }
1426
- this._maybeRunFnOnSettlement();
1427
1479
  }
1428
1480
  // --- Centralized dep-state transitions (A3 settlement counters) ---
1429
1481
  //
@@ -1795,10 +1847,10 @@ var NodeImpl = class _NodeImpl {
1795
1847
  }
1796
1848
  }
1797
1849
  if (immediate.length > 0) {
1798
- downWithBatch(this._deliverToSinks, immediate, tierOf);
1850
+ this._dispatchOrAccumulate(immediate);
1799
1851
  }
1800
1852
  } else {
1801
- downWithBatch(this._deliverToSinks, finalMessages, this._config.tierOf);
1853
+ this._dispatchOrAccumulate(finalMessages);
1802
1854
  }
1803
1855
  }
1804
1856
  if (equalsError != null) {
@@ -1921,6 +1973,50 @@ var NodeImpl = class _NodeImpl {
1921
1973
  const snapshot = [...this._sinks];
1922
1974
  for (const sink of snapshot) sink(messages);
1923
1975
  };
1976
+ /**
1977
+ * @internal Dispatch entry point that respects the per-batch emit
1978
+ * accumulator (Bug 2). Inside an explicit `batch()` scope, append to
1979
+ * `_batchPendingMessages` and register a flush hook on first append.
1980
+ * Outside batch — or during a drain (where `flushInProgress` is true
1981
+ * but `batchDepth` is 0) — dispatch synchronously through `downWithBatch`.
1982
+ *
1983
+ * Per-emit state updates (`_frameBatch`, `_updateState`) have already
1984
+ * happened by the time we reach here; only the **downstream delivery**
1985
+ * is coalesced. Cache, version, and status are visible mid-batch on
1986
+ * the emitting node itself.
1987
+ */
1988
+ _dispatchOrAccumulate(messages) {
1989
+ if (isExplicitlyBatching()) {
1990
+ if (this._batchPendingMessages === null) {
1991
+ this._batchPendingMessages = [];
1992
+ registerBatchFlushHook(() => this._flushBatchPending());
1993
+ }
1994
+ for (const m of messages) this._batchPendingMessages.push(m);
1995
+ return;
1996
+ }
1997
+ downWithBatch(this._deliverToSinks, messages, this._config.tierOf);
1998
+ }
1999
+ /**
2000
+ * @internal Flushes the accumulated batch through `downWithBatch` and
2001
+ * clears the pending state. Idempotent — safe to call when pending is
2002
+ * already null or empty (e.g. on a `batch()` throw, where the hook
2003
+ * fires for cleanup but the drainPhase queues are wiped after).
2004
+ *
2005
+ * Critical: the accumulated batch is interleaved per-emit framings like
2006
+ * `[DIRTY, DATA(1), DIRTY, DATA(2)]` — non-monotone tier order. We must
2007
+ * re-frame to sort by tier before handing to `downWithBatch`, which
2008
+ * assumes pre-sorted input. `_frameBatch` also handles the synthetic
2009
+ * DIRTY prepend rule (no-op here — `hasDirty` is true since each
2010
+ * accumulated emit already carries its own DIRTY prefix).
2011
+ */
2012
+ _flushBatchPending() {
2013
+ const pending = this._batchPendingMessages;
2014
+ if (pending === null) return;
2015
+ this._batchPendingMessages = null;
2016
+ if (pending.length === 0) return;
2017
+ const framed = this._frameBatch(pending);
2018
+ downWithBatch(this._deliverToSinks, framed, this._config.tierOf);
2019
+ }
1924
2020
  };
1925
2021
  var isNodeArray = (value) => Array.isArray(value);
1926
2022
  var isNodeOptionsObject = (value) => typeof value === "object" && value != null && !Array.isArray(value);