@graphrefly/graphrefly 0.6.0 → 0.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.
Files changed (75) hide show
  1. package/README.md +30 -14
  2. package/dist/{chunk-HP7OKEOE.js → chunk-A2AJJOSJ.js} +3 -3
  3. package/dist/chunk-A2AJJOSJ.js.map +1 -0
  4. package/dist/{chunk-CP6MNKAA.js → chunk-E7OH6ZAZ.js} +10 -4
  5. package/dist/{chunk-CP6MNKAA.js.map → chunk-E7OH6ZAZ.js.map} +1 -1
  6. package/dist/chunk-LR2CLSEF.js +106 -0
  7. package/dist/chunk-LR2CLSEF.js.map +1 -0
  8. package/dist/{chunk-5X3LAO3B.js → chunk-QTZSBQGJ.js} +79 -20
  9. package/dist/chunk-QTZSBQGJ.js.map +1 -0
  10. package/dist/{chunk-V3UACY6A.js → chunk-TZLX4KIT.js} +790 -203
  11. package/dist/chunk-TZLX4KIT.js.map +1 -0
  12. package/dist/{chunk-QW7H3ICI.js → chunk-UCW3VWMN.js} +4 -4
  13. package/dist/{chunk-6W5SGIGB.js → chunk-WYI7YW54.js} +142 -30
  14. package/dist/chunk-WYI7YW54.js.map +1 -0
  15. package/dist/chunk-WZ2Z2CRV.js +32 -0
  16. package/dist/chunk-WZ2Z2CRV.js.map +1 -0
  17. package/dist/{chunk-Z4Y4FMQN.js → chunk-XCZPGOVP.js} +7 -7
  18. package/dist/{chunk-KWXPDASV.js → chunk-YWTP2XRJ.js} +2 -2
  19. package/dist/compat/nestjs/index.cjs +268 -61
  20. package/dist/compat/nestjs/index.cjs.map +1 -1
  21. package/dist/compat/nestjs/index.d.cts +4 -4
  22. package/dist/compat/nestjs/index.d.ts +4 -4
  23. package/dist/compat/nestjs/index.js +8 -7
  24. package/dist/core/index.cjs +163 -35
  25. package/dist/core/index.cjs.map +1 -1
  26. package/dist/core/index.d.cts +2 -2
  27. package/dist/core/index.d.ts +2 -2
  28. package/dist/core/index.js +10 -4
  29. package/dist/extra/index.cjs +892 -221
  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 +22 -3
  34. package/dist/graph/index.cjs +268 -61
  35. package/dist/graph/index.cjs.map +1 -1
  36. package/dist/graph/index.d.cts +3 -3
  37. package/dist/graph/index.d.ts +3 -3
  38. package/dist/graph/index.js +4 -4
  39. package/dist/{graph-CL_ZDAj9.d.cts → graph-DqTICAY2.d.cts} +69 -12
  40. package/dist/{graph-D18qmsNm.d.ts → graph-X9uwnD_z.d.ts} +69 -12
  41. package/dist/{index-C3BMRmmp.d.cts → index-3U0WxdD-.d.cts} +3 -3
  42. package/dist/{index-Bk_idZm1.d.cts → index-BP1t_38S.d.cts} +406 -61
  43. package/dist/{index-BtK55IE2.d.ts → index-BPCeYDS4.d.ts} +4 -2
  44. package/dist/{index-Bvy_6CaN.d.ts → index-BVG5pjin.d.ts} +50 -5
  45. package/dist/{index-C5mqLhMX.d.cts → index-BYEgosAX.d.cts} +50 -5
  46. package/dist/{index-D_geH2Bm.d.cts → index-BYa2YMat.d.cts} +3 -3
  47. package/dist/{index-CP_QvbWu.d.ts → index-DLO8wnYU.d.ts} +3 -3
  48. package/dist/{index-B7eOdgEx.d.ts → index-DMv1Etbi.d.ts} +3 -3
  49. package/dist/{index-BvhgZRHK.d.cts → index-DbwgQ4Cw.d.cts} +4 -2
  50. package/dist/{index-B2jmzVxL.d.ts → index-a5gHmH5b.d.ts} +406 -61
  51. package/dist/index.cjs +2966 -1790
  52. package/dist/index.cjs.map +1 -1
  53. package/dist/index.d.cts +112 -14
  54. package/dist/index.d.ts +112 -14
  55. package/dist/index.js +385 -20
  56. package/dist/index.js.map +1 -1
  57. package/dist/{meta-BsF6Sag9.d.cts → meta-BJEU8fYz.d.cts} +31 -4
  58. package/dist/{meta-BsF6Sag9.d.ts → meta-BJEU8fYz.d.ts} +31 -4
  59. package/dist/patterns/reactive-layout/index.cjs +268 -61
  60. package/dist/patterns/reactive-layout/index.cjs.map +1 -1
  61. package/dist/patterns/reactive-layout/index.d.cts +3 -3
  62. package/dist/patterns/reactive-layout/index.d.ts +3 -3
  63. package/dist/patterns/reactive-layout/index.js +4 -4
  64. package/dist/{reactive-log-BfvfNWQh.d.cts → reactive-log-BfX6bOSZ.d.cts} +2 -2
  65. package/dist/{reactive-log-ohLmTXoZ.d.ts → reactive-log-RhgIog2Z.d.ts} +2 -2
  66. package/package.json +29 -18
  67. package/dist/chunk-5X3LAO3B.js.map +0 -1
  68. package/dist/chunk-6W5SGIGB.js.map +0 -1
  69. package/dist/chunk-HP7OKEOE.js.map +0 -1
  70. package/dist/chunk-O3PI7W45.js +0 -68
  71. package/dist/chunk-O3PI7W45.js.map +0 -1
  72. package/dist/chunk-V3UACY6A.js.map +0 -1
  73. /package/dist/{chunk-QW7H3ICI.js.map → chunk-UCW3VWMN.js.map} +0 -0
  74. /package/dist/{chunk-Z4Y4FMQN.js.map → chunk-XCZPGOVP.js.map} +0 -0
  75. /package/dist/{chunk-KWXPDASV.js.map → chunk-YWTP2XRJ.js.map} +0 -0
@@ -1,7 +1,7 @@
1
- export { o as observeGraph$, c as observeNode$, t as toMessages$, d as toObservable } from '../../reactive-log-BfvfNWQh.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-D_geH2Bm.cjs';
1
+ export { o as observeGraph$, c as observeNode$, t as toMessages$, d as toObservable } from '../../reactive-log-BfX6bOSZ.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-BYa2YMat.cjs';
3
3
  import 'rxjs';
4
- import '../../meta-BsF6Sag9.cjs';
5
- import '../../graph-CL_ZDAj9.cjs';
4
+ import '../../meta-BJEU8fYz.cjs';
5
+ import '../../graph-DqTICAY2.cjs';
6
6
  import '@nestjs/common';
7
7
  import '@nestjs/core';
@@ -1,7 +1,7 @@
1
- export { o as observeGraph$, c as observeNode$, t as toMessages$, d as toObservable } from '../../reactive-log-ohLmTXoZ.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-CP_QvbWu.js';
1
+ export { o as observeGraph$, c as observeNode$, t as toMessages$, d as toObservable } from '../../reactive-log-RhgIog2Z.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-DLO8wnYU.js';
3
3
  import 'rxjs';
4
- import '../../meta-BsF6Sag9.js';
5
- import '../../graph-D18qmsNm.js';
4
+ import '../../meta-BJEU8fYz.js';
5
+ import '../../graph-X9uwnD_z.js';
6
6
  import '@nestjs/common';
7
7
  import '@nestjs/core';
@@ -31,18 +31,19 @@ import {
31
31
  getNodeToken,
32
32
  observeSSE,
33
33
  observeSubscription
34
- } from "../../chunk-QW7H3ICI.js";
35
- import "../../chunk-CP6MNKAA.js";
36
- import "../../chunk-HP7OKEOE.js";
34
+ } from "../../chunk-UCW3VWMN.js";
35
+ import "../../chunk-E7OH6ZAZ.js";
36
+ import "../../chunk-A2AJJOSJ.js";
37
37
  import {
38
38
  observeGraph$,
39
39
  observeNode$,
40
40
  toMessages$,
41
41
  toObservable
42
- } from "../../chunk-KWXPDASV.js";
43
- import "../../chunk-6W5SGIGB.js";
44
- import "../../chunk-O3PI7W45.js";
45
- import "../../chunk-5X3LAO3B.js";
42
+ } from "../../chunk-YWTP2XRJ.js";
43
+ import "../../chunk-WZ2Z2CRV.js";
44
+ import "../../chunk-WYI7YW54.js";
45
+ import "../../chunk-LR2CLSEF.js";
46
+ import "../../chunk-QTZSBQGJ.js";
46
47
  export {
47
48
  ACTOR_KEY,
48
49
  COMMAND_HANDLERS,
@@ -31,6 +31,7 @@ __export(core_exports, {
31
31
  PAUSE: () => PAUSE,
32
32
  RESOLVED: () => RESOLVED,
33
33
  RESUME: () => RESUME,
34
+ ResettableTimer: () => ResettableTimer,
34
35
  TEARDOWN: () => TEARDOWN,
35
36
  accessHintForGuard: () => accessHintForGuard,
36
37
  advanceVersion: () => advanceVersion,
@@ -59,6 +60,7 @@ __export(core_exports, {
59
60
  policyFromRules: () => policyFromRules,
60
61
  producer: () => producer,
61
62
  propagatesToMeta: () => propagatesToMeta,
63
+ resolveDescribeFields: () => resolveDescribeFields,
62
64
  state: () => state,
63
65
  wallClockNs: () => wallClockNs
64
66
  });
@@ -227,10 +229,14 @@ function partitionForBatch(messages) {
227
229
  }
228
230
  return { immediate, deferred, terminal };
229
231
  }
230
- function emitWithBatch(emit, messages, phase = 2) {
232
+ function emitWithBatch(emit, messages, phase = 2, options) {
231
233
  if (messages.length === 0) {
232
234
  return;
233
235
  }
236
+ if (options?.strategy === "sequential") {
237
+ _emitSequential(emit, messages, phase);
238
+ return;
239
+ }
234
240
  const queue = phase === 3 ? pendingPhase3 : pendingPhase2;
235
241
  if (messages.length === 1) {
236
242
  const t = messages[0][0];
@@ -271,6 +277,29 @@ function emitWithBatch(emit, messages, phase = 2) {
271
277
  }
272
278
  }
273
279
  }
280
+ function _emitSequential(emit, messages, phase = 2) {
281
+ const dataQueue = phase === 3 ? pendingPhase3 : pendingPhase2;
282
+ for (const msg of messages) {
283
+ const tier = messageTier(msg[0]);
284
+ if (tier === 2) {
285
+ if (isBatching()) {
286
+ const m = msg;
287
+ dataQueue.push(() => emit([m]));
288
+ } else {
289
+ emit([msg]);
290
+ }
291
+ } else if (tier >= 3) {
292
+ if (isBatching()) {
293
+ const m = msg;
294
+ pendingPhase3.push(() => emit([m]));
295
+ } else {
296
+ emit([msg]);
297
+ }
298
+ } else {
299
+ emit([msg]);
300
+ }
301
+ }
302
+ }
274
303
 
275
304
  // src/core/clock.ts
276
305
  function monotonicNs() {
@@ -434,6 +463,7 @@ function isV1(info) {
434
463
  }
435
464
 
436
465
  // src/core/node.ts
466
+ var NO_VALUE = /* @__PURE__ */ Symbol.for("graphrefly/NO_VALUE");
437
467
  function createIntBitSet() {
438
468
  let bits = 0;
439
469
  return {
@@ -563,10 +593,10 @@ var NodeImpl = class {
563
593
  this._hasDeps = deps.length > 0;
564
594
  this._autoComplete = opts.completeWhenDepsComplete ?? true;
565
595
  this._isSingleDep = deps.length === 1 && fn != null;
566
- this._cached = opts.initial;
596
+ this._cached = "initial" in opts ? opts.initial : NO_VALUE;
567
597
  this._status = this._hasDeps ? "disconnected" : "settled";
568
598
  this._hashFn = opts.versioningHash ?? defaultHash;
569
- this._versioning = opts.versioning != null ? createVersioning(opts.versioning, this._cached, {
599
+ this._versioning = opts.versioning != null ? createVersioning(opts.versioning, this._cached === NO_VALUE ? void 0 : this._cached, {
570
600
  id: opts.versioningId,
571
601
  hash: this._hashFn
572
602
  }) : void 0;
@@ -650,10 +680,14 @@ var NodeImpl = class {
650
680
  _applyVersioning(level, opts) {
651
681
  if (this._versioning != null) return;
652
682
  this._hashFn = opts?.hash ?? this._hashFn;
653
- this._versioning = createVersioning(level, this._cached, {
654
- id: opts?.id,
655
- hash: this._hashFn
656
- });
683
+ this._versioning = createVersioning(
684
+ level,
685
+ this._cached === NO_VALUE ? void 0 : this._cached,
686
+ {
687
+ id: opts?.id,
688
+ hash: this._hashFn
689
+ }
690
+ );
657
691
  }
658
692
  hasGuard() {
659
693
  return this._guard != null;
@@ -663,7 +697,7 @@ var NodeImpl = class {
663
697
  return this._guard(normalizeActor(actor), "observe");
664
698
  }
665
699
  get() {
666
- return this._cached;
700
+ return this._cached === NO_VALUE ? void 0 : this._cached;
667
701
  }
668
702
  down(messages, options) {
669
703
  if (messages.length === 0) return;
@@ -720,6 +754,7 @@ var NodeImpl = class {
720
754
  }
721
755
  if (this._terminal && this._opts.resubscribable) {
722
756
  this._terminal = false;
757
+ this._cached = NO_VALUE;
723
758
  this._status = this._hasDeps ? "disconnected" : "settled";
724
759
  this._opts.onResubscribe?.();
725
760
  }
@@ -819,7 +854,7 @@ var NodeImpl = class {
819
854
  const cleanupFn = this._cleanup;
820
855
  this._cleanup = void 0;
821
856
  cleanupFn?.();
822
- this._cached = void 0;
857
+ this._cached = NO_VALUE;
823
858
  this._lastDepValues = void 0;
824
859
  }
825
860
  this._status = statusAfterMessage(this._status, m);
@@ -828,7 +863,7 @@ var NodeImpl = class {
828
863
  }
829
864
  if (t === TEARDOWN) {
830
865
  if (this._opts.resetOnTeardown) {
831
- this._cached = void 0;
866
+ this._cached = NO_VALUE;
832
867
  }
833
868
  const teardownCleanup = this._cleanup;
834
869
  this._cleanup = void 0;
@@ -859,7 +894,15 @@ var NodeImpl = class {
859
894
  }
860
895
  _emitAutoValue(value) {
861
896
  const wasDirty = this._status === "dirty";
862
- const unchanged = this._equals(this._cached, value);
897
+ let unchanged;
898
+ try {
899
+ unchanged = this._cached !== NO_VALUE && this._equals(this._cached, value);
900
+ } catch (eqErr) {
901
+ const eqMsg = eqErr instanceof Error ? eqErr.message : String(eqErr);
902
+ const wrapped = new Error(`Node "${this.name}": equals threw: ${eqMsg}`, { cause: eqErr });
903
+ this._downInternal([[ERROR, wrapped]]);
904
+ return;
905
+ }
863
906
  if (unchanged) {
864
907
  this._downInternal(wasDirty ? [[RESOLVED]] : [[DIRTY], [RESOLVED]]);
865
908
  return;
@@ -906,7 +949,9 @@ var NodeImpl = class {
906
949
  if (out === void 0) return;
907
950
  this._emitAutoValue(out);
908
951
  } catch (err) {
909
- this._downInternal([[ERROR, err]]);
952
+ const errMsg = err instanceof Error ? err.message : String(err);
953
+ const wrapped = new Error(`Node "${this.name}": fn threw: ${errMsg}`, { cause: err });
954
+ this._downInternal([[ERROR, wrapped]]);
910
955
  }
911
956
  }
912
957
  _onDepDirty(index) {
@@ -941,7 +986,11 @@ var NodeImpl = class {
941
986
  try {
942
987
  if (this._onMessage(msg, index, this._actions)) continue;
943
988
  } catch (err) {
944
- this._downInternal([[ERROR, err]]);
989
+ const errMsg = err instanceof Error ? err.message : String(err);
990
+ const wrapped = new Error(`Node "${this.name}": onMessage threw: ${errMsg}`, {
991
+ cause: err
992
+ });
993
+ this._downInternal([[ERROR, wrapped]]);
945
994
  return;
946
995
  }
947
996
  }
@@ -1077,7 +1126,7 @@ var DynamicNodeImpl = class {
1077
1126
  _actions;
1078
1127
  _boundEmitToSinks;
1079
1128
  // Mutable state
1080
- _cached;
1129
+ _cached = NO_VALUE;
1081
1130
  _status = "disconnected";
1082
1131
  _terminal = false;
1083
1132
  _connected = false;
@@ -1171,7 +1220,7 @@ var DynamicNodeImpl = class {
1171
1220
  return this._guard(normalizeActor(actor), "observe");
1172
1221
  }
1173
1222
  get() {
1174
- return this._cached;
1223
+ return this._cached === NO_VALUE ? void 0 : this._cached;
1175
1224
  }
1176
1225
  down(messages, options) {
1177
1226
  if (messages.length === 0) return;
@@ -1229,6 +1278,7 @@ var DynamicNodeImpl = class {
1229
1278
  }
1230
1279
  if (this._terminal && this._resubscribable) {
1231
1280
  this._terminal = false;
1281
+ this._cached = NO_VALUE;
1232
1282
  this._status = "disconnected";
1233
1283
  this._onResubscribe?.();
1234
1284
  }
@@ -1306,10 +1356,13 @@ var DynamicNodeImpl = class {
1306
1356
  const t = m[0];
1307
1357
  if (t === DATA) this._cached = m[1];
1308
1358
  if (t === INVALIDATE) {
1309
- this._cached = void 0;
1359
+ this._cached = NO_VALUE;
1360
+ this._status = "dirty";
1310
1361
  }
1311
- if (t === DATA || t === RESOLVED) {
1362
+ if (t === DATA) {
1312
1363
  this._status = "settled";
1364
+ } else if (t === RESOLVED) {
1365
+ this._status = "resolved";
1313
1366
  } else if (t === DIRTY) {
1314
1367
  this._status = "dirty";
1315
1368
  } else if (t === COMPLETE) {
@@ -1320,7 +1373,7 @@ var DynamicNodeImpl = class {
1320
1373
  this._terminal = true;
1321
1374
  }
1322
1375
  if (t === TEARDOWN) {
1323
- if (this._resetOnTeardown) this._cached = void 0;
1376
+ if (this._resetOnTeardown) this._cached = NO_VALUE;
1324
1377
  try {
1325
1378
  this._propagateToMeta(t);
1326
1379
  } finally {
@@ -1343,7 +1396,15 @@ var DynamicNodeImpl = class {
1343
1396
  }
1344
1397
  _emitAutoValue(value) {
1345
1398
  const wasDirty = this._status === "dirty";
1346
- const unchanged = this._equals(this._cached, value);
1399
+ let unchanged;
1400
+ try {
1401
+ unchanged = this._cached !== NO_VALUE && this._equals(this._cached, value);
1402
+ } catch (eqErr) {
1403
+ const eqMsg = eqErr instanceof Error ? eqErr.message : String(eqErr);
1404
+ const wrapped = new Error(`Node "${this.name}": equals threw: ${eqMsg}`, { cause: eqErr });
1405
+ this._downInternal([[ERROR, wrapped]]);
1406
+ return;
1407
+ }
1347
1408
  if (unchanged) {
1348
1409
  this._downInternal(wasDirty ? [[RESOLVED]] : [[DIRTY], [RESOLVED]]);
1349
1410
  return;
@@ -1509,6 +1570,19 @@ var DynamicNodeImpl = class {
1509
1570
  };
1510
1571
 
1511
1572
  // src/core/meta.ts
1573
+ function resolveDescribeFields(detail, fields) {
1574
+ if (fields != null && fields.length > 0) return new Set(fields);
1575
+ switch (detail) {
1576
+ case "standard":
1577
+ return /* @__PURE__ */ new Set(["type", "status", "value", "deps", "meta", "v"]);
1578
+ case "full":
1579
+ return null;
1580
+ // null = include everything
1581
+ case "minimal":
1582
+ default:
1583
+ return /* @__PURE__ */ new Set(["type", "deps"]);
1584
+ }
1585
+ }
1512
1586
  function inferDescribeType(n) {
1513
1587
  if (n._describeKind != null) return n._describeKind;
1514
1588
  if (!n._hasDeps) return n._fn != null ? "producer" : "state";
@@ -1526,12 +1600,10 @@ function metaSnapshot(node2) {
1526
1600
  }
1527
1601
  return out;
1528
1602
  }
1529
- function describeNode(node2) {
1530
- const meta = { ...metaSnapshot(node2) };
1531
- const guard = node2 instanceof NodeImpl && node2._guard || node2 instanceof DynamicNodeImpl && node2._guard || void 0;
1532
- if (guard != null && meta.access === void 0) {
1533
- meta.access = accessHintForGuard(guard);
1534
- }
1603
+ function describeNode(node2, includeFields) {
1604
+ const all = includeFields == null;
1605
+ const metaKeys = !all && includeFields != null ? [...includeFields].filter((f) => f.startsWith("meta.")).map((f) => f.slice(5)) : null;
1606
+ const wantsMeta = all || includeFields.has("meta") || metaKeys != null && metaKeys.length > 0;
1535
1607
  let type = "state";
1536
1608
  let deps = [];
1537
1609
  if (node2 instanceof NodeImpl) {
@@ -1541,20 +1613,36 @@ function describeNode(node2) {
1541
1613
  type = node2._describeKind ?? "derived";
1542
1614
  deps = [];
1543
1615
  }
1544
- const out = {
1545
- type,
1546
- status: node2.status,
1547
- deps,
1548
- meta
1549
- };
1616
+ const out = { type, deps };
1617
+ if (all || includeFields.has("status")) {
1618
+ out.status = node2.status;
1619
+ }
1620
+ const guard = node2 instanceof NodeImpl && node2._guard || node2 instanceof DynamicNodeImpl && node2._guard || void 0;
1621
+ if (wantsMeta) {
1622
+ const rawMeta = { ...metaSnapshot(node2) };
1623
+ if (guard != null && rawMeta.access === void 0) {
1624
+ rawMeta.access = accessHintForGuard(guard);
1625
+ }
1626
+ if (metaKeys != null && metaKeys.length > 0 && !includeFields.has("meta")) {
1627
+ const filtered = {};
1628
+ for (const k of metaKeys) {
1629
+ if (k in rawMeta) filtered[k] = rawMeta[k];
1630
+ }
1631
+ out.meta = filtered;
1632
+ } else {
1633
+ out.meta = rawMeta;
1634
+ }
1635
+ }
1550
1636
  if (node2.name != null) {
1551
1637
  out.name = node2.name;
1552
1638
  }
1553
- try {
1554
- out.value = node2.get();
1555
- } catch {
1639
+ if (all || includeFields.has("value")) {
1640
+ try {
1641
+ out.value = node2.get();
1642
+ } catch {
1643
+ }
1556
1644
  }
1557
- if (node2.v != null) {
1645
+ if ((all || includeFields.has("v")) && node2.v != null) {
1558
1646
  const vInfo = { id: node2.v.id, version: node2.v.version };
1559
1647
  if ("cid" in node2.v) {
1560
1648
  vInfo.cid = node2.v.cid;
@@ -1562,6 +1650,16 @@ function describeNode(node2) {
1562
1650
  }
1563
1651
  out.v = vInfo;
1564
1652
  }
1653
+ if (all || includeFields.has("guard")) {
1654
+ if (guard != null) {
1655
+ out.guard = accessHintForGuard(guard);
1656
+ }
1657
+ }
1658
+ if (all || includeFields.has("lastMutation")) {
1659
+ if (node2.lastMutation != null) {
1660
+ out.lastMutation = node2.lastMutation;
1661
+ }
1662
+ }
1565
1663
  return out;
1566
1664
  }
1567
1665
 
@@ -1585,6 +1683,34 @@ function pipe(source, ...ops) {
1585
1683
  }
1586
1684
  return current;
1587
1685
  }
1686
+
1687
+ // src/core/timer.ts
1688
+ var ResettableTimer = class {
1689
+ _timer;
1690
+ _gen = 0;
1691
+ /** Schedule callback after delayMs. Cancels any pending timer. */
1692
+ start(delayMs, callback) {
1693
+ this.cancel();
1694
+ this._gen += 1;
1695
+ const gen = this._gen;
1696
+ this._timer = setTimeout(() => {
1697
+ this._timer = void 0;
1698
+ if (gen !== this._gen) return;
1699
+ callback();
1700
+ }, delayMs);
1701
+ }
1702
+ /** Cancel the pending timer (if any). */
1703
+ cancel() {
1704
+ if (this._timer !== void 0) {
1705
+ clearTimeout(this._timer);
1706
+ this._timer = void 0;
1707
+ }
1708
+ }
1709
+ /** Whether a timer is currently pending. */
1710
+ get pending() {
1711
+ return this._timer !== void 0;
1712
+ }
1713
+ };
1588
1714
  // Annotate the CommonJS export names for ESM import in node:
1589
1715
  0 && (module.exports = {
1590
1716
  COMPLETE,
@@ -1598,6 +1724,7 @@ function pipe(source, ...ops) {
1598
1724
  PAUSE,
1599
1725
  RESOLVED,
1600
1726
  RESUME,
1727
+ ResettableTimer,
1601
1728
  TEARDOWN,
1602
1729
  accessHintForGuard,
1603
1730
  advanceVersion,
@@ -1626,6 +1753,7 @@ function pipe(source, ...ops) {
1626
1753
  policyFromRules,
1627
1754
  producer,
1628
1755
  propagatesToMeta,
1756
+ resolveDescribeFields,
1629
1757
  state,
1630
1758
  wallClockNs
1631
1759
  });